diff options
author | Karl Berry <karl@freefriends.org> | 2011-02-19 00:37:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-02-19 00:37:41 +0000 |
commit | 8f846f8a8c7b2774059df2db0f153948e98cccf1 (patch) | |
tree | ff1781fa9b83db1e66c931962c18f57ae3428294 /Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html | |
parent | 09eb455bf0a899e9231b600e1326d5e0e4a67aca (diff) |
FAQ-en 3.21 (18feb11)
git-svn-id: svn://tug.org/texlive/trunk@21459 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html')
-rw-r--r-- | Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html | 181 |
1 files changed, 100 insertions, 81 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html index 807ac5b8872..81f528daa1e 100644 --- a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html +++ b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-filename.html @@ -19,90 +19,109 @@ 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. -<p/>If you’re not inputting things from a file that’s already been input, -the job is almost trivial: -<blockquote> -<pre> -\def\ThisFile{\jobname} -\let\OldInput\input -\renewcommand{\input}[1]{% - \renewcommand{\ThisFile}{#1}% - \OldInput#1% -} -</pre> -</blockquote><p> -With that, the macro <code>\</code><code>ThisFile</code> always contains the last thing -input: it starts pointing at the base file of your document -(<code>\</code><code>jobname</code>), and thereafter changes every time you use -<code>\</code><code>input{</code><em>file</em><code>}</code>. Note that this is not satisfactory if your -document contains things <em>other</em> than <code>\</code><code>input</code> commands. For -example, in: -<blockquote> -<pre> -\documentclass{article} -... (macros above) -\begin{document} -\input{preamble} -<body of document> -\input{postamble} -\end{document} -</pre> -</blockquote><p> -<code>\</code><code>ThisFile</code> contains <code>postamble</code> throughout the -<<i>body of document</i>>. -<p/>Most ordinary users will quickly become irritated with the simplicity -of of the <code>\</code><code>ThisFile</code> mechanism above. The following code is more -cunning: it maintains details of the files you’ve ‘come through’ to -get to where you are, and it restores <code>\</code><code>ThisFile</code> to what the -previous file was before returning. -<blockquote> -<pre> -\def\ThisFile{\jobname} -\newcounter{FileStack} -\let\OrigInput\input -\renewcommand{\input}[1]{% - \stackinput{#1}{\OrigInput}% -} -\newcommand{\stackinput}[2]{% - \stepcounter{FileStack}% - \expandafter\let - \csname NameStack\theFileStack\endcsname - \ThisFile - \def\ThisFile{#1}% - #2#1% - \expandafter\let\expandafter - \ThisFile - \csname NameStack\theFileStack\endcsname - \addtocounter{FileStack}{-1}% -} -</pre> -</blockquote><p> -To do the same for <code>\</code><code>include</code>, we need the simple addition: -<blockquote> -<pre> -\let\OrigInclude\include -\renewcommand{\include}[1]{% - \stackinput{#1}{\OrigInclude}% -} -</pre> -</blockquote><p> -Both examples of patching <code>\</code><code>input</code> assume you always use -LaTeX syntax, i.e., always use braces around the argument. -<p/>The <i>FiNK</i> (“File Name Keeper”) package provides a -regular means of keeping track of the current file name (with its -extension), in a macro <code>\</code><code>finkfile</code>. If you need the unadorned file -name (without its ‘<code>.tex</code>’), use the commands: -<blockquote> -<pre> -\def\striptexext#1.tex{#1} -... -\edef\ThisFile{\expandafter\stripext\finkfile} -</pre> -</blockquote><p> +used on them. (Note that latex’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’s surprisingly difficult (these FAQs offered +code, for a long time, that just didn’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 ‘base’ 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> (“File Name Keeper”) 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> |