summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-graphicspath.html
blob: ed6f705ccf388ff38e05c5ad000697f793cfccfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<head>
<title>UK TeX FAQ -- question label graphicspath</title>
</head><body>
<h3>Importing graphics from &#8220;somewhere else&#8221;</h3>
<p/>By default, graphics commands like <code>\</code><code>includegraphics</code> look
&#8220;wherever TeX files are found&#8221; for the graphic file they&#8217;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.
<p/>The simplest solution is to patch TeX&#8217;s path, by changing the
default path.  On most systems, the default path is taken from the
environment variable <code>TEXINPUTS</code>, if it&#8217;s present; you can adapt that
to take in the path it already has, by setting the variable to
<blockquote>
<pre>
TEXINPUTS=.:&#60;graphics path(s)&#62;:
</pre>
</blockquote><p>
on a Unix system; on a Windows system the separator will be &#8220;<code>;</code>&#8221;
rather than &#8220;<code>:</code>&#8221;.  The &#8220;<code>.</code>&#8221; is there to ensure
that the current directory is searched first; the trailing
&#8220;<code>:</code>&#8221; says &#8220;patch in the value of <code>TEXINPUTS</code> from
your configuration file, here&#8221;.
<p/>This method has the merit of efficiency ((La)TeX does <em>all</em> of
the searches, which is quick), but it&#8217;s always clumsy and may prove
inconvenient to use in Windows setups (at least).
<p/>The alternative is to use the <i>graphics</i> package command
<code>\</code><code>graphicspath</code>; this command is of course also available to users
of the <i>graphicx</i> and the <i>epsfig</i> packages.  The
syntax of <code>\</code><code>graphicspath</code>&#8217;s one argument is slightly odd: it&#8217;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 <i>graphics</i> bundle documentation) is:
<blockquote>
<pre>
\graphicspath{{eps/}{png/}}
</pre>
</blockquote><p>
which will search for graphics files in subdirectories <i>eps</i> and
<i>png</i> of the directory in which LaTeX is running.  (Note that
the trailing &#8220;<code>/</code>&#8221; <em>is</em> required.)
<p/>(Note that some (La)TeX systems will only allow you to use files in
the current directory and its sub-directories, for security reasons.
However, <code>\</code><code>graphicspath</code> imposes no such restriction: as far as
<em>it</em> is concerned, you can access files anywhere.)
<p/>Be aware that <code>\</code><code>graphicspath</code> does not affect the operations of
graphics macros other than those from the graphics bundle &#8212; in
particular, those of the outdated <i>epsf</i> and
<i>psfig</i> packages are immune.
<p/>The slight disadvantage of the <code>\</code><code>graphicspath</code> 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&#8217;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 &#8220;memory starvation&#8221; is pretty unlikely with any
ordinary document in a reasonably modern (La)TeX system, but it
should be borne in mind.)
<p/>If your document is split into a variety of directories, and each
directory has its associated graphics, the <i>import</i> package
may well be the thing for you; see the discussion 
in the question &#8220;
<a href="FAQ-docotherdir.html">bits of document in other directories</a>
&#8221;.
<dl>
<dt><tt><i>graphics bundle</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/required/graphics.zip">macros/latex/required/graphics</a> (or <a href="http://mirror.ctan.org/macros/latex/required/graphics/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/graphics.html">catalogue entry</a>
<dt><tt><i>import.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/import.zip">macros/latex/contrib/import</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/import/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/import.html">catalogue entry</a>
</dl>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=graphicspath">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=graphicspath</a>
</body>