[Tex/LaTex] Package pdftex.def Error

graphicstexstudio

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

Best Answer

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}