It’s a shame that pdflatex supports jpg, png, pdf… graphic type but not EPS while latex supports EPS but not the others. From my previous post, there is an easy way to convert EPS to pdf. But it is just annoying that every time you want to include an eps graphic you have to do the conversion manually. After googling, I found out that there is a way to let pdflatex do the conversion for you. Here is how.
1. Install texlive-extra-utils which contains epstopdf.
sudo apt-get install texlive-extra-utils
2. Insert the following code in in the preamble of your document.
\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse
\else
\pdfoutput=1
\pdftrue
\fi
\ifpdf
\usepackage{graphicx}
\usepackage{epstopdf}
\DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf #1}
\pdfcompresslevel=9
\else
\usepackage{graphicx}
\fi
3. Include eps graphics like usual
\includegraphics[width=7in]{result_1.eps}
4. Compile the tex file with -shell-escape option
pdflatex -shell-escape texWithEPSYAY.tex
During the compiling pdflatex converts the included eps graphic files into pdf files on the fly using epstopdf. After compiling, esptopdf generates a lot of pdf files (conversion from eps files). You will find the compile (is compile a noun?) a little bit slow. That is because it takes some time for epstopdf to convert eps files to pdf files. As one can imagine, it will become REALLY slow as the number of eps graphics included in a document increases. One way to fix this problem is that when inserting an eps graphic in a document, LEAVE THE FILE EXTENSION OFF. For example, instead of
\includegraphics[width=7in]{result_1.eps}
use
\includegraphics[width=7in]{result_1}.
By this way, pdflatex first checks if result_1.pdf exists. If not, it locates result_1.eps and converts it to a pdf file. When result_1.pdf does exist, it simply inserts result_1.pdf in the document. Therefore, pdflatex only does the conversion when the corresponding pdf file does not exist. If you do NOT leave the file extension off, pdflatex would convert the eps graphics in the document to pdf files every time you compile.
Hope this helps.
This is not working under window xp. Can you help me. The output of the compilation is as follow:
%%%%%%%%%%%%%%%%%%
This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7)
entering extended mode
(tst1.tex
LaTeX2e
Babel and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.
(“C:\Program Files\MiKTeX 2.7\tex\latex\base\report.cls”
Document Class: report 2005/09/16 v1.4f Standard LaTeX document class
(“C:\Program Files\MiKTeX 2.7\tex\latex\base\size12.clo”))
(“C:\Program Files\MiKTeX 2.7\tex\latex\graphics\graphicx.sty”
(“C:\Program Files\MiKTeX 2.7\tex\latex\graphics\keyval.sty”)
(“C:\Program Files\MiKTeX 2.7\tex\latex\graphics\graphics.sty”
(“C:\Program Files\MiKTeX 2.7\tex\latex\graphics\trig.sty”)
(C:\localtexmf\tex\latex\misc\graphics\graphics.cfg)
(“C:\Program Files\MiKTeX 2.7\tex\latex\pdftex-def\pdftex.def”)))
(C:\localtexmf\tex\latex\misc\oberdiek\epstopdf.sty) (tst1.aux)
(“C:\Program Files\MiKTeX 2.7\tex\context\base\supp-pdf.tex”
[Loading MPS to PDF converter (version 2006.09.02).]
)
! Package pdftex.def Error: File `kw.pdf’ not found.
See the pdftex.def package documentation for explanation.
Type H for immediate help.
…
l.22 \includegraphics[width=7in]{kw.eps}
?
Overfull \hbox (133.51482pt too wide) in paragraph at lines 22–23
[][]
[1{C:/Documents and Settings/All Users/Application Data/MiKTeX/2.7/pdftex/confi
g/pdftex.map}] (tst1.aux) )
Output written on tst1.pdf (1 page, 6551 bytes).
Transcript written on tst1.log.
You should state, that you need to use
\epstopdfsetup{suffix=}
in the other case the name of your created pdf is default nameofthefile-eps-converted-to.pdf and pdtlatex call error because nameofthefile.eps doesnt exist…
But thank you! I like it
That is a great hint! thank you very much!!!!!
Thanks! Works perfect!
I am trying to include Matlab generated eps file using MikTex and getting the following problem. Could anyone help me ?
(“C:\Program Files\MiKTeX 2.8\tex\generic\oberdiek\pdftexcmds.sty”
(“C:\Program Files\MiKTeX 2.8\tex\generic\oberdiek\ifluatex.sty”)
(“C:\Program Files\MiKTeX 2.8\tex\generic\oberdiek\ltxcmds.sty”))))
(“C:\Documents and Settings\sss210\Thesis\uofsthesis-cs\Test.aux”)
(“C:\Program Files\MiKTeX 2.8\tex\context\base\supp-pdf.tex”
[Loading MPS to PDF converter (version 2006.09.02).]
)epstopdf: Not a valid EPS file.
! Package pdftex.def Error: File `z101-eps-converted-to.pdf’ not found.
See the pdftex.def package documentation for explanation.
Type H for immediate help.
…
l.10 \includegraphics[scale=0.6]{z101}
?
Samia: Your problem I solved several lines up. I had the same.
Again: You need to use \epstopdfsetup{suffix=}
in the other case the name of your created pdf is default nameofthefile-eps-converted-to.pdf and pdtlatex call error because nameofthefile.eps doesnt exist…
Thanks Jirka for your comments.
Thanks for the tip. Works wonderfully!
Beautiful trick!!! Compliments…
Hello, I tried your hints but i can not success, i get this message:
“m81-2.pdf not found”
but i write this \epstopdfsetup{suffix=}
and
i cannot install first step
sudo apt-get install texlive-extra-utils
how can i solve this problem could you help me plaese.
I have the same problem.
It seems that epstopdf does not create such file.
Any suggestions?
documentclass[12 pt]{article}
usepackage[pdftex]{graphicx,epstopdf}
epstopdfsetup{suffix=}
begin{document}
includegraphics{C:/Articles/temp.eps}
end{document}
The above code did not work at first, and I struggled for a long time trying to figure out what was wrong. Finally, I reinstalled MikTeX 2.9 and all of a sudden it works perfectly!!
So if all else fails, reinstall MikTeX.
Thx ! Reinstalling MikTeX works perfectly.
I own you a lot.
There’s an easier way around this problem. Just refresh the FNDB and Update the formats in the MikTeX Options. Saves you al lot of work with the same result.
Hi,
I have the same error, but I could not fix after refreshing FNDB in Miktex. Please help me to fix.
Thanks.
Bal
Did you enable the write18 feature?
[...] eps-and-pdflatex-no-more-converting-eps-to-pdf [...]
This worked for me.
I didn’t have to change any single thing, other than including this line in the beginning
\usepackage[update,prepend]{epstopdf}
It works for me as well! thanks a lot!
Yes, this is the solution in Windows+Miktex, just add that line in the preamble. Thanks a lot
Thanks worked like a charm!
Thanks for posting “Include EPS graphics in pdflatex Jason Yu-Tseh Chis Notes”.
I personallymight undoubtedly end up being back
again for a great deal more browsing and commenting here shortly.
Thanks a lot, Cora
It works, after a lot of search. Thank you