Importing graphics from "somewhere else"
By default, graphics commands like
“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
The simplest solution is to patch TeX's path, by changing the
default path. On most systems, the default path is taken from the
TEXINPUTS, if it's present; you can adapt that
to take in the path it already has, by setting the variable to
on a Unix system; on a Windows system the separator will be
. is there to ensure
that the current directory is searched first; the trailing
“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
\graphicspaths one argument is slightly odd: it's a
sequence of paths (typically relative paths), each of which is
enclosed in braces. A slightly odd example (slightly modified from one
given in the graphics bundle documentation) is:
which will search for graphics files in subdirectories
png of the directory in which LaTeX is running. (Note that
/ is required.)
(Note that some (La)TeX systems will only allow you to use files in
the current directory and its sub-directories, for security reasons.
\graphicspath imposes no such restriction: as far as
it is concerned, you can access files anywhere.)
The slight disadvantage of the
\graphicspath method is
inefficiency. The package will call (La)TeX once for each entry in
the list to look for a file, which of course slows things. Further,
(La)TeX remembers the name of any file it's asked to look up, thus
effectively losing memory, so that in the limit a document that uses a
huge number of graphical inputs could be embarrassed by lack of
memory. (Such “memory starvation” is pretty unlikely with any
ordinary document in a reasonably modern (La)TeX system, but it
should be borne in mind.)
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”.