Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The command \insertpresentationendpage is supposed to insert the page number of the last page of the presentation, excluding the appendix. However its value is incorrectly increased if \uncover is used during the presentation. Does anyone know a good fix or workaround for this problem?

Example:

\documentclass{beamer}
\setbeamertemplate{footline}{\insertframenumber/\insertpresentationendpage}
\begin{document}
\begin{frame}
  Slide one
  %Comment out next line to get desired behaviour
  \uncover<2>{still} 
\end{frame}
\appendix
\begin{frame}
  Slide two (appendix)
\end{frame}
\begin{frame}
  Slide three (appendix)
\end{frame}
\end{document}
share|improve this question
    
I found a similar query with a bit more information here. –  Dennis Prangle Dec 7 '11 at 14:41
    
Of course, in the interim, one work-around is to specify this manually. That is, find the last frame (say 20) and use \setbeamertemplate{footline}{\insertframenumber/20}. –  Werner Dec 10 '11 at 20:36
    
Thanks Werner, that is my current solution. My worry is it can easily go wrong if I forget to update this command after a hasty edit. –  Dennis Prangle Dec 12 '11 at 9:00

1 Answer 1

up vote 4 down vote accepted

This is actually the intended behaviour. Compare the description of \inserttotalframenumber and \insertpresentationendpage in the beamer manual (p. 66):

\inserttotalframenumber Inserts the total number of the frames (not slides) into a template. The number is only correct on the second run of TeX on your document.

vs.

\insertpresentationendpage Inserts the page number of the last page of the presentation (excluding the appendix).

So \inserttotalframenumber counts the number of frames, which means it isn't increased in frames with overlays, while \insertpresentationendpage counts the absolute number of pages in the presentation, with each overlay as a single page.

What you're looking for instead is an \insertpresentationendframe command, which is unfortunately not available in beamer. However, you can define it yourself:

\def\insertpresentationendframe{\inserttotalframenumber}
\makeatletter
\g@addto@macro{\appendix}{\immediate\write\@auxout{\string\@writefile{nav}{\noexpand\headcommand{\noexpand\def\noexpand\insertpresentationendframe{\the\c@framenumber}}}}}
\makeatother

Insert this code into the preamble of your document, i. e. somewhere between \documentclass{beamer} and \begin{document}. It defines a macro \insertpresentationendframe which defaults to the total number of frames, but is "locked" to the number of the last frame of the main presentation if an appendix is encountered.

Using it is straightforward:

\documentclass{beamer}

\def\insertpresentationendframe{\inserttotalframenumber}
\makeatletter
\g@addto@macro{\appendix}{\immediate\write\@auxout{\string\@writefile{nav}{\noexpand\headcommand{\noexpand\def\noexpand\insertpresentationendframe{\the\c@framenumber}}}}}
\makeatother

\setbeamertemplate{footline}{\insertframenumber/\insertpresentationendframe}

\begin{document}
\begin{frame}
  Slide one
  \uncover<2>{still} 
\end{frame}
\appendix
\begin{frame}
  Slide two (appendix)
\end{frame}
\begin{frame}
  Slide three (appendix)
\end{frame}
\end{document}

Observe that the frame counter now correctly shows 1/1 instead of 1/2.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.