Search code examples
animationlatexgifbeamer

How to add a gif/animation onto Beamer (post Adobe retiring Flash)


I'm having trouble adding a gif onto my Beamer. I've searched for answers but I haven't found one that was written after Adobe retired it's Flash Player. I've tried using the animate package, and it does compile the file, but it doesn't let me play it (the controls appear, but if I click them nothing happens). I've tried the media9 and movie15 packages, but apparently they are obsolete. So, I am very confused on how to add an animation at this point in time. And honestly, I don't even know if the lack of Adobe Flash Player is the problem. I know there has to be a simple answer.

I don't think it's necessary to add my code, since I feel it's such a trivial matter.

Thanks in advance!


Solution

  • You can split your .gif file into individual images. There are many different converters to be found online or you could use image magick from the command line:

    convert -coalesce test.gif test.png
    

    This will result in a series of images called test-0.png etc.

    You can then include these in your beamer presentation using the xmpmulti package.

    To animate this sequence of slides, you can use \transduration<0-16>{0}. Replace 16 with how many images you have and {0} with the duration in seconds each image should be shown. With 0 seconds from my example, the time will be determined by how long your computer takes to render the slide.

    If you now open the presentation with adober reader in presentation mode, the slides will change automatically and thus create an animation.

    \documentclass{beamer}
    \usepackage{xmpmulti}
    \begin{document}
        \begin{frame}
            \transduration<0-16>{0}
            \multiinclude[<+->][format=png, graphics={width=\textwidth}]{test}
        \end{frame}
    
    \end{document}
    

    Or if abandoning the pdf format is an option, you could have a look at the media4svg package.