41

When using graphicx's \includegraphics you can specify the file extension or not. For generic use and perhaps portability, extensions are commonly dropped. The types of "approved" inclusions and their order of precedence depends on the driver/compiler being used. What are these driver-defaults?

Related: Which graphics formats can be included in documents processed by latex or pdflatex?

4 Answers 4

31

pdftex.def

Version 2011/05/28 v0.06e

The list depends on

  • the version of pdftex.def,
  • the version of pdfTeX (temporarily TIFF was available, latest addition is JBIG2),
  • the version of the generated PDF (JBIG2 requires PDF 1.4).

For the current versions (2012) and PDF ≥ 1.4, the list is:

.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2

The order of the list is not optimal, it is a victim of compatibility.

The list can be extended by package epstopdf that adds .eps to the list and provide means to support further image formats.

dvips.def

Version: 1999/02/16 v3.01i

.eps,.ps,.eps.gz,.ps.gz,.eps.Z

Other supported extensions:

.pcx,.bmp,.msp,.pict,.pntg

dvipdfm.def

Version: 1999/9/6 vx.x (Bug: should be 1999/09/06)

.jpg,.jpeg,.pdf,.png

Also supported are EPS files.

dvipdfmx.def

Version: 1999/02/16 v3.0i

.pdf,.jpg,.jpeg,.png,.bmp,.ps,.eps,.pz,.eps.Z,.ps.Z,.ps.gz,.eps.gz

xetex.def

Version: 2009/11/22 v0.94

.pdf,.eps,.ps,.png,.jpg,.bmp,.pict,.tif,.psd,.mac,.sga,.tga,.gif

vtex.def

Version 2001/10/02 v7.45

.gif,.png,.jpg,.tif,.bmp,.tga,.pcx,.eps,.ps,.mps,.emf,.wmf
(also .tiff, .targa, .jpeg)

Other drivers in the graphics bundle

Version: 1999/02/16 v3.0i

dvipdf.def:  .eps,.ps,.eps.gz,.ps.gz,.eps.Z
dvipson.def: .eps,.ps,.pcx,.bmp (also .tif)
dviwin.def:  .eps,.ps,.wmf,.tif
emtex.def:   .eps,.ps,.pcx,.bmp
pctex32.def: .eps,.ps,.wmf,.bmp
pctexhp.def: .pcl
pctexps.def: .eps.ps
pctexwin.def: .eps,.ps,.wmf,.bmp
tcidvi.def:   <empty> (also .ps,.eps,.PS,.EPS and BMP)
truetex.def:  .eps,.ps (also .tif,.bmp)

List manipulation

I recommend package grfext for manipulating the list of graphics extensions.

  • Extensions can be added: \AppendGraphicsExtensions, \PrependGraphicsExtensions.
  • Extensions can be removed: \RemoveGraphicsExtensions.

For example, prefer vector graphics over bitmap graphics, indenpendent of the driver:

\documentclass{article}
\usepackage{graphicx}
\usepackage{grfext}

\AtBeginDocument{%
  \PrependGraphicsExtensions*{
    .mps,.MPS,.pdf,.PDF,.eps,.EPS,.ps,.PS,
    .png,.PNG,.jpg,.jpeg,.JPG,.JPEG,
    .funny,.foobar
  }%
  \PrintGraphicsExtensions % see .log file
}

\begin{document}
\end{document}

Package grfext prints the list in the .log file (example for pdflatex/TL2011):

Package grfext Info: Graphics extension search list:
(grfext)             [.mps,.pdf,.PDF,.eps,.png,.PNG,.jpg,.jpeg,.JPG,.JPEG,.jbig2,.jb2,.JBIG2,.JB2]

The star form of \PrependGraphicsExtensions only adds the extensions that are supported by the graphics driver.

20

The defaults are defined in the driver files, not by graphicx itself. A simple way to see them is to use texdef, e.g. texdef -t pdflatex -p graphicx Gin@extensions.

For latex in DVI mode the default extension list is .eps,.ps,.eps.gz,.ps.gz,.eps.Z, for pdflatex and lualatex it is .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2,.eps and for xelatex it is .pdf,.eps,.ps,.png,.jpg,.bmp,.pict,.tif,.psd,.mac,.sga,.tga,.gif.

6
  • 6
    I have always wondered why .png has precedence over .pdf in pdflatex. I mean, if you have a vector and a bitmap version of the same image, the bitmap version should be preferred? Does anybody have a clue about the rationale behind this?
    – Daniel
    Commented Sep 17, 2012 at 19:02
  • @Daniel Compatibility. Commented Sep 17, 2012 at 19:16
  • @HeikoOberdiek Yes, but ... compatibility to what? Given that PNG is (historically) newer than PDF and no other driver seems to give PNG precedence over PDF this seems to be quite strange.
    – Daniel
    Commented Sep 18, 2012 at 7:50
  • 1
    @Daniel Compatibility to older versions of pdftex.def. Commented Sep 18, 2012 at 8:02
  • 2
    @Daniel I am the wrong person to ask, because my maintenance does not start from the very beginning. PDF is much more complicate for including. Perhaps PNG was earlier supported by pdfTeX or PDF inclusion was too unstable in early versions of pdfTeX. Commented Sep 18, 2012 at 8:35
2

If someone came here because he/she tried to take e.g. .pngs instead of .pdfs for the draft, put this in your preamble:

\DeclareGraphicsExtensions{.png,.pdf}

Feel free to adapt this to your needs.

1

As of ~2021 (MiKTeX 21.7), it seems the order has been updated. (install directory e.g. MiKTeX)\tex\latex\graphics-def\pdftex.def, line 586:

\def\Gin@extensions{%
  .pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,%
  .PDF,.PNG,.JPG,.JPEG,.JBIG2,.JB2%
}

You must log in to answer this question.

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