0

I have two latex files, that are very similar. One works perfectly fine. and the other one mysteriously does not work. The only difference is that in the first one the image file is in the same folder as .tex file, and in the other one the image file is in a separate folder, but the full path is passed.

Code one:

\documentclass{article}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{epstopdf}

\begin{document}
\begin{figure}
\includegraphics[trim=0cm 0cm 0cm 0cm, clip=true, totalheight=0.2\textheight]{test}
\caption{test}
\end{figure}

\end{document}

Code two:

\documentclass{article}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}

\begin{figure}
\includegraphics[trim=0cm 0cm 0cm 0cm, clip=true, totalheight=0.2\textheight]{test}
\caption{test}
\end{figure}

\begin{figure}
\includegraphics[trim=0cm 0cm 0cm 0cm, clip=true, totalheight=0.2\textheight]{/home/amaleki/Desktop/test2}
\caption{test2}
\end{figure}

\end{document}

Anyone has any clue what could have gone wrong here?

The log output is also not helping; it says repstopdf is executed safely.

(epstopdf) Output file: (epstopdf) Command: (epstopdf) \includegraphics on input line 22. runsystem(repstopdf --outfile=/home/amaleki/Desktop/test2-eps-converted-to.pdf /home/amaleki/Desktop/test2.eps)...executed safely (allowed). Package epstopdf Info: Result file: . ! Package pdftex.def Error: File `/home/amaleki/Desktop/test2-eps-converted-to. pdf' not found.

  • you do not show the error that you get. tex has a security setting to disallow reading files not below the current directory but that isn't set by default, also unrelated do not use the epsfig package unless you need to emulate documents from 1990 using psfig. – David Carlisle Apr 17 '18 at 17:52
  • Thanks for the comment. That was very helpful. I added --shell-escape option and now it works. About your other comment, what other package then do you suggest when dealing with eps figures? – Amir Apr 17 '18 at 18:17
  • you do not need any other package, just delete the \usepackage{epsfig} line. – David Carlisle Apr 17 '18 at 18:54
1

It seams the eps-to-pdf converter is a bit messed up when parents directories are used, as it cannot find where to save the converted pdf. Deleting the \usepackage{epsfig} won't help here, but you can specify to the epstopdf package the eps figure location when importing the module :

\usepackage[outdir=./]{epstopdf}

Now putting a figure in the parent directory works. You can also specify an absolute path as outdir.

But for what it's worth, there is no problem if your figures are in a subdirectory rather than a parent directory :

\begin{figure}
\includegraphics[trim=0cm 0cm 0cm 0cm, clip=true, totalheight=0.2\textheight]{fig/test}
\caption{test2}
\end{figure}

I hope this helped !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.