Graphics inclusion

From TeX on Mac OS X wiki

Jump to: navigation, search



Including graphics in a LaTeX-document is done with a command like this:


where image.jpg is a graphic-file of the JPEG-type. It is assumemed that you have loaded the graphics-package in your preamble. There are variants of this command, for example


- see for other options, for example, here or the documentation of the graphics-package. While this is very easy, one needs to be aware that not all file types are supported.

supported file types

These are the file types that are supported, depending on the typesetting-mode you are using. As a Mac-User, you are most likely a user of (pdf)latex with pdf-output.

latex with dvi-output latex with pdf-output
eps pdf,jpg,png,mps

See this article in the PracTeX Journal for more on this.

epstopf: including eps-graphics in a pdfLaTeX-document

The epstopf-package helps to overcome the limitations of latex and pdflatex when it comes to available graphic-formats. Its main purpose is to allow the inclusion of .eps-graphic in documents that are typeset in pdflatex (with a pdf as an output file). What the package does is that it calls an external script (with the same name: epstopdf) that converts a eps-graphic into a pdf such that pdflatex can use this. So, if you are using pdflatex, the following document would work:


It is essential for epstopdf to work that pdf(la)tex (with PDF output) is allowed to call external programs. Therefore a typical call to pdf(la)tex includes the option --shell-escape:

pdflatex --shell-escape --synctex=1

If you are using a recent version of epstopdf (at least 2009/07/16 v2.2), running the example above will result in a file image-epsf-converted-to.pdf in your working directory. See the documentation of epstopf for more details on the inner-workings of the package.

support for other image-formats

The epstopf-package offers also a very convenient way to add support for other graphic-types. For example, if you want to add support for .tif-files, you can add the following to your preamble (again, you need a recent version of epstopdf):

convert #1 \OutputFile

Whenever pdflatex finds a command


it will try to convert it to an .png-file and use this. However, you need to have the command 'convert' to be available. It is availalable from ImageMagick, see Graphics_helpers#ImageMagick. If you are using the MacTeX-distribution, convert has been installed. ImageMagick can handle a lot of file types! So you can add support for almost any image-format by using epstopdf for a conversion to one of the #supported_file_types.

filenames and the list of known graphics-extensions

If pdflatex finds a command \includegraphics, it looks internally at íts list of supported file types. By default, this list is


This lists needs to altered if you add support for other file-types, hence the command \AppendGraphicsExtensions{.tif} in the example above that alters the internal list of supported file-types to


(There is also a command \PrependGraphicsExtensions that would put the new file type at the beginning of the list. Does the order make a difference? Consider you have several version of your a graphics-file in your working directory along with you .tex-document, for example


If you include your image with a command


that is WITHOUT THE EXTENSION, the order of the internal list matters. If the list of supported file types is the default one, see above, it will be the image.png that is included in your final project.pdf. If you are using




the image.eps will be found first, converted to image-eps-converted-to.pdf (recent epstoopdf) or image.pdf may be overwritten by a newly converted one (older epstopdf), and this will be used. And so on - it can be rather complicated to determine which file is actually used depending on your configuration. Note that this is a problem if you a graphic file in an external program and then it turns out that you were working on a file that doesn't make into your final pdf!

If you include graphics WITH THE EXTENSION, like in


it will always be this file that is used - either directly ift the file type is supported or after an appropriate conversion triggered by epstopdf.

Personal tools