I am trying to create a manual continuation annotation for my presentations (because I need more flexibility than provided by the automatic splitting feature of beamer).
What I thought of is, for each sequence of slides create a counter and then increment and print its value on each successive slide of the sequence.
If I do that "manually", everything works fine.
Then I tried to automate things a little bit more, as shown below. The countslides
command takes an argument, constructs a counter using the argument for its name (if it does not exist) and then increments and prints its value.
Unfortunately, the code produces an error "Missing number, treated as zero" on the first slide (even though the result is correct). The error goes away if I remove the \pause
command on this slide (or if I remove the \resetcounteronoverlays
from my command definition, but I cannot afford this).
Maybe my code is wrong, but I cannot see how (and it has worked fine in all other cases).
\documentclass{beamer}
\usepackage{ifthen}
\begin{document}
\makeatletter
\newcommand{\countslides}[1]{%
\ifthenelse{\expandafter\isundefined\csname c@cnt#1\endcsname}%
{\newcounter{cnt#1}%
\resetcounteronoverlays{cnt#1}%
}%
{}%
\stepcounter{cnt#1}%
{~\footnotesize (\arabic{cnt#1})}%
}
\makeatother
\begin{frame}
\frametitle{Hello \countslides{abc}}
A
\pause
B
\end{frame}
\begin{frame}
\frametitle{Bye \countslides{abc}}
C
\pause
D
\end{frame}
\end{document}
\newcounter
is global.\pause
will cause the frame contents to be typeset more than once. That sounds like something that could conflict.totcount
package with the above code, but I will see how this can be implemented using your (second) solution.