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 [2016/11/09 v1.2b 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.
59 % \changes{v1.0f}{1994/05/22}{Use new warning and error commands}
60 % \changes{v1.0l}{1994/11/17}{\cs{@tempa} to \cs{reserved@a}}
61 % \changes{v1.0z}{1998/03/21}{Added to documentation of filecontents}
62 % \changes{v1.1c}{1998/08/17}{(RmS) Minor documentation fixes.}
64 % \section{Introduction}
66 % This file implements the following declarations, which replace
67 % |\documentstyle| in \LaTeXe\ documents.
69 % Note that old documents containing |\documentstyle| will be run using
70 % a compatibility option---thus keeping everyone happy, we hope!
72 % The overall idea is that there are two types of `style files':
73 % `class files' which define elements and provide a default formatting
74 % for them; and `packages' which provide extra functionality. One
75 % difference between \LaTeXe\ and \LaTeX2.09 is that \LaTeXe\ packages
76 % may have options. Note that options to classes packages may be
77 % implemented such that they input files, but these file names are not
78 % necessarily directly related to the option name.
80 % \section{User interface}
82 % |\documentclass[|\meta{main-option-list}|]{|^^A
83 % \meta{class}|}[|\meta{version}|]|
85 % There must be exactly one such declaration, and it must come first.
86 % The \meta{main-option-list} is a list of options which can modify the
87 % formatting of elements which are defined in the \meta{class} file
88 % as well as in all following |\usepackage| declarations (see below).
89 % The \meta{version} is a version number, beginning with a date in the
90 % format |YYYY/MM/DD|. If an older version of the class is found, a
95 % |\documentstyle[|\meta{main-option-list}|]{|^^A
96 % \meta{class}|}[|\meta{version}|]|
98 % The |\documentstyle| declaration is kept in order to maintain upward
99 % compatibility with \LaTeX2.09 documents. It is similar to
100 % |\documentclass|, but it causes all options in
101 % \meta{main-option-list} that the \meta{class} does not use to be
102 % passed to |\RequirePackage| after the options have been processed.
103 % This maintains compatibility with the 2.09 behaviour. Also a flag is
104 % set to indicate that the document is to be processed in \LaTeX2.09
105 % compatibility mode. As far as most packages are concerned, this
106 % only affects the warnings and errors \LaTeX\ generates. This flag
107 % does affect the definition of font commands, and |\sloppy|.
111 % |\usepackage[|\meta{package-option-list}|]{|^^A
112 % \meta{package-list}|}[|\meta{version}|]|
114 % There can be any number of these declarations. All packages in
115 % \meta{package-list} are called with the same options.
117 % Each \meta{package} file defines new elements (or modifies those
118 % defined in the \meta{class}), and thus extends the range of documents
119 % which can be processed.
120 % The \meta{package-option-list} is a list of options which can modify
121 % the formatting of elements defined in the \meta{package} file.
122 % The \meta{version} is a version number, beginning with a date in the
123 % format |YYYY/MM/DD|. If an older version of the package is found, a
126 % Each package is loaded only once. If the same package is requested
127 % more than once, nothing happens, unless the package has been requested
128 % with options that were not given the first time it was loaded, in
129 % which case an error is produced.
131 % As well as processing the options given in the
132 % \meta{package-option-list}, each package processes the
133 % \meta{main-option-list}. This means that options that affect all
134 % of the packages can be given globally, rather than repeated for every
137 % Note that class files have the extension |.cls|, packages have the
140 % \DescribeEnv{filecontents}
141 % The environment |filecontents| is intended for passing the contents
142 % of packages, options, or other files along with a document in a
144 % It has one argument, which is the name of the file to create. If that
145 % file already exists (maybe only in the current directory if the OS
146 % supports a notion of a `current directory' or `default directory')
147 % then nothing happens
148 % (except for an information message) and the body of the environment
149 % is bypassed. Otherwise, the body of the environment is written
150 % verbatim to the file name given as the first argument, together with
151 % some comments about how it was produced.
153 % The environment is allowed only before |\documentclass| to ensure
154 % that all packages or options necessary for this particular run are
155 % present when needed. The begin and end tags should each be on a
156 % line by itself. There is also a star-form; this does not write
157 % extra comments into the file.
159 % \subsection{Option processing}
161 % When the options are processed, they are divided into two types: {\em
162 % local\/} and {\em global}:
165 % \item For a class, the options in the |\documentclass| command are
168 % \item For a package, the options in the |\usepackage| command are
169 % local, and the options in the |\documentclass| command are global.
172 % The options for |\documentclass| and |\usepackage|
173 % are processed in the following way:
176 % \item The local and global options that have been declared
177 % (using |\DeclareOption| as described below) are processed
180 % In the case of |\ProcessOptions|, they are processed in the order
181 % that they were declared in the class or package.
183 % In the case of |\ProcessOptions*|, they are processed in the order
184 % that they appear in the option-lists. First the global options, and
185 % then the local ones.
187 % \item Any remaining local options are dealt with using the default
188 % option (declared using the |\DeclareOption*| declaration described
189 % below). For document classes, this usually does nothing, but
190 % records the option on a list of unused options.
191 % For packages, this usually produces an error.
194 % Finally, when |\begin{document}| is reached, if there are any global
195 % options which have not been used by either the class or any package,
196 % the system will produce a warning.
199 % \section{Class and Package interface}
201 % \subsection{Class name and version}
203 % \DescribeMacro\ProvidesClass
204 % A class can identify itself with the
205 % |\ProvidesClass{|\meta{name}|}[|\meta{version}|]| command. The
206 % \meta{version} should begin with a date in the format |YYYY/MM/DD|.
208 % \subsection{Package name and version}
210 % \DescribeMacro\ProvidesPackage
211 % A package can identify itself with the
212 % |\ProvidesPackage|\marg{name}\oarg{version} command. The
213 % \meta{version} should begin with a date in the format |YYYY/MM/DD|.
215 % \subsection{Requiring other packages}
217 % \DescribeMacro\RequirePackage
218 % Packages or classes can load other packages using\\
219 % |\RequirePackage|\oarg{options}\marg{name}\oarg{version}.\\
220 % If the package has already been loaded, then nothing happens unless
221 % the requested options are not a subset of the options with which it
222 % was loaded, in which case an error is called.
224 % \DescribeMacro\LoadClass
225 % Similar to |\RequirePackage|, but for classes, may not be used in
228 % \DescribeMacro\PassOptionsToPackage
229 % Packages can pass options to other packages using:\\
230 % |\PassOptionsToPackage{|\meta{options}|}{|\meta{package}|}|.\\
231 % \DescribeMacro\PassOptionsToClass
232 % This adds the \meta{options} to the options list of any future
233 % |\RequirePackage| or |\usepackage| command. For example:
235 % \PassOptionsToPackage{foo,bar}{fred}
236 % \RequirePackage[baz]{fred}\end{verbatim}
239 % \RequirePackage[foo,bar,baz]{fred}\end{verbatim}
241 % \DescribeMacro\LoadClassWithOptions
242 % |\LoadClassWithOptions|\marg{name}\oarg{version}:\\
244 % |\LoadClass|, but it always calls class \meta{name} with
245 % exactly the same option list that is being used by the current class,
246 % rather than an option explicitly supplied or passed on by
247 % |\PassOptionsToClass|.
248 % \DescribeMacro\RequirePackageWithOptions
249 % |\RequirePackageWithOptions| is the analogous command for packages.
251 % This is mainly intended to allow one class to simply build on another,
254 % \LoadClassWithOptions{article}
257 % This should be contrasted with the slightly different construction
259 % \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
261 % \LoadClass{article}
264 % As used here, the effects are more or less the same, but the
265 % version using |\LoadClassWithOptions| is slightly quicker
266 % (and less to type).
267 % If, however, the class declares options of its own then
268 % the two constructions are different; compare, for example:
270 % \DeclareOption{landscape}{...}
272 % \LoadClassWithOptions{article}
276 % \DeclareOption{landscape}{...}
277 % \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
279 % \LoadClass{article}
281 % In the first case, the \textsf{article} class will be called with
282 % option |landscape| precisely when the current class is called with
283 % this option; but in the second example it will
284 % not as in that case \textsf{article} is only passed options by the
285 % default option handler, which is not used for |landscape| as that
286 % option is explicitly declared.
288 % \DescribeMacro\@ifpackageloaded
289 % To find out if a package has already been loaded, use\\
290 % \DescribeMacro\@ifclassloaded
291 % |\@ifpackageloaded{|\meta{package}|}{|\meta{true}|}{|\meta{false}|}|.
293 % \DescribeMacro\@ifpackagelater
294 % \changes{v1.1i}{2013/07/07}{Correctly describe how the date in
295 % \cs{@ifpackagelater} is used}
296 % To find out if a package has already been loaded with a version
298 % recent than \meta{version}, use\\
299 % \DescribeMacro\@ifclasslater
300 % |\@ifpackagelater{|\meta{package}|}{|\meta{version}|}{|^^A
301 % \meta{true}|}{|\meta{false}|}|.
303 % \DescribeMacro\@ifpackagewith
304 % To find out if a package has already been loaded with at least the
305 % options \meta{options}, use
306 % \DescribeMacro\@ifclasswith
307 % |\@ifpackagewith{|\meta{package}|}{|\meta{options}|}{|^^A
308 % \meta{true}|}{|\meta{false}|}|.
310 % There exists one package that can't be tested with the above
311 % commands: the \texttt{fontenc} package pretends that it was never
312 % loaded to allow for repeated reloading with different options (see
313 % \texttt{ltoutenc.dtx} for details).
316 % \subsection{Declaring new options}
318 % Options for classes and packages are built using the same macros.
320 % \DescribeMacro\DeclareOption To define a builtin option, use
321 % |\DeclareOption{|\meta{name}|}{|\meta{code}|}|.
323 % \DescribeMacro{\DeclareOption*} To define the default action to
324 % perform for local options which have not been declared, use
325 % |\DeclareOption*{|\meta{code}|}|.
327 % {\em Note\/}: there should be no use of\\
328 % |\RequirePackage|, |\DeclareOption|, |\DeclareOption*| or
329 % |\ProcessOptions|\\
330 % inside |\DeclareOption| or |\DeclareOption*|.
332 % Possible uses for |\DeclareOption*| include:
334 % |\DeclareOption*{}|\\
335 % Do nothing. Silently accept unknown options. (This suppresses the
338 % |\DeclareOption*{\@unkownoptionerror}|\\
339 % Complain about unknown local options. (The initial setting for
342 % |\DeclareOption*{\PassOptionsToPackage{\CurrentOption}|^^A
343 % |{|\meta{pkg-name}|}|\\
344 % Handle the the current option by passing it on to the package
345 % \meta{pkg-name}, which will presumably be loaded via
346 % |\RequirePackage| later in the file. This is useful for building
347 % `extension' packages, that perhaps handle a couple of new options,
348 % but then pass everything else on to an existing package.
350 % |\DeclareOption*{\InputIfFileExists{xx-\CurrentOption.yyy}%|\\
352 % | {\OptionNotUsed}}|\\
353 % Handle the option foo by loading the file |xx-foo.yyy| if it
354 % exists, otherwise do nothing, but declare that the option was not
356 % Actually the |\OptionNotUsed| declaration is only needed if this is
357 % being used in class files, but does no harm in package files.
360 % \subsection{Safe Input Macros}
361 % \DescribeMacro{\InputIfFileExists}
362 % |\InputIfFileExists{|\meta{file}|}{|\meta{then}|}{|\meta{else}|}|\\
363 % Inputs \meta{file} if it exists. Immediately before the input,
364 % \meta{then} is executed. Otherwise \meta{else} is executed.
366 % \DescribeMacro{\IfFileExists}
367 % As above, but does not input the file.
369 % One thing you might like to put in the \meta{else} clause is
371 % \DescribeMacro{\@missingfileerror}
372 % This starts an interactive request for a filename, supplying default
373 % extensions. Just hitting return causes the whole input to be skipped
374 % and entering |x| quits the current run,
376 % \DescribeMacro{\input}
377 % This has been redefined from the \LaTeX2.09 definition, in terms of
378 % the new commands |\InputIfFileExists| and |\@missingfileerror|.
381 % \DescribeMacro{\listfiles} Giving this declaration in the preamble
382 % causes a list of all files input via the `safe input' commands to be
383 % listed at the end. Any strings specified in the optional argument to
384 % |\ProvidesPackage| are listed alongside the file name. So files in
385 % standard (and other non-standard) distributions can put informative
386 % strings in this argument.
390 % \section{Implementation}
397 % \changes{v0.2g}{1993/11/23}
398 % {Various macros now moved to latex.tex.}
399 % \changes{v0.2g}{1993/11/23}
400 % {Warnings and errors now directly coded.}
401 % \changes{v0.2h}{1993/11/28}
402 % {Primitive filenames now terminated by space not \cs{relax}.}
403 % \changes{v0.2h}{1993/11/28}
404 % {Directory syntax checing moved to dircheck.dtx}
405 % \changes{v0.2h}{1993/11/28}
406 % {Assorted commands now in the kernel removed.}
407 % \changes{v0.2i}{1993/12/03}
408 % {\cs{@onlypreamble}: Many commands declared.}
409 % \changes{v0.2i}{1993/12/03}
410 % {Removed obsolete \cs{@documentclass}}
411 % \changes{v0.2o}{1993/12/13}
412 % {Removed setting \cs{errorcontextlines}\ (now in latex.tex)}
413 % \changes{v0.2p}{1993/12/15}
414 % {Removed extra `.'s from \cs{@@warning}s}
415 % \changes{v0.2s}{1994/01/17}
416 % {Added many more \cs{@onlypreamble} commands}
417 % \changes{v0.2s}{1994/01/17}
418 % {Wrapped long lines to column 72}
419 % \changes{v0.3a}{1994/03/02}
420 % {Remove need for driver file}
421 % \changes{v0.3b}{1994/03/08}
422 % {Modify driver code into `new style'}
423 % \changes{v0.3c}{1994/03/12}
424 % {Change name from docclass to ltclass}
425 % \changes{v0.3h}{1994/04/25}
426 % {Removed spurious extra `.'s at the end of error messages}
427 % \changes{v1.0a}{1994/04/29}
428 % {Change version number to 1 (no other change)}
429 % \changes{v1.0k}{1994/11/03}
430 % {Move \cs{@missingfileerror} to ltfiles}
432 % \begin{macro}{\if@compatibility}
433 % The flag for compatibility mode.
435 \newif\if@compatibility
439 % \begin{macro}{\@documentclasshook}
440 % The hook called after the first |\documentclass| command. By
441 % default this checks to see if |\@normalsize| is undefined, and if
442 % so, sets it to |\normalsize|.
443 % \changes{v0.2q}{1993/12/17}
445 % \changes{v0.2z}{1994/02/10}
446 % {Changed the name from \cs{@compatibility} to
447 % \cs{@documentclasshook}, and added the check for whether
448 % \cs{@normalsize} has been defined. ASAJ.}
450 \def\@documentclasshook{%
451 \ifx\@normalsize\@undefined
452 \let\@normalsize\normalsize
458 % \begin{macro}{\@declaredoptions}
459 % This list is automatically built by |\DeclareOption|.
460 % It is the list of options (separated by commas) declared in
461 % the class or package file and it defines the order in which the
462 % the corresponding |\ds@|\meta{option} commands are executed.
463 % All local \meta{option}s which are not declared will be processed
464 % in the order defined by the optional argument of |\documentclass|
467 \let\@declaredoptions\@empty
471 % \begin{macro}{\@classoptionslist}
472 % List of options of the main class.
473 % \changes{v1.0u}{1996/07/26}{made only preamble}
475 \let\@classoptionslist\relax
476 \@onlypreamble\@classoptionslist
480 % \begin{macro}{\@unusedoptionlist}
481 % \changes{v1.0u}{1996/07/26}{made only preamble}
482 % List of options of the main class that haven't been declared or
483 % loaded as class option files.
485 \let\@unusedoptionlist\@empty
486 \@onlypreamble\@unusedoptionlist
490 % \begin{macro}{\CurrentOption}
491 % Name of current package or option.
492 % \changes{v0.2c}{1993/11/17}
493 % {Name changed from \cs{@curroption}}
495 \let\CurrentOption\@empty
499 % \begin{macro}{\@currname}
500 % Name of current package or option.
502 \let\@currname\@empty
506 % \begin{macro}{\@currext}
507 % The current file extension.
508 % \changes{v0.2a}{1993/11/14}{Name changed from \cs{@currextension}}
510 \global\let\@currext=\@empty
514 % \begin{macro}{\@clsextension}
515 % \begin{macro}{\@pkgextension}
516 % The two possible values of |\@currext|.
518 \def\@clsextension{cls}
519 \def\@pkgextension{sty}
520 \@onlypreamble\@clsextension
521 \@onlypreamble\@pkgextension
526 % \begin{macro}{\@pushfilename}
527 % \begin{macro}{\@popfilename}
528 % \begin{macro}{\@currnamestack}
529 % Commands to push and pop the file name and extension. \\
530 % |#1| current name. \\
531 % |#2| current extension. \\
532 % |#3| current catcode of |@|. \\
533 % |#4| Rest of the stack.
536 \xdef\@currnamestack{%
541 \@onlypreamble\@pushfilename
545 \def\@popfilename{\expandafter\@p@pfilename\@currnamestack\@nil}
546 \@onlypreamble\@popfilename
550 \def\@p@pfilename#1#2#3#4\@nil{%
554 \gdef\@currnamestack{#4}}
555 \@onlypreamble\@p@pfilename
559 \gdef\@currnamestack{}
560 \@onlypreamble\@currnamestack
566 % \begin{macro}{\@ptionlist}
567 % Returns the option list of the file.
570 \@ifundefined{opt@#1}\@empty{\csname opt@#1\endcsname}}
571 \@onlypreamble\@ptionlist
575 % \begin{macro}{\@ifpackageloaded}
576 % \begin{macro}{\@ifclassloaded}
577 % |\@ifpackageloaded{|\meta{name}|}|
578 % Checks to see whether a file has been loaded.
579 % \changes{v0.2t}{1994/01/18}
580 % {Fix typo \cs{@pkgetension}}
582 \def\@ifpackageloaded{\@ifl@aded\@pkgextension}
583 \def\@ifclassloaded{\@ifl@aded\@clsextension}
584 \@onlypreamble\@ifpackageloaded
585 \@onlypreamble\@ifclassloaded
590 \expandafter\ifx\csname ver@#2.#1\endcsname\relax
591 \expandafter\@secondoftwo
593 \expandafter\@firstoftwo
595 \@onlypreamble\@ifl@aded
600 % \begin{macro}{\@ifpackagelater}
601 % \begin{macro}{\@ifclasslater}
602 % |\@ifpackagelater{|\meta{name}|}{YYYY/MM/DD}|
603 % Checks that the package loaded is more recent than the given date.
605 \def\@ifpackagelater{\@ifl@ter\@pkgextension}
606 \def\@ifclasslater{\@ifl@ter\@clsextension}
607 \@onlypreamble\@ifpackagelater
608 \@onlypreamble\@ifclasslater
613 \expandafter\@ifl@t@r
614 \csname ver@#2.#1\endcsname}
615 \@onlypreamble\@ifl@ter
618 % This internal macro is also used in |\NeedsTeXFormat|.
619 % \changes{v0.2f}{1993/11/22}
620 % {Added //00 so parsing never produces a runaway argument.}
623 \ifnum\expandafter\@parse@version#1//00\@nil<%
624 \expandafter\@parse@version#2//00\@nil
625 \expandafter\@secondoftwo
627 \expandafter\@firstoftwo
629 \@onlypreamble\@ifl@t@r
632 % \changes{v1.1j}{2016/06/20}
633 % {don't declare as \cs{@onlypreamble}}
635 \def\@parse@version#1/#2/#3#4#5\@nil{#1#2#3#4 }
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.}
666 %<latexrelease>\IncludeInRelease{2017/01/01}%
667 %<latexrelease> {\@if@pti@ns}{Spaces in option clash check}%
668 %<*2ekernel|latexrelease>
669 \def\@if@pti@ns#1#2{%
670 \let\reserved@a\@firstoftwo
672 % \changes{v1.2a}{2016/10/02}
673 % {Ignore spaces while checking for option clash}
675 \edef\reserved@b{\zap@space#2 \@empty}%
676 \@for\reserved@b:=\reserved@b\do{%
677 \ifx\reserved@b\@empty
679 \expandafter\in@\expandafter{\expandafter,\reserved@b,}{,#1,}%
682 \let\reserved@a\@secondoftwo
687 %</2ekernel|latexrelease>
688 %<latexrelease>\EndIncludeInRelease
689 %<latexrelease>\IncludeInRelease{0000/00/00}%
690 %<latexrelease> {\@if@pti@ns}{Spaces in option clash check}%
691 %<latexrelease>\def\@if@pti@ns#1#2{%
692 %<latexrelease> \let\reserved@a\@firstoftwo
693 %<latexrelease> \@for\reserved@b:=#2\do{%
694 %<latexrelease> \ifx\reserved@b\@empty
695 %<latexrelease> \else
696 %<latexrelease> \expandafter\in@\expandafter
697 %<latexrelease> {\expandafter,\reserved@b,}{,#1,}%
698 %<latexrelease> \ifin@
699 %<latexrelease> \else
700 %<latexrelease> \let\reserved@a\@secondoftwo
704 %<latexrelease> \reserved@a}
709 \@onlypreamble\@if@pti@ns
714 % \begin{macro}{\ProvidesPackage}
715 % Checks that the current filename is correct, and defines
717 % \changes{v0.3c}{1994/03/12}
719 % \changes{v0.3c}{1994/03/12}
722 \def\ProvidesPackage#1{%
724 \ifx\@gtempa\@currname\else
725 \@latex@warning@no@line{You have requested
726 \@cls@pkg\space`\@currname',\MessageBreak
727 but the \@cls@pkg\space provides `#1'}%
729 \@ifnextchar[\@pr@videpackage{\@pr@videpackage[]}}%]
730 \@onlypreamble\ProvidesPackage
734 \def\@pr@videpackage[#1]{%
735 \expandafter\xdef\csname ver@\@currname.\@currext\endcsname{#1}%
736 \ifx\@currext\@clsextension
737 \typeout{Document Class: \@gtempa\space#1}%
739 \wlog{Package: \@gtempa\space#1}%
741 \@onlypreamble\@pr@videpackage
745 % \begin{macro}{\ProvidesClass}
746 % Like |\ProvidesPackage|, but for classes.
748 \let\ProvidesClass\ProvidesPackage
749 \@onlypreamble\ProvidesClass
753 % \begin{macro}{\ProvidesFile}
754 % Like |\ProvidesPackage|, but for arbitrary files. Do not apply
755 % |\@onlypreamble| to these, as we may want to label files input
756 % during the document.
757 % \changes{v0.2l}{1993/12/07}
759 % \changes{v0.3c}{1994/03/12}
761 % \changes{v0.3g}{1994/04/11}
762 % {Protect against weird catcodes.}
763 % \begin{macro}{\@providesfile}
764 % \changes{v1.0r}{1995/10/17}
765 % {Delay definition of \cs{ProvidesFile} till ltfinal}
766 % \changes{v1.1a}{1998/03/21}
767 % {Allow \&. Internal/2702}
768 % \changes{v1.1d}{2001/05/25}{Explicitly set catcode of
769 % \cs{endlinechar} to 10 (pr/3334)}
770 % \changes{v1.1e}{2001/06/04}{But only if it is a char (pr/3334)}
771 % \changes{v1.1f}{2001/08/26}{Readded setting of space char (pr/3353)}
773 \def\ProvidesFile#1{%
776 \ifnum \endlinechar<256 %
777 \ifnum \endlinechar>\m@ne
778 \catcode\endlinechar 10 %
784 % \changes{v1.1g}{2004/01/28}{Use kernel version of
785 % \cs{@ifnextchar} (pr/3501)}
787 \kernel@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}}
790 % During initex a special version of |\@providesfile| is used.
791 % The real definition is installed right at the end, in |ltfinal.dtx|.
793 %\def\@providesfile#1[#2]{%
794 % \wlog{File: #1 #2}%
795 % \expandafter\xdef\csname ver@#1\endcsname{#2}%
802 % \begin{macro}{\PassOptionsToPackage}
803 % \begin{macro}{\PassOptionsToClass}
804 % If the package has been loaded, we check that it was first loaded with
805 % the options. Otherwise we add the option list to that of the package.
807 \def\@pass@ptions#1#2#3{%
808 \expandafter\xdef\csname opt@#3.#1\endcsname{%
809 \@ifundefined{opt@#3.#1}\@empty
810 {\csname opt@#3.#1\endcsname,}%
811 \zap@space#2 \@empty}}
812 \@onlypreamble\@pass@ptions
816 \def\PassOptionsToPackage{\@pass@ptions\@pkgextension}
817 \def\PassOptionsToClass{\@pass@ptions\@clsextension}
818 \@onlypreamble\PassOptionsToPackage
819 \@onlypreamble\PassOptionsToClass
824 % \begin{macro}{\DeclareOption}
825 % \begin{macro}{\DeclareOption*}
826 % Adds an option as a |\ds@| command, or the default |\default@ds|
828 % \changes{v0.2c}{1993/11/17}
829 % {Error checking added}
830 % \changes{v1.0m}{1995/04/21}
832 % \changes{v1.0n}{1995/05/12}
833 % {Use \cs{toks@} to remove need to double hash /1557}
836 \let\@fileswith@pti@ns\@badrequireerror
837 \@ifstar\@defdefault@ds\@declareoption}
838 \long\def\@declareoption#1#2{%
839 \xdef\@declaredoptions{\@declaredoptions,#1}%
841 \expandafter\edef\csname ds@#1\endcsname{\the\toks@}}
842 \long\def\@defdefault@ds#1{%
844 \edef\default@ds{\the\toks@}}
845 \@onlypreamble\DeclareOption
846 \@onlypreamble\@declareoption
847 \@onlypreamble\@defdefault@ds
852 % \begin{macro}{\OptionNotUsed}
853 % If we are in a class file, add |\CurrentOption| to the list of
854 % unused options. Otherwise, in a package file do nothing.
857 \ifx\@currext\@clsextension
858 \xdef\@unusedoptionlist{%
859 \ifx\@unusedoptionlist\@empty\else\@unusedoptionlist,\fi
862 \@onlypreamble\OptionNotUsed
866 % \begin{macro}{\default@ds}
867 % The default default option code.
868 % Set by |\@onefilewithoptions| to either |\OptionNotUsed| for
869 % classes, or |\@unknownoptionerror| for packages. This may be reset
870 % in either case with |\DeclareOption*|.
872 % \let\default@ds\OptionNotUsed
876 % \begin{macro}{\ProcessOptions}
877 % \begin{macro}{\ProcessOptions*}
878 % |\ProcessOptions| calls |\ds@option| for each known package option,
879 % then calls |\default@ds| for each option on the local options list.
880 % Finally resets all the declared options to |\relax|. The empty option
881 % does nothing, this has to be reset on the off chance it's set to
882 % |\relax| if an empty element gets into the |\@declaredoptions| list.
884 % The star form is similar but executes options given in the order
885 % specified in the document, not the order they are declared in the
886 % file. In the case of packages, global options are executed before
888 % \changes{v0.2a}{1993/11/14}
889 % {Stop adding the global option list inside class files.}
890 % \changes{v0.2a}{1993/11/14}
891 % {Optimise `empty option' code.}
892 % \changes{v0.2b}{1993/11/15}
894 % \changes{v0.2c}{1993/11/17}
895 % {restoring \cs{@fileswith@pti@ns} added.}
897 \def\ProcessOptions{%
899 \edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
900 \@ifstar\@xprocess@ptions\@process@ptions}
901 \@onlypreamble\ProcessOptions
904 % \changes{v0.2y}{1994/02/07}
905 % {Add extra ,s so `two' is not matched with `twocolumn'}
907 \def\@process@ptions{%
908 \@for\CurrentOption:=\@declaredoptions\do{%
909 \ifx\CurrentOption\@empty\else
910 \@expandtwoargs\in@{,\CurrentOption,}{%
911 ,\ifx\@currext\@clsextension\else\@classoptionslist,\fi
915 \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
919 \@onlypreamble\@process@ptions
922 % \changes{v0.2y}{1994/02/07}
923 % {Add extra ,s so `two' is not matched with `twocolumn'}
925 \def\@xprocess@ptions{%
926 \ifx\@currext\@clsextension\else
927 \@for\CurrentOption:=\@classoptionslist\do{%
928 \ifx\CurrentOption\@empty\else
929 \@expandtwoargs\in@{,\CurrentOption,}{,\@declaredoptions,}%
932 \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
937 \@onlypreamble\@xprocess@ptions
940 % The common part of |\ProcessOptions| and |\ProcessOptions*|.
942 \def\@process@pti@ns{%
943 \@for\CurrentOption:=\@curroptions\do{%
944 \@ifundefined{ds@\CurrentOption}%
948 % There should not be any non-empty definition of |\CurrentOption| at
949 % this point, as all the declared options were executed earlier. This is
950 % for compatibility with 2.09 styles which use |\def\ds@|\ldots\
951 % directly, and so have options which do not appear in
952 % |\@declaredoptions|.
956 % Clear all the definitions for option code. First set all the declared
957 % options to |\relax|, then reset the `default' and `empty' options. and
958 % the lst of declared options.
960 \@for\CurrentOption:=\@declaredoptions\do{%
961 \expandafter\let\csname ds@\CurrentOption\endcsname\relax}%
963 % \changes{v1.0r}{1995/10/17}
964 % {Reset \cs{CurrentOption} for graphics/1873}
966 \let\CurrentOption\@empty
967 \let\@fileswith@pti@ns\@@fileswith@pti@ns
968 \AtEndOfPackage{\let\@unprocessedoptions\relax}}
969 \@onlypreamble\@process@pti@ns
974 % \begin{macro}{\@options}
975 % |\@options| is a synonym for |\ProcessOptions*| for upward
976 % compatibility with \LaTeX2.09 style files.
978 \def\@options{\ProcessOptions*}
979 \@onlypreamble\@options
983 % \begin{macro}{\@use@ption}
984 % Execute the code for the current option.
985 % \changes{v0.2g}{1993/11/23}
986 % {Name changed from \cs{@executeoption}}
987 % \changes{v1.0e}{1994/05/17}
988 % {Execute option after removing from list, not before}
991 \@expandtwoargs\@removeelement\CurrentOption
992 \@unusedoptionlist\@unusedoptionlist
993 \csname ds@\CurrentOption\endcsname}
994 \@onlypreamble\@use@ption
998 % \begin{macro}{\ExecuteOptions}
999 % |\ExecuteOptions{|\meta{option-list}|}| executes the code declared
1001 % \changes{v0.2d}{1993/11/18}
1002 % {Use \cs{CurrentOption} not \cs{reserved@a}}
1003 % \changes{v0.2k}{1993/12/06}
1004 % {Preserve \cs{CurrentOption}.}
1007 %<latexrelease>\IncludeInRelease{2017/01/01}%
1008 %<latexrelease> {\@if@pti@ns}{Spaces in \ExecuteOptions}%
1009 %<*2ekernel|latexrelease>
1010 \def\ExecuteOptions#1{%
1012 % \changes{v1.2a}{2016/10/02}
1013 % {Ignore spaces in argument}
1014 % Use |\@fortmp| here as it is anyway cleared during |\@for| loop
1015 % so does not change any existing names.
1017 \edef\@fortmp{\zap@space#1 \@empty}%
1018 \def\reserved@a##1\@nil{%
1019 \@for\CurrentOption:=\@fortmp\do
1020 {\csname ds@\CurrentOption\endcsname}%
1021 \edef\CurrentOption{##1}}%
1022 \expandafter\reserved@a\CurrentOption\@nil}
1023 %</2ekernel|latexrelease>
1024 %<latexrelease>\EndIncludeInRelease
1025 %<latexrelease>\IncludeInRelease{0000/00/00}%
1026 %<latexrelease> {\@if@pti@ns}{Spaces in \ExecuteOptions}%
1027 %<latexrelease>\def\ExecuteOptions#1{%
1028 %<latexrelease> \def\reserved@a##1\@nil{%
1029 %<latexrelease> \@for\CurrentOption:=#1\do
1030 %<latexrelease> {\csname ds@\CurrentOption\endcsname}%
1031 %<latexrelease> \edef\CurrentOption{##1}}%
1032 %<latexrelease> \expandafter\reserved@a\CurrentOption\@nil}
1037 \@onlypreamble\ExecuteOptions
1041 % The top-level commands, which just set some parameters then call
1042 % the internal command, |\@fileswithoptions|.
1043 % \begin{macro}{\documentclass}
1044 % \changes{v1.0q}{1995/06/19}
1045 % {Dont redefine \cs{usepackage} in compat mode for /1634}
1046 % The main new-style class declaration.
1048 \def\documentclass{%
1049 \let\documentclass\@twoclasseserror
1050 \if@compatibility\else\let\usepackage\RequirePackage\fi
1051 \@fileswithoptions\@clsextension}
1052 \@onlypreamble\documentclass
1056 % \begin{macro}{\documentstyle}
1057 % 2.09 style class `style' declaration.
1058 % \changes{v0.2a}{1993/11/14}
1059 % {Added \cs{RequirePackage} \cs{@unusedoptionlist} stuff.}
1060 % \changes{v0.2b}{1993/11/15}
1061 % {Modified to match \cs{ProcessOption*}}
1062 % \changes{v0.2d}{1993/11/18}
1063 % {Modified \cs{RequirePackage} stuff.}
1064 % \changes{v0.2n}{1993/12/09}
1065 % {input 209 compatibility file.}
1066 % \changes{v0.2o}{1993/12/13}
1067 % {compatibility file now latex209.sty.}
1068 % \changes{v0.2q}{1993/12/17}
1069 % {Match Alan's new code.}
1070 % \changes{v0.2u}{1994/01/21}
1071 % {compatibility file now latex209.def.}
1073 \def\documentstyle{%
1074 \makeatletter\input{latex209.def}\makeatother
1076 \@onlypreamble\documentstyle
1080 % \begin{macro}{\RequirePackage}
1081 % Load package if not already loaded.
1083 \def\RequirePackage{%
1084 \@fileswithoptions\@pkgextension}
1085 \@onlypreamble\RequirePackage
1089 % \begin{macro}{\LoadClass}
1093 \ifx\@currext\@pkgextension
1095 {\noexpand\LoadClass in package file}%
1096 {You may only use \noexpand\LoadClass in a class file.}%
1098 \@fileswithoptions\@clsextension}
1099 \@onlypreamble\LoadClass
1103 % \begin{macro}{\@loadwithoptions}
1104 % \changes{v1.0t}{1995/11/14}{macro added}
1105 % Pass the current option list on to a class or package.
1106 % |#1| is |\@|\emph{cls-or-pkg}|extension|,
1107 % |#2| is |\RequirePackage| or |\LoadClass|,
1108 % |#3| is the class or package to be loaded.
1110 \def\@loadwithoptions#1#2#3{%
1111 \expandafter\let\csname opt@#3.#1\expandafter\endcsname
1112 \csname opt@\@currname.\@currext\endcsname
1114 \@onlypreamble\@loadwithoptions
1119 % \begin{macro}{\LoadClassWithOptions}
1120 % \changes{v1.0t}{1995/11/14}{macro added}
1121 % Load class `|#1|' with the current option list.
1123 \def\LoadClassWithOptions{%
1124 \@loadwithoptions\@clsextension\LoadClass}
1125 \@onlypreamble\LoadClassWithOptions
1129 % \begin{macro}{\RequirePackageWithOptions}
1130 % \changes{v1.0t}{1995/11/14}{macro added}
1131 % \changes{v1.0v}{1996/10/04}{Reset \cs{@unprocessedoptions} for /2269}
1132 % Load package `|#1|' with the current option list.
1134 \def\RequirePackageWithOptions{%
1135 \AtEndOfPackage{\let\@unprocessedoptions\relax}%
1136 \@loadwithoptions\@pkgextension\RequirePackage}
1137 \@onlypreamble\RequirePackageWithOptions
1141 % \begin{macro}{\usepackage}
1142 % To begin with, |\usepackage| produces an error. This is reset by
1144 % \changes{v0.2o}{1993/12/13}
1145 % {Fixed error handling}
1146 % \changes{v1.0h}{1994/05/23}{Remove argument if possible}
1148 \def\usepackage#1#{%
1150 {\noexpand \usepackage before \string\documentclass}%
1151 {\noexpand \usepackage may only appear in the document
1152 preamble, i.e.,\MessageBreak
1153 between \noexpand\documentclass and
1154 \string\begin{document}.}%
1156 \@onlypreamble\usepackage
1160 % \begin{macro}{\NeedsTeXFormat}
1161 % Check that the document is running on the correct system.
1162 % \changes{v0.2a}{1993/11/14}
1163 % {made more robust for alternative syntax for other formats.}
1164 % \changes{v0.2c}{1993/11/17}
1165 % {Name changed from \cs{NeedsFormat}}
1166 % \changes{v0.2d}{1993/11/18}
1167 % {\cs{fmtname} \cs{fmtversion} not \cs{@}\ldots}
1169 \def\NeedsTeXFormat#1{%
1170 \def\reserved@a{#1}%
1171 \ifx\reserved@a\fmtname
1172 \expandafter\@needsformat
1174 \@latex@error{This file needs format `\reserved@a'%
1175 \MessageBreak but this is `\fmtname'}{%
1176 The current input file will not be processed
1177 further,\MessageBreak
1178 because it was written for some other flavor of
1179 TeX.\MessageBreak\@ehd}%
1181 % If the file is not meant to be processed by \LaTeXe{} we stop
1182 % inputting it, but we do not end the run. We just end inputting
1184 % \changes{v1.0h}{1994/05/23}
1185 % {Don't stop completely when format is wrong}
1188 \@onlypreamble\NeedsTeXFormat
1196 \@onlypreamble\@needsformat
1199 % \changes{v1.0b}{1994/05/04}
1200 % {Changed wording of the warning}
1202 \def\@needsf@rmat[#1]{%
1203 \@ifl@t@r\fmtversion{#1}{}%
1204 {\@latex@warning@no@line
1205 {You have requested release `#1' of LaTeX,\MessageBreak
1206 but only release `\fmtversion' is available}}}
1207 \@onlypreamble\@needsf@rmat
1211 % \begin{macro}{\zap@space}
1212 % |\zap@space foo|\meta{space}|\@empty| removes all spaces from |foo|
1213 % that are not protected by |{ }| groups.
1215 \def\zap@space#1 #2{%
1217 \ifx#2\@empty\else\expandafter\zap@space\fi
1222 % \begin{macro}{\@fileswithoptions}
1223 % The common part of |\documentclass| and |\usepackage|.
1225 \def\@fileswithoptions#1{%
1227 {\@fileswith@ptions#1}%
1228 {\@fileswith@ptions#1[]}}
1229 \@onlypreamble\@fileswithoptions
1232 % \changes{v0.2f}{1993/11/22}
1233 % {Made the default [] not [\cs{@unknownversion}]}
1234 % \changes{v1.1h}{2007/08/05}
1235 % {Prevent loss of brackets PR/3965}
1237 \def\@fileswith@ptions#1[#2]#3{%
1239 {\@fileswith@pti@ns#1[{#2}]#3}%
1240 {\@fileswith@pti@ns#1[{#2}]#3[]}}
1241 \@onlypreamble\@fileswith@ptions
1243 % Then we do some work.
1245 % First of all, we define the global variables.
1246 % Then we look to see if the file has already been loaded.
1247 % If it has, we check that it was first loaded with at least the current
1249 % If it has not, we add the current options to the package options,
1250 % set the default version to be |0000/00/00|, and load the file if we
1252 % Then we check the version number.
1254 % Finally, we restore the old file name, reset the default option,
1255 % and we set the catcode of |@|.
1257 % For classes, we can immediately process the file. For other types,
1258 % |#2| could be a comma separated list, so loop through, processing
1259 % each one separately.
1260 % \changes{v0.2q}{1993/12/17}
1261 % {Add \cs{@compatibility} hook}
1262 % \changes{v0.2s}{1994/01/17}
1263 % {Modify to reduce parameter stack usage}
1264 % \changes{v0.2y}{1994/02/07}
1265 % {Run \cs{@compatibility} on the first class to start
1266 % (not the first to finish) }
1267 % \changes{v0.2z}{1994/02/10}
1268 % {Renamed \cs{@compatibility} to \cs{@documentclasshook}.
1270 % \changes{v1.1h}{2007/08/05}
1271 % {Prevent loss of brackets PR/3965}
1272 % \changes{v2.1b}{2016/11/09}
1273 % {Improve \cs{ifx} tests PR/4497}
1276 %<latexrelease>\IncludeInRelease{2017/01/01}%
1277 %<latexrelease> {\@fileswith@pti@ns}{ifx tests in \@fileswith@pti@ns}%
1278 %<*2ekernel|latexrelease>
1279 \def\@fileswith@pti@ns#1[#2]#3[#4]{%
1280 \ifx#1\@clsextension
1281 \ifx\@classoptionslist\relax
1282 \xdef\@classoptionslist{\zap@space#2 \@empty}%
1284 \@onefilewithoptions#3[{#2}][{#4}]#1%
1285 \@documentclasshook}%
1288 \@onefilewithoptions#3[{#2}][{#4}]#1}%
1292 % build up a list of calls to |\@onefilewithoptions|
1293 % (one for each package) without thrashing the parameter stack.
1295 \def\reserved@b##1,{%
1297 % If |#1| is |\@nnil| we have reached the end of the list
1298 % (older version used |\@nil| here but |\@nil| is undefined so |\ifx|
1299 % equal to all undefined commands)
1301 \ifx\@nnil##1\relax\else
1303 % If |\ifx\@nnil##1\n@nil| is true then |#1| is (presumably) empty
1304 % (Older code used |\relax| which is slighly easier to get into |#1|
1305 % by mistake, which would spoil this test.)
1307 \ifx\@nnil##1\@nnil\else
1311 \noexpand\@onefilewithoptions##1[{#2}][{#4}]%
1312 \noexpand\@pkgextension
1314 \expandafter\reserved@b
1316 \edef\reserved@a{\zap@space#3 \@empty}%
1317 \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nnil,}%
1320 %</2ekernel|latexrelease>
1324 %<latexrelease>\EndIncludeInRelease
1325 %<latexrelease>\IncludeInRelease{0000/00/00}%
1326 %<latexrelease> {\@fileswith@pti@ns}{ifx tests in \@fileswith@pti@ns}%
1327 %<latexrelease>\def\@fileswith@pti@ns#1[#2]#3[#4]{%
1328 %<latexrelease> \ifx#1\@clsextension
1329 %<latexrelease> \ifx\@classoptionslist\relax
1330 %<latexrelease> \xdef\@classoptionslist{\zap@space#2 \@empty}%
1331 %<latexrelease> \def\reserved@a{%
1332 %<latexrelease> \@onefilewithoptions#3[{#2}][{#4}]#1%
1333 %<latexrelease> \@documentclasshook}%
1334 %<latexrelease> \else
1335 %<latexrelease> \def\reserved@a{%
1336 %<latexrelease> \@onefilewithoptions#3[{#2}][{#4}]#1}%
1338 %<latexrelease> \else
1339 %<latexrelease> \def\reserved@b##1,{%
1340 %<latexrelease> \ifx\@nil##1\relax\else
1341 %<latexrelease> \ifx\relax##1\relax\else
1342 %<latexrelease> \noexpand\@onefilewithoptions##1[{#2}][{#4}]%
1343 %<latexrelease> \noexpand\@pkgextension
1345 %<latexrelease> \expandafter\reserved@b
1346 %<latexrelease> \fi}%
1347 %<latexrelease> \edef\reserved@a{\zap@space#3 \@empty}%
1348 %<latexrelease> \edef\reserved@a{%
1349 %<latexrelease> \expandafter\reserved@b\reserved@a,\@nil,}%
1351 %<latexrelease> \reserved@a}
1356 \@onlypreamble\@fileswith@pti@ns
1359 % Have the main argument as |#1|, so we only need one |\expandafter|
1361 % \changes{v0.2a}{1993/11/14}
1362 % {Moved resetting of \cs{default@ds}, \cs{ds@} and
1363 % \cs{@declaredoptions} here, from the end of
1364 % \cs{ProcessOptions}.}
1365 % \changes{v0.2f}{1993/11/22}
1366 % {Made the initial version [] not [\cs{@unknownversion}]}
1367 % \changes{v0.2m}{1993/12/07}
1368 % {Reset \cs{CurrentOption}}
1370 \def\@onefilewithoptions#1[#2][#3]#4{%
1372 \xdef\@currname{#1}%
1373 \global\let\@currext#4%
1374 \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty
1375 \let\CurrentOption\@empty
1379 % Grab everything in a macro, so the parameter stack is popped before
1380 % any processing begins.
1381 % \changes{v0.2s}{1994/01/17}
1382 % {Modify to reduce parameter stack usage}
1383 % \changes{v1.1b}{1998/05/07}
1384 % {Modify help message for latex/2805}
1387 \@ifl@aded\@currext{#1}%
1388 {\@if@ptions\@currext{#1}{#2}{}%
1390 {Option clash for \@cls@pkg\space #1}%
1391 {The package #1 has already been loaded
1392 with options:\MessageBreak
1393 \space\space[\@ptionlist{#1.\@currext}]\MessageBreak
1394 There has now been an attempt to load it
1395 with options\MessageBreak
1396 \space\space[#2]\MessageBreak
1397 Adding the global options:\MessageBreak
1399 \@ptionlist{#1.\@currext},#2\MessageBreak
1400 to your \noexpand\documentclass declaration may fix this.%
1402 Try typing \space <return> \space to proceed.}}}%
1403 {\@pass@ptions\@currext{#2}{#1}%
1405 % \changes{v0.3c}{1994/03/12}
1406 % {Do not use \cs{@pr@videpackage} to avoid typeout}
1409 \let\csname ver@\@currname.\@currext\endcsname\@empty
1411 {\@currname.\@currext}%
1413 {\@missingfileerror\@currname\@currext}%
1415 % |\@unprocessedoptions| will generate an error for each specified
1416 % option in a package unless a |\ProcessOptions| has appeared in the
1418 % \changes{v0.2v}{1994/01/29}
1419 % {All options raise error if no \cs{ProcessOptions} appears}
1420 % \changes{v0.2x}{1994/02/02}
1421 % {Only run the hook and options check if the file was loaded.}
1423 \let\@unprocessedoptions\@@unprocessedoptions
1424 \csname\@currname.\@currext-h@@k\endcsname
1425 \expandafter\let\csname\@currname.\@currext-h@@k\endcsname
1427 \@unprocessedoptions}
1431 \@ifl@ter\@currext{#1}{#3}{}%
1432 {\@latex@warning@no@line
1433 {You have requested,\on@line,
1434 version\MessageBreak
1435 `#3' of \@cls@pkg\space #1,\MessageBreak
1436 but only version\MessageBreak
1437 `\csname ver@#1.\@currext\endcsname'\MessageBreak
1440 % \changes{v0.2c}{1993/11/17}
1441 % {Added trap for two \cs{LoadClass} commands.}
1443 \ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi
1447 \@onlypreamble\@onefilewithoptions
1451 % \begin{macro}{\@@fileswith@pti@ns}
1452 % Save the definition (for error checking).
1453 % \changes{v0.2c}{1993/11/17}
1456 \let\@@fileswith@pti@ns\@fileswith@pti@ns
1457 \@onlypreamble\@@fileswith@pti@ns
1461 % \begin{macro}{\@reset@ptions}
1462 % Reset the default option, and clear lists of declared options.
1463 % \changes{v0.2a}{1993/11/14}{macro added}
1465 \def\@reset@ptions{%
1466 \global\ifx\@currext\@clsextension
1467 \let\default@ds\OptionNotUsed
1469 \let\default@ds\@unknownoptionerror
1471 \global\let\ds@\@empty
1472 \global\let\@declaredoptions\@empty}
1473 \@onlypreamble\@reset@ptions
1477 % \subsection{Hooks}
1479 % Allow code do be saved to be executed at specific later times.
1481 % Save things in macros, I considered using toks registers, (and
1482 % |\addto@hook| from the NFSS code, that would require stacking the
1483 % contents in the case of required packages, so just generate a new
1484 % macro for each package.
1485 % \begin{macro}{\@begindocumenthook}
1486 % \changes{v1.0s}{1995/10/20}
1487 % {Make setting conditional, for autoload version}
1488 % \begin{macro}{\@enddocumenthook}
1489 % Stuff to appear at the beginning or end of the document.
1491 \ifx\@begindocumenthook\@undefined
1492 \let\@begindocumenthook\@empty
1494 \let\@enddocumenthook\@empty
1499 % \begin{macro}{\g@addto@macro}
1500 % Globally add to the end of a macro.
1501 % \changes{v0.2a}{1993/11/14}{Made global}
1502 % \changes{v0.2w}{1994/01/31}
1503 % {Use toks register to avoid `hash' problems}
1504 % \changes{v1.0o}{1995/05/17}
1505 % {Make long for latex/1522}
1506 % \changes{v1.0w}{1996/12/17}
1507 % {Use \cs{begingroup} to save making a mathord}
1508 % \changes{v1.0x}{1997/02/05}
1509 % {missing percent /2402}
1511 \long\def\g@addto@macro#1#2{%
1513 \toks@\expandafter{#1#2}%
1514 \xdef#1{\the\toks@}%
1519 % \begin{macro}{\AtEndOfPackage}
1520 % \begin{macro}{\AtEndOfClass}
1521 % \begin{macro}{\AtBeginDocument}
1522 % \begin{macro}{\AtEndDocument}
1523 % The access functions.
1524 % \changes{v0.2a}{1993/11/14}
1525 % {Included extension in the generated macro name for package
1528 \def\AtEndOfPackage{%
1529 \expandafter\g@addto@macro\csname\@currname.\@currext-h@@k\endcsname}
1530 \let\AtEndOfClass\AtEndOfPackage
1531 \@onlypreamble\AtEndOfPackage
1532 \@onlypreamble\AtEndOfClass
1536 \def\AtBeginDocument{\g@addto@macro\@begindocumenthook}
1537 \def\AtEndDocument{\g@addto@macro\@enddocumenthook}
1538 \@onlypreamble\AtBeginDocument
1546 % \begin{macro}{\@cls@pkg}
1547 % The current file type.
1548 % \changes{v0.2i}{1993/12/03}
1549 % {Name changed to avoid clash with output routine.}
1552 \ifx\@currext\@clsextension
1557 \@onlypreamble\@cls@pkg
1561 % \begin{macro}{\@unknownoptionerror}
1564 \def\@unknownoptionerror{%
1566 {Unknown option `\CurrentOption' for \@cls@pkg\space`\@currname'}%
1567 {The option `\CurrentOption' was not declared in
1568 \@cls@pkg\space`\@currname', perhaps you\MessageBreak
1569 misspelled its name.
1570 Try typing \space <return>
1571 \space to proceed.}}
1572 \@onlypreamble\@unknownoptionerror
1576 % \begin{macro}{\@@unprocessedoptions}
1577 % Declare an error for each option, unless a |\ProcessOptions| occurred.
1578 % \changes{v0.2v}{1994/01/29}
1580 % \changes{v1.0t}{1995/11/14}{Allow empty option}
1582 \def\@@unprocessedoptions{%
1583 \ifx\@currext\@pkgextension
1584 \edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
1585 \@for\CurrentOption:=\@curroptions\do{%
1586 \ifx\CurrentOption\@empty\else\@unknownoptionerror\fi}%
1588 \@onlypreamble\@unprocessedoptions
1589 \@onlypreamble\@@unprocessedoptions
1593 % \begin{macro}{\@badrequireerror}
1594 % |\RequirePackage| or |\LoadClass| occurs in the options section.
1595 % \changes{v0.2c}{1993/11/17}
1598 \def\@badrequireerror#1[#2]#3[#4]{%
1600 {\noexpand\RequirePackage or \noexpand\LoadClass
1601 in Options Section}%
1602 {The \@cls@pkg\space `\@currname' is defective.\MessageBreak
1603 It attempts to load `#3' in the options section, i.e.,\MessageBreak
1604 between \noexpand\DeclareOption and \string\ProcessOptions.}}
1605 \@onlypreamble\@badrequireerror
1609 % \begin{macro}{\@twoloadclasserror}
1610 % Two |\LoadClass| in a class.
1611 % \changes{v0.2c}{1993/11/17}
1614 \def\@twoloadclasserror{%
1616 {Two \noexpand\LoadClass commands}%
1617 {You may only use one \noexpand\LoadClass in a class file}}
1618 \@onlypreamble\@twoloadclasserror
1622 % \begin{macro}{\@twoclasseserror}
1623 % Two |\documentclass| or |\documentstyle|.
1624 % \changes{v0.2h}{1993/11/28}
1627 \def\@twoclasseserror#1#{%
1629 {Two \noexpand\documentclass or \noexpand\documentstyle commands}%
1630 {The document may only declare one class.}\@gobble}
1631 \@onlypreamble\@twoclasseserror
1635 % \subsection{Providing shipment}
1637 % \begin{macro}{\two@digits}
1638 % Prefix a number less than 10 with `0'.
1640 \def\two@digits#1{\ifnum#1<10 0\fi\number#1}
1644 % \begin{macro}{\filecontents}
1645 % \begin{macro}{\endfilecontents}
1646 % This environment implements inline files.
1647 % The star-form does not write extra comments into the file.
1649 % \changes{v0.2h}{1993/11/28}
1650 % {Don't globally allocate a write stream (always use 15)}
1651 % \changes{v0.2r}{1993/12/19}{Different message when ignoring a file}
1652 % \changes{v0.3g}{1994/04/11}
1654 % dont write \cs{endinput} at the end of the file.}
1655 % \changes{v1.0c}{1994/05/11}
1656 % {Add checks for form feed and tab}
1657 % \changes{v1.0m}{1995/04/21}
1658 % {Close input check stream: latex/1487}
1659 % \changes{v1.0p}{1995/05/25}{Delete \cs{filec@ntents} after preamble}
1663 \catcode`\^^M\active%
1664 \catcode`\^^L\active\let^^L\relax%
1665 \catcode`\^^I\active%
1669 \gdef\filecontents{\@tempswatrue\filec@ntents}%
1670 \gdef\filecontents*{\@tempswafalse\filec@ntents}%
1674 \gdef\filec@ntents#1{%
1675 \openin\@inputcheck#1 %
1677 \@latex@warning@no@line%
1678 {Writing file `\@currdir#1'}%
1681 % \changes{v1.0y}{1997/10/10}
1682 % {\cs{reserved@c} not \cs{verbatim@out} to save a csname}
1684 \chardef\reserved@c15 %
1685 \ch@ck7\reserved@c\write%
1686 \immediate\openout\reserved@c#1\relax%
1690 % \changes{v1.0y}{1997/10/10}
1691 % {Use \cs{@gobbletwo}}
1693 \closein\@inputcheck%
1694 \@latex@warning@no@line%
1695 {File `#1' already exists on the system.\MessageBreak%
1696 Not generating it from this source}%
1697 \let\write\@gobbletwo%
1698 \let\closeout\@gobble%
1703 % \changes{v1.0y}{1997/10/10}
1704 % {\cs{@currenvir} in banner}
1706 \immediate\write\reserved@c{%
1707 \@percentchar\@percentchar\space%
1708 \expandafter\@gobble\string\LaTeX2e file `#1'^^J%
1709 \@percentchar\@percentchar\space generated by the %
1710 `\@currenvir' \expandafter\@gobblefour\string\newenvironment^^J%
1711 \@percentchar\@percentchar\space from source `\jobname' on %
1712 \number\year/\two@digits\month/\two@digits\day.^^J%
1713 \@percentchar\@percentchar}%
1715 \let\do\@makeother\dospecials%
1718 % \changes{v1.0y}{1997/10/10}
1719 % {Check for text before or after \cs{end} environment. latex/2636}
1721 \edef\E{\@backslashchar end\string{\@currenvir\string}}%
1723 \def\noexpand\reserved@b%
1724 ####1\E####2\E####3\relax}%
1726 \ifx\relax##3\relax%
1728 % There was no |\end{filecontents}|
1730 \immediate\write\reserved@c{##1}%
1733 % There was a |\end{filecontents}|, so stop this time.
1735 \edef^^M{\noexpand\end{\@currenvir}}%
1736 \ifx\relax##1\relax%
1739 % Text before the |\end|, write it with a warning.
1741 \@latex@warning{Writing text `##1' before %
1742 \string\end{\@currenvir}\MessageBreak as last line of #1}%
1743 \immediate\write\reserved@c{##1}%
1745 \ifx\relax##2\relax%
1748 % Text after the |\end|, ignore it with a warning.
1751 Ignoring text `##2' after \string\end{\@currenvir}}%
1758 \catcode`\^^L\active%
1760 \def^^L{\@ifundefined L^^J^^J^^J}%
1761 \catcode`\^^I\active%
1763 \def^^I{\@ifundefined I\space\space}%
1764 \catcode`\^^M\active%
1766 \noexpand\reserved@b##1\E\E\relax}}%
1772 \catcode`|=\catcode`\%
1775 \gdef\@percentchar{%}
1776 \gdef\endfilecontents{|
1777 \immediate\closeout\reserved@c
1779 \ifx##1\@undefined\else
1780 \@latex@warning@no@line{##2 has been converted to Blank ##3e}|
1782 \T\L{Form Feed}{Lin}|
1784 \immediate\write\@unused{}}
1785 \global\let\endfilecontents*\endfilecontents
1786 \@onlypreamble\filecontents
1787 \@onlypreamble\endfilecontents
1788 \@onlypreamble\filecontents*
1789 \@onlypreamble\endfilecontents*
1791 \@onlypreamble\filec@ntents
1797 % \changes{v0.2f}{1993/11/22}
1798 % {\cs{@unknownversion} removed}
1799 % \changes{v1.0j}{1994/10/18}
1800 % {Move \cs{listfiles} to ltfiles.dtx}
1806 % \section{After Preamble}
1807 % Finally we declare a package that allows all the commands declared
1808 % above to be |\@onlypreamble| to be used after |\begin{document}|.
1809 % \changes{v0.3f}{1994/03/16}
1810 % {Add pkgindoc package}
1811 % \changes{v1.1a}{1998/03/21}
1812 % {Correct to new onlypreamble command list}
1815 \NeedsTeXFormat{LaTeX2e}
1816 \ProvidesPackage{pkgindoc}
1817 [1994/10/20 v1.1 Package Interface in Document (DPC)]
1818 \def\reserved@a#1\do\@classoptionslist#2\do\filec@ntents#3\relax{%
1819 \gdef\@preamblecmds{#1#3}}
1820 \expandafter\reserved@a\@preamblecmds\relax