summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/base/ltfssdcl.dtx
blob: 25ac234848da10036da0dbf3c198e3f3a4db11ba (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
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
% \iffalse meta-comment
%
% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
% 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
%    http://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: ltfssdcl.dtx
%% Copyright (C) 1989-1998 Frank Mittelbach and Rainer Sch\"opf,
%% all rights reserved.
%
%<*driver>
% \fi
% 
%
\ProvidesFile{ltfssdcl.dtx}
            [2007/08/31 v3.0l LaTeX Kernel (NFSS Declarative Interface)]
% \iffalse
\documentclass{ltxdoc}
\begin{document}
\DocInput{ltfssdcl.dtx}
\end{document}
%</driver>
% \fi
%
% \iffalse
%<+checkmem>\def\CHECKMEM{\tracingstats=2
%<+checkmem>  \newlinechar=`\^^J
%<+checkmem>  \message{^^JMemory usage: \filename}\shipout\hbox{}}
%<+checkmem>\CHECKMEM
% \fi
%
% \CheckSum{1879}
%
%
% \GetFileInfo{ltfssdcl.dtx}
% \title{A new font selection scheme for \TeX{} macro packages\\
%        (Declarative Interface)\thanks
%       {This file has version number
%       \fileversion\ dated \filedate}}
%
% \author{Frank Mittelbach \and Rainer Sch\"opf}
%
% \maketitle
%
% This file contains the main implementation of the font selection
% scheme commands. See other parts of the \LaTeX\ distribution, or 
% \emph{The \LaTeX\ Companion} for higher level documentation of these
% commands.
%
% \begin{quote}
%   \textbf{Warning:} 
%  The macro documentation is still basically the documentation from the
%  first NFSS release and therefore in some cases probably not
%  completely accurate.
% \end{quote}
%
% \StopEventually{}
%
% \section{Interface Commands}
%
% \changes{v3.0i}{1998/08/17}
%      {(RmS) Corrected minor glitches in changes entries.}
% \changes{v3.0b}{1995/06/15}
%      {(DPC) minor documentation changes}
% \changes{v3.0a}{1995/05/24}
%      {(DPC) Make file from previous file, latint.dtx 1995/05/21 v2.1t}
%
%
% \changes{v2.1o}{1994/11/22}
%         {wrap long lines}
% \changes{v2.1m}{1994/11/17}
%         {\cs{@tempa} to \cs{reserved@a}}
% \changes{v2.1j}{1994/05/29}{Use new error commands}
% \changes{v2.1h}{1994/05/13}{Removed file identification typeout}
% \changes{v2.1g}{1994/05/12}{Allow \cs{relax}'ed cmds to be declared}
% \changes{v2.1g}{1994/05/12}{Allow \cs{relax} as undefined command}
% \changes{v2.1e}{1994/04/28}{Removed all \cs{uppercase} in hex num
%                             parsing macros}
% \changes{v2.1d}{1994/04/18}{Removed surplus \cs{no@alphabet@error}
%                             (see fam.dtx)}
%
%
%
% \changes{v2.1f}{1994/05/03}{Renamed \cs{@@DeclareMathDelimiter} to
%                             \cs{@DeclareMathDelimiter}}
% \changes{v2.1c}{1994/03/13}{add 2ekernel module to omit repeated code}
%
%
% \begin{macro}{\in@}
% \begin{macro}{\ifin@}
%    |\@in| is a utility macro with two arguments.  It determines
%    whether its first argument occurs in its second (after expanding
%    it) and sets the switch |\if@in| accordingly.
%    \begin{macrocode}
%<*2ekernel|autoload>
\def\in@#1#2{%
 \def\in@@##1#1##2##3\in@@{%
  \ifx\in@##2\in@false\else\in@true\fi}%
 \in@@#2#1\in@\in@@}
\newif\ifin@
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% Before the |\begin{document}| command several
% \meta{math versions} and \meta{math alphabet identifiers} may
% be declared.
% In principle, there should be exactly one family/series/shape
% combination be declared for each version/alphabet pair.
% But we want to allow for defaults as well for automagical
% filling of holes.
%
% While building the tables for math alphabet identifiers and math
% versions we keep several lists:
% \begin{itemize}
%   \item the list of all math versions, |\version@list|,
%         each entry prefixed by the control sequence |\version@elt|,
%         i.e.\ this list has the following form
%         \begin{quote}
%           |\version@elt|\meta{version$_1$}^^A
%           |\version@elt|\meta{version$_2$}\ldots\\\hspace*{\fill}^^A
%           |\version@elt|\meta{version$_n$}
%         \end{quote}
%   \item the list of all math alphabet identifiers.  Here every
%         entry has the form:\\[2pt]
%         \hspace*{\MacroIndent}
%         |\group@elt|\meta{math group number}\\
%         \hspace*{\MacroIndent}
%         |{{|\meta{default family}^^A
%         |}{|\meta{default series}^^A
%         |}{|\meta{default shape}|}}|.
%   \item Each defined math alphabet identifier holds a list containing
%         Information about the {\em versions\/} for which it is
%         defined.  This list has a more complicated structure: it
%         looks as follows:
%         \begin{quote}
%           |\set@alpha|\meta{the alphabet identifier itself}\\
%           \hspace*{\MacroIndent}
%             |\reserved@c|\meta{math version}\meta{font info}\\
%           \hspace*{\MacroIndent}\ldots\\
%           |\@nil|
%         \end{quote}
%         where \meta{font info} is either |\reserved@e|
%         (if the combination is not defined yet) or
%         \begin{quote}
%           |{{|\meta{family}|}{|\meta{series}^^A
%           |}{|\meta{shape}|}}|
%         \end{quote}
% \end{itemize}
%
% \begin{macro}{\version@list}
%    We initialize the version list to be empty.
%    \begin{macrocode}
\let\version@list=\@empty
\@onlypreamble\version@list
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\version@elt}
%    \begin{macrocode}
\let\version@elt\relax
\@onlypreamble\version@elt
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\new@mathversion}
%    The macro |\new@mathversion| is called with the version control
%    sequence as its argument.
%    \begin{macrocode}
%\def\new@mathversion#1{%
%    \end{macrocode}
%    The first thing this macro does is to check if the version
%    identifier is already present in |\version@list|.
%    We enclose |\version@list| in braces since it might be empty
%    (if no {\em version\/} is defined yet).  But this means that
%    we need a suitable number of |\expandafter| primitives.
%    \begin{macrocode}
%  \expandafter\in@\expandafter#1\expandafter{\version@list}%
%  \ifin@
%    \end{macrocode}
%    If so it prints an error message.
%    The |\next| macro is used to get rid of the four characters
%    |\mv@| that would otherwise appear at the begin of the
%    version name in the error message.
%    \begin{macrocode}
%    \@latex@error{Math version
%               `\expandafter\@gobblefour\string#1'
%               already defined}\@eha
%    \end{macrocode}
%    Otherwise we have a new version, and we can proceed with
%    entering it into the tables.
%    We add it to |\version@list|.  This is very easy:
%    we define |\version@elt| (which is the delimiter in
%    |\version@list|) to protect itself and the following token
%    from being expanded and simply redefine |\version@list|.
%    \begin{macrocode}
%  \else
%     \global\expandafter\newcount\csname c@\expandafter
%                                 \@gobble\string#1\endcsname
%     \global\csname c@\expandafter
%                                 \@gobble\string#1\endcsname\@ne
%     \def\version@elt{\noexpand\version@elt\noexpand}%
%     \edef\version@list{\version@list\version@elt#1}%
%    \end{macrocode}
%    Then we prepare to enter the new version into all math
%    alphabet identifier lists.  Remember that these lists
%    use |\reserved@c| as delimiter, and that there appears the
%    control sequence |\reserved@e| that must not be expanded.
%    Therefore we take suitable precautions.
%    \begin{macrocode}
%     \def\reserved@c{\noexpand\reserved@c\noexpand}%
%     \let\reserved@e\relax
%    \end{macrocode}
%    We will now go through the |\alpha@list| to process every
%    \meta{math alphabet identifier} in turn.
%    Since this list has |\group@elt| as a delimiter we define
%    this control sequence.  It has three arguments as every
%    entry consists of three items (as explained above).
%    \begin{macrocode}
%     \def\group@elt##1##2##3{%
%    \end{macrocode}
%    The first of these arguments is the \meta{math alphabet
%    identifier}.  We redefine it by appending the information
%    about the new version at the end of the list contained in
%    it.  However, there is one subtlety: the definitions for
%    |\reserved@c| and |\reserved@e| made above prevent the
%    main part of the list from being expanded.  But we still have
%    to take care of the header and the trailer.  To do this we
%    remove the trailer by means of the macro |\remove@nil|
%    which also protect the header from being expanded.  Its
%    definition is given below.  Now we can prepare to add the
%    new version.
%    \begin{macrocode}
%          \edef##1{\expandafter\remove@nil##1%
%                   \reserved@c
%                   #1%
%                   \reserved@e
%                   \noexpand\@nil}}%
%    \end{macrocode}
%    Finally we call |\alpha@list| which will now execute
%    the macro |\group@elt| once for every defined \meta{math
%    alphabet identifier}.  And that's all for now.
%    \begin{macrocode}
%     \alpha@list
%  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\alpha@list}
%    As we explained above every entry in |\alpha@list| has
%    the form\\[2pt]
%    |\alpha@elt|\\\meta{alphabet identifier}\meta{internal
%    group number}\meta{default font assignments}\ldots\\[2pt]
%    We initialize it to |\@empty|.
%    \begin{macrocode}
\let\alpha@list\@empty
\@onlypreamble\alpha@list
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\alpha@elt}
%    \begin{macrocode}
\let\alpha@elt\relax
\@onlypreamble\alpha@elt
%    \end{macrocode}
% \end{macro}
%
%
%
%  \begin{macro}{\newgroup}
% Start the group (fam) allocation at 0. (Doesn't belong here.)
%    \begin{macrocode}
\count18=-1
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\stepcounter}
% \changes{v3.0f}{1997/11/13}
%      {(DPC) Remove as never used. (Re)defined in ltcounts}
% \end{macro}
%
% \begin{macro}{\select@group}
%    We surround |\select@group| with braces so that functions using it
%    can be used directly after |_| or |^|.
% \changes{v2.1p}{1994/12/10}{Surround with braces (add fourth arg)}
%    However, if we use oldstyle syntax where the math alphabet
%    doesn't have arguments (ie if |\math@bgroup| is not |\bgroup|) we
%    need to get rid of the extra group.
% \changes{v2.1q}{1995/04/02}{fix problem for pr/1275}
% \changes{v3.0g}{1997/11/20}
%      {(DPC) inline use of \cs{stepcounter} (faster, and saves a csname
%       per math version as no reset list)}
%    \begin{macrocode}
\def\select@group#1#2#3#4{%
 \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi
 {%
 \ifmmode
  \ifnum\csname c@mv@\math@version\endcsname<\sixt@@n
     \begingroup
       \escapechar\m@ne
       \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3%
       \globaldefs\@ne  \math@fonts
     \endgroup
     \init@restore@version
     \xdef#1{\noexpand\use@mathgroup\noexpand#2%      
             {\number\csname c@mv@\math@version\endcsname}}%
     \global\advance\csname c@mv@\math@version\endcsname\@ne
   \else
     \let#1\relax
     \@latex@error{Too many math alphabets used in 
                   version \math@version}%
        \@eha
   \fi
 \else \expandafter\non@alpherr\fi 
 #1{#4}%
 }%
}
\@onlypreamble\restore@mathversion
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\init@restore@version}
% \changes{v3.0e}{1996/07/26}{Removed \cs{ifrestore@version} switch
%          and replaced by \cs{init@restore@version}}
%    \begin{macrocode}
\def\init@restore@version{%
        \global\let\init@restore@version\relax
        \xdef\restore@mathversion
             {\expandafter\noexpand\csname mv@\math@version\endcsname
              \global\csname c@mv@\math@version\endcsname
              \number\csname c@mv@\math@version\endcsname\relax}%
        \aftergroup\dorestore@version
}
\@onlypreamble\init@restore@version
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\non@alpherr}
% \changes{v3.0c}{1995/10/10}
%         {(DPC) autoload error message}
% \changes{v3.0j}{2005/07/27}
%         {(MH) Change because command is now properly robust}
%    \begin{macrocode}
%</2ekernel|autoload>
%<*2ekernel|autoerr>
\gdef\non@alpherr#1{\@latex@error{%
%    \end{macrocode}
% The command here will have a space at the end of its name, so we make
% sure not to insert an extra one.
%    \begin{macrocode}
    \string#1allowed only in math mode}\@ehd}
