25

I have a sequence of images in one pdf file. The first page in the pdf corresponds to the first step in the animation, the second page corresponds to the second step in the animation and in general, the n th page corresponds to the n th step in the animation. I want to run this animation from he pdf file in a single beamer frame and run the animation with a gap of 1 second between each page of the pdf. How do I go about doing this? I use pdflatex. Let us say the pdf file has 100 pages and each page contains the image sequentially for the animation and the name of the pdf file is animation.pdf.

  • fyi, this might be of use also pages.uoregon.edu/noeckel/PDFmovie.html Including animations in PDF using LaTeX (the page is a little outdated, but thought it might be useful as it talks about using latex to make animations in pdf) – Nasser Jun 4 '13 at 4:17
22

You can use the animate package to do this:

Code

\documentclass{beamer}
\usepackage{animate}

\begin{document}

\begin{center}
  \animategraphics[autoplay,loop]{1}{animation}{}{}
\end{center}

\end{document}

The syntax is the following:

\animategraphics[<options>]{<frames per second>}{<name without extension>}{<first frame>}{<last frame>}

If you don't specify <first frame> or <last frame>, the first respectively last page are used. In the given example the <options> make the animation looping continuosely. Other things, as control buttons (start, stop etc.) are possible, please refer to the manual for more options.

  • 1
    When I use the following command, \animategraphics[autoplay,loop]{1}{./animation.pdf}{1}{61}, I get the following errors: ! Package animate Error: Neither of the files (animate) ./animation.pdf1.pdf', (animate) ./animation.pdf1.mps', (animate) ./animation.pdf1.png', (animate) ./animation.pdf1.jpg', (animate) ./animation.pdf1.jpeg', (animate) ./animation.pdf1.jbig2', (animate) ./animation.pdf1.jb2', (animate) ./animation.pdf1.jp2', (animate) ./animation.pdf1.j2k' or (animate) ./animation.pdf1.jpx', (animate) could be found. (animate) Wrong file type? Mis-spelled file name?. – user1876 Jun 4 '13 at 6:01
  • You have to leave out the extension, so \animategraphics[autoplay,loop]{1}{./animation}{1}{61} – Tom Bombadil Jun 4 '13 at 6:08
  • Thanks. This is a very cool package. I have searching for such a nice package for couple of years. Thanks again. – user1876 Jun 4 '13 at 6:31
  • You're very welcome. I also only learned of this package through this site :D – Tom Bombadil Jun 4 '13 at 6:32
  • One last question. Is there a way to add caption to the video? I looked at the manual here, but was not able to find any. – user1876 Jun 4 '13 at 6:51
7

Alternatively, the media9 package can be used, movie15 is outdated, and playback, of GIF files in particular, is very unreliable as it depends on third-party plug-ins used by AdobeReader.

For use with media9, the PDF needs to be converted to SWF, using pdf2swf. This conversion keeps the vector-graphical nature of the original file:

pdf2swf  --set framerate=1 --output animation.swf animation.pdf

The frame rate is adjusted to 1 FPS, as requested.

Inclusion is done as:

\usepackage{media9}
\usepackage{graphicx}
...

\includemedia{\includegraphics[page=1]{animation}}{animation.swf}

The first page of the original animation.pdf is used as the poster image.

  • Hmm, but you also can't play Flash on all machines either. A lot of Linux people I know don't have installed any programm for playing .swf files and curse anyone using them ;) – Tom Bombadil Jun 4 '13 at 11:22
  • @Tom: Yes that is certain. It was more thought as a reply to Peters answer, which probably has the lowest mileage of all given here. – AlexG Jun 4 '13 at 11:27
2

1. Animated .gif:

You can produce an animated.gif file via:

pdfcrop animation.pdf

and then use convert from ImageMagick to obtain a .gif file. So something like:

 convert -verbose -delay 100 -loop 0 -density 400 animation-crop.pdf animation.gif

2. Include .gif:

As per How to add a gif file to my LaTeX file? the .gif file can be included by including the movie15 package in the preamble:

\includemovie{1cm}{1cm}{animation.gif}
  • I tried that before but it gives the following error: ! No room for a new \dimen . \ch@ck ...\else \errmessage {No room for a new #3} \fi l.170 \newdimen\@MXV@braiselen – user1876 Jun 4 '13 at 4:50
  • 1
    movie15 is horribly outdated, @Peter, and playback is extremely unreliable. It is much better to use either animate or media9. For the latter, one has to convert the PDF to SWF (the vector-graphical nature is kept), using pdf2swf. – AlexG Jun 4 '13 at 7:14

Your Answer

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