UK TeX FAQ -- question label graphicspath

### Importing graphics from “somewhere else”

By default, graphics commands like `\``includegraphics` look “wherever TeX files are found” for the graphic file they’re being asked to use. This can reduce your flexibility if you choose to hold your graphics files in a common directory, away from your (La)TeX sources.

The simplest solution is to patch TeX’s path, by changing the default path. On most systems, the default path is taken from the environment variable `TEXINPUTS`, if it’s present; you can adapt that to take in the path it already has, by setting the variable to

>     TEXINPUTS=.:<graphics path(s)>:

on a Unix system; on a Windows system the separator will be “`;`” rather than “`:`”. The “`.`” is there to ensure that the current directory is searched first; the trailing “`:`” says “patch in the value of `TEXINPUTS` from your configuration file, here”.

This method has the merit of efficiency ((La)TeX does all of the searches, which is quick), but it’s always clumsy and may prove inconvenient to use in Windows setups (at least).

The alternative is to use the graphics package command `\``graphicspath`; this command is of course also available to users of the graphicx and the epsfig packages. The syntax of `\``graphicspath`’s one argument is slightly odd: it’s a sequence of paths (typically relative paths), each of which is enclosed in braces. A slightly odd sample, given in the graphics bundle documentation, is:

>     \graphicspath{{eps/}{tiff/}}

however, if the security checks on your (La)TeX system allow, the path may be anything you choose (rather than strictly relative, like those above); note that the trailing “`/`” is required.

Be aware that `\``graphicspath` does not affect the operations of graphics macros other than those from the graphics bundle — in particular, those of the outdated epsf and psfig packages are immune.

The disadvantage of the `\``graphicspath` method is inefficiency. The package will call (La)TeX once for each entry in the list, which is itself slows things. More seriously, TeX remembers the file name, thus effectively losing memory, every time it’s asked to look up a file, so a document that uses a huge number of graphical inputs could be embarrassed by lack of memory.

If your document is split into a variety of directories, and each directory has its associated graphics, the import package may well be the thing for you; see the discussion in the question “ bits of document in other directories ”.

`graphics bundle`
  macros/latex/required/graphics (or browse the directory)
`import.sty`
  macros/latex/contrib/misc/import.sty

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=graphicspath