0

I encounter an issue with the following code and must admit that I was able to find trick on the forum for now.

\begin{frame}{Title}

\begin{figure}[htbp]
\begin{center}
\begin{animateinline}[loop,poster = first, controls]{1}
   \foreach \x in {a,b}{
     \includegraphics[scale=1]{../figures/fig-\x}%
       \newframe
    }
\end{animateinline}

\end{center}
\end{figure}
\end{frame}

When I unflatten the list, there is no problem. However, the \foreach loop throws an error (Undefined control sequence).

I can't find any workaround.

Thank you for your help

  • 1
    Hi, welcomme. Please add a compileable code. – AndréC Sep 13 at 12:41
1

Pkg animate has its own looping device, \multiframe. It should be used instead of external looping commands, such as \foreach, with a \newframe in the loop body.

For parameterizing the file name argument of \includegraphics with non-numeric values ("a", "b", "c"), use pkg pgf's array-like expression in combination with \multiframe:

\documentclass{article}

\usepackage{pgf}
\usepackage{graphicx}
\usepackage{animate}

\def\imgID{{"a", "b", "c"}}

\begin{document}

\begin{animateinline}[loop, controls]{1}
  \multiframe{3}{i=0+1}{  % i = <init. val.> + <incr.>
    \pgfmathparse{\imgID[\i]}%
    \includegraphics[scale=0.5]{example-image-\pgfmathresult}%
  }
\end{animateinline}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.