5
  • Normally I have something like Frame 4 / 30 in the footline.
  • The total frame count is done by the command \insertframenumber.
  • In my beamer presentation, I have an extensive appendix/backup.
  • Therefore I didn't want the appendix frames to be counted to the total frame count.
  • I used this and that question to do that -- leading to a new custom command called \myLastContentFrame.
  • Everything was good.
  • Now I used overlay specifications like [<+->] and the \myLastContentFrame sadly also considers the overlays into account.

How to determine the last frame before the appendix even if overlay specifications are used? In the appendix frames I want e. g. 34 / 30 (where 30 is the last content frame count).

enter image description here

\documentclass[c]{beamer}

%% Appearance
% -----------------------
\setbeamercolor{block title}{fg=white,bg=red}
\setbeamercolor{block body}{fg=black,bg=gray}
\setbeamercolor{background canvas}{bg=pink}
% -----------------------

%% Functionality
% -----------------------
\usepackage{xparse}

% https://tex.stackexchange.com/questions/347560
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\myLastContentFrame}{}
 {
  \fp_to_int:n
   {
     (
      \use:c{beamer@startpageofappendix} - 1 > 0
      ?
      \use:c{beamer@startpageofappendix} - 1 
      :
      \inserttotalframenumber
     )
   }
 }
\ExplSyntaxOff
% -----------------------

\begin{document}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Last Content Frame}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}

\begin{block}{Last Content Frame}
The number of this frame -- the last frame befpore the appendix starts -- should be the value of \texttt{\textbackslash myLastContentFrame}.
\end{block}

\end{frame}

\appendix

\begin{frame}
\frametitle{First Appendix Frame}
\Huge \textcolor{red}{Start of Appendix!}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}
\end{frame}

\end{document}

2 Answers2

5

No need to reinvent the wheel, appendixnumberbeamer already did this for you:

(the only thing I changed is to comment two lines from the original appendix definition, otherwise the appendix would restart counting from 1)

\documentclass[c]{beamer}

\usepackage{appendixnumberbeamer}

\setbeamertemplate{footline}{\insertframenumber~/~\inserttotalframenumber}

\makeatletter
\def\appendix{
  \xdef\mainend{\theframenumber}
  \immediate\write\@auxout{\string\global\string\@namedef{mainendframenumber}{\mainend}}
  \appendixorig
%  \gdef\inserttotalframenumber{\appendixtotalframenumber}%
%  \setcounter{framenumber}{0}
}
\makeatother

\begin{document}

\begin{frame}
test
\pause[3]
\end{frame}

\begin{frame}
test
\end{frame}

\appendix

\begin{frame}
Appendix
\end{frame}

\end{document}
4

You might suspend the counter framenumber with the command \SuspendCounters from the xassoccnt package, i.e.

with \SuspendCounters{framenumber}.

If the counting should be reenabled, say \ResumeSuspendedCounters{framenumber} later on.

I also changed to using total counters, i.e. with \DeclareTotalAssociatedCounters (requires xassoccnt v1.2)

\documentclass[c]{beamer}

\usepackage{xassoccnt}

% Pre version 1.1 of xassoccnt version
\NewTotalDocumentCounter{totalframenumbers}
\DeclareAssociatedCounters{framenumber}{totalframenumbers}

% Version 1.2. of xassoccnt allows this in one go...
%\DeclareTotalAssociatedCounters{framenumber}{totalframenumbers}

%% Appearance
% -----------------------
\setbeamercolor{block title}{fg=white,bg=red}
\setbeamercolor{block body}{fg=black,bg=gray}
\setbeamercolor{background canvas}{bg=pink}
% -----------------------

%% Functionality
% -----------------------
\usepackage{xparse}

% http://tex.stackexchange.com/questions/347560

\newcommand{\myReallyLastContentFrame}{%
  \TotalValue{totalframenumbers}
}
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\myLastContentFrame}{}
 {
  \fp_to_int:n
   {
     (
      \use:c{beamer@startpageofappendix} - 1 > 0
      ?
      \use:c{beamer@startpageofappendix} - 1 
      :
      \inserttotalframenumber
     )
   }
 }
\ExplSyntaxOff
% -----------------------

\begin{document}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame 
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Last Content Frame}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame
\end{itemize}

\begin{block}{Last Content Frame}
The number of this frame -- the last frame befpore the appendix starts -- should be the value of \texttt{\textbackslash myLastContentFrame}.
\end{block}

\end{frame}

\appendix

\SuspendCounters{framenumber}
\begin{frame}
\frametitle{First Appendix Frame}
\Huge \textcolor{red}{Start of Appendix!}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame
\end{itemize}
\end{frame}

\end{document}
  • Thanks for the fresh idea. I'll try it tomorrow. Is the idea that there is a new counter that synchronizes with the beamer counter? – Dr. Manuel Kuehner Mar 05 '17 at 19:30
  • 1
    @Dr.ManuelKuehner: Yes, that's the basic purpose of the xassoccnt packages. The total document counter feature is used in order to store the counter value at the end of the document to the .aux file and reuse it with the next run. –  Mar 05 '17 at 19:32
  • I just tested the code. It compiles well. Apparently I was unclear about my objective: I still want that the framenumber counter counts on so that in the appendix I have e. g. frame 34/30. So every frame still has an individual frame number to which I can refer to. – Dr. Manuel Kuehner Mar 06 '17 at 15:58
  • @Dr.ManuelKuehner: I can change my solution but actually, I can't follow the strategy behind your numbering scheme –  Mar 06 '17 at 16:38