% % 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 where 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}