Sunday, September 2, 2012

How to make pdflatex accept .eps images

Unfortunately, pdflatex does not support .eps images, for example the following code fails:
\usepackage{graphicx}
...
\includegraphics{qc.eps}
The fix is to put the following lines at the top of the document:
\usepackage{epstopdf}
\epstopdfsetup{suffix=}
\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf #1}
and compile with the -shell-escape flag:
pdflatex -shell-escape my_file.tex
Then the above code works. You need the epstopdf program that is run behind the scene.

Update: Apparently, it's enough to just include the following line at the top of the document:
\usepackage{epstopdf}
One still has to compile with the -shell-escape flag. This works for me in Ubuntu 12.04.

Thanks to: http://chi3x10.wordpress.com/2009/06/18/eps-and-pdflatex-no-more-converting-eps-to-pdf/

1 comment:

Rhys Ulerich said...

Some additional mucking about is necessary to get the epstopdf package to accept images from TEXINPUTS:

\usepackage{epstopdf}
\epstopdfsetup{outdir=./,suffix=-generated,update,verbose}
\epstopdfDeclareGraphicsRule{.eps}{pdf}{.pdf}{%
epstopdf --outfile=\OutputFile \space `kpsewhich \space "\SourceFile"`
}

It turns out the \space is crucial otherwise the filenames get concatenated together.

Thank you for the tip.

-- Rhys