TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Do you think it's possible to include images into LaTeX without specifying the exact path to them. So instead of:


It would be:


While the image would still reside in the path/to/image/ directory. Basically, I'm asking if there is a macro that can recursively search for the image.

An alternative for me is to write a script outside of LaTeX that determines all the images that are included, performs the recursive search and copies those files temporarily in the same directory as the .tex file.

share|improve this question
up vote 18 down vote accepted

You can do this the following ways:

  1. Use the \graphicspath macro:

  2. Define the environment variable TEXINPUTS to contain the path:


    Note the leading '.' (current dir) and the trailing empty field (default texmf tree).

  3. Put your graphics in an own local texmf tree, so that they are found automatically. Then the path doesn't has to be defined. However this causes problems if you have multiple files with the same name in different directories.

share|improve this answer
See also my answer to the question "How to switch from using color graphics to grayscale graphics?" for further information about the topic of variable graphic input paths. – Martin Scharrer Mar 8 '11 at 20:09
Doesn't this also cause problem in case you want to share the project, including its figures? They all live somewhere else, and zipping/taring will miss them. Am I right? – Dror Apr 6 '11 at 6:55
@Dror: If you use subdirectories with the first method and include these in the ZIP file it should be fine. You can't have everything at once. – Martin Scharrer Apr 6 '11 at 8:20

The TeX Directory Structure (TDS) reserves the images "package" name for includable graphics. So if you want your graphics to be findable and to be TDS-compliant, put them in ${TEXMFHOME}/tex/generic/images.

(personal story, name drop alert) I brought this up on texhax ages ago and Karl Berry said he had completely forgotten about that convention despite the fact that he's TDS editor. Apparently it's not used by many distributions. But I've found it handy.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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