LaTeX Beamer: How to get distinct page numbers when using overlays?

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


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.


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.