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.

The question

When I create slides for presentations in LaTeX with the Beamer class, I like to use constructions with overprint like this:

\begin{frame}
  \begin{block}{}
    \begin{itemize}
      \item Some general remarks about ALL plots
    \end{itemize}
  \end{block}
  \begin{block}{}
    \begin{center}
      \begin{overprint}
        \only<+>{
          \incgraphics{width=7cm}{plot1.pdf}\\
          Explanation of Figure 1
        }
        \only<+>{
          \incgraphics{width=7cm}{plot2.pdf}\\
          Explanation of Figure 2
        }
        % maybe more plots...
      \end{overprint}
    \end{center}
  \end{block}
\end{frame}

The problem is that like this all slides created from one frame are assigned the same page number which makes people complain that it's difficult to follow which slide I am on (when giving the talk via phone etc.).

How can I change this?

A minimal example to reproduce the problem

\documentclass{beamer}

\usetheme{Madrid}

\begin{document}

\begin{frame}
  Common text\\
  \begin{overprint}
    \only<+>{
      Figure 1 and explanation of Figure 1
    }
    \only<+>{
      Figure 2 and explanation of Figure 2
    }
  \end{overprint}
\end{frame}

\end{document}

Partial answer

One can mess around with \setbeamertemplate and use \insertpagenumber{} instead of \insertframenumber{}, but like this you lose generality (e.g. you cannot switch between themes easily).

Maybe there is a better solution?

share|improve this question
    
I use \setbeamertemplate{footline}{\hfill\large\insertpagenumber} –  Konrad Swanepoel Oct 12 '10 at 5:34

5 Answers 5

up vote 4 down vote accepted

Good question. There seems to be no built-in functionality to do what you want. There must be a counter that holds the slide number, but the manual doesn't seem to expose it and I don't want to delve into the source.

My solution might be classified as "messing around", but here goes:

\documentclass{beamer}
\usetheme{Madrid}
\newcounter{slidenumber}

\defbeamertemplate*{footline}{infolines theme frame plus slide}{
    \setcounter{slidenumber}{\insertpagenumber}%
    \addtocounter{slidenumber}{-\insertframestartpage}%
    \addtocounter{slidenumber}{1}%
    \leavevmode%
    \hbox{%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor~~(\insertshortinstitute)
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
            \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
            \insertframenumber.\arabic{slidenumber}{}/ \inserttotalframenumber\hspace*{2ex} 
        \end{beamercolorbox}}%
        \vskip0pt%
    }

\setbeamertemplate{footline}[infolines theme frame plus slide]

\begin{document}
\begin{frame}
    Common text\\
    \begin{overprint}
        \only<+>{
            Figure 1 and explanation of Figure 1
        }
        \only<+>{
            Figure 2 and explanation of Figure 2
        }
    \end{overprint}
\end{frame}

\begin{frame}
    Common text on frame 2\\
    \begin{overprint}
        \only<+>{
            Figure 1 and explanation of Figure 1
        }
        \only<+>{
            Figure 2 and explanation of Figure 2
        }
    \end{overprint}
\end{frame}

\end{document}

Any theme which uses the infolines inner theme can thus be modified. If you didn't want to touch any templating, you could redefine \insertframenumber to return the frame number . slide number, but I don't know if that's going to break anything else.

share|improve this answer
    
I have played around with redefining \insertframenumber before; if I recall correctly, it does have the potential to break things (especially if you are using hyperlinks between frames). –  ESultanik Nov 19 '10 at 18:49

The number of the current slide within the frame is stored in the TeX count register \beamer@slideinframe. You could turn it into a LaTeX counter with

\makeatletter
\setcounter{currentslide}{\the\beamer@slideinframe}
\makeatother

if you like.

share|improve this answer
5  
I would rather use \makeatletter\def\c@slideinframe{\beamer@slideinframe}\makeatother to create an LaTeX counter alias named slideinframe (or using another name) which is always in sync with the internal beamer counter. However, the issue is that the counter doesn't hold the correct value inside the footer. I always get 2 for both slides. –  Martin Scharrer May 11 '11 at 15:08

I had this same question and approached it using the built-in beamer macros \insertpagenumber and \insertsectionendpage or \insertpresentationendpage to show the current page number out of the total number of pages in the section, or presentation respectively. The page number is incremented using overlays, while the frame number is not. You can use this command within footlines. An MWE is below. I know this question is old but it took me a while to find these commands so I wanted to draw attention to them.

\documentclass{beamer}

\usetheme{Madrid}

\setbeamertemplate{footline}{% set footline options
 \insertpagenumber/\insertsectionendpage
 }

\begin{document}

\begin{frame}
  Common text\\
  Frame - \insertframenumber{} of \inserttotalframenumber \\
  Page - \insertpagenumber{} of \insertpresentationendpage \\
  \begin{overprint}
    \only<+>{
      Figure 1 and explanation of Figure 1
    }
    \only<+>{
      Figure 2 and explanation of Figure 2
    }
  \end{overprint}
\end{frame}

\end{document}

frame1 frame2

share|improve this answer

I would think the easiest way is to avoid the overprint environment altogether:

\documentclass{beamer}

\usetheme{Madrid}

\begin{document}

\begin{frame}
Common text\\
\includegraphics{fig1.png} \\
      Figure 1 and explanation of Figure 1
\end{frame}
\begin{frame}
Common text\\
\includegraphics{fig2.png} \\ 
      Figure 2 and explanation of Figure 2
    }
\end{frame}

\end{document}

This will give you two identical slides, but with different figures and different slide numbers. The only issue that I can think of is that compiling the handout mode will not work properly.

share|improve this answer

I am not sure, if this is exactly what you want, but you could also use \begin{frame} and \againframe with labels and overlay specifications:

\documentclass{beamer}

\usetheme{Madrid}

\begin{document}

\begin{frame}<1>[label=somelabel]
  Common text\\
  \begin{overprint}
    \only<+>{
      Figure 1 and explanation of Figure 1
    }
    \only<+>{
      Figure 2 and explanation of Figure 2
    }
  \end{overprint}
\end{frame}

\againframe<2>{somelabel}

\end{document}

With this solution you can at least choose which overlays should have the same frame number and which not.

share|improve this answer

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.