As a follow up to Highlighting specific parts of a TikZ drawing, I'd like to know how to generate an animated image (gif) from a series of beamer slides.

Martin Scharrer came up with this example:

Drawing 1

Some hints on cropping the PDF file are also welcome. =)

  • I don't know the solution but my belief is the solution is possible using beamer or within LaTeX.
    – alhelal
    Sep 13, 2017 at 5:26

4 Answers 4


I generated that animated GIF the following way under Ubuntu Linux. It should work under other OSs as well because the external software is also available for Windows, Mac and others.

This assumes a beamer frame with several overlays as a starting point. The code for the GIF above can be found in my answer to Highlighting specific parts of a TikZ drawing.

  1. Ensure otherwise empty slides, e.g. \setbeamertemplate{navigation symbols}{}%
  2. Ensure that all slides have the same size.
  3. Compile to PDF (directly or indirectly).
  4. Crop the PDF, e.g. using pdfcrop <file>.pdf.
  5. Use ImageMagick to generate an animated GIF from the multi-page PDF:

    convert -verbose -delay 50 -loop 0 -density 300 <file>-crop.pdf <file>.gif

    Change the settings to your liking.
    -verbose is not really required.
    -delay states the duration of every image in the animation in 1/100 s.
    -loop states the number of repeats. 0 here means repeat indefinitely.
    -density determines the density for the raster image in dots-per-inch (dpi). This will influence the GIF size and is required because the PDF is a vector graphic. You can also use 300x300 etc. to select the X and Y density separately.

Here also an external example showing a diagram I had in one of my scientific publications: MP-DPWM (300k)

I might add support for this to standalone. Conversion support is already added in the developer version.

  • 1
    @MartinScharrer, follow your steps, I can't get animated GIF. I only get the first slide of the pdf file in my GIF file. How to solve it? Thanks. My system is Windows 7. I use Ghostscript 9.06.
    – Pig Cry
    Jan 10, 2013 at 2:13
  • @PigCry: The above uses ImageMagick not Ghostscript and works fine with me. No idea why you are only get the first page. Jan 10, 2013 at 7:52
  • @PigCry: I have the same issue on the mac. See my question at Apple-SX. You can workaround with pdftk. Mar 20, 2013 at 12:46
  • That's a great trick which I've been using a lot. However, in rare cases it did not work, but then using this chain saved the day for me.
    – user121799
    Feb 12, 2018 at 16:39
  • If you have problem with this, look at stackoverflow.com/questions/42928765/… (I hope to save a bit of time to fellows LaTeXers...)
    – Rmano
    Jan 15, 2019 at 11:02

For those who need non Beamer version, see the following.

LaTeX Input File:

In this illustration I use PSTricks.

% travelingwave.tex

\paperwidth=\dimexpr\Right cm\relax
\paperheight=\dimexpr\Top cm - \Bottom cm\relax


Batch File:

rem compile.bat takes a LaTeX input file without extension.
echo off
latex %1
dvips -t unknown %1
gswin32c -dAutoRotatePages=/None -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%1.pdf %1.ps
convert -verbose -delay 25 -loop 0 -density 300 %1.pdf %1.gif
rem acrord32 %1.pdf
del %1.log
del %1.aux
del %1.dvi
del %1.ps

For the sake of simplicity, save both travelingwave.tex and compile.bat in the same directory. To compile, type compile travelingwave in DOS-command, and hit enter. Done!


enter image description here


  1. See ImageMagick v6 Examples -- Animation Basics for the detailed description about convert's switches.
  2. If \pagecolor{<any-color-including-white>} is disabled, we will get an effect as follows. enter image description here
  3. ImageMagick's convert invokes GhostScript gswin32c.exe behind the scene as follows. enter image description here
  • I guess, the \pagecolor{<any-color-including-white>} makes the background no longer transparent. Jul 21, 2011 at 19:08

I do not know if my answer meets the requirements of how the answers should be posted on this site (since it has practically no LaTeX code involved), but here it comes.

With the emergence of online tools it has become easy to convert documents of a certain extent into others, without the need to download any programs. All those tools are easy-to-use and so not need any space in our computer.

Since the beamer output is a PDF file, we can convert PDF to GIF with EZGIF by following these simple steps:

  1. Upload the PDF document
  2. Set up the GIF (choose slides and delay amount)
  3. Convert!

Here is an example:

enter image description here


After spending a few hours on ImageMagick with no result (I kept getting error messages), I decided to go for a Photoshop + Acrobat Pro solution. Here's how I did it.

Required software

  • Acrobat Pro (I'm using Acrobat X), or any other PDF reader that allows you to export or save the PDF pages as images
  • Photoshop (I'm using CS3, and presumably newer, or even slightly older, versions will work as well)


  1. Generate a PDF file of your Beamer slides
  2. In Acrobat Pro, go to File > Save as > Image > <select PNG or JPEG>. In the pop-up window, select Settings... on the right, and under "Coversion" change "Resolution" to 600 pixels/inch or above (the default resolution is very low). Then click OK and Save, and images of each page will be saved to the specified location as <PDF_Name>_Page_#.png.
  3. Open Photoshop, go to File > Script > Load Files into Stack. Browse and select all the image files generated in step 2 and click OK. Now all the pages should be imported as layers of a Photoshop document.
  4. Go to Window and select Animation to show the animate panel.
  5. From the flyout menu in the top right of the animation panel, select Make frames from layers, and then Reverse frames to set the frames in correct order.
  6. Select all the frames in the animation panel (click the first frame, and then Shift+click the last one), and choose a frame rate at the bottom right corner of any frame. You can also set the repeat option at the bottom left of the panel. Preview by clicking the play button.
  7. Lastly, go to File > Save for Web & Devices... > Save (top right) > give it a name, and make sure to select .gif as the extension. Then we're done!

Note: If you want to crop the PDF file, then after step 6, select all layers in the layers panel, use the Crop Tool to crop the images.

gif of string recognition

gif of wave

  • This is not a latex solution! However, I appreciate your effort.
    – hola
    Aug 9, 2014 at 17:23
  • @pushpen.paul: Well, the other solutions are not LaTeX solutions either; they use ImageMagick ;)
    – Herr K.
    Aug 9, 2014 at 19:29
  • 2
    @KevinC Yeah! But your method is very much manual! :-)
    – hola
    Aug 9, 2014 at 19:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .