18

I'm trying to include GIF image in my LaTeX document. To my understanding this is possible. I'm using pdflatex and I get the following message:

ERROR: LaTeX Error: Unknown graphics extension: .gif.

And the figure I try is:

\begin{figure}
  \centering
  \subfloat[]{\label{fig:a}}{\includegraphics[width=0.45\textwidth]{Safinya_lamelar.png}}
  \subfloat[]{\label{fig:b}}{\includegraphics[width=0.45\textwidth]{Safinya_hex.png}}
  \subfloat[]{\label{fig:c}}{\includegraphics[width=0.45\textwidth]{Farago_lamelar.gif}}
  \subfloat[]{\label{fig:d}}{\includegraphics[width=0.45\textwidth]{Farago_hex.gif}}
  \caption{Lipoplexes}
  \label{gene.fig1}
\end{figure}  

What am I doing wrong?

4
  • Where do you get your understanding from? It's wrong. Nov 15, 2011 at 7:33
  • @MartinSchröder: In the above linked page it says '... and pdflatex will look for "figure.pdf", "figure.gif", or "figure.jpg".' Should be .png instead of .gif. Nov 15, 2011 at 7:57
  • @MartinScharrer: Well, that page is some years old. :-> But GIF was always wrong. Nov 15, 2011 at 13:29
  • @MartinSchröder: gif was always wrong (as you say -- it was still covered by that stupid patent when pdftex appeared), but tiff (extension tif) was once valid. perhaps the site author was simply confused rather than just "plain wrong"? Jun 14, 2012 at 15:02

1 Answer 1

27

No, pdftex does not support GIF. Your online source is incorrect. See the pdftex manual, which is the ultimate guide here:

The image type is specified by the extension of the given file name: .png stands for png image, .jpg (or .jpeg) for jpeg, .jbig2 (preferred, but .jb2 works also) for jbig2, and .pdf for pdf file.

Simply convert your GIF to PNG. You won't be able to include animated GIFs or MPNGs directly, AFAIK.

The error you get is because there is no graphics rule set-up for .gif. You could define your own using \DeclareGraphicsRule, but there is no driver support for it, so that won't help you.

3
  • Last year I wrote my Ms.C. presentation in LaTeX (beamer) and I did include gif animation. could it be that I actually used XeLaTeX?
    – Yotam
    Nov 14, 2011 at 11:27
  • 1
    XeTeX seems to support the GIF format. Nov 14, 2011 at 11:33
  • 5
    For animated GIFs, try the animate package. However, as GIF is not directly supported, convert animated GIFs to a sequence of numbered PNG files first using ImageMagick convert (convert in.gif out.png). Then animate this file sequence with aforementioned package. Works with XeLaTeX and others.
    – AlexG
    Nov 14, 2011 at 12:49

You must log in to answer this question.

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