1

There is very simple and fool-proof solution for default actions if included file is missing. It is using

\IfFileExists{IncludedFile}%
{% routine if file exists
}%
{% routine if file does not exist
}

Question is, how to make it work with directory tree. I have my images organised in several directories and I'm using \graphicspath command to simplify the figure including.

2
  • Why can't you use Werner's solution tex.stackexchange.com/a/39987/15925 to the other question? May 14 '15 at 9:32
  • I don't want to redefine behaviour of all \includegraphics commands in the file, just in part, which is automatically generated from different data.
    – Crowley
    May 14 '15 at 14:52
4

All the file input tests use \input@path as well as the standard TEXINPUTS variable, personally I find it easier to just set TEXINPUTS rather than use \input@path (\graphicspath just sets a version of \input@path used locally during the scope of \includegraphics)

However if you want to use the macro directory list for all such operations, replace

\graphicspath{{dir1}{dir2}}

by

\makeatletter\def\input@path{{dir1}{dir2}}\makeatother

and all latex file input commands should use that path.

3
  • How to change the TEXINPUTS? Changing \graphicspath doesnt work, or the dir1 must be absolute path, not relative?
    – Crowley
    May 14 '15 at 11:55
  • 1
    @Crowley changing \input@path will work (set it before loading graphics package) all it does is set \input@path locally, setting TEXINPUTS can be done in your texmf.cnf file or in most command lines just done on the commandline for example TEXINPUTS.//: pdflatex file will make \input{chapter1} find chapter1.tex in any directory recursivelu under the current directory, or anywhere on the standard input path. May 14 '15 at 12:07
  • Yes, I was changing \input@path after calling graphicx package. Now it works as it should work. Thank You.
    – Crowley
    May 14 '15 at 15:15

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.