The PDF file format does not support animated and static GIFs as direct embeds. For PDF you will need to split an animated GIF into a PNG sequence and follow, for example, instructions given in Getting Gif and/or moving images into a LaTeX presentation .
However, the SVG format allows animated GIFs to be directly embedded in SVGs. SVG can be produced from TeX input by means of
dvisvgm. The SVG file can be opened and displayed in a WEB browser.
Click and press F11 to put the Web browser to full-screen:
Commands for producing SVG
dvisvgm --zoom=-1 --font-format=woff file.dvi
For every GIF to be embedded, the bounding box information must be provided by the user in an
.xbb file. In the example code,
ms_2d_bw_2.xbb is written by means of the
filecontents environment. Also, a GIF embedding rule must be defined, such that the
graphicx package knows how to deal with remote (online) GIF files.
%Graphics rule for Web-located Gifs (use local .xbb file and prepend base URL)
% write auxiliary file with BoundingBox information
% %%BoundingBox 0 0 <width in pixels> <height in pixels>
%%BoundingBox: 0 0 1013 715