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.
- 223,288
3 Answers
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.
- 215
- 40,123
-
1When I use the following command,
\animategraphics[autoplay,loop]{1}{./animation.pdf}{1}{61}, I get the following errors:
– Jun 04 '13 at 06:01! 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?. -
You have to leave out the extension, so
\animategraphics[autoplay,loop]{1}{./animation}{1}{61}– Tom Bombadil Jun 04 '13 at 06:08 -
1Thanks. This is a very cool package. I have searching for such a nice package for couple of years. Thanks again. – Jun 04 '13 at 06:31
-
You're very welcome. I also only learned of this package through this site :D – Tom Bombadil Jun 04 '13 at 06: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. – Jun 04 '13 at 06:51
-
Probably but the whole thing in a figure environment? Like
\begin{figure} <animation> \caption{my caption} \end{figure}. – Tom Bombadil Jun 04 '13 at 06:57 -
Yes. Thats what I have done now. Thanks, this is probably the most useful package, I have been looking for a long time. Thanks again. – Jun 04 '13 at 07:05
-
-
Sorry to buzz you again. @AlexG If I run it under Ubuntu, I get the following message
! No room for a new \dimen . \ch@ck ...\else \errmessage {No room for a new #3} \fi l.137 ... \csname newdimen\endcsname \scratchdimen,! No room for a new \dimen . \ch@ck ...\else \errmessage {No room for a new #3} \fi l.1253 \newdimen\MPscratchDim % will be assigned globaland! No room for a new \dimen . \ch@ck ...\else \errmessage {No room for a new #3} \fi l.304 \newdimen\@anim@tmpdima %length registers for occasional use, though the file compile and the movie plays in the pdf. How to fix this? – Jun 04 '13 at 16:28 -
-
Is there a way to increase the speed of animation without skipping any of the frames? – Nidish Narayanaa Feb 20 '21 at 15:11
Notice of obsolescense: The embedded playback of Flash content is no longer possible due to EOL of Flash and FlashPlayer.
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.
- 54,894
-
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
.swffiles and curse anyone using them ;) – Tom Bombadil Jun 04 '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 04 '13 at 11:27
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}
- 223,288
-
I tried that before but it gives the following error:
– Jun 04 '13 at 04:50! No room for a new \dimen . \ch@ck ...\else \errmessage {No room for a new #3} \fi l.170 \newdimen\@MXV@braiselen -
2
movie15is horribly outdated, @Peter, and playback is extremely unreliable. It is much better to use eitheranimateormedia9. For the latter, one has to convert the PDF to SWF (the vector-graphical nature is kept), using pdf2swf. – AlexG Jun 04 '13 at 07:14
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 04 '13 at 04:17