## Include EPS graphics in pdflatex

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.

### 45 Responses to Include EPS graphics in pdflatex

1. Maurya says:

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”
)

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.

2. Jirka says:

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…

3. Jirka says:

But thank you! I like it :)

4. Heitor says:

That is a great hint! thank you very much!!!!!

5. JM says:

Thanks! Works perfect!

6. Samia says:

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”
)epstopdf: Not a valid EPS file.

See the pdftex.def package documentation for explanation.
Type H for immediate help.

l.10 \includegraphics[scale=0.6]{z101}

?

• Jirka says:

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…

• chi3x10 says:

7. TJ says:

Thanks for the tip. Works wonderfully!

8. Riccardo says:

Beautiful trick!!! Compliments…

9. Musti says:

Hello, I tried your hints but i can not success, i get this message:

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.

• Berto says:

I have the same problem.
It seems that epstopdf does not create such file.

Any suggestions?

• berto says:

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.

• Regnarock says:

Thx ! Reinstalling MikTeX works perfectly.
I own you a lot.

10. Jan says:

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.

• Bal says:

Hi,
I have the same error, but I could not fix after refreshing FNDB in Miktex. Please help me to fix.
Thanks.
Bal

• Jan says:

Did you enable the write18 feature?

11. […] eps-and-pdflatex-no-more-converting-eps-to-pdf […]

12. Numan Sheikh says:

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!

• Theebg says:

Yes, this is the solution in Windows+Miktex, just add that line in the preamble. Thanks a lot

13. kaanaksit says:

Thanks worked like a charm!

14. 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

15. vamsi says:

It works, after a lot of search. Thank you

16. Controllare says:

Hi there this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
I’m starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

17. Havingg read this I brlieved it was very informative. I appreciate you
spending some time annd effort tto putt this hort article together.

I once again find myself personally spencing way too much time both
reading and commenting. But so what, it was still worthwhile!

18. future, the researchers want to find out whether a
combination of several educated in the gastrointestinal
tract hormones can further enhance the effect of the gastric band.
It’s conceivable to accomplish this objective the conventional path moreover through an equalized eating methodology and exercise.
Adiphene Weight Loss Supplements Offers a Unique 25%
Discount n select package fr Online B Worldwide If the online critiques
are something to go by, Adiphene is an efficient weight-loss option.

19. This basically suggests that you will be able to eat anything that you
want without the worry of gaining weight. This alone offers
it some credit score as a authentic contender within the eating regimen complement arena; at the moment oversaturated with poor high quality diet products.

Adiphene are being marketed as safe weight-loss drugs and going by the numbers so far,
have turn into extremely popular.

20. lose fat says:

Such are the ingredients of Adiphene that its one finest selling level is the shortage of dangerous uncomfortable side effects.
Safety is also assured when taking Adiphene because of
its natural ingredients, which means that serious side effects are unlikely
to happen if taken as directed. Assuming that you aren’t a super-taught individual, you will have some major snags adding on control over your zealous urges
towards consuming distinctive sustenances.

In the signature line provide a link back to your blog. In your
Ad – Words campaigns you must wisely find high profitable keywords, the “buyer kind” of keywords.
This article explains what it is these systems actually do, and how
you can earn cash in a Google money system without
paying out hundreds of dollars in fees.

22. proactol fat binding weight loss

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

24. the linden method

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

25. proactol review

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

27. weight loss pill

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

29. overcoming anxiety disorders

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

31. customer reviews

Include EPS graphics in pdflatex | Jason Yu-Tseh Chi’s Notes

32. Great article! We are linking to this particularly great article on our website.
Keep up the great writing.

33. […] Unfortunately, the pdflatex compiler does not support EPS images. But don’t worry, there is a package which converts your EPS files to PDF files on the fly, which then can be included in your document. This is how you must configure your graphic packages in the preamble of your LaTeX document (code from this blog post): […]

34. Krishnamurthy Ramanujam says:

This explanation is amazing. Hundreds of thousands of thanks to you. No words to Express my thanks to you. It helped me a lot in the crucial time. Keep it up………………….!