3

I made an animation with the animate package and I want to integrate it into a Beamer presentation, and I only get a blank page. Can you tell me how to integrate an external animation into a Beamer presentation.

Here are two files to test, compile first the animation.tex ====Animation.tex===

\documentclass{standalone}
\usepackage{animate}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\pgfdeclarelindenmayersystem{A}{%
  \symbol{F}{\pgflsystemstep=0.6\pgflsystemstep\pgflsystemdrawforward}
  \rule{A->F[+A][-A]}
}

\begin{document}
\begin{animateinline}[controls,autoplay,loop]{2}
\multiframe{8}{n=1+1}{
  \begin{tikzpicture}[scale=10,rotate=90]
    \draw (-.1,-.2) rectangle (.4,0.2);
    \draw [blue,opacity=0.5,line width=0.1cm,line cap=round]
      l-system [l-system={A,axiom=A,order=\n,angle=45,step=0.25cm}];
  \end{tikzpicture}    
}
\end{animateinline}
\end{document}

=======

Beamer file

=======

\documentclass{beamer}

\begin{document}
\begin{frame}
first frame
\end{frame}
\begin{frame}
animation
\includegraphics{animation.pdf}
\end{frame}
\begin{frame}
last frame
\end{frame}
\end{document}

========

rpapa
  • 12,350

1 Answers1

4

Animations produced with animate are based on PDF annotations, very much like hyperlinks. Such interactive elements get lost if they are embedded from external PDF documents with the usual methods (\includepdf, \includegraphics).

Therefore, a different procedure is needed:


  1. Build a multi-page PDF with the animation frames (animation.tex):

\documentclass[class=beamer,tikz]{standalone}

\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\pgfdeclarelindenmayersystem{A}{%
  \symbol{F}{\pgflsystemstep=0.6\pgflsystemstep\pgflsystemdrawforward}
  \rule{A->F[+A][-A]}
}

\usepackage{multido}

\begin{document}
\multido{\n=1+1}{8}{%
  \begin{tikzpicture}[scale=10,rotate=90]
    \draw (-.1,-.2) rectangle (.4,0.2);
    \draw [blue,opacity=0.5,line width=0.1cm,line cap=round]
      l-system [l-system={A,axiom=A,order=\n,angle=45,step=0.25cm}];
  \end{tikzpicture}%    
}
\end{document}

  1. Build animation inside the target document, using \animategraphics:

\documentclass{beamer}
\usepackage{animate}

\begin{document}

\begin{frame}{first frame}
\end{frame}

\begin{frame}{animation}
  \animategraphics[controls,autoplay,loop]{2}{animation}{}{}
\end{frame}

\begin{frame}{last frame}
\end{frame}

\end{document}

AlexG
  • 54,894
  • Thank you egreg, but it does not completely solve the problem, \ animategraphics recompiles again, the different images and it does not reduce the compilation time of the final document (tries with a lot of images) – rpapa Feb 24 '17 at 09:25
  • This procedure avoids re-processing TikZ code rather than rebuilding the animation. But to my experience, processing TikZ code is the more time consuming of both actions. Rebuilding the animation, while compiling the final document, cannot be avoided. – AlexG Feb 24 '17 at 10:11
  • @rpapa I am currently optimizing the animate code to accelerate \animategraphics (animating external graphics). It seems that doubling the speed will be possible once I am done with it. – AlexG Feb 24 '17 at 10:18
  • Related thread https://tex.stackexchange.com/q/373379/13173 – Léo Léopold Hertz 준영 Jun 05 '17 at 14:40