summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/inputfile.sty
blob: 5fa26e2fa41b58c5fdbaa4644965523aca7ef3ca (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
%
% Inputfile style : Designed by R.Tucci, Ciba-Geigy AG Basle, June 29, 1990
%                   modified by R.Tucci Feb. 21, 1991
%
% The following commands are defined for internal use
%
% \@fileindex        : To keep the current level of \input{}
% \@iinput              : Redefines the \@iinput command of \latex.tex to
%                         save the filename of \input{...}
% \inputfilename         : Returns the filename depending on \@fileindex
% \@filenamei        : Contains the filename for \@fileindex=1
% \@filenameii       : Contains the filename for \@fileindex=2
% \@filenameiii      : Contains the filename for \@fileindex=3
% \@filename...      : ... etc.
% This Style should be used in the following manner
%
% 1. add this file to the \documentstyle[...]
% 2. use the command \inputfilename somewhere in the text and the current
%    input file name will be substituted
\typeout{filename environment loaded. WRTC , Version 1.1 22.02.91}
                        %
                        % Redefine \@iinput from latex.tex to keep the filename
                        % available
\newcount\@fileindex         % defines the pointer to the current filename
\@fileindex=0                %  and initialize it.
\def\@iinput#1{\advance\@fileindex by 1      % increment the pointer
                                % save the filename
        % the following line dose this Job:
        % 1. \expandafter prevents to redefine \csname, so
        % 2. \csname filename\romannumeral\@fileindex\endcsname
        %    expands to the control sequence \filename<x> where <x> is
        %    the roman character representation of \@fileindex. (e.g ii)
        % 3. \def defines the resulted control sequence of 2. to be #1
        \expandafter\def\csname filename\romannumeral\@fileindex\endcsname
{#1}
        \@@input#1                              % now read the file
        \ifnum\@fileindex>0                  % check for end of stack
        \advance\@fileindex by -1 \fi}       %   and decrement the pointer
                                % read the current filename if an \input
                                % has been performed, otherwise use \jobname
\def\inputfilename{\ifnum\@fileindex=0\jobname
                  \else\csname filename\romannumeral\@fileindex\endcsname
                  \fi}