Insert eps graphics with graphicx (file not found)
You are probably use pdflatex
instead of latex
. The former is actually recommended but doesn't support EPS graphics but only JPG, PNG and PDF.
You should convert the EPS to PDF using e.g. epstopdf
. Newer versions of pdflatex
from TeX Live should do this conversion automatically by running a restricted version (for safety reasons) called repstopdf
.
Using MiKTeX you have to use the recommended graphics format depending on the engine you are using.
So, if you are using latex—mostly at a queue latex→dvips→pstopdf—you can only use EPS, PCX, BMP, MSP, PICT or PNTG, all of them with different file extensions and sometimes with additional endings. EPS is the most recommended file format with latex→dvips, because the dimensions of EPS may be detected by graphics/graphicx
itself. For the other file formats you need additional bb-files with the dimensions or to use option boundingbox
.
If you are using pdflatex with direct PDF output, you can only use PDF, JPEG, PNG and MPS. (Note: MPS is a subtype of EPS generated by MetaPost
and needs parts of ConTeXt
to be installed.)
With TeX Live since 2010, support for on-the-fly conversion of EPS to PDF has been added. This should be activated out if the box. The conversion consists in three parts:
- A
graphics.cfg
file, that supports file extensions.ps
and.eps
even, if pdflatex with direct pdf output is used. - LaTeX package epstopdf, that uses shell escapes to convert eps to pdf on the fly using repstopdf.
- A
texmf.cnf
with settingsshell_escpape = p
andshell_escape_commands = repstopdf
.
Because of this, you may use EPS with pdflatex and direct PDF output, if you are using TeX Live since 2010.
With MiKTeX you may use on-the-fly conversion, too. In this case you have to load LaTeX package epstopdf
on your own (see the manual for more information) and you have to set command line option --enable-write18
at call of pdflatex
. If you call pdflatex
from within a LaTeX editor, have a look at the editor or the profile settings and the editor manual to find out, where you may add this command line option.
You may test the on-the-fly conversion using:
\begin{filecontents*}{\jobname.eps}
%!
%%BoundingBox:100 100 172 172
100 100 moveto
72 72 rlineto
72 neg 0 rlineto
72 72 neg rlineto
stroke
100 100 moveto
/Times-Roman findfont
72 scalefont
setfont
(A) show
showpage
\end{filecontents*}
\documentclass{article}
\usepackage{graphicx}
\usepackage{ifpdf}
\begin{document}
\ifpdf
You are using pdf\LaTeX. If you see the picture, on-the-fly conversion does work!
\else
You need to use pdflatex to test the on-the-fly conversion! You may see the
original eps file without conversion now:
\fi
\includegraphics{\jobname.eps}
\end{document}
Instead of using on-the-fly conversion you may simply convert every EPS to PDF using epstopdf. In this case you may remove extra white space around the picture using pdfcrop.
Note, that sometimes the conversion to PDF results in PDFs with bad Bounding Box. In this case, you should search for %%PageBoundingBox
at the PS file and copy the four dimensions at this line to the line %%BoundingBox
at the begin or end of the file (replacing the values you'd find there). On-the-fly conversion will be use these new values at next run of pdflatex. If you are using manual conversion, don't forget to do it again.
To convert PDF to EPS the usage of pdftops --eps
is recommended. This is a command line utility from xpdf. Note, that this is available not only for Linux, but for Windows too. Alternative you may use pdf2ps
, a ghostscript command line utility. But the results may be not a good as the results of pdftops
.