2

I'm trying to include a figure which is saved as two files (eps and tex). I can get it to work if the files are in the same folder as the main document, but not if I move them elsewhere, even just to a subdirectory.

I'm using Windows 7, TexnicCenter, and miktex 2.9.

This is what I've tried to do:

\documentclass{article}

\usepackage{graphicx,epstopdf}

\begin{document}

\begin{figure}

\input{ImageDir/TestFile}

\end{figure}

\end{document}

It doesn't work. If I move the "TestFile" files out of "ImageDir" and change the above to "\input{TestFile}" then it works fine. Also the code below DOES work for png image file, and I don't understand the difference:

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{figure}

\includegraphics{ImageDir/TestPNG}

\end{figure}

\end{document}

I've been searching the internet and tried different syntax for the path but I just can't get the \input version to work with files in a different directory. Does anyone know what I'm doing wrong?

Thanks a lot for any help!

4

when you go

 \input{ImageDir/TestFile}

then Testfile.tex has \includegraphics{TestFile.eps} but file inclusion is always relative to the working directory where TeX is started, not relative to teh file being processed. So TeX looks in the current directory for the image.

The simplest is just to put it in the working directory, or if not, to put the directory in the search path either add it to the TEXINPUTS kpathsea variable or to add it to the graphics path with \graphicspath{{ImageDir/}} (which is slower but can be more convenient).

  • I haven't tried using kpathsea but \graphicspath worked, thank you! I think I read this solution elsewhere but didn't realise that you have to pass the path to \graphicspath AND \include. It does make sense that both have to be used though. e.g. for my example the following are needed: \graphicspath{{ImageDir/}} and \input{ImageDir/TestFile} – Cog77 Jun 27 '14 at 20:16

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.