# Frame numbering with multiple frames in a page in beamer

I am working on a beamer presentation where I number frames using

\addtobeamertemplate{navigation symbols}{}{%
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\hspace{1em}%
}


Now I want a printable version with 4 frames per page, so I used Loop Space's reply at this question. But incorporating this creates a problem when frame number exceeds 4. For my current 8 frame slide, frames are numbered: 1/4, 2/4, ..., 8/4. How can I fix that (i.e., frames are numbered this way: 1/8, 2/8, ..., 8/8)?

MWE

\documentclass[10pt, a4paper, english, aspectratio=169,handout]{beamer}

\mode<handout>
{
\usepackage{pgf}
\usepackage{pgfpages}

\pgfpagesdeclarelayout{4 on 1 boxed}
{
\edef\pgfpageoptionheight{\the\paperheight}
\edef\pgfpageoptionwidth{\the\paperwidth}
\edef\pgfpageoptionborder{0pt}
}
{
\pgfpagesphysicalpageoptions
{%
logical pages=4,%
physical height=\pgfpageoptionheight,%
physical width=\pgfpageoptionwidth%
}
\pgfpageslogicalpageoptions{1}
{%
border code=\pgfsetlinewidth{2pt}\pgfstroke,%
border shrink=\pgfpageoptionborder,%
resized width=.5\pgfphysicalwidth,%
resized height=.5\pgfphysicalheight,%
center=\pgfpoint{.25\pgfphysicalwidth}{.75\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{2}
{%
border code=\pgfsetlinewidth{2pt}\pgfstroke,%
border shrink=\pgfpageoptionborder,%
resized width=.5\pgfphysicalwidth,%
resized height=.5\pgfphysicalheight,%
center=\pgfpoint{.75\pgfphysicalwidth}{.75\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{3}
{%
border code=\pgfsetlinewidth{2pt}\pgfstroke,%
border shrink=\pgfpageoptionborder,%
resized width=.5\pgfphysicalwidth,%
resized height=.5\pgfphysicalheight,%
center=\pgfpoint{.25\pgfphysicalwidth}{.25\pgfphysicalheight}%
}%
\pgfpageslogicalpageoptions{4}
{%
border code=\pgfsetlinewidth{2pt}\pgfstroke,%
border shrink=\pgfpageoptionborder,%
resized width=.5\pgfphysicalwidth,%
resized height=.5\pgfphysicalheight,%
center=\pgfpoint{.75\pgfphysicalwidth}{.25\pgfphysicalheight}%
}%
}

\pgfpagesuselayout{4 on 1 boxed}[a4paper, border shrink=5mm, landscape]
\nofiles
}

\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\hspace{1em}%
}

\setbeamercolor{footline}{fg=black}
\setbeamerfont{footline}{series=\bfseries}

\begin{document}
\begin{frame}
Frame 1
\end{frame}
\begin{frame}
Frame 2
\end{frame}
\begin{frame}
Frame 3
\end{frame}
\begin{frame}
Frame 4
\end{frame}

\begin{frame}
Frame 5
\end{frame}
\begin{frame}
Frame 6
\end{frame}
\begin{frame}
Frame 7
\end{frame}
\begin{frame}
Frame 8
\end{frame}
\end{document}

• This is a bit in the "black magic" camp so I'm posting as a comment. If you comment out \pgfpagesuselayout{4 on 1 boxed}[a4paper, border shrink=5mm, landscape] and \nofiles and compile until you get the numbers right (like 1/8,2/8,...,8/8), then you can uncomment the two lines above and the numbers will stay right. – Nico Boni Oct 16 '14 at 16:31
• Wow! That worked. Do you have enough time to explain it mo me, please? – pushpen.paul Oct 16 '14 at 18:00
• I added an answer, too long for a comment... – Nico Boni Oct 16 '14 at 18:18
• By the way, why do you have the \nofiles macro loaded in the first place? If you comment it \inserttotalframenumber will give you the right number. So if you don't need it for some specific purpose, just remove it and you're set. – Nico Boni Oct 17 '14 at 14:11
• @dcmst Yeah, I did that already (but thought it is not worth mentioning here). :-). Thanks. – pushpen.paul Oct 17 '14 at 18:51

What the "black magic" method does is to take advantage of the \nofiles macro, that prevents modification of the .aux file.

If we comment out

%\pgfpagesuselayout{4 on 1 boxed}[a4paper, border shrink=5mm, landscape]
%\nofiles


We get a 1 frame on 1 page document with correct page numbering. Looking into the .aux file now (last line), we get:

\@writefile{nav}{\headcommand {\def \inserttotalframenumber {8}}} % 8 is the number we want for the total frame count


Which is the correct value, since now the pages are counted one on one.

At this point we uncomment the two lines above:

 \pgfpagesuselayout{4 on 1 boxed}[a4paper, border shrink=5mm, landscape]
\nofiles


\nofiles will ensure that the .aux file is not modified, so that it will keep the correct total number.

Of course the black magic fails as soon as we add another frame/page, so the enchantment must be used when the document is complete, otherwise bad things will happens (so they say...).

• So they say do not use black magic? :-). Thanks. It is helpful. – pushpen.paul Oct 17 '14 at 7:25