beamer: not incrementing framenumber for "fully restricted" frames
Asked Answered
D

2

5

My documents often contain "fully restricted" frames of this form:

\begin{frame}<0>
    Lorem ipsum dolor.
\end{frame}

Because of the <0> at the end of the first line, frames like this do not appear in the documents that I produce with pdflatex or xelatex. But they still cause the framenumber counter to increment, which leads to strange results. Here is an example:

\documentclass[xelatex]{beamer}
\begin{document}
  \setbeamertemplate{footline}{\hfill\insertframenumber}
  \begin{frame}<0>{Frame A}
  \end{frame}

  \begin{frame}{Frame B}
  \end{frame}

\end{document}

When I process this document with xelatex, I get a PDF document containing one frame. The framenumber in the footline of the frame is 2. I would like it to be 1. I could manually reset the frame counter after every restricted frame, but in large documents with many such frames, that is a hassle. Is there any way to stop restricted frames from incrementing the counter?

Diplostemonous answered 11/5, 2011 at 23:18 Comment(1)
Comment for anyone brought here by search engine: you can find an entire community on the TeX StackExchange, where no TeX-related question is too small. There are oodles of beamer questions.Spirochaetosis
P
4

You could create a new environment macro that contains the counter fix:

\newenvironment{restrictedframe}[1]
  {\begin{frame}<0>{#1}}
  {\end{frame} \addtocounter{framenumber}{-1}}
Putrescent answered 12/5, 2011 at 0:1 Comment(3)
Thank you. This works, provided that I change \addtocounter{framecounter} to \addtocounter{framenumber}.Diplostemonous
With the current beamer version, the numbering will be off because now frames with <0> are automatically excluded from increasing the framecounter. Also there are many situations in which beamer needs to actually see \end{frame} and will freak out if you hide it away in a custom environment. If you really, really must do this, at least use the environmnet key to inform beamer about it:Waldheim
\newenvironment{restrictedframe}[2][] {\begin{frame}<0>[environment=restrictedframe,#1]\frametitle{#2}} {\end{frame}}Waldheim
W
4

Beamer now automatically excludes frames which are hidden with <0> from increasing the frame counter. So the solution is now increadible easy:

do nothing :)

\documentclass{beamer}

\setbeamertemplate{footline}[frame number]

\begin{document}

  \begin{frame}<0>
  \frametitle{Frame A}
  \end{frame}

  \begin{frame}
  \frametitle{Frame B}
  \end{frame}

\end{document}

enter image description here

Pre-v3.65 solution:

The frames can be excluded from the frame counter by using the noframenumbering option:

\documentclass{beamer}

\setbeamertemplate{footline}[frame number]

\begin{document}

  \begin{frame}<0>[noframenumbering]
  \frametitle{Frame A}
  \end{frame}

  \begin{frame}
  \frametitle{Frame B}
  \end{frame}

\end{document}
Waldheim answered 28/2, 2019 at 0:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.