I want to loop 4x2 figures on many pages in beamer.
The page number setting fails page=\numexp \ii * 2 \relax.
Code
\documentclass{beamer}
\usepackage{pgffor}
\usepackage{graphicx}
\usepackage{subcaption} % http://tex.stackexchange.com/a/37597/13173
\begin{document}
\begin{frame}[allowframebreaks]
\foreach \ii in {1,...,4}{
\begin{figure}
\centering% not \center!
\begin{subfigure}{0.5\textwidth}
\includegraphics[scale=0.2, page=\ii]{{Rplots.bland.altman.1}.pdf}
\caption{Image \ii.}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[scale=0.2, page=\numexp \ii * 2 \relax]{{Rplots.bland.altman.1}.pdf}
\caption{Image \ii.}
\end{subfigure}
\end{figure}
}
\end{frame}
\end{document}
Output does not make sense to me; trying to solve it by \newcounter{ii} does not help.
! Undefined control sequence.
\GPT@page ->\numexp
\ii * 2 \relax
l.23 \end{frame}
Output with \the\numexp ...
...
?
! You can't use `the character 1' after \the.
\ii ->1
l.23 \end{frame}
?
! Missing \endcsname inserted.
<to be read again>
\relax
l.23 \end{frame}
?
! Missing { inserted.
<to be read again>
*
l.23 \end{frame}
?
! Missing \endcsname inserted.
<to be read again>
\relax
l.23 \end{frame}
TeXLive: 2016
OS: Debian 8.5

\includegraphics[scale=0.2, page=\the\numexpr \ii * 2 \relax]{{Rplots.bland.altman.1}.pdf}2 mistakes: 1)\numexpr, not\numexpand 2) you need\the\numexprin order to make it digestible by something looking for a string. – Steven B. Segletes Nov 15 '16 at 19:57\numexpr, not\numexp, and it has to resolve to a number, so usepage=\number\numexpr\ii*2orpage=\the\numexpr\ii*2. – Werner Nov 15 '16 at 20:04scale=parameter. Perhaps using\width=orheight=would work better for you, instead ofscale=. – Steven B. Segletes Nov 15 '16 at 20:05