The problem with redefining \pgfsys@endpicture
is that this is called at the end of each PGF graphic you use (including the six tiny navigation symbols on each beamer slide). It is also used to hold special instructions when you use certain drivers; so if you use XeLaTeX you will find the slides are not positioned correctly on the second and later pages. Best to leave that alone.
To get the fewest nasty surprises, you need to inject your code for writing the page numbers directly into the pgfpages
output routine. The \patchcmd
command from etoolbox
works for this.
While using a \makebox
directly works, it also takes up vertical space, so the tops of your slides on the first row may get pushed off the page. The code below uses the same technique as pgfpages
for positioning the number on the page without taking up room. To move it around, change the distances in the \pgfpoint
(measuring from the bottom left corner):
\documentclass{beamer}
\usepackage{etoolbox,pgfpages}
\pgfpagesuselayout{4 on 1}[a4paper,landscape]
\newcounter{physicalpage}
\makeatletter
\patchcmd{\pgfpages@buildshipoutbox}{%
\pgfsys@endpicture
}{%
\stepcounter{physicalpage}%
\setbox0\vbox{\makebox[0pt][c]{\arabic{physicalpage}}}%
\pgfsys@beginscope
\pgflowlevel{\pgftransformshift{\pgfpoint{.5\pgfphysicalwidth}{5mm}}}%
\wd0=0pt%
\dp0=-\ht0%
\pgfsys@hbox0%
\pgfsys@endscope
\pgfsys@endpicture
}{}{}
\makeatother
\begin{document}
\frame{foo}
\frame{bar}
\frame{baz}
\frame{bazbarfoo}
\end{document}
pdfpages
instead of (or after) usinghandout+pgfpages
, take a look at Actual page number (and total number of pages) in the handout – Ignasi Jun 13 '14 at 14:28\makeatletter \def\pgfsys@endpicture{% \makebox[\pgfphysicalwidth]{\the\numexpr\value{page}/4\relax} }\makeatother
– touhami Oct 30 '15 at 13:10