What I Want
I'm creating a presentation with pdflatex and the beamer documentclass.
In an external program I created a stepwise graphic. The graphic is one PDF file where each page in that PDF is a single step.
I want to show the steps of this graphics one at a time. The graphic for each step should replace the graphic of the previous step. This is essentially what \multiinclude
from xmpmulti.sty
does, except that all steps are taken from a single PDF file.
I did so with the following tex code:
\begin{frame}
Content before
\pause
\begin{overprint}
\onslide<+|handout:0>\includegraphics[page=1]{img}
\onslide<+|handout:0>\includegraphics[page=2]{img}
\onslide<+-|handout:1>\includegraphics[page=3]{img}
\end{overprint}
\onslide<+->
Content after
\end{frame}
As I want to include many such stepwise graphics I wanted to automate this process with a for loop and later with a command. However, I cannot seem to get it right.
What I Have
At the moment I have the following
\nonstopmode
\pdfsuppresswarningpagegroup=1
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{pgffor}
\begin{document}
\begin{frame}
\pdfximage{img.pdf}
\newcounter{laststep}
\setcounter{laststep}{\pdflastximagepages}
\begin{overprint}
\foreach \x in {1,...,\value{laststep}} {
%\onslide<+|handout:0>
\includegraphics[page=\x]{img}
}
\end{overprint}
\end{frame}
\end{document}
To make this example self contained: Here is the output of base64 img.pdf
. Copy-paste this into base64 -d > img.pdf
to the get the file or use an online service.
The code as shown compiles and includes all steps of img.pdf
at the same time, but when I uncomment \onslide<+|handout:0>
I get the following error over and over again. pdflatex runs endlessly.
! Missing number, treated as zero.
<to be read again>
p
l.19 \end{frame}
I spent several hours trying to automate inclusion of these stepwise graphics. In other attempts I also used other loop macros such as forloop
but nothing worked so far. This is my best attempt so far.
Question
How can I include a stepwise graphic from a single PDF? Either by fixing the broken \foreach
or by using a different approach or even existing solution in form of a package.
\newcounter{iloop} \setcounter{iloop}{0} \loop\stepcounter{iloop} \onslide<+|handout:0> \includegraphics[page=\number\value{iloop}]{img} \ifnum\value{iloop}<\value{laststep}\repeat
. BTW, your question is very similar to tex.stackexchange.com/q/445916.Command \c@laststep already defined
and 2×Command \c@iloop already defined
.\newcounter{iloop}
should not be inside the frame, and the same statement applies to\newcounter{laststep}
.img.pdf
, so you have to coope with the base64 representation. But the content is irrelevant. You can take any pdf you have lying around.\newcounter
s before the frame.