%</2ekernel|autoerr>
%<autoload>\def\non@alpherr{\@autoerr\non@alpherr}
%<*2ekernel|autoload>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dorestore@version}
%    \begin{macrocode}
\def\dorestore@version
 {\ifmmode
    \aftergroup\dorestore@version
  \else
    \gdef\init@restore@version{%
        \global\let\init@restore@version\relax
        \xdef\restore@mathversion
             {\expandafter\noexpand\csname mv@\math@version\endcsname
              \global\csname c@mv@\math@version\endcsname
              \number\csname c@mv@\math@version\endcsname\relax}%
        \aftergroup\dorestore@version
    }%
    \begingroup
      \let\getanddefine@fonts\@gobbletwo
      \restore@mathversion
    \endgroup
  \fi}%
\@onlypreamble\dorestore@version
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\document@select@group}
%    We surround |\select@group| with braces so that functions using it
%    can be used directly after |_| or |^|.
% \changes{v2.1p}{1994/12/10}{Surround with braces (add fourth arg)}
% \changes{v2.1q}{1995/04/02}{fix problem for pr/1275}
% \changes{v3.0g}{1997/11/20}
%      {(DPC) inline use of \cs{stepcounter} (faster, and saves a csname
%       per math version as no reset list)}
%    \begin{macrocode}
\def\document@select@group#1#2#3#4{%
 \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi
 {%
 \ifmmode
   \ifnum\csname c@mv@\math@version\endcsname<\sixt@@n
     \begingroup
       \escapechar\m@ne
       \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3%
       \globaldefs\@ne  \math@fonts
     \endgroup
     \expandafter\extract@alph@from@version
         \csname mv@\math@version\expandafter\endcsname
         \expandafter{\number\csname 
                       c@mv@\math@version\endcsname}%
          #1%
     \global\advance\csname c@mv@\math@version\endcsname\@ne
   \else
     \let#1\relax
     \@latex@error{Too many math alphabets used 
                   in version \math@version}%
        \@eha
  \fi
 \else \expandafter\non@alpherr\fi
 #1{#4}%
 }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\process@table}
%    \begin{macrocode}
\def\process@table{%
    \def\cdp@elt##1##2##3##4{%
        \@font@info{Checking defaults for
                  ##1/##2/##3/##4}%
        \expandafter
        \ifx\csname##1/##2/##3/##4\endcsname\relax
%    \end{macrocode}
%    Grouping is important for two reasons, first |\cdp@elt| will get
%    redefined if |\Declare...| functions are executed within the
%    external |.fd| file and secondly |\try@load@fontshape| changes a
%    lot of catcodes without surrounding itself with a group.
%    \begin{macrocode}
          \begingroup
           \def\f@encoding{##1}\def\f@family{##2}%
           \try@load@fontshape
          \endgroup
        \fi
        \expandafter
        \ifx\csname##1/##2/##3/##4\endcsname\relax
             \@latex@error{This NFSS system isn't set up properly}%
                       {For encoding scheme ##1 the defaults
                        ##2/##3/##4 do not form a valid font shape}%
        \else
             \@font@info{... okay}%
        \fi}%
    \cdp@list
%    \end{macrocode}
%    Now we make sure that |\error@fontshape| is okay.
%    \begin{macrocode}
    \begingroup
       \escapechar\m@ne
       \error@fontshape
       \expandafter\ifx\csname \curr@fontshape\endcsname\relax
          \begingroup
            \try@load@fontshape
           \endgroup
       \fi
       \expandafter\ifx\csname \curr@fontshape\endcsname\relax
         \@latex@error{This NFSS system isn't set up properly}%
            {The system maintainer forgot to specify a suitable
             substitution
             font shape using the \noexpand\DeclareErrorFont 
             command}%
       \fi
    \endgroup
%    \end{macrocode}
%    Set |\select@group| to its meaning used within the document body.
%    \begin{macrocode}
    \let\select@group\document@select@group
%    \end{macrocode}
%    Install the default font attributes they are currently pointing
%    to error font shape.
%    Don't use |\reset@font| since that would trigger |\selectfont|.
%    \begin{macrocode}
    \fontencoding{\encodingdefault}%
    \fontfamily{\familydefault}%
    \fontseries{\seriesdefault}%
    \fontshape{\shapedefault}%
%    \end{macrocode}
%    kill all macros not longer needed.
%    we need to add many more!!!!!!
%    \begin{macrocode}
 \everyjob{}%
}
\@onlypreamble\process@table
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%\@onlypreamble\set@mathradical
%    \end{macrocode}
%
% \begin{macro}{\DeclareMathVersion}
%    \begin{macrocode}
\def\DeclareMathVersion#1{%
  \expandafter\new@mathversion\csname mv@#1\endcsname}
\@onlypreamble\DeclareMathVersion
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\new@mathversion}
%    \begin{macrocode}
\def\new@mathversion#1{%
  \expandafter\in@\expandafter#1\expandafter{\version@list}%
  \ifin@
    \@font@info{Redeclaring math version
               `\expandafter\@gobblefour\string#1'}%
  \else
    \global\expandafter\newcount\csname c@\expandafter
                                \@gobble\string#1\endcsname
    \def\version@elt{\noexpand\version@elt\noexpand}%
    \edef\version@list{\version@list\version@elt#1}%
  \fi
%    \end{macrocode}
%    |\toks@| is used to gather all tokens for the math version.
%    |\count@| will be used to count the math groups we add to this
%    version.
%    \begin{macrocode}
  \toks@{}%
  \count@\z@
%    \end{macrocode}
%    Now we loop over |\group@list| to add all math groups defined so
%    far to the version and at the same time to count them.
%    \begin{macrocode}
  \def\group@elt##1##2{%
       \advance\count@\@ne
       \addto@hook\toks@{\getanddefine@fonts##1##2}%
       }%
  \group@list
%    \end{macrocode}
%    We set the counter for this math version to the number of math
%    groups found in |\group@list|.
%    \begin{macrocode}
  \global\csname c@\expandafter\@gobble\string#1\endcsname\count@
%    \end{macrocode}
%    Now we loop over |\alpha@list| to add all math alphabets known so
%    far. We have to distinugish the case that an alphabet by default
%    should produce an error in new versions.
%    \begin{macrocode}
  \def\alpha@elt##1##2##3{%
       \ifx##2\no@alphabet@error
         \toks@\expandafter{\the\toks@\install@mathalphabet##1%
             {\no@alphabet@error##1}}%
       \else
         \toks@\expandafter{\the\toks@\install@mathalphabet##1%
             {\select@group##1##2##3}}%
       \fi
          }%
  \alpha@list
%    \end{macrocode}
%    Finally we define the math version to expand to the contents of
%    |\toks@|.
% \changes{v2.0e}{1993/08/18}{Exchanged names of encodings in warning
%              message of \cs{SetSymbolFont}.}
%    \begin{macrocode}
  \xdef#1{\the\toks@}%
}
\@onlypreamble\new@mathversion
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareSymbolFont}
%    \begin{macrocode}
\def\DeclareSymbolFont#1#2#3#4#5{%
 \@tempswafalse
 \edef\reserved@b{#2}%
 \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
      \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
 \cdp@list
 \if@tempswa
   \@ifundefined{sym#1}{%
%    \end{macrocode}
%
%    \begin{macrocode}
      \expandafter\new@mathgroup\csname sym#1\endcsname
      \expandafter\new@symbolfont\csname sym#1\endcsname
                        {#2}{#3}{#4}{#5}}%
     {%
%    \end{macrocode}
%
%    \begin{macrocode}
      \@font@info{Redeclaring symbol font `#1'}%
%    \end{macrocode}
% \changes{v3.0f}{1997/11/13}
%      {(DPC) Really update \cs{group@list} dont
%         leave new version in \cs{toks@}. latex/2661}
% Update the group list.
%    \begin{macrocode}
      \def\group@elt##1##2{%
           \noexpand\group@elt\noexpand##1%
           \expandafter\ifx\csname sym#1\endcsname##1%
             \expandafter\noexpand\csname#2/#3/#4/#5\endcsname
           \else
               \noexpand##2%
           \fi}%
      \xdef\group@list{\group@list}%
%    \end{macrocode}
% Update the version list.
%    \begin{macrocode}
      \def\version@elt##1{%
          \expandafter
          \SetSymbolFont@\expandafter##1\csname#2/#3/#4/#5\expandafter
              \endcsname \csname sym#1\endcsname
          }%
      \version@list
     }%
  \else
    \@latex@error{Encoding scheme  `#2' unknown}\@eha
  \fi
  }
\@onlypreamble\DeclareSymbolFont
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\group@list}
%    \begin{macrocode}
\let\group@list\@empty
\@onlypreamble\group@list
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\group@elt}
%    \begin{macrocode}
\let\group@elt\relax
\@onlypreamble\group@elt
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\new@symbolfont}
%    \begin{macrocode}
\def\new@symbolfont#1#2#3#4#5{%
    \toks@\expandafter{\group@list}%
    \edef\group@list{\the\toks@\noexpand\group@elt\noexpand#1%
                     \expandafter\noexpand\csname#2/#3/#4/#5\endcsname}%
    \def\version@elt##1{\toks@\expandafter{##1}%
                   \edef##1{\the\toks@\noexpand\getanddefine@fonts
                   #1\expandafter\noexpand\csname#2/#3/#4/#5\endcsname}%
                  \global\advance\csname c@\expandafter
                                 \@gobble\string##1\endcsname\@ne
                 }%
    \version@list
}
\@onlypreamble\new@symbolfont
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetSymbolFont}
%    \begin{macrocode}
\def\SetSymbolFont#1#2#3#4#5#6{%
 \@tempswafalse
 \edef\reserved@b{#3}%
 \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
      \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
 \cdp@list
 \if@tempswa
  \expandafter\SetSymbolFont@
    \csname mv@#2\expandafter\endcsname\csname#3/#4/#5/#6\expandafter
    \endcsname \csname sym#1\endcsname
 \else
  \@latex@error{Encoding scheme  `#3' unknown}\@eha
 \fi
}
\@onlypreamble\SetSymbolFont
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetSymbolFont@}
% \changes{v3.0l}{2007/08/31}{Font warning changed to info 
%    for encoding change (pr/3975)}
%    \begin{macrocode}
\def\SetSymbolFont@#1#2#3{%
  \expandafter\in@\expandafter#1\expandafter{\version@list}%
  \ifin@
    \expandafter\in@\expandafter#3\expandafter{\group@list}%
    \ifin@
      \begingroup
        \expandafter\get@cdp\string#2\@nil\reserved@a
        \toks@{}%
        \def\install@mathalphabet##1##2{%
             \addto@hook\toks@{\install@mathalphabet##1{##2}}%
            }%
        \def\getanddefine@fonts##1##2{%
          \ifnum##1=#3%
             \addto@hook\toks@{\getanddefine@fonts#3#2}%
             \expandafter\get@cdp\string##2\@nil\reserved@b
             \ifx\reserved@a\reserved@b\else
                \@font@info{Encoding `\reserved@b' has changed
                    to `\reserved@a' for symbol font\MessageBreak
                   `\expandafter\@gobblefour\string#3' in the
                    math version `\expandafter
                    \@gobblefour\string#1'}%
             \fi
             \@font@info{%
                Overwriting symbol font
                `\expandafter\@gobblefour\string#3' in
                 version `\expandafter
                \@gobblefour\string#1'\MessageBreak
                \@spaces \expandafter\@gobble\string##2 -->
                         \expandafter\@gobble\string#2}%
          \else
             \addto@hook\toks@{\getanddefine@fonts##1##2}%
          \fi}%
         #1%
         \xdef#1{\the\toks@}%
      \endgroup
    \else
       \@latex@error{Symbol font `\expandafter\@gobblefour\string#3' 
                  not defined}\@eha
    \fi
  \else
    \@latex@error{Math version `\expandafter\@gobblefour\string#1' 
       is not
       defined}{You probably mispelled the name of the math
       version.^^JOr you have to specify an additional package.}%
  \fi
}
\@onlypreamble\SetSymbolFont@
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\get@cdp}
%    \begin{macrocode}
\def\get@cdp#1#2/#3\@nil#4{\def#4{#2}}
\@onlypreamble\get@cdp
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareMathAlphabet}
% \changes{v3.0j}{2005/07/27}
%         {(MH) Make document commands robust}
%    \begin{macrocode}
\def\DeclareMathAlphabet#1#2#3#4#5{%
 \@tempswafalse
 \edef\reserved@b{#2}%
 \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
      \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
 \cdp@list
 \if@tempswa
   \expandafter\ifx
   \csname\expandafter\@gobble\string#1\endcsname
   \relax
      \new@mathalphabet#1{#2}{#3}{#4}{#5}%
   \else
%    \end{macrocode}
%    Check if it is already a math alphabet.
%    \begin{macrocode}
     \edef\reserved@a{\noexpand\in@{\string\select@group}%
         {\expandafter\meaning\csname \expandafter
          \@gobble\string#1\space\endcsname}}%
     \reserved@a
     \ifin@
       \@font@info{Redeclaring math alphabet \string#1}%
       \def\version@elt##1{%
         \expandafter\SetMathAlphabet@\expandafter
            ##1\csname#2/#3/#4/#5\expandafter\endcsname
%    \end{macrocode}
% \changes{???}{1994/04/18}{Pass correct arg (2 not 3)}
%    \begin{macrocode}
            \csname M@#2\expandafter\endcsname
            \csname \expandafter\@gobble\string#1\space\endcsname#1}%
       \version@list
     \else
%    \end{macrocode}
%    Check if it is a math alphabet defined via
%    |\DeclareSymbolFontAlphabet|.
%    \begin{macrocode}
       \edef\reserved@a{\noexpand\in@{\string\use@mathgroup}%
         {\expandafter\meaning\csname \expandafter
          \@gobble\string#1\space\endcsname}}%
       \reserved@a
       \ifin@
%    \end{macrocode}
%    In that case overwriting is simple since there is nothing
%    inserted in the math version macros.
%    \begin{macrocode}
         \@font@info{Redeclaring math alphabet \string#1}%
         \new@mathalphabet#1{#2}{#3}{#4}{#5}%
%    \end{macrocode}
%    Otherwise panic.
%    \begin{macrocode}
       \else
         \@latex@error{Command `\string#1' already defined}\@eha
       \fi
     \fi
  \fi
 \else
  \@latex@error{Encoding scheme  `#2' unknown}\@eha
 \fi
  }
\@onlypreamble\DeclareMathAlphabet
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\new@mathalphabet}
% \changes{v3.0j}{2005/07/27}
%         {(MH) Make document commands robust}
%    \begin{macrocode}
\def\new@mathalphabet#1#2#3#4#5{%
    \toks@\expandafter{\alpha@list}%
    \edef#1{\expandafter\noexpand\csname \expandafter
            \@gobble\string#1\space\endcsname
            \if/#5/%
               \noexpand\no@alphabet@error
               \noexpand\no@alphabet@error
            \else
               \expandafter\noexpand\csname M@#2\endcsname
               \expandafter\noexpand\csname#2/#3/#4/#5\endcsname
            \fi
           }%
    \toks2\expandafter{#1}%
    \edef\alpha@list{\the\toks@\noexpand\alpha@elt\the\toks2}%
    \def\version@elt##1{\toks@\expandafter{##1}%
                   \edef##1{\the\toks@\install@mathalphabet
                            \expandafter\noexpand
                            \csname \expandafter\@gobble
                               \string#1\space\endcsname
                           {\if/#5/%
                             \noexpand\no@alphabet@error
                             \noexpand#1%
                            \else
                             \noexpand\select@group\the\toks2
                            \fi}}%
                 }%
    \version@list
    \expandafter\edef\csname \expandafter\@gobble
                \string#1\space\endcsname{\if/#5/%
              \noexpand\no@alphabet@error
              \noexpand#1%
            \else
              \noexpand\select@group\the\toks2
            \fi}%
    \edef#1{\noexpand\protect
            \expandafter\noexpand\csname \expandafter
            \@gobble\string#1\space\endcsname}%
}
\@onlypreamble\new@mathalphabet
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetMathAlphabet}
% \changes{v3.0j}{2005/07/27}
%         {(MH) Make document commands robust}
%    \begin{macrocode}
\def\SetMathAlphabet#1#2#3#4#5#6{%
 \@tempswafalse
 \edef\reserved@b{#3}%
 \def\cdp@elt##1##2##3##4{\def\reserved@c{##1}%
      \ifx\reserved@b\reserved@c \@tempswatrue\fi}%
 \cdp@list
 \if@tempswa
  \expandafter\SetMathAlphabet@
    \csname mv@#2\expandafter\endcsname\csname#3/#4/#5/#6\expandafter
    \endcsname \csname M@#3\expandafter\endcsname
    \csname \expandafter\@gobble\string#1\space\endcsname#1%
 \else
  \@latex@error{Encoding scheme  `#3' unknown}\@eha
 \fi
}
\@onlypreamble\SetMathAlphabet
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetMathAlphabet@}
%    \begin{macrocode}
\def\SetMathAlphabet@#1#2#3#4#5{%
  \expandafter\in@\expandafter#1\expandafter{\version@list}%
  \ifin@
    \expandafter\in@\expandafter#4\expandafter{\alpha@list}%
    \ifin@
      \begingroup
        \toks@{}%
        \def\getanddefine@fonts##1##2{%
             \addto@hook\toks@{\getanddefine@fonts##1##2}%
            }%
        \def\reserved@c##1##2##3##4{%                % for message below
            \expandafter\@gobble\string##4}%
        \def\install@mathalphabet##1##2{%
          \ifx##1#4%
             \addto@hook\toks@
                {\install@mathalphabet#4{\select@group#4#3#2}}%
             \@font@info{Overwriting math alphabet
                `\string#5' in version `\expandafter
                 \@gobblefour\string#1'\MessageBreak
                 \@spaces \reserved@c##2 -->
                        \expandafter\@gobble\string#2}%
          \else
             \addto@hook\toks@{\install@mathalphabet##1{##2}}%
          \fi
          }%
        #1%
        \xdef#1{\the\toks@}%
      \endgroup
    \else
%    \end{macrocode}
%    If the math alphabet was defined via |\DeclareSymbolFontAlphabet|
%    we have remove its external definition and add it as a normal
%    math alphabet to every version before trying to change it in one
%    version.
% \changes{v2.1b}{1994/03/11}{Changed parameter template in temporary
%          macro to catch check add below.}
%    \begin{macrocode}
       \edef\reserved@a{%
         \noexpand\in@{\string\use@mathgroup}{\meaning#4}}%
       \reserved@a
       \ifin@
         \def\reserved@b##1\use@mathgroup##2##3{%
             \def\reserved@b{##3}\def\reserved@c{##2}}%
         \expandafter\reserved@b#4%
         \begingroup
           \def\install@mathalphabet##1##2{%
               \addto@hook\toks@{\install@mathalphabet##1{##2}}%
               }%
            \def\getanddefine@fonts##1##2{%
              \addto@hook\toks@{\getanddefine@fonts##1##2}%
              \ifnum##1=\reserved@b
                 \expandafter
                 \addto@hook\expandafter\toks@
                 \expandafter{\expandafter\install@mathalphabet
                 \expandafter#4\expandafter
                       {\expandafter\select@group\expandafter
                         #4\reserved@c##2}}%
              \fi
                      }%
           \def\version@elt##1{%
               \toks@{}%
               ##1%
               \xdef##1{\the\toks@}%
              }%
           \version@list
         \endgroup
%    \end{macrocode}
%    Put it into the |\alpha@list| with default `error'
%    \begin{macrocode}
         \expandafter\gdef\expandafter\alpha@list\expandafter
             {\alpha@list
              \alpha@elt #4\no@alphabet@error \no@alphabet@error}%
         \gdef#4{\no@alphabet@error #5}% fake things :-)
%    \end{macrocode}
%    Then call the internal setting routine again:
%    \begin{macrocode}
         \SetMathAlphabet@{#1}{#2}{#3}#4#5%
       \else
         \@latex@error{Command `\string#5' not defined as a 
                       math alphabet}%
            {Use \noexpand\DeclareMathAlphabet to define it.}%
       \fi
    \fi
  \else
    \@latex@error{Math version `\expandafter\@gobblefour\string#1'
       is not
       defined}{You probably mispelled the name of the math
       version.^^JOr you have to specify an additional package.}%
  \fi
}
\@onlypreamble\SetMathAlphabet@
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareMathAlphabet}
% could do with more checks like allowing single number in |#4|
% lowercase in |#4| etc
%    \begin{macrocode}
\def\DeclareMathAccent#1#2#3#4{%
  \expandafter\in@\csname sym#3\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
    \begingroup
      \count\z@=#4\relax
      \count\tw@\count\z@
      \divide\count\z@\sixt@@n
      \count@\count\z@
      \multiply\count@\sixt@@n
      \advance\count\tw@-\count@
      \if\relax\noexpand#1% is command?
        \edef\reserved@a{\noexpand\in@{\string\mathaccent}{\meaning#1}}%
        \reserved@a
        \ifin@
          \expandafter\set@mathaccent
             \csname sym#3\endcsname#1#2%
             {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
          \@font@info{Redeclaring math accent \string#1}%
        \else
          \expandafter\ifx
          \csname\expandafter\@gobble\string#1\endcsname
          \relax
            \expandafter\set@mathaccent
               \csname sym#3\endcsname#1#2%
               {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
          \else
            \@latex@error{Command `\string#1' already defined}\@eha
          \fi
        \fi
      \else
       \@latex@error{Not a command name: `\noexpand#1'}\@eha
      \fi
    \endgroup
  \else
    \@latex@error{Symbol font `#3' is not defined}\@eha
  \fi
}
\@onlypreamble\DeclareMathAccent
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\set@mathaccent}
%    \begin{macrocode}
\def\set@mathaccent#1#2#3#4{%
  \xdef#2{\mathaccent"\mathchar@type#3\hexnumber@#1#4\relax}}
\@onlypreamble\set@mathaccent
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareMathSymbol}
%    \begin{macrocode}
\def\DeclareMathSymbol#1#2#3#4{%
  \expandafter\in@\csname sym#3\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
    \begingroup
      \count\z@=#4\relax
      \count\tw@\count\z@
      \divide\count\z@\sixt@@n
      \count@\count\z@
      \multiply\count@\sixt@@n
      \advance\count\tw@-\count@
      \if\relax\noexpand#1% is command?
        \edef\reserved@a{\noexpand\in@{\string\mathchar}{\meaning#1}}%
        \reserved@a
        \ifin@
          \expandafter\set@mathsymbol
             \csname sym#3\endcsname#1#2%
             {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
          \@font@info{Redeclaring math symbol \string#1}%
        \else
            \expandafter\ifx
            \csname\expandafter\@gobble\string#1\endcsname
            \relax
            \expandafter\set@mathsymbol
               \csname sym#3\endcsname#1#2%
               {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
          \else
            \@latex@error{Command `\string#1' already defined}\@eha
          \fi
        \fi
      \else
        \expandafter\set@mathchar
          \csname sym#3\endcsname#1#2
          {\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
      \fi
    \endgroup
  \else
    \@latex@error{Symbol font `#3' is not defined}\@eha
  \fi
}
\@onlypreamble\DeclareMathSymbol
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\set@mathchar}
%    \begin{macrocode}
\def\set@mathchar#1#2#3#4{%
  \global\mathcode`#2="\mathchar@type#3\hexnumber@#1#4\relax}
\@onlypreamble\set@mathchar
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\set@mathsymbol}
%    \begin{macrocode}
\def\set@mathsymbol#1#2#3#4{%
  \global\mathchardef#2"\mathchar@type#3\hexnumber@#1#4\relax}
\@onlypreamble\set@mathsymbol
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%\def\mathsymbol#1#2#3{%
%  \@tempcnta=#3\relax
%  \@tempcntb\@tempcnta
%  \divide\@tempcnta\sixt@@n
%  \count@\@tempcnta
%  \multiply\count@\sixt@@n
%  \advance\@tempcntb-\count@
%  \mathchar"\mathchar@type#1\hexnumber@#2%
%             \hexnumber@\@tempcnta\hexnumber@\@tempcntb\relax}
%
%\def\DeclareMathAlphabetCharacter#1#2#3{%
%  \DeclareMathSymbol{#1}7{#2}{#3}}
%    \end{macrocode}
%
% \begin{macro}{\DeclareMathDelimiter}
% \changes{v2.1m}{1994/11/18}
%         {(DPC) \cs{expandafter} instead of \cs{next}}
%    \begin{macrocode}
\def\DeclareMathDelimiter#1{%
  \if\relax\noexpand#1%
    \expandafter\@DeclareMathDelimiter
  \else
    \expandafter\@xxDeclareMathDelimiter
  \fi
  #1}
\@onlypreamble\DeclareMathDelimiter
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xxDeclareMathDelimiter}
% \changes{v3.0h}{1998/04/15}{Macro added (pr/2662)}
%    This macro checks if the second arg is a ``math type'' such 
%    as |\mathopen|. The undocumented original code didn't use math
%    types when the delimiter was a single letter.
%    For this reason the coding is a bit strange as it tries to
%    support the undocumented syntax for compatibility reasons.
%    \begin{macrocode}
\def\@xxDeclareMathDelimiter#1#2#3#4{%
%    \end{macrocode}
%    7 is the default value returned in the case that |\mathchar@type|
%    is passed something unexpected, like a math symbol font name.
%    We locally move |\mathalpha| out of the way so if you use that
%    the right branch is taken. This will still fail if an explicit
%    number |7| is used!
%    \begin{macrocode}
   \begingroup
    \let\mathalpha\mathord
    \ifnum7=\mathchar@type{#2}%
      \endgroup
%    \end{macrocode}
%    If this branch is taken we have old syntax (5 arguments).
%    \begin{macrocode}
      \expandafter\@firstofone
    \else
%    \end{macrocode}
%    If this branch is taken |\mathchar@type| is different from 7 so
%    we assume new syntax. In this case we also use the arguments to
%    set up the letter as a math symbol for the case where it is not
%    used as a delimiter.
%    \begin{macrocode}
      \endgroup
      \DeclareMathSymbol#1{#2}{#3}{#4}%
%    \end{macrocode}
%    Then we arrange that |\@xDeclareMathDelimiter| only gets |#1|, 
%    |#3|, |#4| \ldots\ as it does not expect a math type as argument.
%    \begin{macrocode}
      \expandafter\@firstoftwo
    \fi
    {\@xDeclareMathDelimiter#1}{#2}{#3}{#4}}
\@onlypreamble\@xxDeclareMathDelimiter
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@DeclareMathDelimiter}
%    \begin{macrocode}
\def\@DeclareMathDelimiter#1#2#3#4#5#6{%
  \expandafter\in@\csname sym#3\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
    \expandafter\in@\csname sym#5\expandafter\endcsname
       \expandafter{\group@list}%
    \ifin@
      \begingroup
        \count\z@=#4\relax
        \count\tw@\count\z@
        \divide\count\z@\sixt@@n
        \count@\count\z@
        \multiply\count@\sixt@@n
        \advance\count\tw@-\count@
        \edef\reserved@c{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
      %
        \count\z@=#6\relax
        \count\tw@\count\z@
        \divide\count\z@\sixt@@n
        \count@\count\z@
        \multiply\count@\sixt@@n
        \advance\count\tw@-\count@
        \edef\reserved@d{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
      %
        \edef\reserved@a{\noexpand\in@{\string\delimiter}{\meaning#1}}%
        \reserved@a
        \ifin@
          \expandafter\set@mathdelimiter
             \csname sym#3\expandafter\endcsname
             \csname sym#5\endcsname#1#2%
             \reserved@c\reserved@d
          \@font@info{Redeclaring math delimiter \string#1}%
        \else
            \expandafter\ifx
            \csname\expandafter\@gobble\string#1\endcsname
            \relax
            \expandafter\set@mathdelimiter
              \csname sym#3\expandafter\endcsname
              \csname sym#5\endcsname#1#2%
              \reserved@c\reserved@d
          \else
            \@latex@error{Command `\string#1' already defined}\@eha
          \fi
        \fi
      \endgroup
    \else
      \@latex@error{Symbol font `#5' is not defined}\@eha
    \fi
  \else
    \@latex@error{Symbol font `#3' is not defined}\@eha
  \fi
}
\@onlypreamble\@DeclareMathDelimiter
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@xDeclareMathDelimiter}
%    \begin{macrocode}
\def\@xDeclareMathDelimiter#1#2#3#4#5{%
  \expandafter\in@\csname sym#2\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
    \expandafter\in@\csname sym#4\expandafter\endcsname
       \expandafter{\group@list}%
    \ifin@
      \begingroup
        \count\z@=#3\relax
        \count\tw@\count\z@
        \divide\count\z@\sixt@@n
        \count@\count\z@
        \multiply\count@\sixt@@n
        \advance\count\tw@-\count@
        \edef\reserved@c{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
      %
        \count\z@=#5\relax
        \count\tw@\count\z@
        \divide\count\z@\sixt@@n
        \count@\count\z@
        \multiply\count@\sixt@@n
        \advance\count\tw@-\count@
        \edef\reserved@d{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
        \expandafter\set@@mathdelimiter
           \csname sym#2\expandafter\endcsname\csname sym#4\endcsname#1%
           \reserved@c\reserved@d
      \endgroup
    \else
      \@latex@error{Symbol font `#4' is not defined}\@eha
    \fi
  \else
    \@latex@error{Symbol font `#2' is not defined}\@eha
  \fi
}
\@onlypreamble\@xDeclareMathDelimiter
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\set@mathdelimiter}
%    We have to end the definition of a math delimiter like |\lfloor|
%    with a space and not with |\relax| as we did before, because
%    otherwise contructs involving |\abovewithdelims| will prematurely
%    end (pr/1329)
%
% \changes{v2.1q}{1995/04/02}{fix pr/1329}
%    \begin{macrocode}
\def\set@mathdelimiter#1#2#3#4#5#6{%
  \xdef#3{\delimiter"\mathchar@type#4\hexnumber@#1#5%
                                     \hexnumber@#2#6 }}
\@onlypreamble\set@mathdelimiter
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\set@@mathdelimiter}
%    \begin{macrocode}
\def\set@@mathdelimiter#1#2#3#4#5{%
  \global\delcode`#3="\hexnumber@#1#4\hexnumber@#2#5\relax}
\@onlypreamble\set@@mathdelimiter
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareMathRadical}
%    \begin{macrocode}
\def\DeclareMathRadical#1#2#3#4#5{%
%    \end{macrocode}
%    Below is a crude fix to make this macro work if |#1| is undefined
%    or |\relax|.  Should be improved!
% \changes{v2.1t}{1995/05/21}{Allow for undefined cs names}
%    \begin{macrocode}
  \expandafter\ifx
       \csname\expandafter\@gobble\string#1\endcsname
       \relax
     \let#1\radical
  \fi
  \edef\reserved@a{\noexpand\in@{\string\radical}{\meaning#1}}%
  \reserved@a
  \ifin@
    \expandafter\in@\csname sym#2\expandafter\endcsname
       \expandafter{\group@list}%
    \ifin@
      \expandafter\in@\csname sym#4\expandafter\endcsname
         \expandafter{\group@list}%
      \ifin@
        \begingroup
          \count\z@=#3\relax
          \count\tw@\count\z@
          \divide\count\z@\sixt@@n
          \count@\count\z@
          \multiply\count@\sixt@@n
          \advance\count\tw@-\count@
          \edef\reserved@c{%
            \hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
          \count\z@=#5\relax
          \count\tw@\count\z@
          \divide\count\z@\sixt@@n
          \count@\count\z@
          \multiply\count@\sixt@@n
          \advance\count\tw@-\count@
          \edef\reserved@d{%
            \hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
%    \end{macrocode}
%    Coded inline instead of using |\set@mathradical|
%    \begin{macrocode}
%          \expandafter\set@mathradical
%             \csname sym#2\expandafter\endcsname
%             \csname sym#4\endcsname#1%
%             \reserved@c\reserved@d
          \xdef#1{\radical"\expandafter\hexnumber@
                                \csname sym#2\endcsname\reserved@c
                             \expandafter\hexnumber@
                                \csname sym#4\endcsname\reserved@d
                  \relax}%
        \endgroup
      \else
        \@latex@error{Symbol font `#4' is not defined}\@eha
      \fi
    \else
      \@latex@error{Symbol font `#2' is not defined}\@eha
    \fi
  \else
    \@latex@error{Command `\string#1' already defined}\@eha
  \fi
}
\@onlypreamble\DeclareMathRadical
%    \end{macrocode}
% \end{macro}
%
% Definition below was wrong it contained |\delimiter| !
%
%\begin{verbatim}
%\def\set@mathradical#1#2#3#4#5{%
%  \xdef#3{\radical"\hexnumber@#1#4\hexnumber@#2#5\relax}}
%\end{verbatim}
%
% \begin{macro}{\mathalpha}
% just a dummy currently
%    \begin{macrocode}
\let\mathalpha\relax
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mathchar@type}
%    \begin{macrocode}
\def\mathchar@type#1{%
  \ifodd 2#11 #1\else             % is this non-negative number?
    \ifx#1\mathord 0\else
     \ifx#1\mathop   1\else
       \ifx#1\mathbin 2\else
         \ifx#1\mathrel 3\else
           \ifx#1\mathopen 4\else
             \ifx#1\mathclose 5\else
               \ifx#1\mathpunct 6\else
                   7%             % anything else is variable ord
               \fi
             \fi
           \fi
         \fi
       \fi
     \fi
    \fi
  \fi}
\@onlypreamble\mathchar@type
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareSymbolFontAlphabet}
% \changes{v3.0j}{2005/07/27}
%         {(MH) Make document commands robust}
%    \begin{macrocode}
\def\DeclareSymbolFontAlphabet#1#2{%
   \expandafter\DeclareSymbolFontAlphabet@
     \csname \expandafter\@gobble\string#1\space\endcsname{#2}#1}
\@onlypreamble\DeclareSymbolFontAlphabet
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareSymbolFontAlphabet@}
%    \begin{macrocode}
\def\DeclareSymbolFontAlphabet@#1#2#3{%
%    \end{macrocode}
%    We use the switch |\if@tempswa| to decide if we can declare this
%    symbol font alphabet.
%    \begin{macrocode}
    \@tempswatrue
%    \end{macrocode}
%    First check if |#2| is known to be a symbol font
%    \begin{macrocode}
  \expandafter\in@\csname sym#2\expandafter\endcsname
     \expandafter{\group@list}%
  \ifin@
%    \end{macrocode}
%    Check if |#1| is defined as a math alphabet defined via
%    |\DeclareMathAlphabet|:
%    \begin{macrocode}
    \expandafter\in@\expandafter#1\expandafter{\alpha@list}%
    \ifin@
%    \end{macrocode}
%    If so remove it from the |\alpha@list| and from all math version
%    macros.
%    \begin{macrocode}
      \@font@info{Redeclaring math alphabet \string#3}%
      \toks@{}%
      \def\alpha@elt##1##2##3{%
          \ifx##1#1\else\addto@hook\toks@{\alpha@elt##1##2##3}\fi}%
      \alpha@list
      \xdef\alpha@list{\the\toks@}%
%    \end{macrocode}
%    Now we loop over all versions and remove the math alphabet:
%    \begin{macrocode}
      \def\version@elt##1{%
          \begingroup
            \toks@{}%
            \def\getanddefine@fonts####1####2{%
               \addto@hook\toks@{\getanddefine@fonts####1####2}}%
            \def\install@mathalphabet####1####2{%
               \ifx####1#1\else
                 \addto@hook\toks@{\install@mathalphabet
                                    ####1{####2}}\fi}%
            ##1%
            \xdef##1{\the\toks@}%
          \endgroup
          }%
      \version@list
    \else
%    \end{macrocode}
%    If |#3| is not defined as a math alphabet check if it is defined
%    at all:
%    \begin{macrocode}
      \expandafter\ifx
      \csname\expandafter\@gobble\string#1\space\endcsname
      \relax
%    \end{macrocode}
%    If it is undefined, fine otherwise check if it is a math alphabet
%    defined via |\DeclareSymbolFontAlphabet|:
%    \begin{macrocode}
      \else
        \edef\reserved@a{%
          \noexpand\in@{\string\use@mathgroup}{\meaning#1}}%
        \reserved@a
        \ifin@
          \@font@info{Redeclaring math alphabet \string#3}%
        \else
%    \end{macrocode}
%    Since the command |#3| is defined to be something which is not a
%    math alphabet we have to skip redefining it.
%    \begin{macrocode}
          \@tempswafalse
          \@latex@error{Command `\string#3' already defined}\@eha
        \fi
      \fi
    \fi
   \else
%    \end{macrocode}
%    Since the symbol font is not known we better skip defining this
%    alphabet.
%    \begin{macrocode}
     \@tempswafalse
     \@latex@error{Unknown symbol font `#2'}\@eha
   \fi
   \if@tempswa
%    \end{macrocode}
%    When we reach this point we are allowed to define |#1| to be a
%    symbol font math alphabet. This means that we have to set it to
%    \begin{quote}
%      |\use@mathgroup| \meta{math-settings} |\sym|\meta{name}
%    \end{quote}
%    The \meta{math-settings} are the one for the encoding that is
%    used in the font shape where |\sym|\meta{name} is pointing to.
%    This means that we have to get it from the information stored in
%    |\group@list|. Thus we loop through that list after defining
%    |\group@elt| in a suitable way.
% \changes{v2.1b}{1994/03/11}{Added check against use of alphabet
%              switch outside of math mode.}
%    \begin{macrocode}
     \def\group@elt##1##2{%
        \expandafter\ifx\csname sym#2\endcsname##1%
        \expandafter\reserved@a\string##2\@nil
        \fi}%
     \def\reserved@a##1##2/##3\@nil{%
        \def\reserved@a{##2}}%
     \group@list
     \toks@{\relax\ifmmode \else \non@alpherr#1\fi}%
     \edef#1{\the\toks@
             \noexpand\use@mathgroup 
             \expandafter\noexpand\csname M@\reserved@a\endcsname
             \csname sym#2\endcsname}%
     \def#3{\protect#1}%
   \fi
}
\@onlypreamble\DeclareSymbolFontAlphabet@
%</2ekernel|autoload>
%    \end{macrocode}
%  \end{macro}
%
% \Finale
%