16

I am trying to define a central graphics path for my thesis, however, the chapters are included with the \include command and by using \include with \graphicspath, pdflatex complains about it can not find the pictures, is not that possible to use \graphicspath and \include together, for which I do not see a sound reasoning behind.

I use in the preamble

\graphicspath{{/home/utab/thesis/phd_text/figures_all//}}

and use

\include{ch9} 

Then it can can not find the pictures on the above mentioned directories recursively.

lockstep
  • 250,273
  • 1
    @Umut: A tip: If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it). – lockstep Apr 16 '11 at 15:56
  • @lockstep, Thx for the hints – Umut Tabak Apr 16 '11 at 15:57
  • 1
    It should work with an absolute path. Try to remove the doubled / at the end. That's the only thing I see here. – Martin Scharrer Apr 16 '11 at 16:07
  • Does not that extra / make that to search the directories recursively? – Umut Tabak Apr 16 '11 at 16:15
  • @Umut what operating system are you using? – yannisl Apr 16 '11 at 16:20
  • @Ulmut: I never heard about that. So far I know the underlying code this doesn't happen. – Martin Scharrer Apr 16 '11 at 16:40
  • @Yiannis: linux – Umut Tabak Apr 16 '11 at 16:47
  • @Martin, I found that on the wiki pages and tried however your reply made it clear – Umut Tabak Apr 16 '11 at 16:48
  • @Umut: I just looking for it and also found it on the LaTeX wiki and some other places. I don't think it is handled in the LaTeX code of graphics or in the base LaTeX code, but it might be handled by the (pdf)latex executable itself. However, in my tests it doesn't work at all, neither for \included files or in the main file. – Martin Scharrer Apr 16 '11 at 16:57
  • @Umut Try running this code in a minimal with LuaLaTeX \gdef\FindFile#1{% \directlua{local function find_file(...) return kpse.find_file(...) or "" end tex.sprint(find_file("#1"))}} \FindFile{myimage.png} and enter the path as is shown. Change filename to one of your images. See also http://www.tex.ac.uk/cgi-bin/texfaq2html?label=graphicspath – yannisl Apr 16 '11 at 17:05
  • @Umut: Maybe the // is an extension of MikTeX. It would explain that it doesn't work with TeXLive under Linux, but that I find some posts online which tell that it works fine. – Martin Scharrer Apr 16 '11 at 17:29
  • Try \graphicspath{{figures\}} – deepsen Oct 13 '20 at 15:27

3 Answers3

12

The \graphicspath command does not influence the directories \include takes into consideration, because \graphicspath is from the graphics package, while \include is plain LaTeX.

Unfortunately, like stated on Bits of document from other directories, there is no trivial way to build, e.g., an \includepath command. Nevertheless, the site mentioned above links two packages as a possible solution: chapterfolder and import, and especially the \cfinput command from chapterfolder might help. There is also another blog post describing the use of chapterfolder.

David Carlisle
  • 757,742
sqx
  • 121
12

You can use relative path : give as a second argument to \graphicspath what would be the relative path seen from your chapter. In my own case, I have a thesis folder containing chapter folders and a Figures folder. I use :

\graphicspath{{Figures/}{../Figures/}}
lockstep
  • 250,273
Bretzel
  • 121
  • 2
    With relative folders that should also work just using \graphicspath{{Figures/} as long as every \includegraphics the works in that directory. At least for me the secont part you use isn't necessary. – Ronny Feb 13 '13 at 13:54
2

I could not get

\graphicspath{figures\}

to work as desired. I am using a makefile in my writing, though, so I specified an extra rule:

%.pdf: export TEXINPUTS=.:figures:
%.pdf: %.tex
latexmk -pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make $<
Preston
  • 21