0

I have a directory structure with following directories (upper-cased) and files as follows:

Main Folder masterfile.tex Chapter content.tex tempfile.tex Figures figure1.pdf 

All the text of my document is in content.tex, though it includes the graphic figure1.pdf. Both the masterfile.tex and tempfile.tex input content.tex. In masterfile.tex, I use \input{Chapter/content}; in tempfile.tex, I use \input{content}.

How do I properly reference figure1.pdf within content.tex?

If I use \includegraphics{figure1}, then neither masterfile.tex nor tempfile.tex can find it.

If I use \includegraphics{Figures/figure1}, then tempfile.tex can find it, though masterfile.tex can't.

If I use \includegraphics{Chapter/Figures/figure1}, then tempfile.tex can't find it, though masterfile.tex can.

I can't seem to find the right relative pathname to make it work. Martin's solution to this problem seems applicable, but I can't make that work, either.

Yes, I know one solution is to change to location of my files, but let's just say that can't be done.

5
  • Maybe i do not understand the question/structure right, but does simply \includegraphics{Figures/figure1.pdf} work? Commented Jun 13, 2017 at 16:12
  • the filenames are relative to your working directory so should work if you always from latex from main Folder but perhaps simpler is not to put paths in the commands and just use \input{content} and \includegraphics{figure1} Commented Jun 13, 2017 at 16:13
  • @Bobyandbob Since the Figures folder is within the Chapter folder, using just \includegraphics{Figures/figure1.pdf} isn't found when I compile masterfile.tex, though it is found when compiling tempfile.tex. Commented Jun 13, 2017 at 20:32
  • @DavidCarlisle That doesn't seem to work ... with the images one or two directories down, LaTeX doesn't seem to be able to find them. Is there an option for "search all subdirectories"? Commented Jun 13, 2017 at 20:40
  • yes just put .// in your TEXINPUTS path Commented Jun 13, 2017 at 20:41

1 Answer 1

1

I found a solution to my own problem after more searching. (While I didn't try it, David Carlisle's answer works, I'm sure. In my situation, though, I am one of many editing/compiling the same documents, and asking all of my colleagues to edit their TEXINPUTS path wouldn't have turned out well.)

In content.tex, I use \includegraphics{Chapter/Figures/figure1} which allows masterfile.tex to compile just fine. In the preamble of tempfile.tex, I add \graphicspath{{../../Main Folder/}}, which is the start of an acceptable relative path for that file.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.