1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
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.
18 % This file has the LPPL maintenance status "maintained".
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
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.
31 %%% From File: ltclass.dtx
35 \ProvidesFile{ltclass.dtx}
36 [2014/09/29 v1.1i LaTeX Kernel (Class & Package Interface)]
38 \documentclass{ltxdoc}
39 \GetFileInfo{ltclass.dtx}
41 \title{The main structure of documents}
42 \author{Frank Mittelbach\and Chris Rowley\and Alan Jeffrey\and
45 \MaintainedByLaTeXTeam{latex}
53 % (C) Copyright Frank Mittelbach, Chris Rowley,
54 % Alan Jeffrey and David Carlisle 1993-1998.
55 % All rights reserved.
60 % \changes{v1.0f}{1994/05/22}{Use new warning and error commands}
61 % \changes{v1.0l}{1994/11/17}{\cs{@tempa} to \cs{reserved@a}}
62 % \changes{v1.0z}{1998/03/21}{Added to documentation of filecontents}
63 % \changes{v1.1c}{1998/08/17}{(RmS) Minor documentation fixes.}
65 % \section{Introduction}
67 % This file implements the following declarations, which replace
68 % |\documentstyle| in \LaTeXe\ documents.
70 % Note that old documents containing |\documentstyle| will be run using
71 % a compatibility option---thus keeping everyone happy, we hope!
73 % The overall idea is that there are two types of `style files':
74 % `class files' which define elements and provide a default formatting
75 % for them; and `packages' which provide extra functionality. One
76 % difference between \LaTeXe\ and \LaTeX2.09 is that \LaTeXe\ packages
77 % may have options. Note that options to classes packages may be
78 % implemented such that they input files, but these file names are not
79 % necessarily directly related to the option name.
81 % \section{User interface}
83 % |\documentclass[|\meta{main-option-list}|]{|^^A
84 % \meta{class}|}[|\meta{version}|]|
86 % There must be exactly one such declaration, and it must come first.
87 % The \meta{main-option-list} is a list of options which can modify the
88 % formatting of elements which are defined in the \meta{class} file
89 % as well as in all following |\usepackage| declarations (see below).
90 % The \meta{version} is a version number, beginning with a date in the
91 % format |YYYY/MM/DD|. If an older version of the class is found, a
96 % |\documentstyle[|\meta{main-option-list}|]{|^^A
97 % \meta{class}|}[|\meta{version}|]|
99 % The |\documentstyle| declaration is kept in order to maintain upward
100 % compatibility with \LaTeX2.09 documents. It is similar to
101 % |\documentclass|, but it causes all options in
102 % \meta{main-option-list} that the \meta{class} does not use to be
103 % passed to |\RequirePackage| after the options have been processed.
104 % This maintains compatibility with the 2.09 behaviour. Also a flag is
105 % set to indicate that the document is to be processed in \LaTeX2.09
106 % compatibility mode. As far as most packages are concerned, this
107 % only affects the warnings and errors \LaTeX\ generates. This flag
108 % does affect the definition of font commands, and |\sloppy|.
112 % |\usepackage[|\meta{package-option-list}|]{|^^A
113 % \meta{package-list}|}[|\meta{version}|]|
115 % There can be any number of these declarations. All packages in
116 % \meta{package-list} are called with the same options.
118 % Each \meta{package} file defines new elements (or modifies those
119 % defined in the \meta{class}), and thus extends the range of documents
120 % which can be processed.
121 % The \meta{package-option-list} is a list of options which can modify
122 % the formatting of elements defined in the \meta{package} file.
123 % The \meta{version} is a version number, beginning with a date in the
124 % format |YYYY/MM/DD|. If an older version of the package is found, a
127 % Each package is loaded only once. If the same package is requested
128 % more than once, nothing happens, unless the package has been requested
129 % with options that were not given the first time it was loaded, in
130 % which case an error is produced.
132 % As well as processing the options given in the
133 % \meta{package-option-list}, each package processes the
134 % \meta{main-option-list}. This means that options that affect all
135 % of the packages can be given globally, rather than repeated for every
138 % Note that class files have the extension |.cls|, packages have the
141 % \DescribeEnv{filecontents}
142 % The environment |filecontents| is intended for passing the contents
143 % of packages, options, or other files along with a document in a
145 % It has one argument, which is the name of the file to create. If that
146 % file already exists (maybe only in the current directory if the OS
147 % supports a notion of a `current directory' or `default directory')
148 % then nothing happens
149 % (except for an information message) and the body of the environment
150 % is bypassed. Otherwise, the body of the environment is written
151 % verbatim to the file name given as the first argument, together with
152 % some comments about how it was produced.
154 % The environment is allowed only before |\documentclass| to ensure
155 % that all packages or options necessary for this particular run are
156 % present when needed. The begin and end tags should each be on a
157 % line by itself. There is also a star-form; this does not write
158 % extra comments into the file.
160 % \subsection{Option processing}
162 % When the options are processed, they are divided into two types: {\em
163 % local\/} and {\em global}:
166 % \item For a class, the options in the |\documentclass| command are
169 % \item For a package, the options in the |\usepackage| command are
170 % local, and the options in the |\documentclass| command are global.
173 % The options for |\documentclass| and |\usepackage|
174 % are processed in the following way:
177 % \item The local and global options that have been declared
178 % (using |\DeclareOption| as described below) are processed
181 % In the case of |\ProcessOptions|, they are processed in the order
182 % that they were declared in the class or package.
184 % In the case of |\ProcessOptions*|, they are processed in the order
185 % that they appear in the option-lists. First the global options, and
186 % then the local ones.
188 % \item Any remaining local options are dealt with using the default
189 % option (declared using the |\DeclareOption*| declaration described
190 % below). For document classes, this usually does nothing, but
191 % records the option on a list of unused options.
192 % For packages, this usually produces an error.
195 % Finally, when |\begin{document}| is reached, if there are any global
196 % options which have not been used by either the class or any package,
197 % the system will produce a warning.
200 % \section{Class and Package interface}
202 % \subsection{Class name and version}
204 % \DescribeMacro\ProvidesClass
205 % A class can identify itself with the
206 % |\ProvidesClass{|\meta{name}|}[|\meta{version}|]| command. The
207 % \meta{version} should begin with a date in the format |YYYY/MM/DD|.
209 % \subsection{Package name and version}
211 % \DescribeMacro\ProvidesPackage
212 % A package can identify itself with the
213 % |\ProvidesPackage|\marg{name}\oarg{version} command. The
214 % \meta{version} should begin with a date in the format |YYYY/MM/DD|.
216 % \subsection{Requiring other packages}
218 % \DescribeMacro\RequirePackage
219 % Packages or classes can load other packages using\\
220 % |\RequirePackage|\oarg{options}\marg{name}\oarg{version}.\\
221 % If the package has already been loaded, then nothing happens unless
222 % the requested options are not a subset of the options with which it
223 % was loaded, in which case an error is called.
225 % \DescribeMacro\LoadClass
226 % Similar to |\RequirePackage|, but for classes, may not be used in
229 % \DescribeMacro\PassOptionsToPackage
230 % Packages can pass options to other packages using:\\
231 % |\PassOptionsToPackage{|\meta{options}|}{|\meta{package}|}|.\\
232 % \DescribeMacro\PassOptionsToClass
233 % This adds the \meta{options} to the options list of any future
234 % |\RequirePackage| or |\usepackage| command. For example:
236 % \PassOptionsToPackage{foo,bar}{fred}
237 % \RequirePackage[baz]{fred}\end{verbatim}
240 % \RequirePackage[foo,bar,baz]{fred}\end{verbatim}
242 % \DescribeMacro\LoadClassWithOptions
243 % |\LoadClassWithOptions|\marg{name}\oarg{version}:\\
245 % |\LoadClass|, but it always calls class \meta{name} with
246 % exactly the same option list that is being used by the current class,
247 % rather than an option explicitly supplied or passed on by
248 % |\PassOptionsToClass|.
249 % \DescribeMacro\RequirePackageWithOptions
250 % |\RequirePackageWithOptions| is the analogous command for packages.
252 % This is mainly intended to allow one class to simply build on another,
255 % \LoadClassWithOptions{article}
258 % This should be contrasted with the slightly different construction
260 % \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
262 % \LoadClass{article}
265 % As used here, the effects are more or less the same, but the
266 % version using |\LoadClassWithOptions| is slightly quicker
267 % (and less to type).
268 % If, however, the class declares options of its own then
269 % the two constructions are different; compare, for example:
271 % \DeclareOption{landscape}{...}
273 % \LoadClassWithOptions{article}
277 % \DeclareOption{landscape}{...}
278 % \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
280 % \LoadClass{article}
282 % In the first case, the \textsf{article} class will be called with
283 % option |landscape| precisely when the current class is called with
284 % this option; but in the second example it will
285 % not as in that case \textsf{article} is only passed options by the
286 % default option handler, which is not used for |landscape| as that
287 % option is explicitly declared.
289 % \DescribeMacro\@ifpackageloaded
290 % To find out if a package has already been loaded, use\\
291 % \DescribeMacro\@ifclassloaded
292 % |\@ifpackageloaded{|\meta{package}|}{|\meta{true}|}{|\meta{false}|}|.
294 % \DescribeMacro\@ifpackagelater
295 % \changes{v1.1i}{2013/07/07}{Correctly describe how the date in
296 % \cs{@ifpackagelater} is used}
297 % To find out if a package has already been loaded with a version
299 % recent than \meta{version}, use\\
300 % \DescribeMacro\@ifclasslater
301 % |\@ifpackagelater{|\meta{package}|}{|\meta{version}|}{|^^A
302 % \meta{true}|}{|\meta{false}|}|.
304 % \DescribeMacro\@ifpackagewith
305 % To find out if a package has already been loaded with at least the
306 % options \meta{options}, use
307 % \DescribeMacro\@ifclasswith
308 % |\@ifpackagewith{|\meta{package}|}{|\meta{options}|}{|^^A
309 % \meta{true}|}{|\meta{false}|}|.
311 % There exists one package that can't be tested with the above
312 % commands: the \texttt{fontenc} package pretends that it was never
313 % loaded to allow for repeated reloading with different options (see
314 % \texttt{ltoutenc.dtx} for details).
317 % \subsection{Declaring new options}
319 % Options for classes and packages are built using the same macros.
321 % \DescribeMacro\DeclareOption To define a builtin option, use
322 % |\DeclareOption{|\meta{name}|}{|\meta{code}|}|.
324 % \DescribeMacro{\DeclareOption*} To define the default action to
325 % perform for local options which have not been declared, use
326 % |\DeclareOption*{|\meta{code}|}|.
328 % {\em Note\/}: there should be no use of\\
329 % |\RequirePackage|, |\DeclareOption|, |\DeclareOption*| or
330 % |\ProcessOptions|\\
331 % inside |\DeclareOption| or |\DeclareOption*|.
333 % Possible uses for |\DeclareOption*| include:
335 % |\DeclareOption*{}|\\
336 % Do nothing. Silently accept unknown options. (This suppresses the
339 % |\DeclareOption*{\@unkownoptionerror}|\\
340 % Complain about unknown local options. (The initial setting for
343 % |\DeclareOption*{\PassOptionsToPackage{\CurrentOption}|^^A
344 % |{|\meta{pkg-name}|}|\\
345 % Handle the the current option by passing it on to the package
346 % \meta{pkg-name}, which will presumably be loaded via
347 % |\RequirePackage| later in the file. This is useful for building
348 % `extension' packages, that perhaps handle a couple of new options,
349 % but then pass everything else on to an existing package.
351 % |\DeclareOption*{\InputIfFileExists{xx-\CurrentOption.yyy}%|\\
353 % | {\OptionNotUsed}}|\\
354 % Handle the option foo by loading the file |xx-foo.yyy| if it
355 % exists, otherwise do nothing, but declare that the option was not
357 % Actually the |\OptionNotUsed| declaration is only needed if this is
358 % being used in class files, but does no harm in package files.
361 % \subsection{Safe Input Macros}
362 % \DescribeMacro{\InputIfFileExists}
363 % |\InputIfFileExists{|\meta{file}|}{|\meta{then}|}{|\meta{else}|}|\\
364 % Inputs \meta{file} if it exists. Immediately before the input,
365 % \meta{then} is executed. Otherwise \meta{else} is executed.
367 % \DescribeMacro{\IfFileExists}
368 % As above, but does not input the file.
370 % One thing you might like to put in the \meta{else} clause is
372 % \DescribeMacro{\@missingfileerror}
373 % This starts an interactive request for a filename, supplying default
374 % extensions. Just hitting return causes the whole input to be skipped
375 % and entering |x| quits the current run,
377 % \DescribeMacro{\input}
378 % This has been redefined from the \LaTeX2.09 definition, in terms of
379 % the new commands |\InputIfFileExists| and |\@missingfileerror|.
382 % \DescribeMacro{\listfiles} Giving this declaration in the preamble
383 % causes a list of all files input via the `safe input' commands to be
384 % listed at the end. Any strings specified in the optional argument to
385 % |\ProvidesPackage| are listed alongside the file name. So files in
386 % standard (and other non-standard) distributions can put informative
387 % strings in this argument.
391 % \section{Implementation}
398 % \changes{v0.2g}{1993/11/23}
399 % {Various macros now moved to latex.tex.}
400 % \changes{v0.2g}{1993/11/23}
401 % {Warnings and errors now directly coded.}
402 % \changes{v0.2h}{1993/11/28}
403 % {Primitive filenames now terminated by space not \cs{relax}.}
404 % \changes{v0.2h}{1993/11/28}
405 % {Directory syntax checing moved to dircheck.dtx}
406 % \changes{v0.2h}{1993/11/28}
407 % {Assorted commands now in the kernel removed.}
408 % \changes{v0.2i}{1993/12/03}
409 % {\cs{@onlypreamble}: Many commands declared.}
410 % \changes{v0.2i}{1993/12/03}
411 % {Removed obsolete \cs{@documentclass}}
412 % \changes{v0.2o}{1993/12/13}
413 % {Removed setting \cs{errorcontextlines}\ (now in latex.tex)}
414 % \changes{v0.2p}{1993/12/15}
415 % {Removed extra `.'s from \cs{@@warning}s}
416 % \changes{v0.2s}{1994/01/17}
417 % {Added many more \cs{@onlypreamble} commands}
418 % \changes{v0.2s}{1994/01/17}
419 % {Wrapped long lines to column 72}
420 % \changes{v0.3a}{1994/03/02}
421 % {Remove need for driver file}
422 % \changes{v0.3b}{1994/03/08}
423 % {Modify driver code into `new style'}
424 % \changes{v0.3c}{1994/03/12}
425 % {Change name from docclass to ltclass}
426 % \changes{v0.3h}{1994/04/25}
427 % {Removed spurious extra `.'s at the end of error messages}
428 % \changes{v1.0a}{1994/04/29}
429 % {Change version number to 1 (no other change)}
430 % \changes{v1.0k}{1994/11/03}
431 % {Move \cs{@missingfileerror} to ltfiles}
433 % \begin{macro}{\if@compatibility}
434 % The flag for compatibility mode.
436 \newif\if@compatibility
440 % \begin{macro}{\@documentclasshook}
441 % The hook called after the first |\documentclass| command. By
442 % default this checks to see if |\@normalsize| is undefined, and if
443 % so, sets it to |\normalsize|.
444 % \changes{v0.2q}{1993/12/17}
446 % \changes{v0.2z}{1994/02/10}
447 % {Changed the name from \cs{@compatibility} to
448 % \cs{@documentclasshook}, and added the check for whether
449 % \cs{@normalsize} has been defined. ASAJ.}
451 \def\@documentclasshook{%
452 \ifx\@normalsize\@undefined
453 \let\@normalsize\normalsize
459 % \begin{macro}{\@declaredoptions}
460 % This list is automatically built by |\DeclareOption|.
461 % It is the list of options (separated by commas) declared in
462 % the class or package file and it defines the order in which the
463 % the corresponding |\ds@|\meta{option} commands are executed.
464 % All local \meta{option}s which are not declared will be processed
465 % in the order defined by the optional argument of |\documentclass|
468 \let\@declaredoptions\@empty
472 % \begin{macro}{\@classoptionslist}
473 % List of options of the main class.
474 % \changes{v1.0u}{1996/07/26}{made only preamble}
476 \let\@classoptionslist\relax
477 \@onlypreamble\@classoptionslist
481 % \begin{macro}{\@unusedoptionlist}
482 % \changes{v1.0u}{1996/07/26}{made only preamble}
483 % List of options of the main class that haven't been declared or
484 % loaded as class option files.
486 \let\@unusedoptionlist\@empty
487 \@onlypreamble\@unusedoptionlist
491 % \begin{macro}{\CurrentOption}
492 % Name of current package or option.
493 % \changes{v0.2c}{1993/11/17}
494 % {Name changed from \cs{@curroption}}
496 \let\CurrentOption\@empty
500 % \begin{macro}{\@currname}
501 % Name of current package or option.
503 \let\@currname\@empty
507 % \begin{macro}{\@currext}
508 % The current file extension.
509 % \changes{v0.2a}{1993/11/14}{Name changed from \cs{@currextension}}
511 \global\let\@currext=\@empty
515 % \begin{macro}{\@clsextension}
516 % \begin{macro}{\@pkgextension}
517 % The two possible values of |\@currext|.
519 \def\@clsextension{cls}
520 \def\@pkgextension{sty}
521 \@onlypreamble\@clsextension
522 \@onlypreamble\@pkgextension
527 % \begin{macro}{\@pushfilename}
528 % \begin{macro}{\@popfilename}
529 % \begin{macro}{\@currnamestack}
530 % Commands to push and pop the file name and extension. \\
531 % |#1| current name. \\
532 % |#2| current extension. \\
533 % |#3| current catcode of |@|. \\
534 % |#4| Rest of the stack.
537 \xdef\@currnamestack{%
542 \@onlypreamble\@pushfilename
546 \def\@popfilename{\expandafter\@p@pfilename\@currnamestack\@nil}
547 \@onlypreamble\@popfilename
551 \def\@p@pfilename#1#2#3#4\@nil{%
555 \gdef\@currnamestack{#4}}
556 \@onlypreamble\@p@pfilename
560 \gdef\@currnamestack{}
561 \@onlypreamble\@currnamestack
567 % \begin{macro}{\@ptionlist}
568 % Returns the option list of the file.
571 \@ifundefined{opt@#1}\@empty{\csname opt@#1\endcsname}}
572 \@onlypreamble\@ptionlist
576 % \begin{macro}{\@ifpackageloaded}
577 % \begin{macro}{\@ifclassloaded}
578 % |\@ifpackageloaded{|\meta{name}|}|
579 % Checks to see whether a file has been loaded.
580 % \changes{v0.2t}{1994/01/18}
581 % {Fix typo \cs{@pkgetension}}
583 \def\@ifpackageloaded{\@ifl@aded\@pkgextension}
584 \def\@ifclassloaded{\@ifl@aded\@clsextension}
585 \@onlypreamble\@ifpackageloaded
586 \@onlypreamble\@ifclassloaded
591 \expandafter\ifx\csname ver@#2.#1\endcsname\relax
592 \expandafter\@secondoftwo
594 \expandafter\@firstoftwo
596 \@onlypreamble\@ifl@aded
601 % \begin{macro}{\@ifpackagelater}
602 % \begin{macro}{\@ifclasslater}
603 % |\@ifpackagelater{|\meta{name}|}{YYYY/MM/DD}|
604 % Checks that the package loaded is more recent than the given date.
606 \def\@ifpackagelater{\@ifl@ter\@pkgextension}
607 \def\@ifclasslater{\@ifl@ter\@clsextension}
608 \@onlypreamble\@ifpackagelater
609 \@onlypreamble\@ifclasslater
614 \expandafter\@ifl@t@r
615 \csname ver@#2.#1\endcsname}
616 \@onlypreamble\@ifl@ter
619 % This internal macro is also used in |\NeedsTeXFormat|.
620 % \changes{v0.2f}{1993/11/22}
621 % {Added //00 so parsing never produces a runaway argument.}
624 \ifnum\expandafter\@parse@version#1//00\@nil<%
625 \expandafter\@parse@version#2//00\@nil
626 \expandafter\@secondoftwo
628 \expandafter\@firstoftwo
630 \@onlypreamble\@ifl@t@r
634 \def\@parse@version#1/#2/#3#4#5\@nil{#1#2#3#4 }
635 \@onlypreamble\@parse@version
640 % \begin{macro}{\@ifpackagewith}
641 % \begin{macro}{\@ifclasswith}
642 % |\@ifpackagewith{|\meta{name}|}{|\meta{option-list}|}|
643 % Checks that \meta{option-list} is a subset of the options
644 % \textbf{with} which \meta{name} was loaded.
646 \def\@ifpackagewith{\@if@ptions\@pkgextension}
647 \def\@ifclasswith{\@if@ptions\@clsextension}
648 \@onlypreamble\@ifpackagewith
649 \@onlypreamble\@ifclasswith
653 \def\@if@ptions#1#2{%
654 \@expandtwoargs\@if@pti@ns{\@ptionlist{#2.#1}}}
655 \@onlypreamble\@if@ptions
658 % Probably shouldn't use |\CurrentOption| here\ldots (changed to
660 % \changes{v0.2y}{1994/02/07}
661 % {Add extra ,s so `two' is not matched with `twocolumn'}
662 % \changes{v1.1i}{2011/08/19}
663 % {Re-jig definition after more stringent \cs{in@} test.}
665 \def\@if@pti@ns#1#2{%
666 \let\reserved@a\@firstoftwo
667 \@for\reserved@b:=#2\do{%
668 \ifx\reserved@b\@empty
670 \expandafter\in@\expandafter{\expandafter,\reserved@b,}{,#1,}%
673 \let\reserved@a\@secondoftwo
678 \@onlypreamble\@if@pti@ns
683 % \begin{macro}{\ProvidesPackage}
684 % Checks that the current filename is correct, and defines
686 % \changes{v0.3c}{1994/03/12}
688 % \changes{v0.3c}{1994/03/12}
691 \def\ProvidesPackage#1{%
693 \ifx\@gtempa\@currname\else
694 \@latex@warning@no@line{You have requested
695 \@cls@pkg\space`\@currname',\MessageBreak
696 but the \@cls@pkg\space provides `#1'}%
698 \@ifnextchar[\@pr@videpackage{\@pr@videpackage[]}}%]
699 \@onlypreamble\ProvidesPackage
703 \def\@pr@videpackage[#1]{%
704 \expandafter\xdef\csname ver@\@currname.\@currext\endcsname{#1}%
705 \ifx\@currext\@clsextension
706 \typeout{Document Class: \@gtempa\space#1}%
708 \wlog{Package: \@gtempa\space#1}%
710 \@onlypreamble\@pr@videpackage
714 % \begin{macro}{\ProvidesClass}
715 % Like |\ProvidesPackage|, but for classes.
717 \let\ProvidesClass\ProvidesPackage
718 \@onlypreamble\ProvidesClass
722 % \begin{macro}{\ProvidesFile}
723 % Like |\ProvidesPackage|, but for arbitrary files. Do not apply
724 % |\@onlypreamble| to these, as we may want to label files input
725 % during the document.
726 % \changes{v0.2l}{1993/12/07}
728 % \changes{v0.3c}{1994/03/12}
730 % \changes{v0.3g}{1994/04/11}
731 % {Protect against weird catcodes.}
732 % \begin{macro}{\@providesfile}
733 % \changes{v1.0r}{1995/10/17}
734 % {Delay definition of \cs{ProvidesFile} till ltfinal}
735 % \changes{v1.1a}{1998/03/21}
736 % {Allow \&. Internal/2702}
737 % \changes{v1.1d}{2001/05/25}{Explicitly set catcode of
738 % \cs{endlinechar} to 10 (pr/3334)}
739 % \changes{v1.1e}{2001/06/04}{But only if it is a char (pr/3334)}
740 % \changes{v1.1f}{2001/08/26}{Readded setting of space char (pr/3353)}
742 \def\ProvidesFile#1{%
745 \ifnum \endlinechar<256 %
746 \ifnum \endlinechar>\m@ne
747 \catcode\endlinechar 10 %
753 % \changes{v1.1g}{2004/01/28}{Use kernel version of
754 % \cs{@ifnextchar} (pr/3501)}
756 \kernel@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}}
759 % During initex a special version of |\@providesfile| is used.
760 % The real definition is installed right at the end, in |ltfinal.dtx|.
762 %\def\@providesfile#1[#2]{%
763 % \wlog{File: #1 #2}%
764 % \expandafter\xdef\csname ver@#1\endcsname{#2}%
771 % \begin{macro}{\PassOptionsToPackage}
772 % \begin{macro}{\PassOptionsToClass}
773 % If the package has been loaded, we check that it was first loaded with
774 % the options. Otherwise we add the option list to that of the package.
776 \def\@pass@ptions#1#2#3{%
777 \expandafter\xdef\csname opt@#3.#1\endcsname{%
778 \@ifundefined{opt@#3.#1}\@empty
779 {\csname opt@#3.#1\endcsname,}%
780 \zap@space#2 \@empty}}
781 \@onlypreamble\@pass@ptions
785 \def\PassOptionsToPackage{\@pass@ptions\@pkgextension}
786 \def\PassOptionsToClass{\@pass@ptions\@clsextension}
787 \@onlypreamble\PassOptionsToPackage
788 \@onlypreamble\PassOptionsToClass
793 % \begin{macro}{\DeclareOption}
794 % \begin{macro}{\DeclareOption*}
795 % Adds an option as a |\ds@| command, or the default |\default@ds|
797 % \changes{v0.2c}{1993/11/17}
798 % {Error checking added}
799 % \changes{v1.0m}{1995/04/21}
801 % \changes{v1.0n}{1995/05/12}
802 % {Use \cs{toks@} to remove need to double hash /1557}
805 \let\@fileswith@pti@ns\@badrequireerror
806 \@ifstar\@defdefault@ds\@declareoption}
807 \long\def\@declareoption#1#2{%
808 \xdef\@declaredoptions{\@declaredoptions,#1}%
810 \expandafter\edef\csname ds@#1\endcsname{\the\toks@}}
811 \long\def\@defdefault@ds#1{%
813 \edef\default@ds{\the\toks@}}
814 \@onlypreamble\DeclareOption
815 \@onlypreamble\@declareoption
816 \@onlypreamble\@defdefault@ds
821 % \begin{macro}{\OptionNotUsed}
822 % If we are in a class file, add |\CurrentOption| to the list of
823 % unused options. Otherwise, in a package file do nothing.
826 \ifx\@currext\@clsextension
827 \xdef\@unusedoptionlist{%
828 \ifx\@unusedoptionlist\@empty\else\@unusedoptionlist,\fi
831 \@onlypreamble\OptionNotUsed
835 % \begin{macro}{\default@ds}
836 % The default default option code.
837 % Set by |\@onefilewithoptions| to either |\OptionNotUsed| for
838 % classes, or |\@unknownoptionerror| for packages. This may be reset
839 % in either case with |\DeclareOption*|.
841 % \let\default@ds\OptionNotUsed
845 % \begin{macro}{\ProcessOptions}
846 % \begin{macro}{\ProcessOptions*}
847 % |\ProcessOptions| calls |\ds@option| for each known package option,
848 % then calls |\default@ds| for each option on the local options list.
849 % Finally resets all the declared options to |\relax|. The empty option
850 % does nothing, this has to be reset on the off chance it's set to
851 % |\relax| if an empty element gets into the |\@declaredoptions| list.
853 % The star form is similar but executes options given in the order
854 % specified in the document, not the order they are declared in the
855 % file. In the case of packages, global options are executed before
857 % \changes{v0.2a}{1993/11/14}
858 % {Stop adding the global option list inside class files.}
859 % \changes{v0.2a}{1993/11/14}
860 % {Optimise `empty option' code.}
861 % \changes{v0.2b}{1993/11/15}
863 % \changes{v0.2c}{1993/11/17}
864 % {restoring \cs{@fileswith@pti@ns} added.}
866 \def\ProcessOptions{%
868 \edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
869 \@ifstar\@xprocess@ptions\@process@ptions}
870 \@onlypreamble\ProcessOptions
873 % \changes{v0.2y}{1994/02/07}
874 % {Add extra ,s so `two' is not matched with `twocolumn'}
876 \def\@process@ptions{%
877 \@for\CurrentOption:=\@declaredoptions\do{%
878 \ifx\CurrentOption\@empty\else
879 \@expandtwoargs\in@{,\CurrentOption,}{%
880 ,\ifx\@currext\@clsextension\else\@classoptionslist,\fi
884 \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
888 \@onlypreamble\@process@ptions
891 % \changes{v0.2y}{1994/02/07}
892 % {Add extra ,s so `two' is not matched with `twocolumn'}
894 \def\@xprocess@ptions{%
895 \ifx\@currext\@clsextension\else
896 \@for\CurrentOption:=\@classoptionslist\do{%
897 \ifx\CurrentOption\@empty\else
898 \@expandtwoargs\in@{,\CurrentOption,}{,\@declaredoptions,}%
901 \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
906 \@onlypreamble\@xprocess@ptions
909 % The common part of |\ProcessOptions| and |\ProcessOptions*|.
911 \def\@process@pti@ns{%
912 \@for\CurrentOption:=\@curroptions\do{%
913 \@ifundefined{ds@\CurrentOption}%
917 % There should not be any non-empty definition of |\CurrentOption| at
918 % this point, as all the declared options were executed earlier. This is
919 % for compatibility with 2.09 styles which use |\def\ds@|\ldots\
920 % directly, and so have options which do not appear in
921 % |\@declaredoptions|.
925 % Clear all the definitions for option code. First set all the declared
926 % options to |\relax|, then reset the `default' and `empty' options. and
927 % the lst of declared options.
929 \@for\CurrentOption:=\@declaredoptions\do{%
930 \expandafter\let\csname ds@\CurrentOption\endcsname\relax}%
932 % \changes{v1.0r}{1995/10/17}
933 % {Reset \cs{CurrentOption} for graphics/1873}
935 \let\CurrentOption\@empty
936 \let\@fileswith@pti@ns\@@fileswith@pti@ns
937 \AtEndOfPackage{\let\@unprocessedoptions\relax}}
938 \@onlypreamble\@process@pti@ns
943 % \begin{macro}{\@options}
944 % |\@options| is a synonym for |\ProcessOptions*| for upward
945 % compatibility with \LaTeX2.09 style files.
947 \def\@options{\ProcessOptions*}
948 \@onlypreamble\@options
952 % \begin{macro}{\@use@ption}
953 % Execute the code for the current option.
954 % \changes{v0.2g}{1993/11/23}
955 % {Name changed from \cs{@executeoption}}
956 % \changes{v1.0e}{1994/05/17}
957 % {Execute option after removing from list, not before}
960 \@expandtwoargs\@removeelement\CurrentOption
961 \@unusedoptionlist\@unusedoptionlist
962 \csname ds@\CurrentOption\endcsname}
963 \@onlypreamble\@use@ption
967 % \begin{macro}{\ExecuteOptions}
968 % |\ExecuteOptions{|\meta{option-list}|}| executes the code declared
970 % \changes{v0.2d}{1993/11/18}
971 % {Use \cs{CurrentOption} not \cs{reserved@a}}
972 % \changes{v0.2k}{1993/12/06}
973 % {Preserve \cs{CurrentOption}.}
975 \def\ExecuteOptions#1{%
976 \def\reserved@a##1\@nil{%
977 \@for\CurrentOption:=#1\do{\csname ds@\CurrentOption\endcsname}%
978 \edef\CurrentOption{##1}}%
979 \expandafter\reserved@a\CurrentOption\@nil}
980 \@onlypreamble\ExecuteOptions
984 % The top-level commands, which just set some parameters then call
985 % the internal command, |\@fileswithoptions|.
986 % \begin{macro}{\documentclass}
987 % \changes{v1.0q}{1995/06/19}
988 % {Dont redefine \cs{usepackage} in compat mode for /1634}
989 % The main new-style class declaration.
992 \let\documentclass\@twoclasseserror
993 \if@compatibility\else\let\usepackage\RequirePackage\fi
994 \@fileswithoptions\@clsextension}
995 \@onlypreamble\documentclass
999 % \begin{macro}{\documentstyle}
1000 % 2.09 style class `style' declaration.
1001 % \changes{v0.2a}{1993/11/14}
1002 % {Added \cs{RequirePackage} \cs{@unusedoptionlist} stuff.}
1003 % \changes{v0.2b}{1993/11/15}
1004 % {Modified to match \cs{ProcessOption*}}
1005 % \changes{v0.2d}{1993/11/18}
1006 % {Modified \cs{RequirePackage} stuff.}
1007 % \changes{v0.2n}{1993/12/09}
1008 % {input 209 compatibility file.}
1009 % \changes{v0.2o}{1993/12/13}
1010 % {compatibility file now latex209.sty.}
1011 % \changes{v0.2q}{1993/12/17}
1012 % {Match Alan's new code.}
1013 % \changes{v0.2u}{1994/01/21}
1014 % {compatibility file now latex209.def.}
1016 \def\documentstyle{%
1017 \makeatletter\input{latex209.def}\makeatother
1019 \@onlypreamble\documentstyle
1023 % \begin{macro}{\RequirePackage}
1024 % Load package if not already loaded.
1026 \def\RequirePackage{%
1027 \@fileswithoptions\@pkgextension}
1028 \@onlypreamble\RequirePackage
1032 % \begin{macro}{\LoadClass}
1036 \ifx\@currext\@pkgextension
1038 {\noexpand\LoadClass in package file}%
1039 {You may only use \noexpand\LoadClass in a class file.}%
1041 \@fileswithoptions\@clsextension}
1042 \@onlypreamble\LoadClass
1046 % \begin{macro}{\@loadwithoptions}
1047 % \changes{v1.0t}{1995/11/14}{macro added}
1048 % Pass the current option list on to a class or package.
1049 % |#1| is |\@|\emph{cls-or-pkg}|extension|,
1050 % |#2| is |\RequirePackage| or |\LoadClass|,
1051 % |#3| is the class or package to be loaded.
1053 \def\@loadwithoptions#1#2#3{%
1054 \expandafter\let\csname opt@#3.#1\expandafter\endcsname
1055 \csname opt@\@currname.\@currext\endcsname
1057 \@onlypreamble\@loadwithoptions
1062 % \begin{macro}{\LoadClassWithOptions}
1063 % \changes{v1.0t}{1995/11/14}{macro added}
1064 % Load class `|#1|' with the current option list.
1066 \def\LoadClassWithOptions{%
1067 \@loadwithoptions\@clsextension\LoadClass}
1068 \@onlypreamble\LoadClassWithOptions
1072 % \begin{macro}{\RequirePackageWithOptions}
1073 % \changes{v1.0t}{1995/11/14}{macro added}
1074 % \changes{v1.0v}{1996/10/04}{Reset \cs{@unprocessedoptions} for /2269}
1075 % Load package `|#1|' with the current option list.
1077 \def\RequirePackageWithOptions{%
1078 \AtEndOfPackage{\let\@unprocessedoptions\relax}%
1079 \@loadwithoptions\@pkgextension\RequirePackage}
1080 \@onlypreamble\RequirePackageWithOptions
1084 % \begin{macro}{\usepackage}
1085 % To begin with, |\usepackage| produces an error. This is reset by
1087 % \changes{v0.2o}{1993/12/13}
1088 % {Fixed error handling}
1089 % \changes{v1.0h}{1994/05/23}{Remove argument if possible}
1091 \def\usepackage#1#{%
1093 {\noexpand \usepackage before \string\documentclass}%
1094 {\noexpand \usepackage may only appear in the document
1095 preamble, i.e.,\MessageBreak
1096 between \noexpand\documentclass and
1097 \string\begin{document}.}%
1099 \@onlypreamble\usepackage
1103 % \begin{macro}{\NeedsTeXFormat}
1104 % Check that the document is running on the correct system.
1105 % \changes{v0.2a}{1993/11/14}
1106 % {made more robust for alternative syntax for other formats.}
1107 % \changes{v0.2c}{1993/11/17}
1108 % {Name changed from \cs{NeedsFormat}}
1109 % \changes{v0.2d}{1993/11/18}
1110 % {\cs{fmtname} \cs{fmtversion} not \cs{@}\ldots}
1112 \def\NeedsTeXFormat#1{%
1113 \def\reserved@a{#1}%
1114 \ifx\reserved@a\fmtname
1115 \expandafter\@needsformat
1117 \@latex@error{This file needs format `\reserved@a'%
1118 \MessageBreak but this is `\fmtname'}{%
1119 The current input file will not be processed
1120 further,\MessageBreak
1121 because it was written for some other flavor of
1122 TeX.\MessageBreak\@ehd}%
1124 % If the file is not meant to be processed by \LaTeXe{} we stop
1125 % inputting it, but we do not end the run. We just end inputting
1127 % \changes{v1.0h}{1994/05/23}
1128 % {Don't stop completely when format is wrong}
1131 \@onlypreamble\NeedsTeXFormat
1139 \@onlypreamble\@needsformat
1142 % \changes{v1.0b}{1994/05/04}
1143 % {Changed wording of the warning}
1145 \def\@needsf@rmat[#1]{%
1146 \@ifl@t@r\fmtversion{#1}{}%
1147 {\@latex@warning@no@line
1148 {You have requested release `#1' of LaTeX,\MessageBreak
1149 but only release `\fmtversion' is available}}}
1150 \@onlypreamble\@needsf@rmat
1154 % \begin{macro}{\zap@space}
1155 % |\zap@space foo|\meta{space}|\@empty| removes all spaces from |foo|
1156 % that are not protected by |{ }| groups.
1158 \def\zap@space#1 #2{%
1160 \ifx#2\@empty\else\expandafter\zap@space\fi
1165 % \begin{macro}{\@fileswithoptions}
1166 % The common part of |\documentclass| and |\usepackage|.
1168 \def\@fileswithoptions#1{%
1170 {\@fileswith@ptions#1}%
1171 {\@fileswith@ptions#1[]}}
1172 \@onlypreamble\@fileswithoptions
1175 % \changes{v0.2f}{1993/11/22}
1176 % {Made the default [] not [\cs{@unknownversion}]}
1177 % \changes{v1.1h}{2007/08/05}
1178 % {Prevent loss of brackets PR/3965}
1180 \def\@fileswith@ptions#1[#2]#3{%
1182 {\@fileswith@pti@ns#1[{#2}]#3}%
1183 {\@fileswith@pti@ns#1[{#2}]#3[]}}
1184 \@onlypreamble\@fileswith@ptions
1186 % Then we do some work.
1188 % First of all, we define the global variables.
1189 % Then we look to see if the file has already been loaded.
1190 % If it has, we check that it was first loaded with at least the current
1192 % If it has not, we add the current options to the package options,
1193 % set the default version to be |0000/00/00|, and load the file if we
1195 % Then we check the version number.
1197 % Finally, we restore the old file name, reset the default option,
1198 % and we set the catcode of |@|.
1200 % For classes, we can immediately process the file. For other types,
1201 % |#2| could be a comma separated list, so loop through, processing
1202 % each one separately.
1203 % \changes{v0.2q}{1993/12/17}
1204 % {Add \cs{@compatibility} hook}
1205 % \changes{v0.2s}{1994/01/17}
1206 % {Modify to reduce parameter stack usage}
1207 % \changes{v0.2y}{1994/02/07}
1208 % {Run \cs{@compatibility} on the first class to start
1209 % (not the first to finish) }
1210 % \changes{v0.2z}{1994/02/10}
1211 % {Renamed \cs{@compatibility} to \cs{@documentclasshook}.
1213 % \changes{v1.1h}{2007/08/05}
1214 % {Prevent loss of brackets PR/3965}
1216 \def\@fileswith@pti@ns#1[#2]#3[#4]{%
1217 \ifx#1\@clsextension
1218 \ifx\@classoptionslist\relax
1219 \xdef\@classoptionslist{\zap@space#2 \@empty}%
1221 \@onefilewithoptions#3[{#2}][{#4}]#1%
1222 \@documentclasshook}%
1225 \@onefilewithoptions#3[{#2}][{#4}]#1}%
1229 % build up a list of calls to |\@onefilewithoptions|
1230 % (one for each package) without thrashing the parameter stack.
1232 \def\reserved@b##1,{%
1233 \ifx\@nil##1\relax\else
1234 \ifx\relax##1\relax\else
1235 \noexpand\@onefilewithoptions##1[{#2}][{#4}]%
1236 \noexpand\@pkgextension
1238 \expandafter\reserved@b
1240 \edef\reserved@a{\zap@space#3 \@empty}%
1241 \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nil,}%
1244 \@onlypreamble\@fileswith@pti@ns
1247 % Have the main argument as |#1|, so we only need one |\expandafter|
1249 % \changes{v0.2a}{1993/11/14}
1250 % {Moved resetting of \cs{default@ds}, \cs{ds@} and
1251 % \cs{@declaredoptions} here, from the end of
1252 % \cs{ProcessOptions}.}
1253 % \changes{v0.2f}{1993/11/22}
1254 % {Made the initial version [] not [\cs{@unknownversion}]}
1255 % \changes{v0.2m}{1993/12/07}
1256 % {Reset \cs{CurrentOption}}
1258 \def\@onefilewithoptions#1[#2][#3]#4{%
1260 \xdef\@currname{#1}%
1261 \global\let\@currext#4%
1262 \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty
1263 \let\CurrentOption\@empty
1267 % Grab everything in a macro, so the parameter stack is popped before
1268 % any processing begins.
1269 % \changes{v0.2s}{1994/01/17}
1270 % {Modify to reduce parameter stack usage}
1271 % \changes{v1.1b}{1998/05/07}
1272 % {Modify help message for latex/2805}
1275 \@ifl@aded\@currext{#1}%
1276 {\@if@ptions\@currext{#1}{#2}{}%
1278 {Option clash for \@cls@pkg\space #1}%
1279 {The package #1 has already been loaded
1280 with options:\MessageBreak
1281 \space\space[\@ptionlist{#1.\@currext}]\MessageBreak
1282 There has now been an attempt to load it
1283 with options\MessageBreak
1284 \space\space[#2]\MessageBreak
1285 Adding the global options:\MessageBreak
1287 \@ptionlist{#1.\@currext},#2\MessageBreak
1288 to your \noexpand\documentclass declaration may fix this.%
1290 Try typing \space <return> \space to proceed.}}}%
1291 {\@pass@ptions\@currext{#2}{#1}%
1293 % \changes{v0.3c}{1994/03/12}
1294 % {Do not use \cs{@pr@videpackage} to avoid typeout}
1297 \let\csname ver@\@currname.\@currext\endcsname\@empty
1299 {\@currname.\@currext}%
1301 {\@missingfileerror\@currname\@currext}%
1303 % |\@unprocessedoptions| will generate an error for each specified
1304 % option in a package unless a |\ProcessOptions| has appeared in the
1306 % \changes{v0.2v}{1994/01/29}
1307 % {All options raise error if no \cs{ProcessOptions} appears}
1308 % \changes{v0.2x}{1994/02/02}
1309 % {Only run the hook and options check if the file was loaded.}
1311 \let\@unprocessedoptions\@@unprocessedoptions
1312 \csname\@currname.\@currext-h@@k\endcsname
1313 \expandafter\let\csname\@currname.\@currext-h@@k\endcsname
1315 \@unprocessedoptions}
1319 \@ifl@ter\@currext{#1}{#3}{}%
1320 {\@latex@warning@no@line
1321 {You have requested,\on@line,
1322 version\MessageBreak
1323 `#3' of \@cls@pkg\space #1,\MessageBreak
1324 but only version\MessageBreak
1325 `\csname ver@#1.\@currext\endcsname'\MessageBreak
1328 % \changes{v0.2c}{1993/11/17}
1329 % {Added trap for two \cs{LoadClass} commands.}
1331 \ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi
1335 \@onlypreamble\@onefilewithoptions
1339 % \begin{macro}{\@@fileswith@pti@ns}
1340 % Save the definition (for error checking).
1341 % \changes{v0.2c}{1993/11/17}
1344 \let\@@fileswith@pti@ns\@fileswith@pti@ns
1345 \@onlypreamble\@@fileswith@pti@ns
1349 % \begin{macro}{\@reset@ptions}
1350 % Reset the default option, and clear lists of declared options.
1351 % \changes{v0.2a}{1993/11/14}{macro added}
1353 \def\@reset@ptions{%
1354 \global\ifx\@currext\@clsextension
1355 \let\default@ds\OptionNotUsed
1357 \let\default@ds\@unknownoptionerror
1359 \global\let\ds@\@empty
1360 \global\let\@declaredoptions\@empty}
1361 \@onlypreamble\@reset@ptions
1365 % \subsection{Hooks}
1367 % Allow code do be saved to be executed at specific later times.
1369 % Save things in macros, I considered using toks registers, (and
1370 % |\addto@hook| from the NFSS code, that would require stacking the
1371 % contents in the case of required packages, so just generate a new
1372 % macro for each package.
1373 % \begin{macro}{\@begindocumenthook}
1374 % \changes{v1.0s}{1995/10/20}
1375 % {Make setting conditional, for autoload version}
1376 % \begin{macro}{\@enddocumenthook}
1377 % Stuff to appear at the beginning or end of the document.
1379 \ifx\@begindocumenthook\@undefined
1380 \let\@begindocumenthook\@empty
1382 \let\@enddocumenthook\@empty
1387 % \begin{macro}{\g@addto@macro}
1388 % Globally add to the end of a macro.
1389 % \changes{v0.2a}{1993/11/14}{Made global}
1390 % \changes{v0.2w}{1994/01/31}
1391 % {Use toks register to avoid `hash' problems}
1392 % \changes{v1.0o}{1995/05/17}
1393 % {Make long for latex/1522}
1394 % \changes{v1.0w}{1996/12/17}
1395 % {Use \cs{begingroup} to save making a mathord}
1396 % \changes{v1.0x}{1997/02/05}
1397 % {missing percent /2402}
1399 \long\def\g@addto@macro#1#2{%
1401 \toks@\expandafter{#1#2}%
1402 \xdef#1{\the\toks@}%
1407 % \begin{macro}{\AtEndOfPackage}
1408 % \begin{macro}{\AtEndOfClass}
1409 % \begin{macro}{\AtBeginDocument}
1410 % \begin{macro}{\AtEndDocument}
1411 % The access functions.
1412 % \changes{v0.2a}{1993/11/14}
1413 % {Included extension in the generated macro name for package
1416 \def\AtEndOfPackage{%
1417 \expandafter\g@addto@macro\csname\@currname.\@currext-h@@k\endcsname}
1418 \let\AtEndOfClass\AtEndOfPackage
1419 \@onlypreamble\AtEndOfPackage
1420 \@onlypreamble\AtEndOfClass
1424 \def\AtBeginDocument{\g@addto@macro\@begindocumenthook}
1425 \def\AtEndDocument{\g@addto@macro\@enddocumenthook}
1426 \@onlypreamble\AtBeginDocument
1434 % \begin{macro}{\@cls@pkg}
1435 % The current file type.
1436 % \changes{v0.2i}{1993/12/03}
1437 % {Name changed to avoid clash with output routine.}
1440 \ifx\@currext\@clsextension
1445 \@onlypreamble\@cls@pkg
1449 % \begin{macro}{\@unknownoptionerror}
1452 \def\@unknownoptionerror{%
1454 {Unknown option `\CurrentOption' for \@cls@pkg\space`\@currname'}%
1455 {The option `\CurrentOption' was not declared in
1456 \@cls@pkg\space`\@currname', perhaps you\MessageBreak
1457 misspelled its name.
1458 Try typing \space <return>
1459 \space to proceed.}}
1460 \@onlypreamble\@unknownoptionerror
1464 % \begin{macro}{\@@unprocessedoptions}
1465 % Declare an error for each option, unless a |\ProcessOptions| occurred.
1466 % \changes{v0.2v}{1994/01/29}
1468 % \changes{v1.0t}{1995/11/14}{Allow empty option}
1470 \def\@@unprocessedoptions{%
1471 \ifx\@currext\@pkgextension
1472 \edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
1473 \@for\CurrentOption:=\@curroptions\do{%
1474 \ifx\CurrentOption\@empty\else\@unknownoptionerror\fi}%
1476 \@onlypreamble\@unprocessedoptions
1477 \@onlypreamble\@@unprocessedoptions
1481 % \begin{macro}{\@badrequireerror}
1482 % |\RequirePackage| or |\LoadClass| occurs in the options section.
1483 % \changes{v0.2c}{1993/11/17}
1486 \def\@badrequireerror#1[#2]#3[#4]{%
1488 {\noexpand\RequirePackage or \noexpand\LoadClass
1489 in Options Section}%
1490 {The \@cls@pkg\space `\@currname' is defective.\MessageBreak
1491 It attempts to load `#3' in the options section, i.e.,\MessageBreak
1492 between \noexpand\DeclareOption and \string\ProcessOptions.}}
1493 \@onlypreamble\@badrequireerror
1497 % \begin{macro}{\@twoloadclasserror}
1498 % Two |\LoadClass| in a class.
1499 % \changes{v0.2c}{1993/11/17}
1502 \def\@twoloadclasserror{%
1504 {Two \noexpand\LoadClass commands}%
1505 {You may only use one \noexpand\LoadClass in a class file}}
1506 \@onlypreamble\@twoloadclasserror
1510 % \begin{macro}{\@twoclasseserror}
1511 % Two |\documentclass| or |\documentstyle|.
1512 % \changes{v0.2h}{1993/11/28}
1515 \def\@twoclasseserror#1#{%
1517 {Two \noexpand\documentclass or \noexpand\documentstyle commands}%
1518 {The document may only declare one class.}\@gobble}
1519 \@onlypreamble\@twoclasseserror
1523 % \subsection{Providing shipment}
1525 % \begin{macro}{\two@digits}
1526 % Prefix a number less than 10 with `0'.
1528 \def\two@digits#1{\ifnum#1<10 0\fi\number#1}
1532 % \begin{macro}{\filecontents}
1533 % \begin{macro}{\endfilecontents}
1534 % This environment implements inline files.
1535 % The star-form does not write extra comments into the file.
1537 % \changes{v0.2h}{1993/11/28}
1538 % {Don't globally allocate a write stream (always use 15)}
1539 % \changes{v0.2r}{1993/12/19}{Different message when ignoring a file}
1540 % \changes{v0.3g}{1994/04/11}
1542 % dont write \cs{endinput} at the end of the file.}
1543 % \changes{v1.0c}{1994/05/11}
1544 % {Add checks for form feed and tab}
1545 % \changes{v1.0m}{1995/04/21}
1546 % {Close input check stream: latex/1487}
1547 % \changes{v1.0p}{1995/05/25}{Delete \cs{filec@ntents} after preamble}
1551 \catcode`\^^M\active%
1552 \catcode`\^^L\active\let^^L\relax%
1553 \catcode`\^^I\active%
1557 \gdef\filecontents{\@tempswatrue\filec@ntents}%
1558 \gdef\filecontents*{\@tempswafalse\filec@ntents}%
1562 \gdef\filec@ntents#1{%
1563 \openin\@inputcheck#1 %
1565 \@latex@warning@no@line%
1566 {Writing file `\@currdir#1'}%
1569 % \changes{v1.0y}{1997/10/10}
1570 % {\cs{reserved@c} not \cs{verbatim@out} to save a csname}
1572 \chardef\reserved@c15 %
1573 \ch@ck7\reserved@c\write%
1574 \immediate\openout\reserved@c#1\relax%
1578 % \changes{v1.0y}{1997/10/10}
1579 % {Use \cs{@gobbletwo}}
1581 \closein\@inputcheck%
1582 \@latex@warning@no@line%
1583 {File `#1' already exists on the system.\MessageBreak%
1584 Not generating it from this source}%
1585 \let\write\@gobbletwo%
1586 \let\closeout\@gobble%
1591 % \changes{v1.0y}{1997/10/10}
1592 % {\cs{@currenvir} in banner}
1594 \immediate\write\reserved@c{%
1595 \@percentchar\@percentchar\space%
1596 \expandafter\@gobble\string\LaTeX2e file `#1'^^J%
1597 \@percentchar\@percentchar\space generated by the %
1598 `\@currenvir' \expandafter\@gobblefour\string\newenvironment^^J%
1599 \@percentchar\@percentchar\space from source `\jobname' on %
1600 \number\year/\two@digits\month/\two@digits\day.^^J%
1601 \@percentchar\@percentchar}%
1603 \let\do\@makeother\dospecials%
1606 % \changes{v1.0y}{1997/10/10}
1607 % {Check for text before or after \cs{end} environment. latex/2636}
1609 \edef\E{\@backslashchar end\string{\@currenvir\string}}%
1611 \def\noexpand\reserved@b%
1612 ####1\E####2\E####3\relax}%
1614 \ifx\relax##3\relax%
1616 % There was no |\end{filecontents}|
1618 \immediate\write\reserved@c{##1}%
1621 % There was a |\end{filecontents}|, so stop this time.
1623 \edef^^M{\noexpand\end{\@currenvir}}%
1624 \ifx\relax##1\relax%
1627 % Text before the |\end|, write it with a warning.
1629 \@latex@warning{Writing text `##1' before %
1630 \string\end{\@currenvir}\MessageBreak as last line of #1}%
1631 \immediate\write\reserved@c{##1}%
1633 \ifx\relax##2\relax%
1636 % Text after the |\end|, ignore it with a warning.
1639 Ignoring text `##2' after \string\end{\@currenvir}}%
1646 \catcode`\^^L\active%
1648 \def^^L{\@ifundefined L^^J^^J^^J}%
1649 \catcode`\^^I\active%
1651 \def^^I{\@ifundefined I\space\space}%
1652 \catcode`\^^M\active%
1654 \noexpand\reserved@b##1\E\E\relax}}%
1660 \catcode`|=\catcode`\%
1663 \gdef\@percentchar{%}
1664 \gdef\endfilecontents{|
1665 \immediate\closeout\reserved@c
1667 \ifx##1\@undefined\else
1668 \@latex@warning@no@line{##2 has been converted to Blank ##3e}|
1670 \T\L{Form Feed}{Lin}|
1672 \immediate\write\@unused{}}
1673 \global\let\endfilecontents*\endfilecontents
1674 \@onlypreamble\filecontents
1675 \@onlypreamble\endfilecontents
1676 \@onlypreamble\filecontents*
1677 \@onlypreamble\endfilecontents*
1679 \@onlypreamble\filec@ntents
1685 % \changes{v0.2f}{1993/11/22}
1686 % {\cs{@unknownversion} removed}
1687 % \changes{v1.0j}{1994/10/18}
1688 % {Move \cs{listfiles} to ltfiles.dtx}
1694 % \section{After Preamble}
1695 % Finally we declare a package that allows all the commands declared
1696 % above to be |\@onlypreamble| to be used after |\begin{document}|.
1697 % \changes{v0.3f}{1994/03/16}
1698 % {Add pkgindoc package}
1699 % \changes{v1.1a}{1998/03/21}
1700 % {Correct to new onlypreamble command list}
1703 \NeedsTeXFormat{LaTeX2e}
1704 \ProvidesPackage{pkgindoc}
1705 [1994/10/20 v1.1 Package Interface in Document (DPC)]
1706 \def\reserved@a#1\do\@classoptionslist#2\do\filec@ntents#3\relax{%
1707 \gdef\@preamblecmds{#1#3}}
1708 \expandafter\reserved@a\@preamblecmds\relax