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 [2017/03/08 v1.2c 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}}
634 % \changes{v1.2c}{2017/03/08}
635 % {add \cs{@parse@version@dash} to support yyyy-mm-dd as well as yyyy/mm/dd }
639 \def\@parse@version#1/#2/#3#4#5\@nil{%
640 \@parse@version@dash#1-#2-#3#4\@nil
644 % The |\if| test here ensures that an argument with no |/| or |-| produces 0 (actually 00).
646 \def\@parse@version@dash#1-#2-#3#4#5\@nil{%
647 \if\relax#2\relax\else#1\fi#2#3#4 }
654 % \begin{macro}{\@ifpackagewith}
655 % \begin{macro}{\@ifclasswith}
656 % |\@ifpackagewith{|\meta{name}|}{|\meta{option-list}|}|
657 % Checks that \meta{option-list} is a subset of the options
658 % \textbf{with} which \meta{name} was loaded.
660 \def\@ifpackagewith{\@if@ptions\@pkgextension}
661 \def\@ifclasswith{\@if@ptions\@clsextension}
662 \@onlypreamble\@ifpackagewith
663 \@onlypreamble\@ifclasswith
667 \def\@if@ptions#1#2{%
668 \@expandtwoargs\@if@pti@ns{\@ptionlist{#2.#1}}}
669 \@onlypreamble\@if@ptions
672 % Probably shouldn't use |\CurrentOption| here\ldots (changed to
674 % \changes{v0.2y}{1994/02/07}
675 % {Add extra ,s so `two' is not matched with `twocolumn'}
676 % \changes{v1.1i}{2011/08/19}
677 % {Re-jig definition after more stringent \cs{in@} test.}
680 %<latexrelease>\IncludeInRelease{2017/01/01}%
681 %<latexrelease> {\@if@pti@ns}{Spaces in option clash check}%
682 %<*2ekernel|latexrelease>
683 \def\@if@pti@ns#1#2{%
684 \let\reserved@a\@firstoftwo
686 % \changes{v1.2a}{2016/10/02}
687 % {Ignore spaces while checking for option clash}
689 \edef\reserved@b{\zap@space#2 \@empty}%
690 \@for\reserved@b:=\reserved@b\do{%
691 \ifx\reserved@b\@empty
693 \expandafter\in@\expandafter{\expandafter,\reserved@b,}{,#1,}%
696 \let\reserved@a\@secondoftwo
701 %</2ekernel|latexrelease>
702 %<latexrelease>\EndIncludeInRelease
703 %<latexrelease>\IncludeInRelease{0000/00/00}%
704 %<latexrelease> {\@if@pti@ns}{Spaces in option clash check}%
705 %<latexrelease>\def\@if@pti@ns#1#2{%
706 %<latexrelease> \let\reserved@a\@firstoftwo
707 %<latexrelease> \@for\reserved@b:=#2\do{%
708 %<latexrelease> \ifx\reserved@b\@empty
709 %<latexrelease> \else
710 %<latexrelease> \expandafter\in@\expandafter
711 %<latexrelease> {\expandafter,\reserved@b,}{,#1,}%
712 %<latexrelease> \ifin@
713 %<latexrelease> \else
714 %<latexrelease> \let\reserved@a\@secondoftwo
718 %<latexrelease> \reserved@a}
723 \@onlypreamble\@if@pti@ns
728 % \begin{macro}{\ProvidesPackage}
729 % Checks that the current filename is correct, and defines
731 % \changes{v0.3c}{1994/03/12}
733 % \changes{v0.3c}{1994/03/12}
736 \def\ProvidesPackage#1{%
738 \ifx\@gtempa\@currname\else
739 \@latex@warning@no@line{You have requested
740 \@cls@pkg\space`\@currname',\MessageBreak
741 but the \@cls@pkg\space provides `#1'}%
743 \@ifnextchar[\@pr@videpackage{\@pr@videpackage[]}}%]
744 \@onlypreamble\ProvidesPackage
748 \def\@pr@videpackage[#1]{%
749 \expandafter\xdef\csname ver@\@currname.\@currext\endcsname{#1}%
750 \ifx\@currext\@clsextension
751 \typeout{Document Class: \@gtempa\space#1}%
753 \wlog{Package: \@gtempa\space#1}%
755 \@onlypreamble\@pr@videpackage
759 % \begin{macro}{\ProvidesClass}
760 % Like |\ProvidesPackage|, but for classes.
762 \let\ProvidesClass\ProvidesPackage
763 \@onlypreamble\ProvidesClass
767 % \begin{macro}{\ProvidesFile}
768 % Like |\ProvidesPackage|, but for arbitrary files. Do not apply
769 % |\@onlypreamble| to these, as we may want to label files input
770 % during the document.
771 % \changes{v0.2l}{1993/12/07}
773 % \changes{v0.3c}{1994/03/12}
775 % \changes{v0.3g}{1994/04/11}
776 % {Protect against weird catcodes.}
777 % \begin{macro}{\@providesfile}
778 % \changes{v1.0r}{1995/10/17}
779 % {Delay definition of \cs{ProvidesFile} till ltfinal}
780 % \changes{v1.1a}{1998/03/21}
781 % {Allow \&. Internal/2702}
782 % \changes{v1.1d}{2001/05/25}{Explicitly set catcode of
783 % \cs{endlinechar} to 10 (pr/3334)}
784 % \changes{v1.1e}{2001/06/04}{But only if it is a char (pr/3334)}
785 % \changes{v1.1f}{2001/08/26}{Readded setting of space char (pr/3353)}
787 \def\ProvidesFile#1{%
790 \ifnum \endlinechar<256 %
791 \ifnum \endlinechar>\m@ne
792 \catcode\endlinechar 10 %
798 % \changes{v1.1g}{2004/01/28}{Use kernel version of
799 % \cs{@ifnextchar} (pr/3501)}
801 \kernel@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}}
804 % During initex a special version of |\@providesfile| is used.
805 % The real definition is installed right at the end, in |ltfinal.dtx|.
807 %\def\@providesfile#1[#2]{%
808 % \wlog{File: #1 #2}%
809 % \expandafter\xdef\csname ver@#1\endcsname{#2}%
815 % \begin{macro}{\PassOptionsToPackage}
816 % \begin{macro}{\PassOptionsToClass}
817 % If the package has been loaded, we check that it was first loaded with
818 % the options. Otherwise we add the option list to that of the package.
820 \def\@pass@ptions#1#2#3{%
821 \expandafter\xdef\csname opt@#3.#1\endcsname{%
822 \@ifundefined{opt@#3.#1}\@empty
823 {\csname opt@#3.#1\endcsname,}%
824 \zap@space#2 \@empty}}
825 \@onlypreamble\@pass@ptions
829 \def\PassOptionsToPackage{\@pass@ptions\@pkgextension}
830 \def\PassOptionsToClass{\@pass@ptions\@clsextension}
831 \@onlypreamble\PassOptionsToPackage
832 \@onlypreamble\PassOptionsToClass
837 % \begin{macro}{\DeclareOption}
838 % \begin{macro}{\DeclareOption*}
839 % Adds an option as a |\ds@| command, or the default |\default@ds|
841 % \changes{v0.2c}{1993/11/17}
842 % {Error checking added}
843 % \changes{v1.0m}{1995/04/21}
845 % \changes{v1.0n}{1995/05/12}
846 % {Use \cs{toks@} to remove need to double hash /1557}
849 \let\@fileswith@pti@ns\@badrequireerror
850 \@ifstar\@defdefault@ds\@declareoption}
851 \long\def\@declareoption#1#2{%
852 \xdef\@declaredoptions{\@declaredoptions,#1}%
854 \expandafter\edef\csname ds@#1\endcsname{\the\toks@}}
855 \long\def\@defdefault@ds#1{%
857 \edef\default@ds{\the\toks@}}
858 \@onlypreamble\DeclareOption
859 \@onlypreamble\@declareoption
860 \@onlypreamble\@defdefault@ds
865 % \begin{macro}{\OptionNotUsed}
866 % If we are in a class file, add |\CurrentOption| to the list of
867 % unused options. Otherwise, in a package file do nothing.
870 \ifx\@currext\@clsextension
871 \xdef\@unusedoptionlist{%
872 \ifx\@unusedoptionlist\@empty\else\@unusedoptionlist,\fi
875 \@onlypreamble\OptionNotUsed
879 % \begin{macro}{\default@ds}
880 % The default default option code.
881 % Set by |\@onefilewithoptions| to either |\OptionNotUsed| for
882 % classes, or |\@unknownoptionerror| for packages. This may be reset
883 % in either case with |\DeclareOption*|.
885 % \let\default@ds\OptionNotUsed
889 % \begin{macro}{\ProcessOptions}
890 % \begin{macro}{\ProcessOptions*}
891 % |\ProcessOptions| calls |\ds@option| for each known package option,
892 % then calls |\default@ds| for each option on the local options list.
893 % Finally resets all the declared options to |\relax|. The empty option
894 % does nothing, this has to be reset on the off chance it's set to
895 % |\relax| if an empty element gets into the |\@declaredoptions| list.
897 % The star form is similar but executes options given in the order
898 % specified in the document, not the order they are declared in the
899 % file. In the case of packages, global options are executed before
901 % \changes{v0.2a}{1993/11/14}
902 % {Stop adding the global option list inside class files.}
903 % \changes{v0.2a}{1993/11/14}
904 % {Optimise `empty option' code.}
905 % \changes{v0.2b}{1993/11/15}
907 % \changes{v0.2c}{1993/11/17}
908 % {restoring \cs{@fileswith@pti@ns} added.}
910 \def\ProcessOptions{%
912 \edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
913 \@ifstar\@xprocess@ptions\@process@ptions}
914 \@onlypreamble\ProcessOptions
917 % \changes{v0.2y}{1994/02/07}
918 % {Add extra ,s so `two' is not matched with `twocolumn'}
920 \def\@process@ptions{%
921 \@for\CurrentOption:=\@declaredoptions\do{%
922 \ifx\CurrentOption\@empty\else
923 \@expandtwoargs\in@{,\CurrentOption,}{%
924 ,\ifx\@currext\@clsextension\else\@classoptionslist,\fi
928 \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
932 \@onlypreamble\@process@ptions
935 % \changes{v0.2y}{1994/02/07}
936 % {Add extra ,s so `two' is not matched with `twocolumn'}
938 \def\@xprocess@ptions{%
939 \ifx\@currext\@clsextension\else
940 \@for\CurrentOption:=\@classoptionslist\do{%
941 \ifx\CurrentOption\@empty\else
942 \@expandtwoargs\in@{,\CurrentOption,}{,\@declaredoptions,}%
945 \expandafter\let\csname ds@\CurrentOption\endcsname\@empty
950 \@onlypreamble\@xprocess@ptions
953 % The common part of |\ProcessOptions| and |\ProcessOptions*|.
955 \def\@process@pti@ns{%
956 \@for\CurrentOption:=\@curroptions\do{%
957 \@ifundefined{ds@\CurrentOption}%
961 % There should not be any non-empty definition of |\CurrentOption| at
962 % this point, as all the declared options were executed earlier. This is
963 % for compatibility with 2.09 styles which use |\def\ds@|\ldots\
964 % directly, and so have options which do not appear in
965 % |\@declaredoptions|.
969 % Clear all the definitions for option code. First set all the declared
970 % options to |\relax|, then reset the `default' and `empty' options. and
971 % the lst of declared options.
973 \@for\CurrentOption:=\@declaredoptions\do{%
974 \expandafter\let\csname ds@\CurrentOption\endcsname\relax}%
976 % \changes{v1.0r}{1995/10/17}
977 % {Reset \cs{CurrentOption} for graphics/1873}
979 \let\CurrentOption\@empty
980 \let\@fileswith@pti@ns\@@fileswith@pti@ns
981 \AtEndOfPackage{\let\@unprocessedoptions\relax}}
982 \@onlypreamble\@process@pti@ns
987 % \begin{macro}{\@options}
988 % |\@options| is a synonym for |\ProcessOptions*| for upward
989 % compatibility with \LaTeX2.09 style files.
991 \def\@options{\ProcessOptions*}
992 \@onlypreamble\@options
996 % \begin{macro}{\@use@ption}
997 % Execute the code for the current option.
998 % \changes{v0.2g}{1993/11/23}
999 % {Name changed from \cs{@executeoption}}
1000 % \changes{v1.0e}{1994/05/17}
1001 % {Execute option after removing from list, not before}
1004 \@expandtwoargs\@removeelement\CurrentOption
1005 \@unusedoptionlist\@unusedoptionlist
1006 \csname ds@\CurrentOption\endcsname}
1007 \@onlypreamble\@use@ption
1011 % \begin{macro}{\ExecuteOptions}
1012 % |\ExecuteOptions{|\meta{option-list}|}| executes the code declared
1014 % \changes{v0.2d}{1993/11/18}
1015 % {Use \cs{CurrentOption} not \cs{reserved@a}}
1016 % \changes{v0.2k}{1993/12/06}
1017 % {Preserve \cs{CurrentOption}.}
1020 %<latexrelease>\IncludeInRelease{2017/01/01}%
1021 %<latexrelease> {\@if@pti@ns}{Spaces in \ExecuteOptions}%
1022 %<*2ekernel|latexrelease>
1023 \def\ExecuteOptions#1{%
1025 % \changes{v1.2a}{2016/10/02}
1026 % {Ignore spaces in argument}
1027 % Use |\@fortmp| here as it is anyway cleared during |\@for| loop
1028 % so does not change any existing names.
1030 \edef\@fortmp{\zap@space#1 \@empty}%
1031 \def\reserved@a##1\@nil{%
1032 \@for\CurrentOption:=\@fortmp\do
1033 {\csname ds@\CurrentOption\endcsname}%
1034 \edef\CurrentOption{##1}}%
1035 \expandafter\reserved@a\CurrentOption\@nil}
1036 %</2ekernel|latexrelease>
1037 %<latexrelease>\EndIncludeInRelease
1038 %<latexrelease>\IncludeInRelease{0000/00/00}%
1039 %<latexrelease> {\@if@pti@ns}{Spaces in \ExecuteOptions}%
1040 %<latexrelease>\def\ExecuteOptions#1{%
1041 %<latexrelease> \def\reserved@a##1\@nil{%
1042 %<latexrelease> \@for\CurrentOption:=#1\do
1043 %<latexrelease> {\csname ds@\CurrentOption\endcsname}%
1044 %<latexrelease> \edef\CurrentOption{##1}}%
1045 %<latexrelease> \expandafter\reserved@a\CurrentOption\@nil}
1050 \@onlypreamble\ExecuteOptions
1054 % The top-level commands, which just set some parameters then call
1055 % the internal command, |\@fileswithoptions|.
1056 % \begin{macro}{\documentclass}
1057 % \changes{v1.0q}{1995/06/19}
1058 % {Dont redefine \cs{usepackage} in compat mode for /1634}
1059 % The main new-style class declaration.
1061 \def\documentclass{%
1062 \let\documentclass\@twoclasseserror
1063 \if@compatibility\else\let\usepackage\RequirePackage\fi
1064 \@fileswithoptions\@clsextension}
1065 \@onlypreamble\documentclass
1069 % \begin{macro}{\documentstyle}
1070 % 2.09 style class `style' declaration.
1071 % \changes{v0.2a}{1993/11/14}
1072 % {Added \cs{RequirePackage} \cs{@unusedoptionlist} stuff.}
1073 % \changes{v0.2b}{1993/11/15}
1074 % {Modified to match \cs{ProcessOption*}}
1075 % \changes{v0.2d}{1993/11/18}
1076 % {Modified \cs{RequirePackage} stuff.}
1077 % \changes{v0.2n}{1993/12/09}
1078 % {input 209 compatibility file.}
1079 % \changes{v0.2o}{1993/12/13}
1080 % {compatibility file now latex209.sty.}
1081 % \changes{v0.2q}{1993/12/17}
1082 % {Match Alan's new code.}
1083 % \changes{v0.2u}{1994/01/21}
1084 % {compatibility file now latex209.def.}
1086 \def\documentstyle{%
1087 \makeatletter\input{latex209.def}\makeatother
1089 \@onlypreamble\documentstyle
1093 % \begin{macro}{\RequirePackage}
1094 % Load package if not already loaded.
1096 \def\RequirePackage{%
1097 \@fileswithoptions\@pkgextension}
1098 \@onlypreamble\RequirePackage
1102 % \begin{macro}{\LoadClass}
1106 \ifx\@currext\@pkgextension
1108 {\noexpand\LoadClass in package file}%
1109 {You may only use \noexpand\LoadClass in a class file.}%
1111 \@fileswithoptions\@clsextension}
1112 \@onlypreamble\LoadClass
1116 % \begin{macro}{\@loadwithoptions}
1117 % \changes{v1.0t}{1995/11/14}{macro added}
1118 % Pass the current option list on to a class or package.
1119 % |#1| is |\@|\emph{cls-or-pkg}|extension|,
1120 % |#2| is |\RequirePackage| or |\LoadClass|,
1121 % |#3| is the class or package to be loaded.
1123 \def\@loadwithoptions#1#2#3{%
1124 \expandafter\let\csname opt@#3.#1\expandafter\endcsname
1125 \csname opt@\@currname.\@currext\endcsname
1127 \@onlypreamble\@loadwithoptions
1132 % \begin{macro}{\LoadClassWithOptions}
1133 % \changes{v1.0t}{1995/11/14}{macro added}
1134 % Load class `|#1|' with the current option list.
1136 \def\LoadClassWithOptions{%
1137 \@loadwithoptions\@clsextension\LoadClass}
1138 \@onlypreamble\LoadClassWithOptions
1142 % \begin{macro}{\RequirePackageWithOptions}
1143 % \changes{v1.0t}{1995/11/14}{macro added}
1144 % \changes{v1.0v}{1996/10/04}{Reset \cs{@unprocessedoptions} for /2269}
1145 % Load package `|#1|' with the current option list.
1147 \def\RequirePackageWithOptions{%
1148 \AtEndOfPackage{\let\@unprocessedoptions\relax}%
1149 \@loadwithoptions\@pkgextension\RequirePackage}
1150 \@onlypreamble\RequirePackageWithOptions
1154 % \begin{macro}{\usepackage}
1155 % To begin with, |\usepackage| produces an error. This is reset by
1157 % \changes{v0.2o}{1993/12/13}
1158 % {Fixed error handling}
1159 % \changes{v1.0h}{1994/05/23}{Remove argument if possible}
1161 \def\usepackage#1#{%
1163 {\noexpand \usepackage before \string\documentclass}%
1164 {\noexpand \usepackage may only appear in the document
1165 preamble, i.e.,\MessageBreak
1166 between \noexpand\documentclass and
1167 \string\begin{document}.}%
1169 \@onlypreamble\usepackage
1173 % \begin{macro}{\NeedsTeXFormat}
1174 % Check that the document is running on the correct system.
1175 % \changes{v0.2a}{1993/11/14}
1176 % {made more robust for alternative syntax for other formats.}
1177 % \changes{v0.2c}{1993/11/17}
1178 % {Name changed from \cs{NeedsFormat}}
1179 % \changes{v0.2d}{1993/11/18}
1180 % {\cs{fmtname} \cs{fmtversion} not \cs{@}\ldots}
1182 \def\NeedsTeXFormat#1{%
1183 \def\reserved@a{#1}%
1184 \ifx\reserved@a\fmtname
1185 \expandafter\@needsformat
1187 \@latex@error{This file needs format `\reserved@a'%
1188 \MessageBreak but this is `\fmtname'}{%
1189 The current input file will not be processed
1190 further,\MessageBreak
1191 because it was written for some other flavor of
1192 TeX.\MessageBreak\@ehd}%
1194 % If the file is not meant to be processed by \LaTeXe{} we stop
1195 % inputting it, but we do not end the run. We just end inputting
1197 % \changes{v1.0h}{1994/05/23}
1198 % {Don't stop completely when format is wrong}
1201 \@onlypreamble\NeedsTeXFormat
1209 \@onlypreamble\@needsformat
1212 % \changes{v1.0b}{1994/05/04}
1213 % {Changed wording of the warning}
1215 \def\@needsf@rmat[#1]{%
1216 \@ifl@t@r\fmtversion{#1}{}%
1217 {\@latex@warning@no@line
1218 {You have requested release `#1' of LaTeX,\MessageBreak
1219 but only release `\fmtversion' is available}}}
1220 \@onlypreamble\@needsf@rmat
1224 % \begin{macro}{\zap@space}
1225 % |\zap@space foo|\meta{space}|\@empty| removes all spaces from |foo|
1226 % that are not protected by |{ }| groups.
1228 \def\zap@space#1 #2{%
1230 \ifx#2\@empty\else\expandafter\zap@space\fi
1235 % \begin{macro}{\@fileswithoptions}
1236 % The common part of |\documentclass| and |\usepackage|.
1238 \def\@fileswithoptions#1{%
1240 {\@fileswith@ptions#1}%
1241 {\@fileswith@ptions#1[]}}
1242 \@onlypreamble\@fileswithoptions
1245 % \changes{v0.2f}{1993/11/22}
1246 % {Made the default [] not [\cs{@unknownversion}]}
1247 % \changes{v1.1h}{2007/08/05}
1248 % {Prevent loss of brackets PR/3965}
1250 \def\@fileswith@ptions#1[#2]#3{%
1252 {\@fileswith@pti@ns#1[{#2}]#3}%
1253 {\@fileswith@pti@ns#1[{#2}]#3[]}}
1254 \@onlypreamble\@fileswith@ptions
1256 % Then we do some work.
1258 % First of all, we define the global variables.
1259 % Then we look to see if the file has already been loaded.
1260 % If it has, we check that it was first loaded with at least the current
1262 % If it has not, we add the current options to the package options,
1263 % set the default version to be |0000/00/00|, and load the file if we
1265 % Then we check the version number.
1267 % Finally, we restore the old file name, reset the default option,
1268 % and we set the catcode of |@|.
1270 % For classes, we can immediately process the file. For other types,
1271 % |#2| could be a comma separated list, so loop through, processing
1272 % each one separately.
1273 % \changes{v0.2q}{1993/12/17}
1274 % {Add \cs{@compatibility} hook}
1275 % \changes{v0.2s}{1994/01/17}
1276 % {Modify to reduce parameter stack usage}
1277 % \changes{v0.2y}{1994/02/07}
1278 % {Run \cs{@compatibility} on the first class to start
1279 % (not the first to finish) }
1280 % \changes{v0.2z}{1994/02/10}
1281 % {Renamed \cs{@compatibility} to \cs{@documentclasshook}.
1283 % \changes{v1.1h}{2007/08/05}
1284 % {Prevent loss of brackets PR/3965}
1285 % \changes{v2.1b}{2016/11/09}
1286 % {Improve \cs{ifx} tests PR/4497}
1289 %<latexrelease>\IncludeInRelease{2017/01/01}%
1290 %<latexrelease> {\@fileswith@pti@ns}{ifx tests in \@fileswith@pti@ns}%
1291 %<*2ekernel|latexrelease>
1292 \def\@fileswith@pti@ns#1[#2]#3[#4]{%
1293 \ifx#1\@clsextension
1294 \ifx\@classoptionslist\relax
1295 \xdef\@classoptionslist{\zap@space#2 \@empty}%
1297 \@onefilewithoptions#3[{#2}][{#4}]#1%
1298 \@documentclasshook}%
1301 \@onefilewithoptions#3[{#2}][{#4}]#1}%
1305 % build up a list of calls to |\@onefilewithoptions|
1306 % (one for each package) without thrashing the parameter stack.
1308 \def\reserved@b##1,{%
1310 % If |#1| is |\@nnil| we have reached the end of the list
1311 % (older version used |\@nil| here but |\@nil| is undefined so |\ifx|
1312 % equal to all undefined commands)
1314 \ifx\@nnil##1\relax\else
1316 % If |\ifx\@nnil##1\n@nil| is true then |#1| is (presumably) empty
1317 % (Older code used |\relax| which is slighly easier to get into |#1|
1318 % by mistake, which would spoil this test.)
1320 \ifx\@nnil##1\@nnil\else
1324 \noexpand\@onefilewithoptions##1[{#2}][{#4}]%
1325 \noexpand\@pkgextension
1327 \expandafter\reserved@b
1329 \edef\reserved@a{\zap@space#3 \@empty}%
1330 \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nnil,}%
1333 %</2ekernel|latexrelease>
1337 %<latexrelease>\EndIncludeInRelease
1338 %<latexrelease>\IncludeInRelease{0000/00/00}%
1339 %<latexrelease> {\@fileswith@pti@ns}{ifx tests in \@fileswith@pti@ns}%
1340 %<latexrelease>\def\@fileswith@pti@ns#1[#2]#3[#4]{%
1341 %<latexrelease> \ifx#1\@clsextension
1342 %<latexrelease> \ifx\@classoptionslist\relax
1343 %<latexrelease> \xdef\@classoptionslist{\zap@space#2 \@empty}%
1344 %<latexrelease> \def\reserved@a{%
1345 %<latexrelease> \@onefilewithoptions#3[{#2}][{#4}]#1%
1346 %<latexrelease> \@documentclasshook}%
1347 %<latexrelease> \else
1348 %<latexrelease> \def\reserved@a{%
1349 %<latexrelease> \@onefilewithoptions#3[{#2}][{#4}]#1}%
1351 %<latexrelease> \else
1352 %<latexrelease> \def\reserved@b##1,{%
1353 %<latexrelease> \ifx\@nil##1\relax\else
1354 %<latexrelease> \ifx\relax##1\relax\else
1355 %<latexrelease> \noexpand\@onefilewithoptions##1[{#2}][{#4}]%
1356 %<latexrelease> \noexpand\@pkgextension
1358 %<latexrelease> \expandafter\reserved@b
1359 %<latexrelease> \fi}%
1360 %<latexrelease> \edef\reserved@a{\zap@space#3 \@empty}%
1361 %<latexrelease> \edef\reserved@a{%
1362 %<latexrelease> \expandafter\reserved@b\reserved@a,\@nil,}%
1364 %<latexrelease> \reserved@a}
1369 \@onlypreamble\@fileswith@pti@ns
1372 % Have the main argument as |#1|, so we only need one |\expandafter|
1374 % \changes{v0.2a}{1993/11/14}
1375 % {Moved resetting of \cs{default@ds}, \cs{ds@} and
1376 % \cs{@declaredoptions} here, from the end of
1377 % \cs{ProcessOptions}.}
1378 % \changes{v0.2f}{1993/11/22}
1379 % {Made the initial version [] not [\cs{@unknownversion}]}
1380 % \changes{v0.2m}{1993/12/07}
1381 % {Reset \cs{CurrentOption}}
1383 \def\@onefilewithoptions#1[#2][#3]#4{%
1385 \xdef\@currname{#1}%
1386 \global\let\@currext#4%
1387 \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty
1388 \let\CurrentOption\@empty
1392 % Grab everything in a macro, so the parameter stack is popped before
1393 % any processing begins.
1394 % \changes{v0.2s}{1994/01/17}
1395 % {Modify to reduce parameter stack usage}
1396 % \changes{v1.1b}{1998/05/07}
1397 % {Modify help message for latex/2805}
1400 \@ifl@aded\@currext{#1}%
1401 {\@if@ptions\@currext{#1}{#2}{}%
1403 {Option clash for \@cls@pkg\space #1}%
1404 {The package #1 has already been loaded
1405 with options:\MessageBreak
1406 \space\space[\@ptionlist{#1.\@currext}]\MessageBreak
1407 There has now been an attempt to load it
1408 with options\MessageBreak
1409 \space\space[#2]\MessageBreak
1410 Adding the global options:\MessageBreak
1412 \@ptionlist{#1.\@currext},#2\MessageBreak
1413 to your \noexpand\documentclass declaration may fix this.%
1415 Try typing \space <return> \space to proceed.}}}%
1416 {\@pass@ptions\@currext{#2}{#1}%
1418 % \changes{v0.3c}{1994/03/12}
1419 % {Do not use \cs{@pr@videpackage} to avoid typeout}
1422 \let\csname ver@\@currname.\@currext\endcsname\@empty
1424 {\@currname.\@currext}%
1426 {\@missingfileerror\@currname\@currext}%
1428 % |\@unprocessedoptions| will generate an error for each specified
1429 % option in a package unless a |\ProcessOptions| has appeared in the
1431 % \changes{v0.2v}{1994/01/29}
1432 % {All options raise error if no \cs{ProcessOptions} appears}
1433 % \changes{v0.2x}{1994/02/02}
1434 % {Only run the hook and options check if the file was loaded.}
1436 \let\@unprocessedoptions\@@unprocessedoptions
1437 \csname\@currname.\@currext-h@@k\endcsname
1438 \expandafter\let\csname\@currname.\@currext-h@@k\endcsname
1440 \@unprocessedoptions}
1444 \@ifl@ter\@currext{#1}{#3}{}%
1445 {\@latex@warning@no@line
1446 {You have requested,\on@line,
1447 version\MessageBreak
1448 `#3' of \@cls@pkg\space #1,\MessageBreak
1449 but only version\MessageBreak
1450 `\csname ver@#1.\@currext\endcsname'\MessageBreak
1453 % \changes{v0.2c}{1993/11/17}
1454 % {Added trap for two \cs{LoadClass} commands.}
1456 \ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi
1460 \@onlypreamble\@onefilewithoptions
1464 % \begin{macro}{\@@fileswith@pti@ns}
1465 % Save the definition (for error checking).
1466 % \changes{v0.2c}{1993/11/17}
1469 \let\@@fileswith@pti@ns\@fileswith@pti@ns
1470 \@onlypreamble\@@fileswith@pti@ns
1474 % \begin{macro}{\@reset@ptions}
1475 % Reset the default option, and clear lists of declared options.
1476 % \changes{v0.2a}{1993/11/14}{macro added}
1478 \def\@reset@ptions{%
1479 \global\ifx\@currext\@clsextension
1480 \let\default@ds\OptionNotUsed
1482 \let\default@ds\@unknownoptionerror
1484 \global\let\ds@\@empty
1485 \global\let\@declaredoptions\@empty}
1486 \@onlypreamble\@reset@ptions
1490 % \subsection{Hooks}
1492 % Allow code do be saved to be executed at specific later times.
1494 % Save things in macros, I considered using toks registers, (and
1495 % |\addto@hook| from the NFSS code, that would require stacking the
1496 % contents in the case of required packages, so just generate a new
1497 % macro for each package.
1498 % \begin{macro}{\@begindocumenthook}
1499 % \changes{v1.0s}{1995/10/20}
1500 % {Make setting conditional, for autoload version}
1501 % \begin{macro}{\@enddocumenthook}
1502 % Stuff to appear at the beginning or end of the document.
1504 \ifx\@begindocumenthook\@undefined
1505 \let\@begindocumenthook\@empty
1507 \let\@enddocumenthook\@empty
1512 % \begin{macro}{\g@addto@macro}
1513 % Globally add to the end of a macro.
1514 % \changes{v0.2a}{1993/11/14}{Made global}
1515 % \changes{v0.2w}{1994/01/31}
1516 % {Use toks register to avoid `hash' problems}
1517 % \changes{v1.0o}{1995/05/17}
1518 % {Make long for latex/1522}
1519 % \changes{v1.0w}{1996/12/17}
1520 % {Use \cs{begingroup} to save making a mathord}
1521 % \changes{v1.0x}{1997/02/05}
1522 % {missing percent /2402}
1524 \long\def\g@addto@macro#1#2{%
1526 \toks@\expandafter{#1#2}%
1527 \xdef#1{\the\toks@}%
1532 % \begin{macro}{\AtEndOfPackage}
1533 % \begin{macro}{\AtEndOfClass}
1534 % \begin{macro}{\AtBeginDocument}
1535 % \begin{macro}{\AtEndDocument}
1536 % The access functions.
1537 % \changes{v0.2a}{1993/11/14}
1538 % {Included extension in the generated macro name for package
1541 \def\AtEndOfPackage{%
1542 \expandafter\g@addto@macro\csname\@currname.\@currext-h@@k\endcsname}
1543 \let\AtEndOfClass\AtEndOfPackage
1544 \@onlypreamble\AtEndOfPackage
1545 \@onlypreamble\AtEndOfClass
1549 \def\AtBeginDocument{\g@addto@macro\@begindocumenthook}
1550 \def\AtEndDocument{\g@addto@macro\@enddocumenthook}
1551 \@onlypreamble\AtBeginDocument
1559 % \begin{macro}{\@cls@pkg}
1560 % The current file type.
1561 % \changes{v0.2i}{1993/12/03}
1562 % {Name changed to avoid clash with output routine.}
1565 \ifx\@currext\@clsextension
1570 \@onlypreamble\@cls@pkg
1574 % \begin{macro}{\@unknownoptionerror}
1577 \def\@unknownoptionerror{%
1579 {Unknown option `\CurrentOption' for \@cls@pkg\space`\@currname'}%
1580 {The option `\CurrentOption' was not declared in
1581 \@cls@pkg\space`\@currname', perhaps you\MessageBreak
1582 misspelled its name.
1583 Try typing \space <return>
1584 \space to proceed.}}
1585 \@onlypreamble\@unknownoptionerror
1589 % \begin{macro}{\@@unprocessedoptions}
1590 % Declare an error for each option, unless a |\ProcessOptions| occurred.
1591 % \changes{v0.2v}{1994/01/29}
1593 % \changes{v1.0t}{1995/11/14}{Allow empty option}
1595 \def\@@unprocessedoptions{%
1596 \ifx\@currext\@pkgextension
1597 \edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
1598 \@for\CurrentOption:=\@curroptions\do{%
1599 \ifx\CurrentOption\@empty\else\@unknownoptionerror\fi}%
1601 \@onlypreamble\@unprocessedoptions
1602 \@onlypreamble\@@unprocessedoptions
1606 % \begin{macro}{\@badrequireerror}
1607 % |\RequirePackage| or |\LoadClass| occurs in the options section.
1608 % \changes{v0.2c}{1993/11/17}
1611 \def\@badrequireerror#1[#2]#3[#4]{%
1613 {\noexpand\RequirePackage or \noexpand\LoadClass
1614 in Options Section}%
1615 {The \@cls@pkg\space `\@currname' is defective.\MessageBreak
1616 It attempts to load `#3' in the options section, i.e.,\MessageBreak
1617 between \noexpand\DeclareOption and \string\ProcessOptions.}}
1618 \@onlypreamble\@badrequireerror
1622 % \begin{macro}{\@twoloadclasserror}
1623 % Two |\LoadClass| in a class.
1624 % \changes{v0.2c}{1993/11/17}
1627 \def\@twoloadclasserror{%
1629 {Two \noexpand\LoadClass commands}%
1630 {You may only use one \noexpand\LoadClass in a class file}}
1631 \@onlypreamble\@twoloadclasserror
1635 % \begin{macro}{\@twoclasseserror}
1636 % Two |\documentclass| or |\documentstyle|.
1637 % \changes{v0.2h}{1993/11/28}
1640 \def\@twoclasseserror#1#{%
1642 {Two \noexpand\documentclass or \noexpand\documentstyle commands}%
1643 {The document may only declare one class.}\@gobble}
1644 \@onlypreamble\@twoclasseserror
1648 % \subsection{Providing shipment}
1650 % \begin{macro}{\two@digits}
1651 % Prefix a number less than 10 with `0'.
1653 \def\two@digits#1{\ifnum#1<10 0\fi\number#1}
1657 % \begin{macro}{\filecontents}
1658 % \begin{macro}{\endfilecontents}
1659 % This environment implements inline files.
1660 % The star-form does not write extra comments into the file.
1662 % \changes{v0.2h}{1993/11/28}
1663 % {Don't globally allocate a write stream (always use 15)}
1664 % \changes{v0.2r}{1993/12/19}{Different message when ignoring a file}
1665 % \changes{v0.3g}{1994/04/11}
1667 % dont write \cs{endinput} at the end of the file.}
1668 % \changes{v1.0c}{1994/05/11}
1669 % {Add checks for form feed and tab}
1670 % \changes{v1.0m}{1995/04/21}
1671 % {Close input check stream: latex/1487}
1672 % \changes{v1.0p}{1995/05/25}{Delete \cs{filec@ntents} after preamble}
1676 \catcode`\^^M\active%
1677 \catcode`\^^L\active\let^^L\relax%
1678 \catcode`\^^I\active%
1682 \gdef\filecontents{\@tempswatrue\filec@ntents}%
1683 \gdef\filecontents*{\@tempswafalse\filec@ntents}%
1687 \gdef\filec@ntents#1{%
1688 \openin\@inputcheck#1 %
1690 \@latex@warning@no@line%
1691 {Writing file `\@currdir#1'}%
1694 % \changes{v1.0y}{1997/10/10}
1695 % {\cs{reserved@c} not \cs{verbatim@out} to save a csname}
1697 \chardef\reserved@c15 %
1698 \ch@ck7\reserved@c\write%
1699 \immediate\openout\reserved@c#1\relax%
1703 % \changes{v1.0y}{1997/10/10}
1704 % {Use \cs{@gobbletwo}}
1706 \closein\@inputcheck%
1707 \@latex@warning@no@line%
1708 {File `#1' already exists on the system.\MessageBreak%
1709 Not generating it from this source}%
1710 \let\write\@gobbletwo%
1711 \let\closeout\@gobble%
1716 % \changes{v1.0y}{1997/10/10}
1717 % {\cs{@currenvir} in banner}
1719 \immediate\write\reserved@c{%
1720 \@percentchar\@percentchar\space%
1721 \expandafter\@gobble\string\LaTeX2e file `#1'^^J%
1722 \@percentchar\@percentchar\space generated by the %
1723 `\@currenvir' \expandafter\@gobblefour\string\newenvironment^^J%
1724 \@percentchar\@percentchar\space from source `\jobname' on %
1725 \number\year/\two@digits\month/\two@digits\day.^^J%
1726 \@percentchar\@percentchar}%
1728 \let\do\@makeother\dospecials%
1731 % \changes{v1.0y}{1997/10/10}
1732 % {Check for text before or after \cs{end} environment. latex/2636}
1734 \edef\E{\@backslashchar end\string{\@currenvir\string}}%
1736 \def\noexpand\reserved@b%
1737 ####1\E####2\E####3\relax}%
1739 \ifx\relax##3\relax%
1741 % There was no |\end{filecontents}|
1743 \immediate\write\reserved@c{##1}%
1746 % There was a |\end{filecontents}|, so stop this time.
1748 \edef^^M{\noexpand\end{\@currenvir}}%
1749 \ifx\relax##1\relax%
1752 % Text before the |\end|, write it with a warning.
1754 \@latex@warning{Writing text `##1' before %
1755 \string\end{\@currenvir}\MessageBreak as last line of #1}%
1756 \immediate\write\reserved@c{##1}%
1758 \ifx\relax##2\relax%
1761 % Text after the |\end|, ignore it with a warning.
1764 Ignoring text `##2' after \string\end{\@currenvir}}%
1771 \catcode`\^^L\active%
1773 \def^^L{\@ifundefined L^^J^^J^^J}%
1774 \catcode`\^^I\active%
1776 \def^^I{\@ifundefined I\space\space}%
1777 \catcode`\^^M\active%
1779 \noexpand\reserved@b##1\E\E\relax}}%
1785 \catcode`|=\catcode`\%
1788 \gdef\@percentchar{%}
1789 \gdef\endfilecontents{|
1790 \immediate\closeout\reserved@c
1792 \ifx##1\@undefined\else
1793 \@latex@warning@no@line{##2 has been converted to Blank ##3e}|
1795 \T\L{Form Feed}{Lin}|
1797 \immediate\write\@unused{}}
1798 \global\let\endfilecontents*\endfilecontents
1799 \@onlypreamble\filecontents
1800 \@onlypreamble\endfilecontents
1801 \@onlypreamble\filecontents*
1802 \@onlypreamble\endfilecontents*
1804 \@onlypreamble\filec@ntents
1810 % \changes{v0.2f}{1993/11/22}
1811 % {\cs{@unknownversion} removed}
1812 % \changes{v1.0j}{1994/10/18}
1813 % {Move \cs{listfiles} to ltfiles.dtx}
1819 % \section{After Preamble}
1820 % Finally we declare a package that allows all the commands declared
1821 % above to be |\@onlypreamble| to be used after |\begin{document}|.
1822 % \changes{v0.3f}{1994/03/16}
1823 % {Add pkgindoc package}
1824 % \changes{v1.1a}{1998/03/21}
1825 % {Correct to new onlypreamble command list}
1828 \NeedsTeXFormat{LaTeX2e}
1829 \ProvidesPackage{pkgindoc}
1830 [1994/10/20 v1.1 Package Interface in Document (DPC)]
1831 \def\reserved@a#1\do\@classoptionslist#2\do\filec@ntents#3\relax{%
1832 \gdef\@preamblecmds{#1#3}}
1833 \expandafter\reserved@a\@preamblecmds\relax