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.

I have a beamer presentation in which I have some additional slides in an appendix. The additional slides are only there in case someone asks a specific question; I won't necessarily have to use any of them.

I am using a theme that prints both the current frame number and the total number of frames on the bottom of each page. My problem is that the total number of frames includes all of the "extra" frames I have in the appendix. Let's say I have 20 "real" frames and then 5 additional frames in the appendix. The problem now is that \inserttotalframenumber (which is what the theme uses to print the total number of frames) returns 25. This is misleading to the audience because I may never even present any of the 5 additional frames.

The ideal behavior would be for \inserttotalframenumber to return 20, not 25. If I did advance to one of the appendix frames then I would like the frame to be "26/25", "27/25", and so on. How can this be done?

Edit:

I see that \inserttotalframenumber is defined in beamerbasemisc.sty by writing the value of the \c@framenumber counter to the .aux file at the end of the document. I guess one way to achieve my desired behavior is to do something like

\AtEndDocument{
  \immediate\write\@auxout{\string\@writefile{nav}%
    {\noexpand\headcommand{\noexpand\def\noexpand\inserttotalframenumber{\insertframenumber}}}}
}

on the last "real" slide of my document. That seems like a bit of a hack though. Is there a better way?

share|improve this question
3  
A slight non sequitur: one of my professors told me never to include the total number of slides in a presentation, because "it will only cause you dread [of running out of time], and the audience despair [of the never ending presentation]". He also said that a good presenter should "know where he is in the talk without referring to a silly number". –  Willie Wong Aug 30 '10 at 19:57
add comment

7 Answers

up vote 13 down vote accepted

I've used the following macros for this purpose:

\newcommand{\backupbegin}{
   \newcounter{framenumberappendix}
   \setcounter{framenumberappendix}{\value{framenumber}}
}
\newcommand{\backupend}{
   \addtocounter{framenumberappendix}{-\value{framenumber}}
   \addtocounter{framenumber}{\value{framenumberappendix}} 
}

The bonus slides are then put between the two commands:

\appendix
\backupbegin

\frame{\frametitle{One more thing}}

\backupend

This will get you the desired numbering, too.

share|improve this answer
add comment

You could use the standard referencing features and redefine \inserttotalframenumber right after \begin{document} (not before):

\renewcommand*{\inserttotalframenumber}{\pageref{lastframe}}

In the last frame, before your appendix, set the label:

\begin{frame}\label{lastframe}
...
\end{frame}
% now your appendix frames follow

If you set the lastframe label on frame 20 and let 5 frames follow, an infolines theme would show "4 / 20" and so on. The last appendix frame would show "25 / 20" like desired.

share|improve this answer
    
This approach will only work if every frame only has a single overlay. The problem is that \pageref refers to the page number of the last frame, not the frame number. Therefore, if any of the previous frames take up multiple pages in the PDF, the \pageref will return the wrong number. –  ESultanik Aug 30 '10 at 20:19
add comment

Have the same problem and found the answer from

stackoverflow

The answer is very simple just to use this package appendixnumberbeamer.sty

share|improve this answer
add comment

You can enable the (undocumented) noframenumbering option for each frame in the appendix. This also works for omitting the title page in the frame total.

\begin{document}
\begin{frame}[plain,noframenumbering]
  \titlepage
\end{frame}
...
\appendix
\begin{frame}[noframenumbering]
  ...
\end{frame}
\end{document}

Unfortunately this setting isn't inherited by additional frames resulting from allowframebreaks. To fix this, add the following to your preamble.

\usepackage{etoolbox}
\makeatletter
\preto{\appendix}{%
  \patchcmd{\beamer@continueautobreak}{\refstepcounter{framenumber}}{}{}{}}
\makeatother
share|improve this answer
    
Interesting! This is much less of a hack than my version. +1 –  ESultanik Apr 25 '13 at 12:48
add comment

Inspired by Stefan's answer, here is the solution up with which I ended (which rectifies the problem of using \pageref):

Immediately before \appendix I added this:

\makeatletter
  \immediate\write\@mainaux{\string\gdef\string\inserttotalframenumbernew{\insertframenumber}}
\makeatother

That writes the number of the last "real" frame to the .aux file as the new command \inserttotalframenumbernew. Then, at the beginning of my document, I added this:

\makeatletter
  \@ifundefined{inserttotalframenumbernew}{
    \gdef\inserttotalframenumbernew{1}
  }{}
  \gdef\inserttotalframenumber{\inserttotalframenumbernew}
\makeatother

That redefines \inserttotalframenumber to be the value of \inserttotalframenumbernew (which is read from the .aux).

This still feels like a bit of a hack to me, though. It would be a lot cleaner if beamer had a macro that acted like \pageref but instead returned a frame number, but beamer doesn't seem to.

share|improve this answer
add comment

I've dealt with this by making two distinct pdfs and then pasting them together with the command line tool pdftk. Not fancy, but it works. (That said, I will be trying the solution @ESultanik ended up with if ever this comes up again.)

share|improve this answer
add comment

The great command \insertpresentationendpage will take care of your problem. Just place \appendix at the begin of your backup slides.

\documentclass[t]{beamer}

\usepackage[absolute,overlay]{textpos}
\setbeamertemplate{navigation symbols}{}

\setbeamertemplate{footline}{%
    \begin{picture}(54,12.5)(0,0)
    \put(0.9,0.52){%
        \begin{minipage}[b][12.5mm][c]{112.5mm}
        \raggedleft
        \insertpagenumber/\insertpresentationendpage
        \end{minipage}
    }
    \end{picture}
}


\begin{document}

    \begin{frame}
        slide in the main part
    \end{frame}

    \appendix
    \section*{Backup}

    \begin{frame}
        \frametitle{backup}
        not counting in the total frame number
    \end{frame}

\end{document}

enter image description here


Edit:

As David Z pointed out in his comment, this does not work when using overlays. The following workaround (stolen from diabonas answer) takes care of this problem:

\documentclass[t]{beamer}

\usepackage[absolute,overlay]{textpos}
\setbeamertemplate{navigation symbols}{}

\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}{%
    \begin{picture}(54,12.5)(0,0)
    \put(0.9,0.52){%
        \begin{minipage}[b][12.5mm][c]{112.5mm}
        \raggedleft
        \insertframenumber/\insertpresentationendframe
        \end{minipage}
    }
    \end{picture}
}

\begin{document}

    \begin{frame}
        slide in the main part
    \end{frame}

    \begin{frame}
        a frame with overlays
        \begin{onlyenv}<1>
            overlay1
        \end{onlyenv}
        \begin{onlyenv}<2>
            overlay2
        \end{onlyenv}
    \end{frame}

    \appendix
    \section*{Backup}

    \begin{frame}
        \frametitle{backup}
        not counting in the total frame number
    \end{frame}

\end{document}
share|improve this answer
    
Unfortunately this doesn't work when there are frames with multiple slides (i.e. if you use overlays): it counts the number of slides, not the number of frames. –  David Z Jan 17 at 9:47
add comment

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.