# How to correct \insertpresentationendpage in presence of \uncover

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}
\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}

-
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

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
\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}

\makeatletter
\makeatother

\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.

-