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}
  • 1
    I think you could save the total frame number much easier. – user31729 Mar 5 '17 at 17:52
  • 2
    Why are you torturing us with such background colours? – user36296 Mar 5 '17 at 20:44
  • @samcarter This time I tried something new...I'll do better/different next time :). – Dr. Manuel Kuehner Mar 5 '17 at 20:53
  • 1
    @Dr.ManuelKuehner Keine Drohungen! – user36296 Mar 5 '17 at 21:02
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 5 '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. – user31729 Mar 5 '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 6 '17 at 15:58
  • @Dr.ManuelKuehner: I can change my solution but actually, I can't follow the strategy behind your numbering scheme – user31729 Mar 6 '17 at 16:38
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}
  • 1
    @Dr.ManuelKuehner The general approach is to use a package which does what you want :) – user36296 Mar 5 '17 at 20:33
  • 1
    @Dr.ManuelKuehner As said in my answer, the "stuff" between \makeatletter and \makeatother is necessary to make make your frame counter to go beyond the total framenumber. Normally it would restart with 1 – user36296 Mar 5 '17 at 21:05
  • 1
    @Dr.ManuelKuehner Perfect time to switch to texlive :) – user36296 Mar 5 '17 at 21:06
  • 1
    @samcarter: A package that uses \makeatletter...\makeatother? Oh my ... But as I can see, it uses a similar approach to totcount, but it is no package at all, in the sense of \ProvidesPackage – user31729 Mar 5 '17 at 21:08
  • 2
    @samcarter: \let\eagle\egreg ;-) ... No, he will never be allowed to write packages again or upload something to the Holy Shrine of Typography (i.e. CTAN );-) – user31729 Mar 5 '17 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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