[OS X TeX] jobname
Alain Schremmer
Schremmer.Alain at gmail.com
Thu Jan 25 03:37:04 CET 2007
Ross Moore wrote:
> This coding doesn't seem to have been well-tested with
> modern LaTeX. It falls foul of things that happen both
> at \begin{document} and \end{document} .
I didn't think it was me but, still, I was worried.
> However, it can be easily fixed as follows:
>
> \def\ThisFile{\jobname}
> \newcounter{FileStack}
> \newcommand{\recordinput}[1]{% <<--- new name
> \stackinput{#1}{\OrigInput}%
> }
> \newcommand{\stackinput}[2]{%
> \stepcounter{FileStack}%
> \expandafter\let
> \csname NameStack\theFileStack\endcsname
> \ThisFile
> \def\ThisFile{#1}% <<---- \edef might be better here !
> #2{#1}%
> \expandafter\let\expandafter
> \ThisFile
> \csname NameStack\theFileStack\endcsname
> \addtocounter{FileStack}{-1}%
> }
>
> %% delay the re-definition of \input until later
> \AtBeginDocument{%
> \let\OrigInput\input
> \let\input\recordinput
> }
> %% set it back at the end of the document
> \AtEndDocument{\let \input \OrigInput}
>
>
>
>> I looked at the reference, patching techniques, but this is way
>> beyond the little bit I have learned so I am crying for help.
>
>
> Above is an example of how it should be done.
> That is,
> (i) define a new function (or "method") to do what you want;
> (ii) preserve, using \let , a pointer to the original method;
> (iii) use \let to rebind the macro-name to your new method,
> delaying to a time when it is safe to do so;
> (iv) use \let again, to rebind the macro name back to the
> original method, after you have finished using your
> new method.
>
>
> Beware though. I've not tested the above instance with a serious job;
> nor have I tested for how it works with \include .
I will test tomorrow.
Very grateful regards
--schremmer
------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/
More information about the macostex-archives
mailing list