zip the unpacked directory below distrib
[latex2e.git] / base / ltfiles.dtx
blob1612509e98898e91572540526bf6ad6e1939dc8c
1 % \iffalse meta-comment
3 % Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
4 % The LaTeX3 Project and any individual authors listed elsewhere
5 % in this file. 
6
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 %    http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX 
16 % version 2005/12/01 or later.
17
18 % This file has the LPPL maintenance status "maintained".
19
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23
24 % The list of derived (unpacked) files belonging to the distribution 
25 % and covered by LPPL is defined by the unpacking scripts (with 
26 % extension .ins) which are part of the distribution.
27
28 % \fi
30 % \iffalse
31 %%% From File: ltfiles.dtx
32 %<*driver>
33 % \fi
34 \ProvidesFile{ltfiles.dtx}
35              [1997/10/06 v1.1l LaTeX Kernel (File Handling)]
36 % \iffalse
37 \documentclass{ltxdoc}
38 \GetFileInfo{ltfiles.dtx}
39 \title{\filename}
40 \date{\filedate}
41  \author{%
42   Johannes Braams\and
43   David Carlisle\and
44   Alan Jeffrey\and
45   Leslie Lamport\and
46   Frank Mittelbach\and
47   Chris Rowley\and
48   Rainer Sch\"opf}
50 \begin{document}
51 \maketitle
52  \DocInput{\filename}
53 \end{document}
54 %</driver>
55 % \fi
57 % \CheckSum{572}
59 % \changes{v1.0h}{1994/05/21}{Use new error commands}
60 % \changes{v1.0n}{1994/11/17}
61 %         {\cs{@tempa} to \cs{reserved@a}}
62 % \changes{v1.0u}{1995/07/13}{Updates to docu}
64 % \section{File Handling}
66 % The following user commands are defined in this part:
68 %  \DescribeMacro{\document} (ie |\begin{document}|)\\
69 %      Reads in the .AUX files and |\catcode|'s |@| to 12.
71 %  \DescribeMacro{\nofiles}\\
72 %       Suppresses all file output by setting |\@filesw| false.
74 %  \DescribeMacro{\includeonly}\marg{NAME1, ... ,NAMEn}\\
75 %       Causes only parts NAME1, ... ,NAMEn to be read by
76 %         their |\include| commands.  Works by setting \@partsw true
77 %         and setting |\@partlist| to NAME1, ... ,NAMEn.
79 %  \DescribeMacro{\include}\marg{NAME}\\
80 %        Does an |\input| NAME unless |\@partsw| is true and
81 %         NAME is not in |\@partlist|.  If |\@filesw| is true, then
82 %         it directs .AUX output to NAME.AUX, including a
83 %         checkpoint at the end.
85 % \DescribeMacro{\input}\marg{NAME}\\
86 %        The same as TeX's |\input|, except it allows optional
87 %         braces around the file name. In \LaTeXe, it also avoids
88 %         the primitive `missing file' error, if the file can not be
89 %         found.
91 % \DescribeMacro{\IfFileExists}\marg{NAME}\marg{then}\marg{else}\\
92 %   If the file exists on the system, execute \emph{then} otherwise
93 %   execute \emph{else}.
95 % \DescribeMacro{\InputIfFileExists}\marg{NAME}\marg{then}\marg{else}\\
96 %   If the file exists on the system, execute \emph{then} and input
97 %   \emph{NAME}  otherwise execute \emph{else}.
99 % \StopEventually{}
101 % \changes{v1.0a}{1994/03/07}{Initial version, split from latex.dtx}
102 % \changes{v1.0a}{1994/03/07}{Long lines wrapped to 72 columns}
104 % \begin{oldcomments}
106 %    \begin{macrocode}
107 %<*2ekernel|autoload>
108 \message{files,}
109 %    \end{macrocode}
111 %  VARIABLES, SWITCHES AND INTERNAL COMMANDS:
112 %    \@mainaux    : Output file number for main .AUX file.
113 %    \@partaux    : Output file number for current part's .AUX file.
114 %    \@auxout     : Either \@mainout or \@partout, depending on
115 %                   which .AUX file output goes to.
116 %    \@input{foo} : If file foo exists, then \input's it,
117 %                   otherwise types a warning message.
118 %    @filesw       : Switch -- set false if no .AUX, .TOC, .IDX etc
119 %                     files are to be written
120 %    @partsw      : Set true by a \includeonly command.
121 %    \@partlist   : Set to the argument of the \includeonly command.
123 %    \cp@FOO      : The checkpoint for \include'd file FOO.TEX, written
124 %                   by \@writeckpt at the end of file FOO.AUX
127 % \includeonly{FILELIST} ==
128 %  BEGIN
129 %   \@partsw   := T
130 %   \@partlist := FILELIST
131 %  END
133 % \include{FILE} ==
134 %  BEGIN
135 %   \clearpage
136 %   if \@filesw = T
137 %     then  \immediate\write\@mainaux{\string\@input{FILE.AUX}}
138 %   fi
139 %   if  \@partsw = T
140 %     then \@tempswa := F
141 %          \reserved@b == FILE
142 %          for \reserved@a := \@partlist
143 %              do if eval(\reserved@a) = eval(\reserved@b)
144 %                   then \@tempswa := T          fi
145 %              od
146 %   fi
148 %   if \@tempswa = T
149 %      then \@auxout := \@partaux
150 %           if \@filesw = T
151 %             then  \immediate\openout\@partaux{FILE.AUX}
152 %                   \immediate\write\@partaux{\relax}
153 %           fi
154 %           \@input{FILE.TEX}
155 %           \clearpage
156 %           \@writeckpt{FILE}
157 %           if @filesw then \closeout \@partaux fi
158 %           \@auxout := \@mainaux
159 %      else \cp@FILE
160 %   fi
161 %  END
163 % \@writeckpt{FILE} ==
164 %  BEGIN
165 %    if \@filesw = T
166 %        \immediate\write on file \@partaux:
167 %                  \@setckpt{FILE}{                  %% }
168 %        for \reserved@a := \cl@@ckpt
169 %           do  \immediate\write on file \@partaux:
170 %                   \global\string\setcounter
171 %                       {eval(\reserved@a)}{eval(\c@eval(\reserved@a))}
172 %           od                                     %% {
173 %        \immediate\write on file \@partaux:  }
174 %    fi
175 %  END
177 % \@setckpt{FILE}{LIST} ==
178 %  BEGIN
179 %    G \cp@FILE := LIST
180 %  END
182 %  INITIALIZATION
183 %    \@tempswa := T
185 % \end{oldcomments}
188 % \task{???}{Do we use @unused or mainaux?}
189 %  \begin{macro}{\@inputcheck}
190 %  \begin{macro}{\@unused}
191 %    Allocate read stream for testing and output stream.
192 % \changes{v1.0l}{1994/11/07}
193 %      {move here from ltdefns, remove duplicate \cs{@mainaux}}
194 %    \begin{macrocode}
195 \newread\@inputcheck
196 \newwrite\@unused
197 %    \end{macrocode}
198 %  \end{macro}
199 %  \end{macro}
201 % \begin{macro}{\@mainaux}
202 % \begin{macro}{\@partaux}
203 %    \begin{macrocode}
204 \newwrite\@mainaux
205 \newwrite\@partaux
206 %    \end{macrocode}
207 %  \end{macro}
208 %  \end{macro}
210 % \begin{macro}{\if@filesw}
211 % \begin{macro}{\if@partsw}
212 %    \begin{macrocode}
213 \newif\if@filesw \@fileswtrue
214 \newif\if@partsw \@partswfalse
215 %    \end{macrocode}
216 %  \end{macro}
217 %  \end{macro}
219 % \begin{macro}{\@clubpenalty}
220 %    This stores the current normal (non-infinite) value of
221 %    \cs{clubpenalty}; it should therefore be reset whenever the
222 %    normal value is changed (as in the bibliography in the standard
223 %    styles).
224 % \changes{v1.1h}{1996/10/05}{Added setting its value}
225 %    \begin{macrocode}
226 \newcount\@clubpenalty
227 \@clubpenalty \clubpenalty
228 %    \end{macrocode}
229 %  \end{macro}
231 %  \begin{macro}{\document}
232 % \changes{v0.9e}{1993/12/09}{Hook added}
233 %    Cancel the |\begingroup| from |\begin|
234 %    \begin{macrocode}
235 \def\document{\endgroup
236 %    \end{macrocode}
237 %    If some options on |\documentclass| haven't been used by any
238 %    package we will now give a warning since this is most certainly a
239 %    misspelling.
240 %    \begin{macrocode}
241   \ifx\@unusedoptionlist\@empty\else
242     \@latex@warning@no@line{Unused global option(s):^^J%
243             \@spaces[\@unusedoptionlist]}%
244   \fi
245   \@colht\textheight
246   \@colroom\textheight \vsize\textheight
247   \columnwidth\textwidth
248   \@clubpenalty\clubpenalty
249   \if@twocolumn
250     \advance\columnwidth -\columnsep
251     \divide\columnwidth\tw@ \hsize\columnwidth \@firstcolumntrue
252   \fi
253   \hsize\columnwidth \linewidth\hsize
254   \begingroup\@floatplacement\@dblfloatplacement
255     \makeatletter\let\@writefile\@gobbletwo
256 %    \end{macrocode}
257 % \changes{v1.1a}{1995/10/24}
258 %            {Removed multiplelabels switch}
259 %    \begin{macrocode}
260     \global \let \@multiplelabels \relax
261     \@input{\jobname.aux}%
262   \endgroup
263   \if@filesw
264     \immediate\openout\@mainaux\jobname.aux
265     \immediate\write\@mainaux{\relax}%
266   \fi
267 %    \end{macrocode}
269 % Dateline 1991/03/26: FMi added |\process@table| to support NFSS;
270 % This will also work with old lfonts if no other style defines
271 % |\process@table|.  The following line forces the initialization of
272 % the math fonts.
273 %    \begin{macrocode}
274   \process@table
275   \let\glb@currsize\@empty  %% Force math initialization.
276 %    \end{macrocode}
277 % \changes{v0.9t}{1994/01/31}
278 %     {set \cs{@normalsize} or \cs{normalsize} if necessary}
279 % \changes{v1.0d}{1994/03/28}
280 %     {(DPC) remove \cs{@normalsize check}}
281 % \changes{v1.0d}{1994/03/28}
282 %     {(DPC) Use \cs{normalsize} not \cs{@normalsize}}
283 % \changes{v1.0g}{1994/05/13}{Added execution of \cs{every@size}}
284 % \changes{v1.0m}{1994/11/07}{Renamed \cs{every@size} to
285 %                \cs{every@math@size}.}
286 % \changes{v1.0q}{1995/04/25}
287 %            {Removed execution of \cs{every@size} latex/1407}
288 %    \begin{macrocode}
289   \normalsize
290   \everypar{}%
291 %    \end{macrocode}
293 % So that punctuation in headings is not disturbed by verbatim
294 % or other local changes to the space factor codes, save the document
295 % default here. This will be locally reset by the output routine.
296 % For special cases a class may want to define |\normalsfcodes|
297 % directly, in case that definition will be used.
298 % (This is an old bug, problem existed in \LaTeX2.0x and plain \TeX.)
299 % \changes{v1.1k}{1997/04/14}
300 %            {Set the document space factor defaults. latex/2404}
301 %    \begin{macrocode}
302   \ifx\normalsfcodes\@empty
303     \ifnum\sfcode`\.=\@m
304       \let\normalsfcodes\frenchspacing
305     \else
306       \let\normalsfcodes\nonfrenchspacing
307     \fi
308   \fi
309 %    \end{macrocode}
310 % Way back in 1991 (08/26) FMi \& RmS set the |\@noskipsec| switch
311 % to true in the preamble and to false here.
312 % This was done to trap lists and related text in the preamble but it
313 % does not catch everything; hence Change 1.1g was introduced.
314 %    \begin{macrocode}
315   \@noskipsecfalse
316 %    \end{macrocode}
317 % \changes{v1.1a}{1995/10/24}
318 %            {Removed refundefined switch}
319 %    \begin{macrocode}
320   \let \@refundefined \relax
321 %    \end{macrocode}
322 %    Just before disabling the preamble commands we execute the begin
323 %    document hook which contains any code contributed by
324 %    |\AtBeginDocument|. Also disable the gathering of the file list,
325 %    if no |\listfiles| has been issued. |\AtBeginDocument| is redefined
326 %    at this point so that and such commands that get into the hook do
327 %    not chase their tail\ldots
328 % \changes{v1.1e}{1996/04/24}
329 %            {(DPC) Reset \cs{AtBeginDocument} eg for latex/1297}
330 %    \begin{macrocode}
331   \let\AtBeginDocument\@firstofone
332   \@begindocumenthook
333 %    \end{macrocode}
334 %    Most of the following assignments will be done globally in case
335 %    the user adds something like |\begin{multicols}| to the document
336 %    hook, i.e. starts are group in |\begin{document}|.
337 % \changes{v1.0r}{1995/04/27}
338 %         {Added \cs{global} to support groups in hook}
339 % \changes{v1.0c}{1994/03/16}
340 %         {(DPC) directly add file list settings}
341 % \changes{v1.0v}{1995/08/16}{set \cs{topskip} globally}
342 % \changes{v1.0v}{1995/08/16}{set \cs{@maxdepth}}
344 % \changes{v1.0s}{1995/05/25}
345 %         {Added check for \cs{topskip} zero}
346 % \changes{v1.0t}{1995/05/25}
347 %         {Corrected typo}
348 %    Since a value of exactly 0pt for \cs{topskip} causes
349 %    \cs{twocolumn[]} to misbehave, we add this check, hoping
350 %    that it will not cause any problems elsewhere.
351 %    \begin{macrocode}
352   \ifdim\topskip<1sp\global\topskip 1sp\relax\fi
353   \global\@maxdepth\maxdepth
354   \global\let\@begindocumenthook\@undefined
355   \ifx\@listfiles\@undefined
356     \global\let\@filelist\relax
357     \global\let\@addtofilelist\@gobble
358   \fi
359 %    \end{macrocode}
360 %    At the very end we disable all preamble commands. This has to
361 %    happen after the begin document hooks was executed so that this
362 %    hook can still use such commands.
363 % \changes{v0.9o}{1994/01/15}
364 %           {move \cs{@preamblecmds} after document hook}
365 % \changes{v1.0v}{1995/08/16}{set \cs{do} globally}
366 %    \begin{macrocode}
367   \gdef\do##1{\global\let ##1\@notprerr}%
368   \@preamblecmds
369 %    \end{macrocode}
370 %    The next line saves tokens and also allows |\@nodocument| to be
371 %    used directly to trap preamble errors.
372 % \changes{v1.1g}{1996/09/29}{Added disabling of \cs{@nodocument}}
373 %    \begin{macrocode}
374   \global\let \@nodocument \relax
375 %    \end{macrocode}
376 %    The next line is a pure safety measure in case a do list is ever
377 %    expanded at the wrong place. In addition it will save a few
378 %    tokens to get rid of the above definition.
379 %    \begin{macrocode}
380   \global\let\do\noexpand
381 %    \end{macrocode}
382 % \changes{v1.1c}{1995/12/05}{\cs{ignorespaces} added for latex/1933}
383 %    Use of |\AtBeginDocument| hook might mean that we are already in
384 %    horizontal mode, so ignore the space after |\begin{document}|.
385 %    \begin{macrocode}
386   \ignorespaces}
387 %    \end{macrocode}
389 %    \begin{macrocode}
390 \@onlypreamble\document
391 %    \end{macrocode}
392 %  \end{macro}
394 % \begin{macro}{\normalsfcodes}
395 % \changes{v1.1k}{1997/04/14}
396 %            {Macro added (from patch file) latex/2404}
397 % The setting of |\@empty| is just a flag. This command may be defined
398 % in a class or package file. If it is still |\@empty| at 
399 % |\begin{document}| it will be defined to be |\frenchspacing| or
400 % |\nonfrenchspacing|, depending on which of those appears to be in
401 % effect at that point.
402 %    \begin{macrocode}
403 \let\normalsfcodes\@empty
404 %    \end{macrocode}
405 %  \end{macro}
407 % \begin{macro}{\nofiles}
408 % \changes{v1.0k}{1994/11/04}
409 %   {Added setting of \cs{protected@write},
410 %    \cs{makeindex} and \cs{makeglossary} to \cs{nofiles}.  ASAJ.}
411 % \changes{v1.0o}{1994/11/30}
412 %         {There is no \cs{@gobblethree}\ldots}
413 % \changes{v1.0t}{1995/05/25}
414 %         {(CAR) added \cs{long}}
415 % \changes{v1.1f}{1996/05/17}
416 %         {added \cs{write} to \cs{protected@write} for latex/2146}
417 % Set |\@fileswfalse| which suppresses the places where \LaTeX\ makes
418 % |\immediate| writes. The |\makeindex| and |\makeglossary| are
419 % disabled. |\protected@write| is redefined not to write to the file
420 % specified, but rather to write a blank line to the log file. This
421 % ensures that a \meta{whatsit} node is still created, and so spacing
422 % is not affected by the |\nofiles| command; to ensure this more
423 % generally, the |\if@nobreak| test is needed.
424 % \changes{v1.1i}{1996/11/05}
425 %                {Standard \cs{if@nobreak} test added}
426 %    \begin{macrocode}
427 \def\nofiles{%
428   \@fileswfalse
429   \typeout{No auxiliary output files.^^J}%
430   \long\def\protected@write##1##2##3%
431     {\write\m@ne{}\if@nobreak\ifvmode\nobreak\fi\fi}%
432   \let\makeindex\relax
433   \let\makeglossary\relax}
434 \@onlypreamble\nofiles
435 %    \end{macrocode}
436 %  \end{macro}
439 % \begin{macro}{\protected@write}
440 %    This takes three arguments: an output stream, some initialization
441 %    code, and some text to write.  It then writes this, with
442 %    appropriate handling of |\protect| and |\thepage|.
443 % \changes{v1.0k}{1994/11/04}{Macro added  ASAJ.}
444 % \changes{v1.0t}{1995/05/25}
445 %         {(CAR) added \cs{long}}
446 %    \begin{macrocode}
447 \long\def \protected@write#1#2#3{%
448       \begingroup
449        \let\thepage\relax
450        #2%
451        \let\protect\@unexpandable@protect
452        \edef\reserved@a{\write#1{#3}}%
453        \reserved@a
454       \endgroup
455       \if@nobreak\ifvmode\nobreak\fi\fi
457 %    \end{macrocode}
458 % \end{macro}
460 %    \begin{macrocode}
461 \let\@auxout=\@mainaux
462 %    \end{macrocode}
465 % \begin{macro}{\includeonly}
466 % \changes{v1.0p}{1995/04/22}{Allow blanks in argument}
467 %    \begin{macrocode}
468 \def\includeonly#1{%
469   \@partswtrue
470   \edef\@partlist{\zap@space#1 \@empty}}
471 \@onlypreamble\includeonly
472 %    \end{macrocode}
473 % \end{macro}
475 % \begin{macro}{\include}
476 % \changes{v0.9p}{1994/01/18}
477 %         {Use \cs{@input@} so include files are listed.}
478 % In the definition of |\include|, |\def\reserved@b| changed to
479 % |\edef\reserved@b| to be consistent with the |\edef| in
480 % |\includeonly|.
481 % (Suggested by Rainer Sch\"opf \& Frank Mittelbach.
482 % Change made 20 Jul 88.)
484 % Changed definition of |\include| to allow space at end of file name
485 % --- otherwise, typing |\include{foo }| would cause \LaTeX\ to
486 % overwrite |foo.tex|.  Change made 24 May 89, suggested by Rainer
487 % Sch\"opf  and Frank Mittelbach
489 % Made |\include| check for being used inside an |\include|'d file, as
490 % this will not work and cause surprising results.
491 %    \begin{macrocode}
492 \def\include#1{\relax
493   \ifnum\@auxout=\@partaux
494     \@latex@error{\string\include\space cannot be nested}\@eha
495   \else \@include#1 \fi}
496 %    \end{macrocode}
497 % \end{macro}
499 % \begin{macro}{\@include}
500 %    \begin{macrocode}
501 \def\@include#1 {%
502   \clearpage
503   \if@filesw
504     \immediate\write\@mainaux{\string\@input{#1.aux}}%
505   \fi
506   \@tempswatrue
507   \if@partsw
508     \@tempswafalse
509     \edef\reserved@b{#1}%
510     \@for\reserved@a:=\@partlist\do
511       {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
512   \fi
513   \if@tempswa
514     \let\@auxout\@partaux
515     \if@filesw
516       \immediate\openout\@partaux #1.aux
517       \immediate\write\@partaux{\relax}%
518     \fi
519     \@input@{#1.tex}%
520     \clearpage
521     \@writeckpt{#1}%
522     \if@filesw
523       \immediate\closeout\@partaux
524     \fi
525   \else
526 %    \end{macrocode}
527 % If the file is not included, reset |\deadcycles|, so that a long
528 % list of non-included files does not generate an `Output loop'
529 % error.
530 % \changes{v1.1j}{1997/01/08}{reset \cs{deadcycles} latex/2365}
531 %    \begin{macrocode}
532     \deadcycles\z@
533     \@nameuse{cp@#1}%
534   \fi
535   \let\@auxout\@mainaux}
536 %    \end{macrocode}
537 % \end{macro}
539 % \begin{macro}{\@writeckpt}
540 %    \begin{macrocode}
541 \def\@writeckpt#1{%
542   \if@filesw
543     \immediate\write\@partaux{\string\@setckpt{#1}\@charlb}%
544     {\let\@elt\@wckptelt \cl@@ckpt}%
545     \immediate\write\@partaux{\@charrb}%
546   \fi}
547 %    \end{macrocode}
548 % \end{macro}
550 % \begin{macro}{\@wckptelt}
551 %    \begin{macrocode}
552 \def\@wckptelt#1{%
553   \immediate\write\@partaux{%
554     \string\setcounter{#1}{\the\@nameuse{c@#1}}}}
555 %    \end{macrocode}
556 % \end{macro}
558 % \begin{macro}{\@setckpt}
559 % RmS 93/08/31: introduced |\@setckpt|
560 %    \begin{macrocode}
561 \def\@setckpt#1{\global\@namedef{cp@#1}}
562 %    \end{macrocode}
563 % \end{macro}
565 % \begin{macro}{\@charlb}
566 % \begin{macro}{\@charrb}
567 % The following defines |\@charlb| and |\@charrb| to be |{| and |}|,
568 % respectively with |\catcode| 11.
569 %    \begin{macrocode}
570 {\catcode`[=1 \catcode`]=2
571 \catcode`{=11 \catcode`}=11
572 \gdef\@charlb[{]
573 \gdef\@charrb[}]
574 ]% }brace matching
575 %    \end{macrocode}
576 % \end{macro}
577 % \end{macro}
580 % \subsection{Safe Input Macros}
582 % \begin{macro}{\IfFileExists}
583 % \changes{v0.9b}{1993/12/04}{Macro added}
584 % \changes{v0.9p}{1994/01/18}{New Definition}
585 % \changes{v1.0t}{1995/05/25}
586 %         {(CAR) added \cs{long}}
588 %    \begin{macrocode}
589 \long\def \IfFileExists#1#2#3{%
590   \openin\@inputcheck#1 %
591   \ifeof\@inputcheck
592     \ifx\input@path\@undefined
593       \def\reserved@a{#3}%
594     \else
595       \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
596     \fi
597   \else
598     \closein\@inputcheck
599     \edef\@filef@und{#1 }%
600     \def\reserved@a{#2}%
601   \fi
602   \reserved@a}
603 %    \end{macrocode}
605 % \begin{macro}{\@iffileonpath}
606 % If the file is not found by |\openin|, and |\input@path| is defined,
607 % look in all the directories specified in |\input@path|.
608 % \changes{v0.9p}{1994/01/18}{Macro added}
609 % \changes{v1.0f}{1994/05/02}
610 %     {\cs{@break@loop} renamed to \cs{@break@tfor}}
611 % \changes{v1.0t}{1995/05/25}
612 %         {(CAR) added \cs{long}}
613 % \changes{v1.1d}{1996/01/10}
614 %     {Change argument handling to not require doubled hash. latex/2024}
615 %    \begin{macrocode}
616 \long\def\@iffileonpath#1{%
617   \let\reserved@a\@secondoftwo
618   \expandafter\@tfor\expandafter\reserved@b\expandafter
619              :\expandafter=\input@path\do{%
620     \openin\@inputcheck\reserved@b#1 %
621     \ifeof\@inputcheck\else
622       \edef\@filef@und{\reserved@b#1 }%
623       \let\reserved@a\@firstoftwo%
624       \closein\@inputcheck
625       \@break@tfor
626     \fi}%
627   \reserved@a}
628 %    \end{macrocode}
629 %  \end{macro}
630 %  \end{macro}
632 % \begin{macro}{\InputIfFileExists}
633 % \changes{v0.9b}
634 %         {1993/12/04}{Macro added}
635 % \changes{v0.9p}
636 %         {1994/01/18}{New Definition}
637 % \changes{v0.3b}{1994/03/13}
638 %         {Use new cmd \cs{@addtofilelist}}
639 % Now define |\InputIfFileExists| to input |#1| if it seems to exist.
640 % Immediately prior to the input, |#2| is executed.
641 % If the file |#1| does not exist, execute `|#3|'.
642 % \changes{v1.0t}{1995/05/25}
643 %         {(CAR) added \cs{long}}
644 %    \begin{macrocode}
645 \long\def \InputIfFileExists#1#2{%
646   \IfFileExists{#1}%
647     {#2\@addtofilelist{#1}\@@input \@filef@und}}
648 %    \end{macrocode}
649 %  \end{macro}
651 %  \begin{macro}{\input}
652 %    Input a file: if the argument is given in braces use safe input
653 %    macros, otherwise use \TeX's primitive |\input| command (which is
654 %    called |\@@input| in \LaTeX).
655 % \changes{v0.9b}{1993/12/04}{Macro reimplemented}
656 %    \begin{macrocode}
657 \def\input{\@ifnextchar\bgroup\@iinput\@@input}
658 %    \end{macrocode}
659 %  \end{macro}
661 % \begin{macro}{\@iinput}
662 %    Define |\@iinput| (i.e., |\input|) in terms of
663 %    |\InputIfIfileExists|.
664 % \changes{v0.9b}{1993/12/04}{Macro reimplemented}
665 %    \begin{macrocode}
666 \def\@iinput#1{%
667   \InputIfFileExists{#1}{}%
668   {\filename@parse{#1}%
669    \edef\reserved@a{\noexpand\@missingfileerror
670      {\filename@area\filename@base}%
671      {\ifx\filename@ext\relax tex\else\filename@ext\fi}}%
672    \reserved@a}}
673 %    \end{macrocode}
674 %  \end{macro}
676 % \begin{macro}{\@input}
677 % \changes{v0.9b}{1993/12/04}{Macro reimplemented}
678 % \changes{v0.9p}{1994/01/18}%
679 %         {do not use a different definition for \cs{input@path}}
680 %    Define |\@input| in terms of |\IfIfileExists|.
681 %    So this is a `safe input' command, but the files input are not
682 %    listed by |\listfiles|.
684 %    We don't want |.aux|, |.toc| files etc be listed by |\listfiles|.
685 %    However, something like |.bbl| probably should be listed and thus
686 %    should be implemented not by |\@input|.
687 %    \begin{macrocode}
688 \def\@input#1{%
689   \IfFileExists{#1}{\@@input\@filef@und}{\typeout{No file #1.}}}
690 %    \end{macrocode}
691 %  \end{macro}
693 % \begin{macro}{\@input@}
694 % \changes{v0.9p}{1994/01/18}{Macro added}
695 % \task{???}{share code with `@input ?}
696 % Version of |\@input| that does add the file to |\@filelist|.
697 %    \begin{macrocode}
698 \def\@input@#1{\InputIfFileExists{#1}{}{\typeout{No file #1.}}}
699 %    \end{macrocode}
700 %  \end{macro}
702 % \begin{macro}{\@missingfileerror}
703 % This `error' command avoids \TeX's primitive missing file loop.
705 % Missing file error. Prompt for a new filename, offering a default
706 % extension.
707 % \changes{LaTeX2e}{1993/11/21}
708 %         {Stop infinite looping on \cs{@er@ext}}
709 % \changes{LaTeX2e}{1993/11/28}
710 %         {Use filename parser from dircheck}
711 % \changes{LaTeX2e}{1994/03/15}
712 %         {Quit on x or X just like a real error}
713 % \changes{LaTeX2e}{1994/05/26}
714 %         {Modify message format}
715 % \changes{v1.0j}{1994/11/03}
716 %         {Move here from ltclass}
717 % \changes{v1.0w}{1995/10/06}
718 %         {Autoload error}
719 %    \begin{macrocode}
720 %<autoload>\def\@missingfileerror{\@autoerr\@missingfileerror}
721 %</2ekernel|autoload>
722 %<*2ekernel|autoerr>
723 \gdef\@missingfileerror#1#2{%
724      \typeout{^^J! LaTeX Error: File `#1.#2' not found.^^J^^J%
725       Type X to quit or <RETURN> to proceed,^^J%
726       or enter new name. (Default extension: #2)^^J}%
727      \message{Enter file name: }%
728       {\endlinechar\m@ne
729        \global\read\m@ne to\@gtempa}%
730     \ifx\@gtempa\@empty
731     \else
732       \def\reserved@a{x}\ifx\reserved@a\@gtempa\batchmode\@@end\fi
733       \def\reserved@a{X}\ifx\reserved@a\@gtempa\batchmode\@@end\fi
734       \filename@parse\@gtempa
735       \edef\filename@ext{%
736         \ifx\filename@ext\relax#2\else\filename@ext\fi}%
737      \edef\reserved@a{%
738        \noexpand\InputIfFileExists
739          {\filename@area\filename@base.\filename@ext}%
740          {}%
741          {\noexpand\@missingfileerror
742             {\filename@area\filename@base}{\filename@ext}}}%
743       \reserved@a
744     \fi}
745 %</2ekernel|autoerr>
746 %<*2ekernel|autoload>
747 %    \end{macrocode}
748 % \end{macro}
750 % \begin{macro}{\@obsoletefile}
751 %    For compatibility with \LaTeX~2.09 document styles, we distribute
752 %    files called |article.sty|, |book.sty|, |report.sty|,
753 %    |slides.sty| and |letter.sty|.  These use the command
754 %    |\@obsoletefile|, which produces a warning message.
755 %    \changes{v0.9m}{1993/12/20}{Added this command, removed
756 %                               @oldfilewarning}
757 % \changes{v1.0f}{1994/05/02}{Make \cs{@onlypreamble}}
758 %    \begin{macrocode}
759 \def\@obsoletefile#1#2{%
760    \@latex@warning@no@line{inputting `#1' instead of obsolete `#2'}}
761 \@onlypreamble\@obsoletefile
762 %    \end{macrocode}
764 % \subsection{Listing files}
766 % \begin{macro}{\@filelist}
767 % A list of files input so far. The initial value of |\@gobble| eats
768 % the comma before the first file name.
769 %    \begin{macrocode}
770 \let\@filelist\@gobble
771 %    \end{macrocode}
772 % \end{macro}
774 % \begin{macro}{\@addtofilelist}
775 % Add to the  list of files input so far.
776 % \changes{LaTeX2e}{1994/03/13}
777 %         {Macro added}
778 % \changes{LaTeX2e}{1995/10/01}
779 %         {Macro added}
780 % This `real' definition is only used for `cfg' files during initex.
781 % An initial definition of |\@gobble| has already been set.
782 %    \begin{macrocode}
783 %\def\@addtofilelist#1{\xdef\@filelist{\@filelist,#1}}
784 %    \end{macrocode}
785 % \end{macro}
787 % \begin{macro}{\listfiles}
788 % A preamble command to cause |\end{document}| to list files input
789 % from the main file.
790 % \changes{LaTeX2e}{1993/11/22}
791 %         {Removed checking for \cs{@unknownversion}}
792 % \changes{LaTeX2e}{1994/01/17}
793 %         {New Version, adds `.tex' if needed, and lines up columns}
794 % \changes{LaTeX2e}{1994/05/13}
795 %         {Stop \cs{listfiles} being run twice}
796 % \changes{v1.0i}{1994/10/18}
797 %         {code moved here from ltclass}
798 %    \begin{macrocode}
799 \def\listfiles{%
800   \let\listfiles\relax
801   \def\@listfiles##1##2##3##4##5##6##7##8##9\@@{%
802      \def\reserved@d{\\}%
803      \@tfor\reserved@c:=##1##2##3##4##5##6##7##8\do{%
804        \ifx\reserved@c\reserved@d
805          \edef\filename@area{ \filename@area}%
806        \fi}}%
807 %    \end{macrocode}
809 % \changes{v1.0o}{1994/11/30}
810 %         {Use \cs{@dofilelist}}
811 %    \begin{macrocode}
812   \def\@dofilelist{%
813      \typeout{^^J *File List*}%
814      \@for\@currname:=\@filelist\do{%
815        \filename@parse\@currname
816        \edef\reserved@a{%
817           \filename@base.%
818           \ifx\filename@ext\relax tex\else\filename@ext\fi}%
819        \expandafter\let\expandafter\reserved@b
820                               \csname ver@\reserved@a\endcsname
821        \expandafter\expandafter\expandafter\@listfiles\expandafter
822              \filename@area\filename@base\\\\\\\\\\\\\\\\\\\@@
823        \typeout{%
824          \filename@area\reserved@a
825          \ifx\reserved@b\relax\else\@spaces\reserved@b\fi}}%
826      \typeout{ ***********^^J}}}
827 %    \end{macrocode}
829 % \changes{LaTeX2e}{1994/03/13}
830 %         {Reset \cs{@addtofilelist} at begin document}
831 % \changes{LaTeX2e}{1994/03/16}
832 %         {Move this code directly into \cs{document}}
833 % The |\@filelist| will be de-activated if |\listfiles| does not
834 % appear in the preamble. |\begin{document}| contains code equivalent
835 % to the following:
836 %\begin{verbatim}
837 % \AtBeginDocument{%
838 %   \ifx\@listfiles\@undefined
839 %     \let\@filelist\relax
840 %     \let\@addtofilelist\@gobble
841 %   \fi}
842 %\end{verbatim}
843 %    \begin{macrocode}
844 \@onlypreamble\listfiles
845 %    \end{macrocode}
846 % \end{macro}
848 %  \begin{macro}{\@dofilelist}
849 % \changes{v1.0o}{1994/11/30}
850 %         {Macro added}
851 %    \begin{macrocode}
852 \let\@dofilelist\relax
853 %    \end{macrocode}
854 %  \end{macro}
856 %    \begin{macrocode}
857 %</2ekernel|autoload>
858 %    \end{macrocode}
859 % \end{macro}
861 % \Finale