Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Related:
Convert gif image to png on the fly

I have an image file -- a gif file, which is the graph of a function. How do I add it to a LaTeX file? Will it come out OK in the subsequent pdf file?

share|improve this question

3 Answers 3

Use movie15 package. For example:

% in preamble
\usepackage{movie15}
% in documenet
\includemovie{1cm}{1cm}{ani.gif}

PDFLaTeX is needed, and you must use Adobe Reader with certain media player plug-in. Thus it often fails.

Another method is to use animate package. You have to convert the animated gif to separate images first, using ImageMagick:

convert foo.gif foo.png

This would sometimes create a suboptimal result; if the GIF is optimized try

convert foo.gif -coalesce foo.png

You may probably get foo-0.png, foo-1.png, ..., foo-18.png.

Then include the graphics:

\animategraphics{12}{foo-}{0}{18}

See the manual of animate for more options.

share|improve this answer
    
Interesting, but the OP didn't request animation ... :-) –  Hendrik Vogt Feb 6 '11 at 8:50
    
Indeed. I noticed @TeX asked for animated GIF, so I appended this answer. –  Leo Liu Feb 6 '11 at 9:40
    
I tried with different (animated) gif and none shows up in the PDF (Acrobat viewer), can any one point to a sample gif that works with movie15? –  alfC Jan 10 '12 at 19:18
    
The original question doesn't mention animated gifs. The workflow for including animated gifs as opposed to plain gifs is so significantly different that I think this answer isn't helpful to the question. –  Matthew Leingang Feb 5 '13 at 20:14
    
Worked for me. Thanks! –  Chris Mueller Jul 17 '14 at 19:26

needs pdflatex -shell-escape ... and an installed program convert which is available for all plarforms

\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}

\epstopdfDeclareGraphicsRule{.gif}{png}{.png}{convert gif:#1 png:\OutputFile}
\AppendGraphicsExtensions{.gif}

\begin{document}

  \includegraphics{demo.eps}\qquad
  \includegraphics{knuth-tex.gif}

\end{document}
share|improve this answer
3  
Unfortunately, animation in the original gif will no longer work after conversion. –  xport Dec 23 '10 at 7:51
13  
would be cool if we can have animation in a printed version .... :-) –  Herbert Dec 23 '10 at 8:04
3  
Electronic paper will come for sure someday! ;-) –  Martin Scharrer Feb 6 '11 at 10:56

You want to \usepackage{graphicx}, then \includegraphics{your.gif}. pdflatex doesn't like gifs so much, so it would be better to convert it (or resave from the application that created it) to PNG.

share|improve this answer
    
When I did what you suggest, I got this output: LaTex Error: cannot determine size of graphic in s2img482.png (no BoundingBox). What should I do? Thanks. –  TCL Dec 23 '10 at 4:29
    
@TCL: What output? –  TH. Dec 23 '10 at 4:30
    
@Mathew. Ok, I got it. Thanks. –  TCL Dec 23 '10 at 5:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.