summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-docotherdir.html
blob: 336f65613923a1b305e7d0dd630faa1cba71f27c (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
<head>
<title>UK TeX FAQ -- question label docotherdir</title>
</head><body>
<h3>Bits of document from other directories</h3>
<p/>A common way of constructing a large document is to break it into a
set of files (for example, one per chapter) and to keep everything
related to each of these subsidiary files in a subdirectory.
<p/>Unfortunately, TeX doesn&rsquo;t have a changeable &ldquo;current directory&rdquo;,
so that all files you refer to have to be specified relative to the
same directory as the main file.  Most people find this
counter-intuitive.
<p/>It may be appropriate to use the &ldquo;path extension&rdquo; technique

<a href="FAQ-tempinst.html">used in temporary installations</a> to deal with
this problem.  However, if there several files with the same name in
your document, such as <i>chapter1/fig1.eps</i> and
<i>chapter2/fig1.eps</i>, you&rsquo;re not giving TeX any hint as to
which you&rsquo;re referring to when in the main chapter file you say
<code>\</code><code>input{sect1}</code>; while this is readily soluble in the case of
human-prepared files (just don&rsquo;t name them all the same),
automatically produced files have a way of having repetitious names,
and changing <em>them</em> is a procedure prone to error.
<p/>The <i>import</i> package comes to your help here: it defines an
<code>\</code><code>import</code> command that accepts a full path name and the name of a
file in that directory, and arranges things to &ldquo;work properly&rdquo;.
So, for example, if <i>/home/friend/results.tex</i> contains
<blockquote>
<pre>
Graph: \includegraphics{picture}
\input{explanation}
</pre>
</blockquote><p>
then <code>\</code><code>import{/home/friend/}{results}</code> will include both
graph and explanation as one might hope.  A <code>\</code><code>subimport</code> command
does the same sort of thing for a subdirectory (a relative path rather
than an absolute one), and there are corresponding <code>\</code><code>includefrom</code>
and <code>\</code><code>subincludefrom</code> commands.
<p/>The <i>chapterfolder</i> package provides commands to deal with its
(fixed) model of file inclusion in a document.  It provides commands
<code>\</code><code>cfpart</code>, <code>\</code><code>cfchapter</code>, <code>\</code><code>cfsection</code> and <code>\</code><code>cfsubsection</code>,
each of which takes directory and file arguments, e.g.:
<blockquote>
<pre>
\cfpart[pt 1]{Part One}{part1}{part}
</pre>
</blockquote><p>
which command will issue a &lsquo;normal&rsquo; command 
<code>\</code><code>part[pt 1]{Part One}</code> and then input the file
<i>part1/part.tex</i>, remembering that <i>part1/</i> is now the
&ldquo;current folder&rdquo;.  There are also commands of the form
<code>\</code><code>cfpartstar</code> (which corresponds to a <code>\</code><code>part*</code> command).
<p/>Once you&rsquo;re &ldquo;in&rdquo; a <i>chapterfolder</i>-included document, you
may use <code>\</code><code>cfinput</code> to input something relative to the &ldquo;current
folder&rdquo;, or you may use <code>\</code><code>input</code>, using <code>\</code><code>cfcurrentfolder</code> to
provide a path to the file.  (There are also
<code>\</code><code>cfcurrentfolderfigure</code> for a <i>figure/</i> subdirectory and
<code>\</code><code>cfcurrentfolderlistings</code> for a <i>listings/</i> subdirectory.)
<p/>Documentation of <i>chapterfolder</i> is in French, but the
<i>README</i> in the directory is in English.
<dl>
<dt><tt><i>chapterfolder.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/chapterfolder.zip">macros/latex/contrib/chapterfolder</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/chapterfolder/">browse the directory</a>)
<dt><tt><i>import.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archivemacros/latex/contrib/misc/import.sty">macros/latex/contrib/misc/import.sty</a>
</dl>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=docotherdir">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=docotherdir</a>
</body>