10

I am a learner to Latex. I am using Texstudio to edit the word. When I try to insert a .eps format figure, this error happens. Error: Package pdftex.def Error

The code is:

\documentclass{book}

\usepackage{graphicx}

\usepackage{epstopdf}

\usepackage{graphics}

\begin{document}

\begin{figure}

\includegraphics{123.eps}

\end{figure}

\end{document}

Thanks a lot,

Hannah

hannah z
  • 131
  • 1
  • 2
  • 4
  • 1
    You have to compile with --shell-escape like pdflatex --shell-escape yourfile for epstopdf to work properly. Also use graphicx instead of graphics. Note the x at the end. Don't load graphics as you are loading graphicx. –  Sep 03 '14 at 07:37
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format.

    PdfTeX can't work with eps files, thats why an extra run is required in the background that you have to allow using the --shell-escape switch.

    – Johannes_B Sep 03 '14 at 07:39
  • See http://tex.stackexchange.com/questions/1072 and http://tex.stackexchange.com/questions/383 – Joseph Wright Sep 03 '14 at 08:08

7 Answers7

13

You should not put the extension .eps to the figure file. The package epstopdf inserts, by default, .eps at the end of the graphics file name. Otherwise, you will get the error

Package epstopdf Info: Source file: <example-image-b.eps>
(epstopdf)                    date: 2012-05-15 17:21:24
(epstopdf)                    size: 52171 bytes
(epstopdf)             Output file: <example-image-b-eps-converted-to.pdf>
(epstopdf)             Command: <epstopdf --outfile=example-image-b-eps-convert
ed-to.pdf example-image-b.eps>
(epstopdf)             \includegraphics on input line 10.
runsystem(epstopdf --outfile=example-image-b-eps-converted-to.pdf example-image
-b.eps)...executed.

Package epstopdf Info: Result file: <example-image-b-eps-converted-to.pdf>.


E:\Latex workshop\framed\test\only-test\doi4.tex:10: Package pdftex.def Error: 
File `example-image-b-eps-converted-to.pdf' not found.

Second, you should use --shell-escape while compiling:

pdflatex --shell-escape yourfile

where yourfile is your main .tex file.

Third, don't use graphicx and graphics both. Use graphicx (more modern than graphics) and load it before epstopdf.

With all above, the MWE is

\documentclass{book}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}

\begin{figure}
\includegraphics[width=2in]{example-image-a}
\end{figure}

\end{document}
4

In order to install eps-to-pdf converter, type in a terminal

sudo apt install texlive-font-utils
3

I met the same problem as you described and tried a lot of methods. If you were using Mac with TexStudio, I think this could be a problem of TexStudio itself. Everything works fine with the same files for me on Windows or on Mac with other software. You may try other software to transfer the eps files to pdf files, such as Sublime or TexShop.

1

An easy way for Mac users with Texstudio: I opened a .eps file by double-clicking which launched via Preview by default, ready for save as pdf. If the .eps files are few and you are patient enough to manually export one by one, I would recommend this simple step. It worked for me.

1

I also encountered this problem. pdfTex tells you to check the log, and there I found the follwoing:

2016-07-24 17:45:18,822+0200 INFO pdflatex - installing package graphics-def triggered by tex\latex\graphics-def\pdftex.def

2016-07-24 17:45:18,898+0200 INFO pdflatex - mpm: starting package maintenance...

2016-07-24 17:45:18,898+0200 INFO pdflatex - mpm: installation directory: "C:\Users\Philipp\AppData\Local\Programs\MiKTeX 2.9"

2016-07-24 17:45:18,898+0200 INFO pdflatex - mpm: package repository: http://ftp.fernuni-hagen.de/ftp-dir/pub/mirrors/www.ctan.org/systems/win32/miktex/tm/packages/

2016-07-24 17:45:19,013+0200 INFO pdflatex - mpm: lightweight database digest: 0d353e43fc36f1131535dede775291d5

2016-07-24 17:45:19,019+0200 FATAL pdflatex - Unknown archive file size.

2016-07-24 17:45:19,019+0200 FATAL pdflatex - Info: package="graphics-def"

2016-07-24 17:45:19,019+0200 FATAL pdflatex - Source: libraries\miktex\packagemanager\internal.h

2016-07-24 17:45:19,019+0200 FATAL pdflatex - Line: 477

The highlighted sentences gave me the feeling that there is an issue with the automated package management trying to install the missing package "graphics-def". Therefore I installed it manually via the MikTeX package manager.

Finally, LaTeX is now running fine again.

PWillms
  • 362
0

I had the same problem, the issue was caused due to mentioning full path of the pdf file. changed to the filename only. Compiles perfectly.

\includegraphics[scale=0.4]{C:/Users/xx/xx/xx/figures/x.pdf}

to

\includegraphics[scale=0.4]{x.pdf}
Khan
  • 99
0

I have changed the format from eps to pdf then worked for me. I believe there is issue with converting eps file to pdf which requires to some modification that has addressed here below: EPS to PDF - Remove "-eps-converted-to" from pdf filename