summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html
blob: 81f528daa1e4b7117426ef8d5b76840aae1b6554 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<head>
<title>UK TeX FAQ -- question label filename</title>
</head><body>
<h3>What&#8217;s the name of this file</h3>
<p/>One might want this so as to automatically generate a page header or
footer recording what file is being processed.  It&#8217;s not easy&#8230;
<p/>TeX retains what it considers the name of the <em>job</em>, only, in
the primitive <code>\</code><code>jobname</code>; this is the name of the file first
handed to TeX, stripped of its directory name and of any extension
(such as <code>.tex</code>).  If no file was passed (i.e., you&#8217;re using
TeX interactively), <code>\</code><code>jobname</code> has the value <code>texput</code>
(the name that&#8217;s given to <code>.log</code> files in this case).
<p/>This is fine, for the case of a small document, held in a single file;
most significant documents will be held in a bunch of files, and
TeX makes no attempt to keep track of files input to the
<em>job</em>.  So the user has to keep track, himself &#8212; the only way
is to patch the input commands and cause them to retain details of the
file name.  This is particularly difficult in the case of Plain TeX,
since the syntax of the <code>\</code><code>input</code> command is so peculiar.
<p/>In the case of LaTeX, the input commands have pretty regular
syntax, and the simplest <a href="FAQ-patch.html">patching techniques</a> can be
used on them.  (Note that latex&#8217;s <code>\</code><code>input</code> command is itself a
patch on top of the Plain TeX command.  Our patches apply to the
LaTeX version of the command, which is used as <code>\</code><code>input{</code><em>file</em><code>}</code>)
<p/>






























<p/>





































<p/>It is possible to keep track of the name of the file currently being
processed, but it&#8217;s surprisingly difficult (these FAQs offered
code, for a long time, that just didn&#8217;t work in many cases).
<p/>The <i>currfile</i> package provides a regular means of keeping
track of the details of the current file (its name in
<code>\</code><code>currfilename</code>, directory in <code>\</code><code>currfiledir</code>, as well as the
file &#8216;base&#8217; name (less its extension) and its extension).
<i>Currfile</i> does this with the help of a second package,
<i>filehook</i>, which spots file operations that use <code>\</code><code>input</code>,
<code>\</code><code>InputIfFileExists</code> and <code>\</code><code>include</code>, as well as package and
class loading.
<p/>The <i>FiNK</i> (&#8220;File Name Keeper&#8221;) package keeps track of the
file name and extension, in a macro <code>\</code><code>finkfile</code>.  <i>FiNK</i> is
now deprecated, in favour of <i>currfile</i>, but remains available
for use in old documents.











The <i>FiNK</i> bundle includes a <i>fink.el</i> that provides
support under <i>emacs</i> with AUC-TeX.
<dl>
<dt><tt><i>currfile.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/currfile.zip">macros/latex/contrib/currfile</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/currfile/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/currfile.html">catalogue entry</a>
<dt><tt><i>filehook.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/filehook.zip">macros/latex/contrib/filehook</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/filehook/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/filehook.html">catalogue entry</a>
<dt><tt><i>fink.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/fink.zip">macros/latex/contrib/fink</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/fink/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/fink.html">catalogue entry</a>
</dl>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=filename">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=filename</a>
</body>