1

EDIT: Marmot has provided me with alternative solution, for which I'm very grateful. Question however remains because I'd like to learn what was wrong with my approach.

I want to make a presentation with beamer, on one frame (beamer frame) I want to have tikz animation with over 30 frames (of animation). I don't want to type out each frame (of animation) manually, so I attempted to use \loop to create frames (of animation).

After removing all excess code, I reduced conflicting part to this:

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage[polish]{babel}
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{animate}

\begin{document}
\begin{frame}
\newcount\spiniter
\spiniter=1
\begin{animateinline}[loop,controls]{10}
Text 0
\loop
\newframe
Text \the\spiniter
\advance \spiniter 1
\ifnum \spiniter<10
\repeat
\end{animateinline}
\end{frame}
\end{document}

Which fails to compile with ! Improper \prevdepth error.

Note: sample does not use tikz, as I wanted to isolate conflict as much as possible, code sample is supposed to animate "Text x", starting with x=0 and ending with x=9.

For comparison, this manually prepared command set works:

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage[polish]{babel}
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{animate}


\begin{document}
\begin{frame}
\begin{animateinline}[loop,controls]{10}
Text 0
\newframe
Text 1
\end{animateinline}
\end{frame}
\end{document}

constantly switching between "Text 0" and "Text 1" as desired (ignore awful positioning of buttons, this is not relevant).

Could someone suggest some way to achieve what I want to do? All other drawing commands are already written and parametrised with integers.

EDIT: Great thanks to marmot, who in comments pointed me towards question containing alternative solution. However if anyone knows, I'd like to learn what was wrong with my approach.

  • 1
    Welcome to TeX-SE! I am not sure I understand what you want to do. animate has its own means to do loops. Replace your loop with \multiframe{10}{icount=1+1}{Text \icount} to see what I mean. Does this give you what you want? – user121799 May 10 at 20:29
  • @marmot Well, in actual presentation I want to have png image+tikz drawing animated together. I "glued" them together with \tabular and "encapsulated" that in animateinline, separating with \newframes, but doing that for multiple frames is a lot of pointless work. I'll try your suggestion. – M i ech May 10 at 20:41
  • 1
    Something like tex.stackexchange.com/q/168140/121799? – user121799 May 10 at 20:43
  • @marmot Solution from question you linked worked for me. Thanks a lot. – M i ech May 10 at 20:53
  • Glad to hear. Something that, according to my experience, often helps to find some useful information is to perform a google (!) search with site:tex.stackexchange.com in it. I found the above link searching for site:tex.stackexchange.com use loop in animate. The built-in search engine of this site is often (again according to what I find) less efficient. This leaves the question what to do with your question. We could close it as a duplicate or one of us writes an answer of the type "animate has its own means to do loops", what do you think? – user121799 May 10 at 20:59
1

Frame content is temporarily saved in TeX saveboxes, before being distilled into so-called PDF Form XObjects. In the code below, the \newframe and animateinline command and environment are replaced by LaTeX box saving commands, leading to the observed error during processing:

\documentclass{beamer}

\usepackage{animate}

\begin{document}
\begin{frame}
\newcount\spiniter

\spiniter=1
\begin{lrbox}{0}
Text 0
\loop
  \end{lrbox}
  \begin{lrbox}{0}
  Text \the\spiniter
  \advance \spiniter by1
  \ifnum \spiniter<10
\repeat
\end{lrbox}

\end{frame}
\end{document}

Interestingly, the error does not occur, if a standard class is used, or if, in the case of beamer, the frame environment has been removed:

\documentclass{beamer}
%\documentclass{article}

\usepackage{animate}

\begin{document}
%\begin{frame}
\newcount\spiniter

\spiniter=1
\begin{lrbox}{0}
Text 0
\loop
  \end{lrbox}
  \begin{lrbox}{0}
  Text \the\spiniter
  \advance \spiniter by1
  \ifnum \spiniter<10
\repeat
\end{lrbox}

%\end{frame}
\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.