I'm trying to create an animation to include into a beamer. I figured (naively I suppose) a way to do that is to create a Pdf with animate package, and then \includegraphics
it into my beamer. Running on Mac Os X 10.5.8 with Texlive.
Here is what I'd like to animate :
\documentclass{article}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\usepackage{animate}
\newcommand{\rotatingarrow}[1]{
\begin{pspicture}(0,0)(10,10)%
\psaxes(0,0)(9,9)
\rput(6,1){\Huge{Temps = #1 s}}
\rput{#1}(4,4){
\psline[linecolor=blue,arrowsize=5pt]{->}(0,0)(2,1)\rput{#1}(2.3,1.3){\Huge{$\textcolor{blue}{\vec{v}}$}}
\psline[linecolor=red,arrowsize=5pt]{->}(2,1)(1,3)\rput{#1}(1.3,3.3){\Huge{$\textcolor{red}{\vec{a}}$}}
}
\end{pspicture}%
}
\begin{document}
\begin{center}
\begin{animateinline}[poster=last,loop,autoplay,width=5cm,height=5cm]{12}%
\multiframe{36}{iAngle=0+10}{%
\rotatingarrow{\iAngle}%
}%
\end{animateinline}%
\end{center}
\end{document}
Then compiling with LaTeX.
When I open it with Adobe, it does what I want. However, the animation isn't cropped. Then, pdfcrop seems to kill the file. After running pdfcrop on it, it'll be simply blank.
My question is : How do I proceed to have a cropped animation like I see in every tutorial ? How to include that animation into a Beamer (I suppose my idea is wrong).
Best Answer
What makes a PDF with working animations no longer work?
There are 3 cases that will make working animations in a PDF file NO longer work. For simplicity, let
animation.pdf
be the PDF file with working animations.animation.pdf
withgswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=animation-compressed.pdf animation.pdf
.animation.pdf
withpdfcrop animation.pdf animation-cropped.pdf
.animation.pdf
from within a LaTeX input file by using\includegraphics{animation.pdf}
.\animateinline
versus\animategraphics
Recall that we cannot embed a PDF with animation into another document as what AlexG said, we have two options to solve your problem. Just choose one of the following.
animateinline
environment to sandwich your animation codes, and put the environment into your host input file (which is an input file withbeamer
document class in your case). However this approach has 3 drawbacks: (a) you cannot usepdflatex
to compile your host input file when the animation codes in PSTricks language. (b) your host input file contains both text and codes so it become long, crowded, hard-to-understand, difficult to maintain, etc, (c) compilation will take longer time because the animation codes get recompiled whenever you make any changes. That is why I suggest you to do the second option below.\animategraphics
instead ofanimateinline
.\animategraphics
allows you to import any PDF with one or more pages to be animated.The theory is enough. Now the following will explain the second option (using
\animategraphics
). There are 2 steps as follows:Solution
In my opinion, it will be better if you cut the animation code from the host input file (presentation with beamer in your case ) and paste the animation code into a single, TeXable input file. TeX the animation input file to produce a PDF output. Later, you can make use of this PDF to create many other projects such as GIF animation, PDF animation (in your case), PNG images, etc. This separation method also make your host input file neater, cleaner, readable, understandable, etc.
Let
Simple.tex
be the TeXable animation input file as follows:For those who are unlucky to use
standalone
document class, the last resort is to usepreview
as follows. Note thatstandalone
also usespreview
internally.TeX it with either
xelatex
orlatex->dvips->ps2pdf
to get a PDF file. In our example, it will contain 36 pages to create a simple animation as follows.Now, you create the beamer as follows.
TeX it with either
pdflatex
(recommended) orxelatex
. And the following image shows your presentation with a working animation.The latest edit
We can also combine both input files into single input file as follows. Compile it with
pdflatex --shell-escape
.