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.

   \DeclareGraphicsRule{.eps}{pdf}{.pdf}{`epstopdf #1}

3. Include eps graphics like usual


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




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.

About these ads

26 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
    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:\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/}] (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
    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”
    [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}


    • 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…

  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:

    “m81-2.pdf not found”
    but i write this \epstopdfsetup{suffix=}
    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}

        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.

  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


  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!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: