summaryrefslogtreecommitdiff
path: root/macros/latex-dev/base/ltfssini.dtx
blob: e948aa4809c4723298b646be3594e2e56263c6d7 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
% \iffalse meta-comment
%
% Copyright (C) 1993-2020
% 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 2008 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: ltfssini.dtx
%% Copyright (C) 1989-2001 Frank Mittelbach and Rainer Sch\"opf,
%% all rights reserved.
%
%<*driver>
% \fi
%
%
\ProvidesFile{ltfssini.dtx}
             [2020/01/11 v3.1f LaTeX Kernel (NFSS Initialisation)]
% \iffalse
\documentclass{ltxdoc}
\begin{document}
\DocInput{ltfssini.dtx}
\end{document}
%</driver>
% \fi
%
% \iffalse
%<+checkmem>\def\CHECKMEM{\tracingstats=2
%<+checkmem>  \newlinechar=`\^^J
%<+checkmem>  \message{^^JMemory usage: \filename}\shipout\hbox{}}
%<+checkmem>\CHECKMEM
% \fi
%
%
%
% \GetFileInfo{ltfssini.dtx}
% \title{A new font selection scheme for \TeX{} macro packages\\
%        (Initialisation)\thanks
%       {This file has version number
%       \fileversion\ dated \filedate}}
%
% \author{Frank Mittelbach \and Rainer Sch\"opf}
%
% \MaintainedByLaTeXTeam{latex}
% \maketitle
%
% This file contains the top level \LaTeX\ interface to the font
% selection scheme commands. See other parts of the \LaTeX\
% distribution, or \emph{The \LaTeX\ Companion} for higher level
% documentation of these commands.
%
% \StopEventually{}
%
%
% \changes{v3.0i}{1998/08/17}{(RmS) Minor documentation fixes.}
% \changes{v3.0b}{1995/06/28}
%      {(DPC) Fix documentation typos}
% \changes{v3.0a}{1995/05/24}
%      {(DPC) Make file from previous file, lfonts.dtx 1995/05/23 v2.2e}
% \changes{v3.1b}{2016/10/15}
%      {Require e\TeX{}}
% \changes{v3.1d}{2019/08/27}{Make various commands robust}
%
%
% \section{NFSS Initialisation}
%
% \iffalse
%<+checkmem>\CHECKMEM
% \fi
%
%
% \changes{v2.2a}{1994/10/14}{New coding for cfg files}
% \changes{v2.1a}{1993/12/03}{update for LaTeX2e}
% \changes{v1.2c}{1992/01/06}{added slitex code}
% \changes{v1.2d}{1992/03/21}{Renamed \cs{text} to \cs{nfss@text}
%                            to make it internal.}
% \changes{v1.2a}{1991/11/27}{All \cs{family}, \cs{shape} etc. renamed
%                        to \cs{fontfamily} etc.}
% \changes{v1.1i}{1990/04/02}{\cs{input} of files now handled
%                          by docstrip.}
% \changes{v1.1g}{1990/02/08}{Protected the commands
%         \cs{family}, \cs{series},
%         \cs{shape}, \cs{size}, \cs{selectfont}, and \cs{mathversion}.}
% \changes{v1.1c}{1989/12/03}{Some internal macros renamed to make them
%           inaccessible.}
% \changes{v1.1b}{1989/12/02}{\cs{rmmath} renamed to \cs{mathrm}}
%
% \changes{v1.0i}{1989/11/07}{All family, series, and shape names
%           abbreviated.}
% \changes{v1.0g}{1989/05/22}{Lines shortened to 72 characters}
% \changes{v1.0f}{1989/04/29}{Corrections to \LaTeX\ tabular env.
%                         added.}
% \changes{v1.0e}{1989/04/27}{Definitions of \LaTeX\ symbols corrected.}
% \changes{v1.0d}{1989/04/26}{\cs{xpt} added.}
% \changes{v1.0c}{1989/04/21}{Changed to conform to fam.tex.}
% \changes{v1.0b}{1989/04/15}{\cs{mathfontset} renamed to
%                                              \cs{mathversion.}}
% \changes{v1.0a}{1989/04/10}{Starting with version numbers!
%           \cs{newif} for \cs{@tempswa} added since this switch is
%           unknown at the time when this file is read in.
%           (latex.tex is loaded later.)
%           \cs{math@famname} changed to \cs{math@version.}}
%
%
% \changes{v2.1j}{1994/05/13}{Removed file identification typeout}
%
% Finally, there are six commands that are to be used in \LaTeX{}
% and that we will therefore protect against expansion at the
% wrong point:
% |\fontfamily|, |\fontseries|, |\fontshape|, |\fontsize|,
% |\selectfont|, and |\mathversion|.
%
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontfamily} to fam.dtx}
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontencoding} to fam.dtx}
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontseries} to fam.dtx}
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontshape} to fam.dtx}
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontsize} to fam.dtx}
% \changes{v2.1i}{1994/05/12}{Moved \cs{mathversion} to fam.dtx}
% \changes{v2.1i}{1994/05/12}{Moved \cs{selectfont} to tracefnt.dtx}
%
%
%    \begin{macrocode}
%<*2ekernel>
%    \end{macrocode}
%
% \subsection{Providing math \emph{versions}}
%
%  \LaTeX{} provides two \emph{versions}. We call them
%  \textsf{normal} and \textsf{bold}, respectively.
%    \begin{macrocode}
\DeclareMathVersion{normal}
\DeclareMathVersion{bold}
%    \end{macrocode}
%
%
%    Now we define the standard font change commands.
%    We don't allow the use of |\rmfamily| etc.\ in math mode.
%
%    (Actually most are now defined further down in the file.)
%
%    First the changes to another \emph{family}:
%    \begin{macrocode}
%\DeclareRobustCommand\rmfamily
%        {\not@math@alphabet\rmfamily\mathrm
%         \fontfamily\rmdefault\selectfont}
%\DeclareRobustCommand\sffamily
%        {\not@math@alphabet\sffamily\mathsf
%         \fontfamily\sfdefault\selectfont}
%\DeclareRobustCommand\ttfamily
%        {\not@math@alphabet\ttfamily\mathtt
%         \fontfamily\ttdefault\selectfont}
%    \end{macrocode}
%    Then the commands changing the \emph{series}:
%    \begin{macrocode}
%\DeclareRobustCommand\bfseries
%        {\not@math@alphabet\bfseries\mathbf
%         \fontseries\bfdefault\selectfont}
%\DeclareRobustCommand\mdseries
%        {\not@math@alphabet\mdseries\relax
%         \fontseries\mddefault\selectfont}
\DeclareRobustCommand\upshape
        {\not@math@alphabet\upshape\relax
         \fontshape\updefault\selectfont}
%    \end{macrocode}
%    Then the commands changing the \emph{shape}:
%    \begin{macrocode}
\DeclareRobustCommand\slshape
        {\not@math@alphabet\slshape\relax
         \fontshape\sldefault\selectfont}
\DeclareRobustCommand\scshape
        {\not@math@alphabet\scshape\relax
         \fontshape\scdefault\selectfont}
\DeclareRobustCommand\itshape
        {\not@math@alphabet\itshape\mathit
         \fontshape\itdefault\selectfont}
%    \end{macrocode}
%
%
%
%
% \section{Custom series settings for main document families}
%
%    This section was introduced 2020/02/02 and for now we support a
%    full rollback (may need splitting later).        
% \changes{v3.1e}{2019/12/17}{Provide custom series settings a la mweights}
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2020/02/02}%
%<latexrelease>                 {\DeclareFontSeriesDefault}{Custom series}%
%    \end{macrocode}
%
%    One problem with the NFSS approach of handling the series axis
%    turned out to be that (especially with respect to ``boldness'')
%    different font families implemented different strategies. For
%    example, with Computer Modern fonts you normally only have
%    \texttt{bx} whereas most PostScript fonts offered only \texttt{b}
%    but not \texttt{bx}. As a result \LaTeX's standard setting for
%    \cs{bfdefault} didn't work with such fonts, but if it got changed
%    to produce \texttt{b}, then that didn't work with Computer Modern
%    if the fonts got combined (e.g., using Computer Modern Typewriter
%    with such fonts).
%
%    The solution back then was to provide substitution rules in the
%    font \texttt{.fd} such that if a \texttt{bx} series got requested
%    the \texttt{b} series got used. While this works in that
%    particular case, it isn't a very
%    general solution. For example, if you happen to have a font family that
%    has several weights you may want to typeset  the whole document
%    in a somewhat lighter or darker font but if you then modify
%    \cs{mddefault} to allow for this, then of course your change only
%    works with that particular family but not with the typewriter
%    or sans serif family you also want to use.
%
%    A better solution was provided by the \texttt{mweights} package by
%    Bob Tennent that offers defaults on the level of the three main
%    font families in the document: for ``rm'', ``sf'' and ``tt'' so
%    that font packages could define defaults for the sans serif
%    document font by providing \cs{bfseries@sf} which then was used
%    when \cs{bfseries} got executed and the current family was the
%    \cs{sffamily}.
%
%  \DescribeMacro\DeclareFontSeriesDefault
%    We now support this concept directly from within \LaTeX{} and for
%    use in font packages (or the document preamble) we offer
%    \cs{DeclareSeriesDefault}. This declaration takes three
%    arguments:
%   \begin{description}
%   \item[document family interface:] Can either be \texttt{rm},
%    \texttt{sf} or \texttt{tt}. This is optional and if not given the
%    overall default.
%   \item[document series interface:] Can be \texttt{md} or
%    \texttt{bf}.
%   \item[series value:] This is the value that is going to be used
%    with the combination is requested.
%  \end{description}
%
%    For example, \verb=\DeclareFontSeriesDefault[rm]{bf}{sb}= would
%    use \texttt{sb} (semi-bold) when \cs{rmfamily} \cs{bfseries} is
%    asked for.
%
%    If used without the optional argument, e.g.,
%    \verb=\DeclareFontSeriesDefault{bf}{b}=  then this is like
%    redefining \cs{bfdefault} or \cs{mddefault}.
%
%    If some family specify defaults aren't given, e.g. if there are
%    no declarations for, say, \texttt{tt} then the format defaults
%    of \cs{mddefault} and \cs{bfdefault} are assumed. If those are
%    later changed this is \emph{not} reflected!\footnote{I see no
%    easy way to achieve this without compromising compatibility with
%    existing packages that currently use \textsf{mweights} and directly
%    define (some) of the \cs{mdseries@..} commands but not others.}
%
%
%
%  \begin{macro}{\DeclareFontSeriesDefault}
%    The command to declare font series defaults for the ``rm'', ``sf'' or
%    ``tt'' family.
%    \begin{macrocode}
\newcommand\DeclareFontSeriesDefault[3][]{%
  \def\@reserveda{#1}%
%    \end{macrocode}
%    No optional argument: set up general default.
%    \begin{macrocode}
  \ifx\@resereda\@empty
    \ifcsname #2series\endcsname           % supported are
                                           % \[md/bf]default
      \expandafter\def
         \csname #2default\endcsname{#3}%                     
    \else
       \@latex@error{Wrong syntax for \string\DeclareFontSeriesDefault}%
          {Mandatory first argument must be 'md'  or 'bf'.}
    \fi
%    \end{macrocode}
%    Optional argument given, set up specific default.
%    \begin{macrocode}
  \else
    \ifcsname #2series@#1\endcsname          % supported are
                                             % \[md/bf]series@[rm/sf/tt]
      \expandafter\edef
         \csname #2series@#1\endcsname{#3}%                     
%    \end{macrocode}
%
%    If the interface is used we remove the frozen kernel
%    default. This way, we know that something was explicitly set up
%    (even if the setup has the same value as the default).
%    \begin{macrocode}
      \expandafter\let
         \csname #2series@#1@kernel\endcsname\@undefined
    \else
       \@latex@error{Wrong syntax for \string\DeclareFontSeriesDefault}%
          {Optional first argument must be 'rm', 'sf', or 'tt'. \MessageBreak
           Second argument must be 'md'  or 'bf'.}
    \fi
  \fi
}
%    \end{macrocode}
%  \end{macro}




%  \begin{macro}{\mdseries@rm}
%  \begin{macro}{\mdseries@sf}
%  \begin{macro}{\mdseries@tt}
%  \begin{macro}{\bfseries@rm}
%  \begin{macro}{\bfseries@sf}
%  \begin{macro}{\bfseries@tt}
%    We initialize the family specific default at the end of the
%    format generation. Later on they may get overwritten in the
%    preamble or a package via \cs{DeclareFontSeriesDefault} (or
%    possibly directly).
%
%    Conceptual change: The \cs{bfdefault} will be \texttt{b} not
%    \texttt{bx} because that is what it should be really for nearly
%    every font except Computer/Latin Modern.
%
%    To account for the fact that by default we typeset in CM or LM we
%    set up the \cs{bfseries@..} defaults to use \texttt{bx} instead.
%
%    This means that it behaves like before because if the default
%    fonts are used then \cs{bfseries@rm} etc kick in and make
%    \cs{textbf} use \texttt{bx}. However, if the font gets changed
%    then \cs{bfdefault} will get used.
%    
%    \begin{macrocode}
\def\bfseries@rm{bx}    
\def\bfseries@sf{bx}
\def\bfseries@tt{bx}
%    \end{macrocode}
%
%    Frozen version of the kernel defaults so we can see if they have changed.
%    \begin{macrocode}
\let\bfseries@rm@kernel\bfseries@rm
\let\bfseries@sf@kernel\bfseries@sf
\let\bfseries@tt@kernel\bfseries@tt
%    \end{macrocode}
%
%    The default for the medium series is \texttt{m} and this will be
%    interpreted as resetting both weight and width. To reset only one
%    of them the virtual value \texttt{?m} and \texttt{m?} are available.
%    \begin{macrocode}
\def\mdseries@rm{m}
\def\mdseries@sf{m}
\def\mdseries@tt{m}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}



%  \begin{macro}{\expand@font@defaults}
%
%    The family specific defaults are fully expanded, i.e., they are
%    defined via \cs{edef} inside \cs{DeclareFontSeriesDefault}.
%    However, the overall defaults, e.g., \cs{bfdefault} may have been
%    redefined by the user and thus may not be fully expanded. So to
%    enable reliable comparison we make expanded versions of
%    them. That we rerun each time. The alternative would be to only
%    allow for changes before begin document.
%    \begin{macrocode}
\def\expand@font@defaults{%
  \edef\rmdef@ult{\rmdefault}%
  \edef\sfdef@ult{\sfdefault}%
  \edef\ttdef@ult{\ttdefault}%
  \edef\bfdef@ult{\bfdefault}%
  \edef\mddef@ult{\mddefault}%
  \edef\famdef@ult{\familydefault}%
}
%    \end{macrocode}
%
%  \end{macro}



%  \begin{macro}{\bfseries}
%    This document command switches to the bold series.
%    \begin{macrocode}
\DeclareRobustCommand\bfseries{%
  \not@math@alphabet\bfseries\mathbf
%    \end{macrocode}
%    In the original NFSS definition it then called \cs{fontseries}
%    with the value \cs{bfdefault}. In the new scheme we have more
%    alternatives and therefore check if the current family
%    (\cs{f@family}) is the current \cs{rmdef@ult}, \cs{sfdef@ult} or
%    \cs{ttdef@ult}  and the select the correct family default in that case.
%    \begin{macrocode}
  \expand@font@defaults
  \fontseries{%
    \ifx\f@family\rmdef@ult      \bfseries@rm
    \else\ifx\f@family\sfdef@ult \bfseries@sf
    \else\ifx\f@family\ttdef@ult \bfseries@tt
%    \end{macrocode}
%    If not \cs{bfdefault} is used.
%    \begin{macrocode}
    \else                        \bfdefault
    \fi\fi\fi
  }%
  \selectfont
}
%    \end{macrocode}
%  \end{macro}



%  \begin{macro}{\mdseries}
%    This document command switches to the medium series.
%    \begin{macrocode}
\DeclareRobustCommand\mdseries{%
  \not@math@alphabet\mdseries\relax
  \expand@font@defaults
  \fontseries{%
    \ifx\f@family\rmdef@ult      \mdseries@rm
    \else\ifx\f@family\sfdef@ult \mdseries@sf
    \else\ifx\f@family\ttdef@ult \mdseries@tt
    \else                        \mddefault
    \fi\fi\fi
  }%
  \selectfont
}
%    \end{macrocode}
%  \end{macro}


%  \begin{macro}{\rmfamily}
%    Here are the document level commands for changing the main font
%    families, or rather, here is a documented outline of the code,
%    the actual code is then streamlined and somewhat generalized.
%\begin{verbatim}
%\DeclareRobustCommand\rmfamily{%
%  \not@math@alphabet\rmfamily\mathrm
%\end{verbatim}
%    If families are changed then we have to do a bit more work.
%    In the original NFSS implementation
%    a family change kept encoding, series shape and size unchanged
%    but now we can't any 
%    longer simply reuse the current series value. Instead we may have
%    to change it from one family default to the next.
%\begin{verbatim}
%  \expand@font@defaults
%\end{verbatim}
%    We have to do the testing while while the current family is still
%    unchanged but we have to do the adjustment of the series after it
%    got changed (because the new family might has different sets
%    ofshapes available and we certainly don't want to see
%    substituation going on. So we use \cs{target@series@value} to
%    hold the target series (if any).
%\begin{verbatim}
%  \let\target@series@value\@empty
%\end{verbatim}
%    Thus, if the current family is the sans family
%\begin{verbatim}
%  \ifx\f@family\sfdef@ult
%\end{verbatim}
%    and if we using the medium series of the sans family
%\begin{verbatim}
%       \ifx\f@series\mdseries@sf
%\end{verbatim}
%    then lets switch to the medium series for the serif family
%\begin{verbatim}
%                                       \let\target@series@value\mdseries@rm
%\end{verbatim}
%    and if we use the bold series of the sans family switch to the
%    bold default of the serif family:
%\begin{verbatim}
%       \else\ifx\f@series\bfseries@sf  \let\target@series@value\bfseries@rm
%\end{verbatim}
%    However, the sans family may not have any specific defaults set,
%    so we also compare with the overall defaults.
%\begin{verbatim}
%       \else\ifx\f@series\mddef@ult    \let\target@series@value\mdseries@rm
%       \else\ifx\f@series\bfdef@ult    \let\target@series@value\bfseries@rm
%\end{verbatim}
%    If neither test was true we leave the series alone. This way a
%    special manual setting such as \verb=\fontseries{lc}= is not
%    undone if the family changes (of course there may not be any
%    support for it in the new family but then the NFSS
%    substitution kicks in and  sorts it out).
%\begin{verbatim}
%       \fi\fi\fi\fi
%
%\end{verbatim}
%    We need to do the same if the current family is the typewriter family:
%\begin{verbatim}
%  \else\ifx\f@family\ttdef@ult
%       \ifx\f@series\mdseries@tt       \let\target@series@value\mdseries@rm
%       \else\ifx\f@series\bfseries@tt  \let\target@series@value\bfseries@rm
%       \else\ifx\f@series\mddef@ult    \let\target@series@value\mdseries@rm
%       \else\ifx\f@series\bfdef@ult    \let\target@series@value\bfseries@rm
%       \fi\fi\fi\fi
%  \fi\fi
%\end{verbatim}
%    With these preparations for series out of the way we can now
%    change the font family to \cs{rmdefault}.
%\begin{verbatim}
%  \fontfamily\rmdefault
%\end{verbatim}
%
%    If \cs{target@series@value} is still empty there is nothing more
%    to do other than selecting the new family. However, if not then
%    we should update the font series now as well. But there is one
%    further subtle issue. We may not have loaded an \texttt{.fd} file
%    for our target font family yet. In the past that was done in
%    \cs{selectfont} if necessary but since we are now doing all the
%    comparisons in \cs{fontseries} we need to make sure that the font
%    family specifications are already loaded prior to calling
%    \cs{fontseries}.
%\begin{verbatim}
%  \ifx\target@series@value\@empty \else
%    \maybe@load@fontshape
%\end{verbatim}
%    Updating the series in this case means directly changing
%    \cs{f@series} to the target value. We don't want to go through
%    \cs{fontseries} because that would apply the mappings and then
%    \texttt{bx + b} would keep \texttt{bx} instead of changing to
%    \texttt{b} as desired.
%    as 
%\begin{verbatim}
%    \let\f@series\target@series@value
%  \fi
%  \selectfont}
%\end{verbatim}
%
%    So now for the real definition: most of the code above gets
%    delegated to a helper command \cs{prepare@family@series@update}
%    so that the definition becomes again fairly short. In addition we
%    add a hook, mainly for our Japanese friends so that the code can
%    be extended prior to the call to \cs{selectfont}.
% 
% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
%    \begin{macrocode}
\DeclareRobustCommand\rmfamily{%
   \not@math@alphabet\rmfamily\mathrm
%    \end{macrocode}
%    This holds all the code discussed above, first argument is the
%    meta family, i.e., \texttt{rm} in this case, and second argument
%    is the default family name, e.g., \texttt{cmr} indirectly
%    accessed via \cs{rmdefault}. This is calling \cs{fontfamily} and
%    if necessary \cs{fontseries} as outline above.
%    \begin{macrocode}
   \prepare@family@series@update{rm}\rmdefault
%    \end{macrocode}
%    The comes the hook code (by default a no-op) and finally the call
%    to \cs{selectfont}.
%    \begin{macrocode}
   \@rmfamilyhook
   \selectfont}
%    \end{macrocode}
%
%  \begin{macro}{\sffamily}
%  \begin{macro}{\ttfamily}
%    The definitions for \cs{sffamily} and \cs{ttfamily} are similar,
%    the differences are only in what font families get checked.
% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
%    \begin{macrocode}
\DeclareRobustCommand\sffamily{%
   \not@math@alphabet\sffamily\mathsf
   \prepare@family@series@update{sf}\sfdefault
   \@sffamilyhook
   \selectfont}
%    \end{macrocode}
%
% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook}
%    \begin{macrocode}
\DeclareRobustCommand\ttfamily{%
   \not@math@alphabet\ttfamily\mathtt
   \prepare@family@series@update{tt}\ttdefault
   \@ttfamilyhook
   \selectfont}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%    
%  \begin{macro}{\@rmfamilyhook}
%  \begin{macro}{\@sffamilyhook}
%  \begin{macro}{\@ttfamilyhook}
%    By default the hooks do nothing.   
%    \begin{macrocode}
\let\@rmfamilyhook\@empty
\let\@sffamilyhook\@empty
\let\@ttfamilyhook\@empty
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}



%  \begin{macro}{\prepare@family@series@update}
%    This is core command that prepares for the family update. The big
%    difference to the documented code above is that the nested
%    \cs{ifx} statements seem to be missing. Instead we loop through
%    an internal list that holds the names of the three meta
%    families. This approach allows us to extend the mechanism at a
%    later stage to allow for additional named meta families.
%
%  \begin{macro}{\@meta@family@list}
%    Here is the current definition of that list:
%    \begin{macrocode}
\def\@meta@family@list{\@elt{rm}\@elt{sf}\@elt{tt}}
%    \end{macrocode}
%  \end{macro}
%    
%    \begin{macrocode}
\def\prepare@family@series@update#1#2{%
   \expand@font@defaults
%    \end{macrocode}
%    We prepare for changing the current series. We have to find it
%    before changing the family as discussed above.
%    \begin{macrocode}
   \let\target@series@value\@empty
   \def\target@meta@family@value{#1}%
%    \end{macrocode}
%    To find it we loop over the meta family list with a suitable
%    definition of \cs{@elt}.
%    \begin{macrocode}
   \let\@elt\update@series@target@value
      \@meta@family@list
   \let\@elt\relax
%    \end{macrocode}
%    That will figure out the correct series value to use without updating
%    it. Now we can change the family.
%    \begin{macrocode}
   \fontfamily#2%
%    \end{macrocode}
%    After that we update the series. That code is again like the one
%    above.
%    \begin{macrocode}
   \ifx\target@series@value\@empty
   \else
     \maybe@load@fontshape
     \let\f@series\target@series@value
   \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%  \begin{macro}{\update@series@target@value}
%    In this macro used in the look you basically find the nested
%    \cs{ifx}s from the outline above. The only difference is that is
%    it is parameterized instead of being written out and only for one
%    block of tests because the code is called reatedly when looping
%    over the meta family list. From the list we get each meta family
%    name in turn.
%    \begin{macrocode}
\def\update@series@target@value#1{%
%    \end{macrocode}
%    There is one additional test at the beginning, because the list
%    contains all meta families and we need to ignore the case where
%    current one from the list and target one are identical.
%    \begin{macrocode}
  \def\@reserveda{#1}%
  \ifx\target@meta@family@value\@reserveda   % rm -> rm do nothing
  \else
%    \end{macrocode}
%    We only ``do'' something if the current font family matches the
%    current meta family.
%    \begin{macrocode}
    \expandafter\ifx\csname#1def@ult\endcsname\f@family
%    \end{macrocode}
%    If that's the case we know that this is the block that applies
%    (only one meta family can match). So  to speed things up we
%    change \cs{@elt} so that the rest of the loop gets gobbled.
%    \begin{macrocode}
      \let\@elt\@gobble
%    \end{macrocode}
%    Then we try to find the right new value for the series (as
%    explained above). The two macros defined first are only there
%    because we now need to use \cs{csname} and this way the code will
%    be a little faster.
%    \begin{macrocode}
      \expandafter\let\expandafter\@reservedb
                      \csname mdseries@\target@meta@family@value\endcsname
      \expandafter\let\expandafter\@reservedc
                      \csname bfseries@\target@meta@family@value\endcsname
%    \end{macrocode}
%    This here is now identical to the nested \cs{ifx} block from the
%    outline, except that it there appeared twice in
%    \cs{rmfamily}. This is now covered by looping and stopping the
%    loop when a match was found.
%    \begin{macrocode}
      \expandafter\ifx\csname mdseries@#1\endcsname\f@series
                                      \let\target@series@value\@reservedb
      \else\expandafter\ifx\csname bfseries@#1\endcsname\f@series
                                      \let\target@series@value\@reservedc
      \else\ifx\f@series\mddef@ult    \let\target@series@value\@reservedb
      \else\ifx\f@series\bfdef@ult    \let\target@series@value\@reservedc
      \fi\fi\fi\fi
    \fi
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%
%
%
%
%
%
%
%
%  \begin{macro}{\init@series@setup}
%    This is code to be run at begin document \ldots
%    \begin{macrocode}
\def\init@series@setup{%
%    \end{macrocode}
%
%    We only want \texttt{bx} in \cs{bfseries@rm} if the roman font is
%    Computer Modern or Latin Modern, otherwise it should be
%    \texttt{b}. It was set to \texttt{bx} in the kernel so that any
%    font use with the default families in the preamble get this
%    value. Now at the real document start we check if the fonts have
%    been changed. If there was a \cs{DeclareFontSeriesDefault}
%    declaration or \cs{bfseries@rm} was directly altered then it
%    differs from \cs{bfseries@rm@kernel} and we do nothing.
%    Otherwise we check if \cs{rmdefault} is one of the CM/LM font
%    families and if so we keep \texttt{bx} otherwise we change it to
%    \texttt{b}.
%
%    This approach doesn't cover one case: CM/LM got changed to a
%    different family that supports \texttt{bx}, but the support
%    package for that family used \verb=\def\bfseries@rm{bx}= instead
%    of using  \cs{DeclareFontSeriesDefault}. In that case the code
%    here changes it to \texttt{b}. Solution: use the
%    \cs{DeclareFontSeriesDefault} interface.
%    \begin{macrocode}
  \ifx\bfseries@rm@kernel\bfseries@rm
    \expandafter\in@\expandafter{\rmdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
    \ifin@ \else \def\bfseries@rm{b}\fi\fi
%    \end{macrocode}
%    Same approach for \cs{bfseries@sf} and \cs{bfseries@tt}:
%    \begin{macrocode}
  \ifx\bfseries@sf@kernel\bfseries@sf
    \expandafter\in@\expandafter{\sfdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
    \ifin@ \else \def\bfseries@sf{b}\fi\fi
  \ifx\bfseries@tt@kernel\bfseries@tt
    \expandafter\in@\expandafter{\ttdefault}{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}%
    \ifin@ \else \def\bfseries@tt{b}\fi\fi
%    \end{macrocode}
%    
%    If the document preamble has changed the \cs{familydefault} or if
%    the if the \cs{rmdefault} contains a new font family, we have to
%    adjust the series defaults accordingly, before starting
%    typesetting.
%
%    On the other hand if we still typeset in CM or LM then
%    \cs{bfdefault} is wrong since it is now saying \texttt{b} and not
%    \texttt{bx}.
    
%    To fix this we run \cs{rmfamily}, \cs{sffamily} or
%    \cs{ttfamily} depending on the situation and this will correct
%    the setup for us.
%    \begin{macrocode}
  \expand@font@defaults
  \ifx\famdef@ult\rmdef@ult      \rmfamily
  \else\ifx\famdef@ult\sfdef@ult \sffamily
  \else\ifx\famdef@ult\ttdef@ult \ttfamily
  \fi\fi\fi
}%
%    \end{macrocode}
%  \end{macro}
%
%
%
%    As the kernel code now implements the same functionality as
%    \textsf{mweights}, albeit internally coded slightly differently,
%    that package shouldn't be loaded any more.  We therefore pretend
%    that it already got loaded. Thus, a font package that tries to
%    load it and then sets \cs{mdseries@..}, etc.\ will continue to
%    work but will now use the kernel code.
%
%    Of course, mid-term such package should probably use
%    \cs{DeclareFontSeriesDefault} instead of making using low-level
%    definitions.
%
%    \begin{macrocode}
\expandafter\let\csname ver@mweights.sty\endcsname\fmtversion
%    \end{macrocode}
%
%
%    
%    \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\DeclareFontSeriesDefault}{Custom series}%
%<latexrelease>
%<latexrelease>\let\DeclareFontSeriesDefault\@undefined
%<latexrelease>\let\bfseries@rm\@undefined
%<latexrelease>\let\bfseries@sf\@undefined
%<latexrelease>\let\bfseries@tt\@undefined
%<latexrelease>\let\bfseries@rm@kernel\@undefined
%<latexrelease>\let\bfseries@sf@kernel\@undefined
%<latexrelease>\let\bfseries@tt@kernel\@undefined
%<latexrelease>\let\mdseries@rm\@undefined
%<latexrelease>\let\mdseries@sf\@undefined
%<latexrelease>\let\mdseries@tt\@undefined
%<latexrelease>\let\expand@font@defaults\@undefined
%<latexrelease>\expandafter\let\csname ver@mweights.sty\endcsname\@undefined
%<latexrelease>
%<latexrelease>\DeclareRobustCommand\bfseries
%<latexrelease>        {\not@math@alphabet\bfseries\mathbf
%<latexrelease>         \fontseries\bfdefault\selectfont}
%<latexrelease>\DeclareRobustCommand\mdseries
%<latexrelease>        {\not@math@alphabet\mdseries\relax
%<latexrelease>         \fontseries\mddefault\selectfont}
%<latexrelease>\DeclareRobustCommand\rmfamily
%<latexrelease>        {\not@math@alphabet\rmfamily\mathrm
%<latexrelease>         \fontfamily\rmdefault\selectfont}
%<latexrelease>\DeclareRobustCommand\sffamily
%<latexrelease>        {\not@math@alphabet\sffamily\mathsf
%<latexrelease>         \fontfamily\sfdefault\selectfont}
%<latexrelease>\DeclareRobustCommand\ttfamily
%<latexrelease>        {\not@math@alphabet\ttfamily\mathtt
%<latexrelease>         \fontfamily\ttdefault\selectfont}
%<latexrelease>
%<latexrelease>\let\@rmfamilyhook\@undefined
%<latexrelease>\let\@sffamilyhook\@undefined
%<latexrelease>\let\@ttfamilyhook\@undefined
%<latexrelease>\let\@meta@family@list\@undefined
%<latexrelease>\let\prepare@family@series@update\@undefined
%<latexrelease>\let\update@series@target@value\@undefined
%<latexrelease>
%    \end{macrocode}
%    This is always called in \cs{document} so don't make it undefined.
%    \begin{macrocode}
%<latexrelease>\let\init@series@setup\relax
%<latexrelease>
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
       
%
%
%
% \section{Supporting nested emphasis}
%
%    By default \LaTeXe{} supports two levels of nested emphasis: if
%    the current font has an upright shape then it switches to
%    \cs{itshape} otherwise to \cs{eminnershape} (which defaults to
%    \cs{upshape}). This means nested emphasis will ocssilate between
%    italic and upright shapes.
%
%    Sometimes it would be nice to allow for a more lengthly sequence,
%    but instead of providing a fixed one \LaTeX{} now offers a
%    general mechanism that allows to define arbitrary sequences.
%
%    \DescribeMacro\DeclareEmphSequence  
%    \DescribeMacro\emforce
%
%    This declaration expects a comma separated list of (font) change
%    declarations corresponding to increasing levels of emphasis.
%    The mechanism tries to be ``smart'' and verifies that the
%    declarations actually alter the font. If not it will ignore this
%    level and tries the next one---the assumption being that
%    there was a manual font change in the document to the font that
%    is now supposed to be used for emphasis. Of course, this only
%    works if the declarations in the list actually change the font
%    and not, say, just the color.
%    In such a case one has to use \cs{emforce} to which directs the
%    mechanism to use the level even if the font attributes haven't changed.
%
%  \DescribeMacro\emreset
%    If the nesting is so deep, that the specified  levels are
%    exhausted then \cs{emreset} is used as a final set of
%    declarations (which by default returns
%    back to the upright shape). Any additional nesting levels will
%    then reuse the list from its beginning. 
%
%
%
%  \begin{macro}{\DeclareEmphSequence}
%    
%    \cs{DeclareEmphSequence} expects a clist of declaration. Spaces in the
%    argument are dropped to avoid surious spaces in the output. The
%    declarations are additive. At the very end the shape is reset
%    using |\emreset| and |\emforce| so that this case is never
%    skipped.\footnote{Maybe we should not add \cs{emforce} but allow
%    that case to be  skipped as well. Of course, that might result in
%    an endless loop if somebody defines a sequence without any font
%    change and without \cs{emforce} but \ldots}
%    Further nested calls restart at the beginning.
% \changes{v3.1e}{2019/12/17}{Provide \cs{emph} sequences}
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2020/02/02}%
%<latexrelease>                 {\DeclareEmphSequence}{Nested emph}%
\def\DeclareEmphSequence#1{%
  \protected@edef\emfontdeclare@clist{\zap@space#1, \@empty\emforce\emreset}%
}
%    \end{macrocode}
%    By default the it is empty, in which case \cs{eminnershape} is
%    used by \LaTeX.
%    \begin{macrocode}
\let\emfontdeclare@clist\@empty  
%    \end{macrocode}
%  \end{macro}



%  \begin{macro}{\emrest}
%    Reset the font to upright and upper/lower case. With the default rules
%    using \cs{shapedefault} does that for us but to be on the safe side we
%    do it like this:
%    \begin{macrocode}
\DeclareRobustCommand\emreset{\upshape\ulcshape}
%    \end{macrocode}
%  \end{macro}



%  \begin{macro}{\em}
%    The new definition for \cs{em} (and implicitly \cs{emph} is like
%    it was before if \cs{emfontdeclare@clist} is empty.
%    \begin{macrocode}
\DeclareRobustCommand\em{%
  \@nomath\em
  \ifx\emfontdeclare@clist\@empty
    \ifdim \fontdimen\@ne\font >\z@
      \eminnershape \else \itshape \fi
  \else
%    \end{macrocode}
%    But if not we use the list to decide how to do emphasis.
%
%    We use the current font to check if the declarations have any
%    effect, so even a size change is allowed and identified as a
%    modification (but a color change, for example, isn't).  So first
%    we save the current status.
%    \begin{macrocode}
  \edef\em@currfont{\csname\curr@fontshape/\f@size\endcsname}%
%    \end{macrocode}
%    Then we grab the next element from the list and check if it can
%    be used.
%    \begin{macrocode}
    \expandafter\do@emfont@update\emfontdeclare@clist\do@emfont@update
  \fi
}
%    \end{macrocode}
%    
%    \begin{macrocode}
\def\eminnershape{\upshape}
%    \end{macrocode}
%  \end{macro}
%
%
%
%  \begin{macro}{\do@emfont@update}
%    We know that the list (if not empty) has at least 2 elements
%    separated by a comma, so we pick up the first in \texttt{\#1} and
%    the rest in \texttt{\#2}.
%    \begin{macrocode}
\def\do@emfont@update#1,#2\do@emfont@update{%
%    \end{macrocode}
%    First action is to alter the list and move the first entry to the end
%    \begin{macrocode}
  \def\emfontdeclare@clist{#2,#1}%  
%    \end{macrocode}
%    Then we execute current declaration. Appending |\selectfont| means one
%    can write just |\fontshape{it}}| and that works then too.
%    \begin{macrocode}
%  \typeout{Use: \detokenize{#1}}%
  #1\selectfont
%    \end{macrocode}
%    We then compare the current font with our saved version, but with
%    a slight twist: we add \cs{em@force} at the end of the
%    name. Normally this is empty so has no effect but if there was an
%    \cs{emforce} as part of \texttt{\#1} it will append a |/| to the
%    font name (making it invalid) thus this will then always fail the
%    test.
%
%    If the test fails we are done and the declarations will be used.
%    Otherwise we will try the next declaration in the sequence.
%    \begin{macrocode}
  \expandafter\ifx\csname \curr@fontshape/\f@size\em@force
%    \end{macrocode}
%    For the comparison with \cs{ifx} we have to exand
%    \cs{em@currfont} once as the relevant info is inside.
%    \begin{macrocode}
                          \expandafter\endcsname
                  \em@currfont
  \expandafter\do@emfont@update\emfontdeclare@clist\do@emfont@update
%    \end{macrocode}
%    If \cs{emforce} was used, we have to undo its effect:
%    \begin{macrocode}
  \else
    \let\em@force\@empty
  \fi
}
%    \end{macrocode}
%  \end{macro}



%  \begin{macro}{\emforce}
%  \begin{macro}{\em@force}
%    The definition of \cs{emforce} is simple: change \cs{em@force} to
%    make the above test always invalid.
%    \begin{macrocode}
\protected\def\emforce{\def\em@force{/}}
\let\em@force\@empty
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%  \end{macro}
%  \end{macro}



%
% \begin{macro}{\em}
% \changes{v1.2b}{1990/01/28}{Call to \cs{@nomath} added.}
% \changes{v3.1a}{2015/01/09}{Allow \cs{emph} to produce small caps (latexrelease)}
% \begin{macro}{\eminnershape}
% \changes{v3.1a}{2015/01/09}{macro added (latexrelease)}
%
%  These are the older definitions for \cs{em}, prior to 2020.
%
% We also have to define the {\em emphasize\/} font change command
% (i.e.\ |\em|). This command will look is the current font is
% sloped (i.e.\ has a positive |\fontdimen1|) and will then
% select either |\upshape| or |\itshape|.
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{2015/01/01}{\DeclareEmphSequence}{Nested emph}%
%<latexrelease>\let\DeclareEmphSequence\@undefined
%<latexrelease>\let\emfontdeclare@clist\@undefined
%<latexrelease>\let\emreset\@undefined
%<latexrelease>\let\do@emfont@update\@undefined
%<latexrelease>\let\emforce\@undefined
%<latexrelease>\let\em@force\@undefined
%<latexrelease>
%<latexrelease>\DeclareRobustCommand\em
%<latexrelease>        {\@nomath\em \ifdim \fontdimen\@ne\font >\z@
%<latexrelease>                       \eminnershape \else \itshape \fi}%
%<latexrelease>\EndIncludeInRelease
%<latexrelease>
%<latexrelease>\IncludeInRelease{0000/00/00}{\DeclareEmphSequence}{Nested emph}%
%<latexrelease>\DeclareRobustCommand\em
%<latexrelease>        {\@nomath\em \ifdim \fontdimen\@ne\font >\z@
%<latexrelease>                       \upshape \else \itshape \fi}%
%<latexrelease>\let\eminnershape\@undefined
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%  \begin{macro}{\not@math@alphabet}
%    This function generates an error message when it is called in
%    math mode. The same function should be defined in
%    \texttt{newlfont.sty}.
% \changes{v1.4d}{1992/09/21}{Macro defined.}
% \changes{v2.1e}{1994/01/17}{Message changed}
% \changes{v2.1f}{1994/01/18}{Message corrected}
% \changes{v2.1g}{1994/04/22}{Message changed again}
% \changes{v2.2d}{1995/04/02}{add \cs{noexpand} to second part of message}
%    \begin{macrocode}
\def\not@math@alphabet#1#2{%
   \relax
   \ifmmode
     \@latex@error{Command \noexpand#1invalid in math mode}%
        {%
         Please
         \ifx#2\relax
            define a new math alphabet^^J%
            if you want to use a special font in math mode%
          \else
%    \end{macrocode}
%    We have to a |\noexpand| below to prevent expansion of |#2|. In
%    case of |#1| we can omit this (due to the current definition of
%    robust commands since they do come out right there :-).
%    \begin{macrocode}
            use the math alphabet \noexpand#2instead of
            the #1command%
         \fi
         .
        }%
   \fi}
%    \end{macrocode}
%  \end{macro}
%
%
%
% Finally we provide two abbreviations to switch to the \LaTeX{}
% \emph{versions}.
%    \begin{macrocode}
\DeclareRobustCommand\boldmath{\@nomath\boldmath
              \mathversion{bold}}
\DeclareRobustCommand\unboldmath{\@nomath\unboldmath
              \mathversion{normal}}
%    \end{macrocode}
% Here we switch to the default math version by defining the internal
% macro |\math@version|. We dare not to call |\mathversion|
% at this place because this would call |\glb@settings|.
%    \begin{macrocode}
\def\math@version{normal}
%    \end{macrocode}
%
% \subsection{Miscellaneous}
%
% \begin{macro}{\newfont}
% \changes{v1.2g}{1991/03/30}{Definition added.}
% \changes{v2.2e}{1995/05/23}{Font assignment made local again.}
% \begin{macro}{\symbol}
% \changes{v1.2g}{1991/03/30}{Definition added.}
%    We start by defining a few macros that are part of
%    standard \LaTeX's user interface. The use of these functions is
%    not encouraged, but they will allow to process older documents
%    without changes to the source.
%    \begin{macrocode}
\def\newfont#1#2{\@ifdefinable#1{\font#1=#2\relax}}
%    \end{macrocode}
%    
%    \begin{macrocode}
\DeclareRobustCommand\symbol[1]{\char #1\relax}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@setfontsize}
% \begin{macro}{\@setsize}
%    This abbreviation is used by \LaTeX's user level size changing
%    commands, such as |\large|.
%    \begin{macrocode}
\def\@setfontsize#1#2#3{\@nomath#1%
%    \end{macrocode}
%    For the benefit of people relying on keeping the name of the
%    current font command saved in |\@currsize| we define it. To ensure
%    that |\@setfontsize| keeps being robust we omit this assignment
%    during times where |\protect| differs from |\@typeset@protect|.
% \changes{v1.4b}{1992/08/20}{Added \cs{@currsize}.}
% \changes{v2.2b}{1994/11/06}{Use \cs{@typeset@protect}}
%    \begin{macrocode}
    \ifx\protect\@typeset@protect
      \let\@currsize#1%
    \fi
    \fontsize{#2}{#3}\selectfont}
%    \end{macrocode}
%    For compatibility  we also define |\@setsize| the 209 command
%    \begin{macrocode}
%<*compat>
\def\@setsize#1#2#3#4{\@setfontsize#1{#4}{#2}}
%</compat>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\hexnumber@}
%    To set up \LaTeX's special math character
%    definitions we first provide a macro to generate hexadecimal
%    numbers.  It is a rather simple |\ifcase|.
% \changes{v?}{1992/11/13}{Made expandable.}
% \changes{v?}{1992/12/03}{Make it accept counters.}
%    \begin{macrocode}
\def\hexnumber@#1{\ifcase\number#1
 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or
 9\or A\or B\or C\or D\or E\or F\fi}
%    \end{macrocode}
%  \end{macro}
%
%
%
% \begin{macro}{\nfss@text}
% \changes{v1.1e}{1990/01/25}{Macro added.}
%    In it simplest form |\nfss@text| is an |\mbox|.  This will
%    produce unbreakable text outside math and inside math you will
%    get text with the same fonts as outside. The only drawback is
%    that such item won't change sizes in subscripts. But this
%    behavior can be easily changed. With the \texttt{amstex} style
%    option one will get a sub style called \texttt{amstext} which will
%    redefine the |\nfss@text| macro to produce correct text in all
%    sizes.
%
%    We have to use |\def| instead of the shorter |\let| since
%    |\mbox| is undefined when we reach this point.
% \changes{v1.1k}{1990/06/23}{Changed to \cs{mbox}.}
% \changes{v2.1n}{1994/05/17}{Added braces to allow use in subscripts}
%    \begin{macrocode}
\def\nfss@text#1{{\mbox{#1}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\copyright}
%    The definition of |\copyright| was changed so
%    that it works in other type styles,
%    and to make it robust. We leave the family untouched so that
%    the copyright notice will come out differently if a different
%    font family is in use.
%    This command is commented out, since it is now defined in
%    ltoutenc.dtx.
% \changes{v1.1m}{1991/03/28}{Extra braces added.}
% \changes{v2.1n}{1994/05/17}{Really add extra braces}
% \changes{v2.2c}{1994/12/02}{\cs{copyright} is now in ltoutenc.
%    ASAJ}
%    \begin{macrocode}
%\DeclareRobustCommand\copyright
%    {{\ooalign{\hfil
%     \raise.07ex\hbox{\mdseries\upshape c}\hfil\crcr
%     \mathhexbox20D}}}
%    \end{macrocode}
% \end{macro}
%
% \changes{v2.1a}{1993/11/24}{Removed \cs{xpt} stuff}
%
%
% \begin{macro}{\normalfont}
% \changes{v2.1a}{1993/11/11}{Macro added}
% \begin{macro}{\reset@font}
% \begin{macro}{\p@reset@font}
% \changes{v1.1n}{1991/08/26}{Macro introduced}
%    The macro |\reset@font| is used in \LaTeX{} to switch to a standard
%    font, in order to initialize the current font in situations where
%    typesetting is done in a new visual context (e.g.\ in a
%    footnote). We define it here to allow the test for the new
%    \LaTeX{} version above but nevertheless are able to run all kind
%    of mixtures.
% \changes{v1.1o}{1991/11/21}{Changed to protected version of macro.}
% \changes{v1.1o}{1991/11/21}{Added extra braces for robustness.}
%
%    The user interface name for |\reset@font| is |\normalfont|:
% \changes{v2.1k}{1994/05/14}{Remove surplus braces}
% \changes{v3.0f}{1995/10/16}{Added \cs{relax} after \cs{usefont},
%              as the latter eats up spaces.}
%    \begin{macrocode}
\DeclareRobustCommand\normalfont
                 {\usefont\encodingdefault
                          \familydefault
                          \seriesdefault
                          \shapedefault
                  \relax}
\let\reset@font\normalfont
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% We left out the special \LaTeX{} fonts which are not automatically
% included in the base version of the font selection since these fonts
% contain only a few characters which are also included in the AMS
% fonts so anybody who is using these fonts doesn't need them.
% But for compatibility reasons we will define these symbols.
%
% \changes{v2.1g}{1994/02/22}{Correct error message}
%    \begin{macrocode}
\def\not@base#1{\@latex@error
  {Command \noexpand#1not provided in base LaTeX2e}%
  {Load the latexsym or the amsfonts package to
   define this symbol}}
\def\mho{\not@base\mho}
\def\Join{\not@base\Join}
\def\Box{\not@base\Box}
\def\Diamond{\not@base\Diamond}
\def\leadsto{\not@base\leadsto}
\def\sqsubset{\not@base\sqsubset}
\def\sqsupset{\not@base\sqsupset}
\def\lhd{\not@base\lhd}
\def\unlhd{\not@base\unlhd}
\def\rhd{\not@base\rhd}
\def\unrhd{\not@base\unrhd}
%    \end{macrocode}
%
%
%
%    We now initialize all variables set by |\DeclareErrorFont|. These
%    values are not really important since they will be overwritten
%    later on by the definition in |fontdef.ltx|.
%
%    However, if \texttt{fontdef.cfg} is corrupted then at least a
%    hopefully suitable error font is present.
%
% \changes{v2.1k}{1994/05/14}{Init error font just before checking for
%                             fontdef.cfg}
%    \begin{macrocode}
\DeclareErrorFont{OT1}{cmr}{m}{n}{10}  %% don't modify this setting
                                       %% overwrite it in fontdef.cfg
                                       %% if necessary
%    \end{macrocode}
%    We also set some default values for |\f@family| etc. Note that we
%    don't yet have any encodings that comes later. In the past this
%    was implicitly done by |\DeclareErrorFont|.
% \changes{v3.1c}{2019/07/09}{Explicitly set some defaults}
%    \begin{macrocode}
\fontfamily{cmr}
\fontseries{m}
\fontshape{n}
\fontsize{10}{10}
%    \end{macrocode}
%
%
%
%
% We now load the customizable parts of NFSS.
% \changes{v3.0d}{1995/07/19}
%      {(DPC) TeX2 support}
% \changes{v3.0e}{1995/09/15}
%      {(DPC) Modify TeX2 message}
% \changes{v3.0g}{1995/11/01}
%      {(DPC) Switch meaning of \cs{@addtofilelist} for cfg files}
% \changes{v3.0h}{1996/12/06}
%      {(DPC) Remove *** from messages internal/2338}
%    \begin{macrocode}
\InputIfFileExists{fonttext.cfg}
           {\typeout{====================================^^J%
                     ^^J%
                      Local config file fonttext.cfg used^^J%
                     ^^J%
                     ====================================}%
             \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%
            }
           {\input{fonttext.ltx}}
\let\@addtofilelist\@gobble
%    \end{macrocode}
%
%
% Ditto for math although I don't think that we will get a lot of
% customisation :-)
%    \begin{macrocode}
\InputIfFileExists{fontmath.cfg}
           {\typeout{====================================^^J%
                     ^^J%
                      Local config file fontmath.cfg used^^J%
                     ^^J%
                     ====================================}%
             \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%
            }
           {\input{fontmath.ltx}}
\let\@addtofilelist\@gobble
%    \end{macrocode}
%
% Then we preload several fonts. This file might be customized
% \emph{without} changing the behavior of the format (i.e.\ necessary
% font definitions will be loaded at runtime if they are not
% preloaded).  This is done in the file \texttt{preload.ltx}.
%    \begin{macrocode}
\InputIfFileExists{preload.cfg}
           {\typeout{====================================^^J%
                     ^^J%
                      Local config file preload.cfg used^^J%
                     ^^J%
                     =====================================}%
             \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%
            }
           {\input{preload.ltx}}
\let\@addtofilelist\@gobble
%    \end{macrocode}
%
%
% \begin{macro}{\@acci}
% \begin{macro}{\@accii}
% \begin{macro}{\@acciii}
% \changes{v2.1m}{1994/05/16}{Define saved versions of accents}
%    We also save the values of some accents in |\@acci|, |\@accii|
%    and |\@acciii| so they can be restored by a |minipage| inside a
%    |tabbing| environment.
%    \begin{macrocode}
\let\@acci\' \let\@accii\` \let\@acciii\=
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\cal}
% \changes{v3.0a}{1995/05/24}
%      {(DPC) Remove definition}
% \begin{macro}{\mit}
% \changes{v3.0a}{1995/05/24}
%      {(DPC) Remove definition}
%    Here were the two old \meta{alphabet identifiers}.
% \end{macro}
% \end{macro}
%
%
% \iffalse
%<+checkmem>\CHECKMEM
% \fi
%
%    \begin{macrocode}
%</2ekernel>
%    \end{macrocode}
%
% \Finale
%