forked from latex3/latex2e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathltclass.dtx
2500 lines (2485 loc) · 82.9 KB
/
ltclass.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% Copyright 1993-2018
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
% -------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.txt'. See also `legal.txt' for additional
% information.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
%
% \iffalse
%%% From File: ltclass.dtx
%
%<*driver>
% \fi
\ProvidesFile{ltclass.dtx}
[2018/05/29 v1.2j LaTeX Kernel (Class & Package Interface)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltclass.dtx}
\begin{document}
\title{The main structure of documents}
\author{Frank Mittelbach\and Chris Rowley\and Alan Jeffrey\and
David Carlisle}
\date{\filedate}
\MaintainedByLaTeXTeam{latex}
\maketitle
\DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \iffalse
% (C) Copyright Frank Mittelbach, Chris Rowley,
% Alan Jeffrey and David Carlisle 1993-1998.
% All rights reserved.
% \fi
%
%
% \changes{v0.2f}{1993/11/22}
% {\cs{@unknownversion} removed}
% \changes{v1.0j}{1994/10/18}
% {Move \cs{listfiles} to ltfiles.dtx}
% \changes{v1.0f}{1994/05/22}{Use new warning and error commands}
% \changes{v1.0l}{1994/11/17}{\cs{@tempa} to \cs{reserved@a}}
% \changes{v1.0z}{1998/03/21}{Added to documentation of filecontents}
% \changes{v1.1c}{1998/08/17}{(RmS) Minor documentation fixes.}
%
%
% \section{Introduction}
%
% This file implements the following declarations, which replace
% |\documentstyle| in \LaTeXe\ documents.
%
% Note that old documents containing |\documentstyle| will be run using
% a compatibility option---thus keeping everyone happy, we hope!
%
% The overall idea is that there are two types of `style files':
% `class files' which define elements and provide a default formatting
% for them; and `packages' which provide extra functionality. One
% difference between \LaTeXe\ and \LaTeX2.09 is that \LaTeXe\ packages
% may have options. Note that options to classes packages may be
% implemented such that they input files, but these file names are not
% necessarily directly related to the option name.
%
% \section{User interface}
%
% |\documentclass[|\meta{main-option-list}|]{|^^A
% \meta{class}|}[|\meta{version}|]|
%
% There must be exactly one such declaration, and it must come first.
% The \meta{main-option-list} is a list of options which can modify the
% formatting of elements which are defined in the \meta{class} file
% as well as in all following |\usepackage| declarations (see below).
% The \meta{version} is a version number, beginning with a date in the
% format |YYYY/MM/DD|. If an older version of the class is found, a
% warning is issued.
%
% \bigskip
%
% |\documentstyle[|\meta{main-option-list}|]{|^^A
% \meta{class}|}[|\meta{version}|]|
%
% The |\documentstyle| declaration is kept in order to maintain upward
% compatibility with \LaTeX2.09 documents. It is similar to
% |\documentclass|, but it causes all options in
% \meta{main-option-list} that the \meta{class} does not use to be
% passed to |\RequirePackage| after the options have been processed.
% This maintains compatibility with the 2.09 behaviour. Also a flag is
% set to indicate that the document is to be processed in \LaTeX2.09
% compatibility mode. As far as most packages are concerned, this
% only affects the warnings and errors \LaTeX\ generates. This flag
% does affect the definition of font commands, and |\sloppy|.
%
% \bigskip
%
% |\usepackage[|\meta{package-option-list}|]{|^^A
% \meta{package-list}|}[|\meta{version}|]|
%
% There can be any number of these declarations. All packages in
% \meta{package-list} are called with the same options.
%
% Each \meta{package} file defines new elements (or modifies those
% defined in the \meta{class}), and thus extends the range of documents
% which can be processed.
% The \meta{package-option-list} is a list of options which can modify
% the formatting of elements defined in the \meta{package} file.
% The \meta{version} is a version number, beginning with a date in the
% format |YYYY/MM/DD|. If an older version of the package is found, a
% warning is issued.
%
% Each package is loaded only once. If the same package is requested
% more than once, nothing happens, unless the package has been requested
% with options that were not given the first time it was loaded, in
% which case an error is produced.
%
% As well as processing the options given in the
% \meta{package-option-list}, each package processes the
% \meta{main-option-list}. This means that options that affect all
% of the packages can be given globally, rather than repeated for every
% package.
%
% Note that class files have the extension |.cls|, packages have the
% extension |.sty|.
%
% \DescribeEnv{filecontents}
% The environment |filecontents| is intended for passing the contents
% of packages, options, or other files along with a document in a
% single file.
% It has one argument, which is the name of the file to create. If that
% file already exists (maybe only in the current directory if the OS
% supports a notion of a `current directory' or `default directory')
% then nothing happens
% (except for an information message) and the body of the environment
% is bypassed. Otherwise, the body of the environment is written
% verbatim to the file name given as the first argument, together with
% some comments about how it was produced.
%
% The environment is allowed only before |\documentclass| to ensure
% that all packages or options necessary for this particular run are
% present when needed. The begin and end tags should each be on a
% line by itself. There is also a star-form; this does not write
% extra comments into the file.
%
% \subsection{Option processing}
%
% When the options are processed, they are divided into two types: {\em
% local\/} and {\em global}:
% \begin{itemize}
%
% \item For a class, the options in the |\documentclass| command are
% local.
%
% \item For a package, the options in the |\usepackage| command are
% local, and the options in the |\documentclass| command are global.
%
% \end{itemize}
% The options for |\documentclass| and |\usepackage|
% are processed in the following way:
% \begin{enumerate}
%
% \item The local and global options that have been declared
% (using |\DeclareOption| as described below) are processed
% first.
%
% In the case of |\ProcessOptions|, they are processed in the order
% that they were declared in the class or package.
%
% In the case of |\ProcessOptions*|, they are processed in the order
% that they appear in the option-lists. First the global options, and
% then the local ones.
%
% \item Any remaining local options are dealt with using the default
% option (declared using the |\DeclareOption*| declaration described
% below). For document classes, this usually does nothing, but
% records the option on a list of unused options.
% For packages, this usually produces an error.
%
% \end{enumerate}
% Finally, when |\begin{document}| is reached, if there are any global
% options which have not been used by either the class or any package,
% the system will produce a warning.
%
%
% \section{Class and Package interface}
%
% \subsection{Class name and version}
%
% \DescribeMacro\ProvidesClass
% A class can identify itself with the
% |\ProvidesClass{|\meta{name}|}[|\meta{version}|]| command. The
% \meta{version} should begin with a date in the format |YYYY/MM/DD|.
%
% \subsection{Package name and version}
%
% \DescribeMacro\ProvidesPackage
% A package can identify itself with the
% |\ProvidesPackage|\marg{name}\oarg{version} command. The
% \meta{version} should begin with a date in the format |YYYY/MM/DD|.
%
% \subsection{Requiring other packages}
%
% \DescribeMacro\RequirePackage
% Packages or classes can load other packages using\\
% |\RequirePackage|\oarg{options}\marg{name}\oarg{version}.\\
% If the package has already been loaded, then nothing happens unless
% the requested options are not a subset of the options with which it
% was loaded, in which case an error is called.
%
% \DescribeMacro\LoadClass
% Similar to |\RequirePackage|, but for classes, may not be used in
% package files.
%
% \DescribeMacro\PassOptionsToPackage
% Packages can pass options to other packages using:\\
% |\PassOptionsToPackage{|\meta{options}|}{|\meta{package}|}|.\\
% \DescribeMacro\PassOptionsToClass
% This adds the \meta{options} to the options list of any future
% |\RequirePackage| or |\usepackage| command. For example:
% \begin{verbatim}
% \PassOptionsToPackage{foo,bar}{fred}
% \RequirePackage[baz]{fred}\end{verbatim}
% is the same as:
% \begin{verbatim}
% \RequirePackage[foo,bar,baz]{fred}\end{verbatim}
%
% \DescribeMacro\LoadClassWithOptions
% |\LoadClassWithOptions|\marg{name}\oarg{version}:\\
% This is similar to
% |\LoadClass|, but it always calls class \meta{name} with
% exactly the same option list that is being used by the current class,
% rather than an option explicitly supplied or passed on by
% |\PassOptionsToClass|.
% \DescribeMacro\RequirePackageWithOptions
% |\RequirePackageWithOptions| is the analogous command for packages.
%
% This is mainly intended to allow one class to simply build on another,
% for example:
%\begin{verbatim}
% \LoadClassWithOptions{article}
%\end{verbatim}
%
% This should be contrasted with the slightly different construction
%\begin{verbatim}
% \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
% \ProcessOptions
% \LoadClass{article}
%\end{verbatim}
%
% As used here, the effects are more or less the same, but the
% version using |\LoadClassWithOptions| is slightly quicker
% (and less to type).
% If, however, the class declares options of its own then
% the two constructions are different; compare, for example:
%\begin{verbatim}
% \DeclareOption{landscape}{...}
% \ProcessOptions
% \LoadClassWithOptions{article}
%\end{verbatim}
% with:
%\begin{verbatim}
% \DeclareOption{landscape}{...}
% \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
% \ProcessOptions
% \LoadClass{article}
%\end{verbatim}
% In the first case, the \textsf{article} class will be called with
% option |landscape| precisely when the current class is called with
% this option; but in the second example it will
% not as in that case \textsf{article} is only passed options by the
% default option handler, which is not used for |landscape| as that
% option is explicitly declared.
%
% \DescribeMacro\@ifpackageloaded
% To find out if a package has already been loaded, use\\
% \DescribeMacro\@ifclassloaded
% |\@ifpackageloaded{|\meta{package}|}{|\meta{true}|}{|\meta{false}|}|.
%
% \DescribeMacro\@ifpackagelater
% \changes{v1.1i}{2013/07/07}{Correctly describe how the date in
% \cs{@ifpackagelater} is used}
% To find out if a package has already been loaded with a version
% equal to or more
% recent than \meta{version}, use\\
% \DescribeMacro\@ifclasslater
% |\@ifpackagelater{|\meta{package}|}{|\meta{version}|}{|^^A
% \meta{true}|}{|\meta{false}|}|.
%
% \DescribeMacro\@ifpackagewith
% To find out if a package has already been loaded with at least the
% options \meta{options}, use
% \DescribeMacro\@ifclasswith
% |\@ifpackagewith{|\meta{package}|}{|\meta{options}|}{|^^A
% \meta{true}|}{|\meta{false}|}|.
%
% There exists one package that can't be tested with the above
% commands: the \texttt{fontenc} package pretends that it was never
% loaded to allow for repeated reloading with different options (see
% \texttt{ltoutenc.dtx} for details).
%
%
% \subsection{Declaring new options}
%
% Options for classes and packages are built using the same macros.
%
% \DescribeMacro\DeclareOption To define a builtin option, use
% |\DeclareOption{|\meta{name}|}{|\meta{code}|}|.
%
% \DescribeMacro{\DeclareOption*} To define the default action to
% perform for local options which have not been declared, use
% |\DeclareOption*{|\meta{code}|}|.
%
% {\em Note\/}: there should be no use of\\
% |\RequirePackage|, |\DeclareOption|, |\DeclareOption*| or
% |\ProcessOptions|\\
% inside |\DeclareOption| or |\DeclareOption*|.
%
% Possible uses for |\DeclareOption*| include:
%
% |\DeclareOption*{}|\\
% Do nothing. Silently accept unknown options. (This suppresses the
% usual warnings.)
%
% |\DeclareOption*{\@unkownoptionerror}|\\
% Complain about unknown local options. (The initial setting for
% package files.)
%
% |\DeclareOption*{\PassOptionsToPackage{\CurrentOption}|^^A
% |{|\meta{pkg-name}|}|\\
% Handle the the current option by passing it on to the package
% \meta{pkg-name}, which will presumably be loaded via
% |\RequirePackage| later in the file. This is useful for building
% `extension' packages, that perhaps handle a couple of new options,
% but then pass everything else on to an existing package.
%
% |\DeclareOption*{\InputIfFileExists{xx-\CurrentOption.yyy}%|\\
% | {}%|\\
% | {\OptionNotUsed}}|\\
% Handle the option foo by loading the file |xx-foo.yyy| if it
% exists, otherwise do nothing, but declare that the option was not
% used.
% Actually the |\OptionNotUsed| declaration is only needed if this is
% being used in class files, but does no harm in package files.
%
%
% \subsection{Safe Input Macros}
% \DescribeMacro{\InputIfFileExists}
% |\InputIfFileExists{|\meta{file}|}{|\meta{then}|}{|\meta{else}|}|\\
% Inputs \meta{file} if it exists. Immediately before the input,
% \meta{then} is executed. Otherwise \meta{else} is executed.
%
% \DescribeMacro{\IfFileExists}
% As above, but does not input the file.
%
% One thing you might like to put in the \meta{else} clause is
%
% \DescribeMacro{\@missingfileerror}
% This starts an interactive request for a filename, supplying default
% extensions. Just hitting return causes the whole input to be skipped
% and entering |x| quits the current run,
%
% \DescribeMacro{\input}
% This has been redefined from the \LaTeX2.09 definition, in terms of
% the new commands |\InputIfFileExists| and |\@missingfileerror|.
%
%
% \DescribeMacro{\listfiles} Giving this declaration in the preamble
% causes a list of all files input via the `safe input' commands to be
% listed at the end. Any strings specified in the optional argument to
% |\ProvidesPackage| are listed alongside the file name. So files in
% standard (and other non-standard) distributions can put informative
% strings in this argument.
%
% \StopEventually{}
%
% \section{Implementation}
%
% \begin{macrocode}
%<*2ekernel>
% \end{macrocode}
%
%
% \changes{v0.2g}{1993/11/23}
% {Various macros now moved to latex.tex.}
% \changes{v0.2g}{1993/11/23}
% {Warnings and errors now directly coded.}
% \changes{v0.2h}{1993/11/28}
% {Primitive filenames now terminated by space not \cs{relax}.}
% \changes{v0.2h}{1993/11/28}
% {Directory syntax checing moved to dircheck.dtx}
% \changes{v0.2h}{1993/11/28}
% {Assorted commands now in the kernel removed.}
% \changes{v0.2i}{1993/12/03}
% {\cs{@onlypreamble}: Many commands declared.}
% \changes{v0.2i}{1993/12/03}
% {Removed obsolete \cs{@documentclass}}
% \changes{v0.2o}{1993/12/13}
% {Removed setting \cs{errorcontextlines}\ (now in latex.tex)}
% \changes{v0.2p}{1993/12/15}
% {Removed extra `.'s from \cs{@@warning}s}
% \changes{v0.2s}{1994/01/17}
% {Added many more \cs{@onlypreamble} commands}
% \changes{v0.2s}{1994/01/17}
% {Wrapped long lines to column 72}
% \changes{v0.3a}{1994/03/02}
% {Remove need for driver file}
% \changes{v0.3b}{1994/03/08}
% {Modify driver code into `new style'}
% \changes{v0.3c}{1994/03/12}
% {Change name from docclass to ltclass}
% \changes{v0.3h}{1994/04/25}
% {Removed spurious extra `.'s at the end of error messages}
% \changes{v1.0a}{1994/04/29}
% {Change version number to 1 (no other change)}
% \changes{v1.0k}{1994/11/03}
% {Move \cs{@missingfileerror} to ltfiles}
%
% \begin{macro}{\if@compatibility}
% The flag for compatibility mode.
% \begin{macrocode}
\newif\if@compatibility
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@documentclasshook}
% The hook called after the first |\documentclass| command. By
% default this checks to see if |\@normalsize| is undefined, and if
% so, sets it to |\normalsize|.
% \changes{v0.2q}{1993/12/17}
% {Macro added}
% \changes{v0.2z}{1994/02/10}
% {Changed the name from \cs{@compatibility} to
% \cs{@documentclasshook}, and added the check for whether
% \cs{@normalsize} has been defined. ASAJ.}
% \begin{macrocode}
\def\@documentclasshook{%
\ifx\@normalsize\@undefined
\let\@normalsize\normalsize
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@declaredoptions}
% This list is automatically built by |\DeclareOption|.
% It is the list of options (separated by commas) declared in
% the class or package file and it defines the order in which the
% the corresponding |\ds@|\meta{option} commands are executed.
% All local \meta{option}s which are not declared will be processed
% in the order defined by the optional argument of |\documentclass|
% or |\usepackage|.
% \begin{macrocode}
\let\@declaredoptions\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@classoptionslist}
% List of options of the main class.
% \changes{v1.0u}{1996/07/26}{made only preamble}
% \begin{macrocode}
\let\@classoptionslist\relax
\@onlypreamble\@classoptionslist
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@unusedoptionlist}
% \changes{v1.0u}{1996/07/26}{made only preamble}
% List of options of the main class that haven't been declared or
% loaded as class option files.
% \begin{macrocode}
\let\@unusedoptionlist\@empty
\@onlypreamble\@unusedoptionlist
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CurrentOption}
% Name of current package or option.
% \changes{v0.2c}{1993/11/17}
% {Name changed from \cs{@curroption}}
% \begin{macrocode}
\let\CurrentOption\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@currname}
% Name of current package or option.
% \begin{macrocode}
\let\@currname\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@currext}
% The current file extension.
% \changes{v0.2a}{1993/11/14}{Name changed from \cs{@currextension}}
% \begin{macrocode}
\global\let\@currext=\@empty
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@clsextension}
% \begin{macro}{\@pkgextension}
% The two possible values of |\@currext|.
% \begin{macrocode}
\def\@clsextension{cls}
\def\@pkgextension{sty}
\@onlypreamble\@clsextension
\@onlypreamble\@pkgextension
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@pushfilename}
% \begin{macro}{\@popfilename}
% \begin{macro}{\@currnamestack}
% Commands to push and pop the file name and extension. \\
% |#1| current name. \\
% |#2| current extension. \\
% |#3| current catcode of |@|. \\
% |#4| Rest of the stack.
% \begin{macrocode}
\def\@pushfilename{%
\xdef\@currnamestack{%
{\@currname}%
{\@currext}%
{\the\catcode`\@}%
\@currnamestack}}
\@onlypreamble\@pushfilename
% \end{macrocode}
%
% \begin{macrocode}
\def\@popfilename{\expandafter\@p@pfilename\@currnamestack\@nil}
\@onlypreamble\@popfilename
% \end{macrocode}
%
% \begin{macrocode}
\def\@p@pfilename#1#2#3#4\@nil{%
\gdef\@currname{#1}%
\gdef\@currext{#2}%
\catcode`\@#3\relax
\gdef\@currnamestack{#4}}
\@onlypreamble\@p@pfilename
% \end{macrocode}
%
% \begin{macrocode}
\gdef\@currnamestack{}
\@onlypreamble\@currnamestack
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@ptionlist}
% Returns the option list of the file.
% \begin{macrocode}
\def\@ptionlist#1{%
\@ifundefined{opt@#1}\@empty{\csname opt@#1\endcsname}}
\@onlypreamble\@ptionlist
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifpackageloaded}
% \begin{macro}{\@ifclassloaded}
% |\@ifpackageloaded{|\meta{name}|}|
% Checks to see whether a file has been loaded.
% \changes{v0.2t}{1994/01/18}
% {Fix typo \cs{@pkgetension}}
% \begin{macrocode}
\def\@ifpackageloaded{\@ifl@aded\@pkgextension}
\def\@ifclassloaded{\@ifl@aded\@clsextension}
\@onlypreamble\@ifpackageloaded
\@onlypreamble\@ifclassloaded
% \end{macrocode}
%
% \begin{macrocode}
\def\@ifl@aded#1#2{%
\expandafter\ifx\csname ver@#2.#1\endcsname\relax
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi}
\@onlypreamble\@ifl@aded
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@ifpackagelater}
% \begin{macro}{\@ifclasslater}
% |\@ifpackagelater{|\meta{name}|}{YYYY/MM/DD}|
% Checks that the package loaded is more recent than the given date.
% \begin{macrocode}
\def\@ifpackagelater{\@ifl@ter\@pkgextension}
\def\@ifclasslater{\@ifl@ter\@clsextension}
\@onlypreamble\@ifpackagelater
\@onlypreamble\@ifclasslater
% \end{macrocode}
%
% \begin{macrocode}
\def\@ifl@ter#1#2{%
\expandafter\@ifl@t@r
\csname ver@#2.#1\endcsname}
\@onlypreamble\@ifl@ter
%</2ekernel>
% \end{macrocode}
%
% This internal macro is also used in |\NeedsTeXFormat|.
% \changes{v0.2f}{1993/11/22}
% {Added //00 so parsing never produces a runaway argument.}
% \changes{v1.2d}{2018/02/18}
% {Added 0 up front to make bad data come out as 0.}
% \changes{v1.2g}{2018/04/08}
% {Strip leading spaces from dates.}
% \begin{macrocode}
%<latexrelease>\IncludeInRelease{2018/04/01}%
%<latexrelease> {\@ifl@t@r}{Guard against bad input}%
%<*2ekernel|latexrelease>
\def\@ifl@t@r#1#2{%
\ifnum\expandafter\@parse@version@#1//00\@nil<%
\expandafter\@parse@version@#2//00\@nil
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi}
\def\@parse@version@#1{\@parse@version0#1}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease> {\@ifl@t@r}{Guard against bad input}%
%<latexrelease>\def\@ifl@t@r#1#2{%
%<latexrelease> \ifnum\expandafter\@parse@version#1//00\@nil<%
%<latexrelease> \expandafter\@parse@version#2//00\@nil
%<latexrelease> \expandafter\@secondoftwo
%<latexrelease> \else
%<latexrelease> \expandafter\@firstoftwo
%<latexrelease> \fi}
%<latexrelease>\let\@parse@version@\@undefined
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
% \end{macrocode}
%
% \begin{macrocode}
\@onlypreamble\@ifl@t@r
% \end{macrocode}
%
% \changes{v1.1j}{2016/06/20}
% {don't declare as \cs{@onlypreamble}}
% \changes{v1.2c}{2017/03/08}
% {add \cs{@parse@version@dash} to support yyyy-mm-dd as well as yyyy/mm/dd }
% \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexreleasefirst>
\def\@parse@version#1/#2/#3#4#5\@nil{%
\@parse@version@dash#1-#2-#3#4\@nil
}
% \end{macrocode}
%
% The |\if| test here ensures that an argument with no |/| or |-| produces 0 (actually 00).
% \begin{macrocode}
\def\@parse@version@dash#1-#2-#3#4#5\@nil{%
\if\relax#2\relax\else#1\fi#2#3#4 }
%</2ekernel|latexreleasefirst>
%<*2ekernel>
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@ifpackagewith}
% \begin{macro}{\@ifclasswith}
% |\@ifpackagewith{|\meta{name}|}{|\meta{option-list}|}|
% Checks that \meta{option-list} is a subset of the options
% \textbf{with} which \meta{name} was loaded.
% \begin{macrocode}
\def\@ifpackagewith{\@if@ptions\@pkgextension}
\def\@ifclasswith{\@if@ptions\@clsextension}
\@onlypreamble\@ifpackagewith
\@onlypreamble\@ifclasswith
% \end{macrocode}
%
% \begin{macrocode}
\def\@if@ptions#1#2{%
\@expandtwoargs\@if@pti@ns{\@ptionlist{#2.#1}}}
\@onlypreamble\@if@ptions
% \end{macrocode}
%
% Probably shouldn't use |\CurrentOption| here\ldots (changed to
% |\reserved@b|.)
% \changes{v0.2y}{1994/02/07}
% {Add extra ,s so `two' is not matched with `twocolumn'}
% \changes{v1.1i}{2011/08/19}
% {Re-jig definition after more stringent \cs{in@} test.}
% \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2017/01/01}%
%<latexrelease> {\@if@pti@ns}{Spaces in option clash check}%
%<*2ekernel|latexrelease>
\def\@if@pti@ns#1#2{%
\let\reserved@a\@firstoftwo
% \end{macrocode}
% \changes{v1.2a}{2016/10/02}
% {Ignore spaces while checking for option clash}
% \begin{macrocode}
\edef\reserved@b{\zap@space#2 \@empty}%
\@for\reserved@b:=\reserved@b\do{%
\ifx\reserved@b\@empty
\else
\expandafter\in@\expandafter{\expandafter,\reserved@b,}{,#1,}%
\ifin@
\else
\let\reserved@a\@secondoftwo
\fi
\fi
}%
\reserved@a}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease> {\@if@pti@ns}{Spaces in option clash check}%
%<latexrelease>\def\@if@pti@ns#1#2{%
%<latexrelease> \let\reserved@a\@firstoftwo
%<latexrelease> \@for\reserved@b:=#2\do{%
%<latexrelease> \ifx\reserved@b\@empty
%<latexrelease> \else
%<latexrelease> \expandafter\in@\expandafter
%<latexrelease> {\expandafter,\reserved@b,}{,#1,}%
%<latexrelease> \ifin@
%<latexrelease> \else
%<latexrelease> \let\reserved@a\@secondoftwo
%<latexrelease> \fi
%<latexrelease> \fi
%<latexrelease> }%
%<latexrelease> \reserved@a}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
% \end{macrocode}
%
% \begin{macrocode}
\@onlypreamble\@if@pti@ns
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ProvidesPackage}
% Checks that the current filename is correct, and defines
% |\ver@filename|.
% \changes{v0.3c}{1994/03/12}
% {Add \cs{wlog}}
% \changes{v0.3c}{1994/03/12}
% {use \cs{@gtempa}}
% \begin{macrocode}
\def\ProvidesPackage#1{%
\xdef\@gtempa{#1}%
\ifx\@gtempa\@currname\else
\@latex@warning@no@line{You have requested
\@cls@pkg\space`\@currname',\MessageBreak
but the \@cls@pkg\space provides `#1'}%
\fi
\@ifnextchar[\@pr@videpackage{\@pr@videpackage[]}}%]
\@onlypreamble\ProvidesPackage
% \end{macrocode}
%
% \begin{macrocode}
\def\@pr@videpackage[#1]{%
\expandafter\xdef\csname ver@\@currname.\@currext\endcsname{#1}%
\ifx\@currext\@clsextension
\typeout{Document Class: \@gtempa\space#1}%
\else
\wlog{Package: \@gtempa\space#1}%
\fi}
\@onlypreamble\@pr@videpackage
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ProvidesClass}
% Like |\ProvidesPackage|, but for classes.
% \begin{macrocode}
\let\ProvidesClass\ProvidesPackage
\@onlypreamble\ProvidesClass
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ProvidesFile}
% Like |\ProvidesPackage|, but for arbitrary files. Do not apply
% |\@onlypreamble| to these, as we may want to label files input
% during the document.
% \changes{v0.2l}{1993/12/07}
% {Macro added}
% \changes{v0.3c}{1994/03/12}
% {Add \cs{wlog}}
% \changes{v0.3g}{1994/04/11}
% {Protect against weird catcodes.}
% \begin{macro}{\@providesfile}
% \changes{v1.0r}{1995/10/17}
% {Delay definition of \cs{ProvidesFile} till ltfinal}
% \changes{v1.1a}{1998/03/21}
% {Allow \&. Internal/2702}
% \changes{v1.1d}{2001/05/25}{Explicitly set catcode of
% \cs{endlinechar} to 10 (pr/3334)}
% \changes{v1.1e}{2001/06/04}{But only if it is a char (pr/3334)}
% \changes{v1.1f}{2001/08/26}{Readded setting of space char (pr/3353)}
% \begin{macrocode}
\def\ProvidesFile#1{%
\begingroup
\catcode`\ 10 %
\ifnum \endlinechar<256 %
\ifnum \endlinechar>\m@ne
\catcode\endlinechar 10 %
\fi
\fi
\@makeother\/%
\@makeother\&%
% \end{macrocode}
% \changes{v1.1g}{2004/01/28}{Use kernel version of
% \cs{@ifnextchar} (pr/3501)}
% \begin{macrocode}
\kernel@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}}
% \end{macrocode}
%
% During initex a special version of |\@providesfile| is used.
% The real definition is installed right at the end, in |ltfinal.dtx|.
%\begin{verbatim}
%\def\@providesfile#1[#2]{%
% \wlog{File: #1 #2}%
% \expandafter\xdef\csname ver@#1\endcsname{#2}%
% \endgroup}
%\end{verbatim}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\PassOptionsToPackage}
% \begin{macro}{\PassOptionsToClass}
% If the package has been loaded, we check that it was first loaded with
% the options. Otherwise we add the option list to that of the package.
% \begin{macrocode}
\def\@pass@ptions#1#2#3{%
\expandafter\xdef\csname opt@#3.#1\endcsname{%
\@ifundefined{opt@#3.#1}\@empty
{\csname opt@#3.#1\endcsname,}%
\zap@space#2 \@empty}}
\@onlypreamble\@pass@ptions
% \end{macrocode}
%
% \begin{macrocode}
\def\PassOptionsToPackage{\@pass@ptions\@pkgextension}
\def\PassOptionsToClass{\@pass@ptions\@clsextension}
\@onlypreamble\PassOptionsToPackage
\@onlypreamble\PassOptionsToClass
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\DeclareOption}
% \begin{macro}{\DeclareOption*}
% Adds an option as a |\ds@| command, or the default |\default@ds|
% command.
% \changes{v0.2c}{1993/11/17}
% {Error checking added}
% \changes{v1.0m}{1995/04/21}
% {Made long /1498}
% \changes{v1.0n}{1995/05/12}
% {Use \cs{toks@} to remove need to double hash /1557}
% \begin{macrocode}
\def\DeclareOption{%
\let\@fileswith@pti@ns\@badrequireerror
\@ifstar\@defdefault@ds\@declareoption}
\long\def\@declareoption#1#2{%
\xdef\@declaredoptions{\@declaredoptions,#1}%
\toks@{#2}%
\expandafter\edef\csname ds@#1\endcsname{\the\toks@}}
\long\def\@defdefault@ds#1{%
\toks@{#1}%
\edef\default@ds{\the\toks@}}
\@onlypreamble\DeclareOption
\@onlypreamble\@declareoption
\@onlypreamble\@defdefault@ds
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\OptionNotUsed}
% If we are in a class file, add |\CurrentOption| to the list of
% unused options. Otherwise, in a package file do nothing.
% \begin{macrocode}
\def\OptionNotUsed{%
\ifx\@currext\@clsextension
\xdef\@unusedoptionlist{%
\ifx\@unusedoptionlist\@empty\else\@unusedoptionlist,\fi
\CurrentOption}%
\fi}
\@onlypreamble\OptionNotUsed
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\default@ds}
% The default default option code.
% Set by |\@onefilewithoptions| to either |\OptionNotUsed| for
% classes, or |\@unknownoptionerror| for packages. This may be reset
% in either case with |\DeclareOption*|.
% \begin{macrocode}
% \let\default@ds\OptionNotUsed
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ProcessOptions}
% \begin{macro}{\ProcessOptions*}
% |\ProcessOptions| calls |\ds@option| for each known package option,
% then calls |\default@ds| for each option on the local options list.
% Finally resets all the declared options to |\relax|. The empty option
% does nothing, this has to be reset on the off chance it's set to
% |\relax| if an empty element gets into the |\@declaredoptions| list.
%
% The star form is similar but executes options given in the order
% specified in the document, not the order they are declared in the
% file. In the case of packages, global options are executed before
% local ones.
% \changes{v0.2a}{1993/11/14}
% {Stop adding the global option list inside class files.}
% \changes{v0.2a}{1993/11/14}
% {Optimise `empty option' code.}
% \changes{v0.2b}{1993/11/15}
% {Star form added.}
% \changes{v0.2c}{1993/11/17}
% {restoring \cs{@fileswith@pti@ns} added.}
% \begin{macrocode}
\def\ProcessOptions{%
\let\ds@\@empty
\edef\@curroptions{\@ptionlist{\@currname.\@currext}}%
\@ifstar\@xprocess@ptions\@process@ptions}
\@onlypreamble\ProcessOptions
% \end{macrocode}
%
% \changes{v0.2y}{1994/02/07}
% {Add extra ,s so `two' is not matched with `twocolumn'}
% \begin{macrocode}
\def\@process@ptions{%
\@for\CurrentOption:=\@declaredoptions\do{%
\ifx\CurrentOption\@empty\else
\@expandtwoargs\in@{,\CurrentOption,}{%
,\ifx\@currext\@clsextension\else\@classoptionslist,\fi
\@curroptions,}%
\ifin@
\@use@ption
\expandafter\let\csname ds@\CurrentOption\endcsname\@empty
\fi
\fi}%
\@process@pti@ns}
\@onlypreamble\@process@ptions
% \end{macrocode}
%
% \changes{v0.2y}{1994/02/07}
% {Add extra ,s so `two' is not matched with `twocolumn'}
% \begin{macrocode}
\def\@xprocess@ptions{%
\ifx\@currext\@clsextension\else
\@for\CurrentOption:=\@classoptionslist\do{%
\ifx\CurrentOption\@empty\else
\@expandtwoargs\in@{,\CurrentOption,}{,\@declaredoptions,}%
\ifin@
\@use@ption
\expandafter\let\csname ds@\CurrentOption\endcsname\@empty
\fi
\fi}%
\fi
\@process@pti@ns}
\@onlypreamble\@xprocess@ptions
% \end{macrocode}
%
% The common part of |\ProcessOptions| and |\ProcessOptions*|.
% \begin{macrocode}
\def\@process@pti@ns{%
\@for\CurrentOption:=\@curroptions\do{%
\@ifundefined{ds@\CurrentOption}%
{\@use@ption
\default@ds}%
% \end{macrocode}
% There should not be any non-empty definition of |\CurrentOption| at
% this point, as all the declared options were executed earlier. This is
% for compatibility with 2.09 styles which use |\def\ds@|\ldots\
% directly, and so have options which do not appear in
% |\@declaredoptions|.
% \begin{macrocode}
\@use@ption}%
% \end{macrocode}