Is there any way to include an animated GIF directly in either PDFLaTeX or XeLaTeX? I realize the
animate package can include animations in a PDF, but it doesn't support animated GIFs and you have to split them up manually into EPS or PNG files as far as I can tell.
Yes, use the movie15 package (in Latex), which supports GIFs directly. You will need to use a PDF viewer that has the right plugin to supported GIF animations.
Note on media9
The movie15 package has been marked deprecated on CTAN for some time in favour of the media9 package, because media9 uses the better supported approach to embedding media of Adobe's Rich Media Annotations, rather than the old, ad-hoc, plug-in based approach of movie15. This has the consequence that building rich media documents in media9 is a more flexible process, supporting several workflows, and the results typically can be displayed with more viewers. However, media9 does not support animated GIFs - the GIFs would have to be converted to a supported format such as FLV or MP4 before embedding.
For animated GIF, package
animate should be used. Animated GIF sequences tend to be short and don't justify a video embedding package, such as
media9, that embeds a videoplayer component alongside the sequence and which requires the GIF to be transcoded into MP4 first.
animate is a lightweight alternative with the bonus of producing embedded animations that work in AR versions for Win, OSX and Linux, while
media9 embedded video only works in AR for Win and OSX. For use with
animate, the GIF must be split into a PNG or JPEG sequence, optimized GIF must be un-optimized first:
These are the steps for a 100 frames animated GIF, using package
animate and playing at 12 frames per second:
gifsicle --unoptimize animated.gif | convert - frame-%d.png
With the deprecated
movie15 package it was, at least theoretically, possible to embed animated GIF without preprocessing. This method depended on the availability of a third-party plugin, some QickTime component to be specific, used by AR for displaying the GIF. This never worked reliably, though.