summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex-dev/base/ltmath.dtx
blob: 3b1518dd2eb51ae6b38049c615fd98df0c81f102 (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
% \iffalse meta-comment
%
% Copyright (C) 1993-2023
% The LaTeX 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: ltmath.dtx
%
%<leqno>\ProvidesFile{leqno.clo}
%<fleqn>\ProvidesFile{fleqn.clo}
%<leqno,fleqn>        [2016/12/29 v1.2b Standard LaTeX option
%<leqno>                                   (left equation numbers)]
%<fleqn>                                   (flush left equations)]
%
%<*driver>
% \fi
\ProvidesFile{ltmath.dtx}
              [2023/05/13 v1.2n LaTeX Kernel (Math Setup)]
% \iffalse
%</driver>
%
%<*driver>
\documentclass{ltxdoc}
\GetFileInfo{ltmath.dtx}
\title{\filename}
\date{\filedate}
\author{%
  Johannes Braams\and
  David Carlisle\and
  Alan Jeffrey\and
  Leslie Lamport\and
  Frank Mittelbach\and
  Chris Rowley\and
  Rainer Sch\"opf}
\begin{document}
  \MaintainedByLaTeXTeam{latex}
  \maketitle
  \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
%
% \changes{v1.1b}{1996/07/26}{Removed \cs{global} before
%     \cs{@ignoretrue} in various places.}
% \changes{v1.1c}{1998/08/17}{(RmS) Minor documentation fixes.}
% \changes{v1.1g}{2005/11/10}{(MH) Minor documentation fixes.}
%
% \section{Math setup}
%
% This file contains a lot of the original plain \TeX{} code, as well
% as the \LaTeX{} environments for math. It still needs sorting out.
%
% \MaybeStop{}
%
%    \begin{macrocode}
%<*2ekernel>
\message{math definitions,}
%    \end{macrocode}
%
%
%
% \subsection{Math commands based on plain \TeX}
%
% \subsubsection{The log-like functions}
%
% \changes{1.0m}{1994/10/29}{ASAJ: Added \cs{DeclareMathOperator}.}
% \changes{v1.0o}{1994/11/17}
%         {\cs{@tempa} to \cs{reserved@a}}
% \changes{1.0q}{1994/11/30}{ASAJ: \cs{DeclareMathOperator} moved to
%    AMS\LaTeX.}
% \changes{v1.0r}{1995/05/07}{Use \cs{hb@xt@}}
% \changes{v1.0r}{1995/05/21}{Update some plain macros}
% \changes{v1.0t}{1995/06/28}{minor doc edits}
% \changes{v1.2c}{2019/08/27}{Make various commands robust}
%
% \begin{macro}{\log}
% The standard operators:
%    \begin{macrocode}
\DeclareRobustCommand\log{\mathop{\operator@font log}\nolimits}
\DeclareRobustCommand\lg{\mathop{\operator@font lg}\nolimits}
\DeclareRobustCommand\ln{\mathop{\operator@font ln}\nolimits}
\DeclareRobustCommand\lim{\mathop{\operator@font lim}}
\DeclareRobustCommand\limsup{\mathop{\operator@font lim\,sup}}
\DeclareRobustCommand\liminf{\mathop{\operator@font lim\,inf}}
\DeclareRobustCommand\sin{\mathop{\operator@font sin}\nolimits}
\DeclareRobustCommand\arcsin{\mathop{\operator@font arcsin}\nolimits}
\DeclareRobustCommand\sinh{\mathop{\operator@font sinh}\nolimits}
\DeclareRobustCommand\cos{\mathop{\operator@font cos}\nolimits}
\DeclareRobustCommand\arccos{\mathop{\operator@font arccos}\nolimits}
\DeclareRobustCommand\cosh{\mathop{\operator@font cosh}\nolimits}
\DeclareRobustCommand\tan{\mathop{\operator@font tan}\nolimits}
\DeclareRobustCommand\arctan{\mathop{\operator@font arctan}\nolimits}
\DeclareRobustCommand\tanh{\mathop{\operator@font tanh}\nolimits}
\DeclareRobustCommand\cot{\mathop{\operator@font cot}\nolimits}
\DeclareRobustCommand\coth{\mathop{\operator@font coth}\nolimits}
\DeclareRobustCommand\sec{\mathop{\operator@font sec}\nolimits}
\DeclareRobustCommand\csc{\mathop{\operator@font csc}\nolimits}
\DeclareRobustCommand\max{\mathop{\operator@font max}}
\DeclareRobustCommand\min{\mathop{\operator@font min}}
\DeclareRobustCommand\sup{\mathop{\operator@font sup}}
\DeclareRobustCommand\inf{\mathop{\operator@font inf}}
\DeclareRobustCommand\arg{\mathop{\operator@font arg}\nolimits}
\DeclareRobustCommand\ker{\mathop{\operator@font ker}\nolimits}
\DeclareRobustCommand\dim{\mathop{\operator@font dim}\nolimits}
\DeclareRobustCommand\hom{\mathop{\operator@font hom}\nolimits}
\DeclareRobustCommand\det{\mathop{\operator@font det}}
\DeclareRobustCommand\exp{\mathop{\operator@font exp}\nolimits}
\DeclareRobustCommand\Pr{\mathop{\operator@font Pr}}
\DeclareRobustCommand\gcd{\mathop{\operator@font gcd}}
\DeclareRobustCommand\deg{\mathop{\operator@font deg}\nolimits}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bmod}
% And some operators have to be done by hand:
%    \begin{macrocode}
\DeclareRobustCommand\bmod{%
  \nonscript\mskip-\medmuskip\mkern5mu%
  \mathbin{\operator@font mod}\penalty900\mkern5mu%
  \nonscript\mskip-\medmuskip}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pmod}
%    \begin{macrocode}
\DeclareRobustCommand\pmod[1]{%
  \allowbreak\mkern18mu({\operator@font mod}\,\,#1)}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Biggggg}
%
% \begin{macro}{\big}
% Variants on |\big| and friends for use with delimiters:
%    \begin{macrocode}
\DeclareRobustCommand\bigl{\mathopen\big}
\DeclareRobustCommand\bigm{\mathrel\big}
\DeclareRobustCommand\bigr{\mathclose\big}
\DeclareRobustCommand\Bigl{\mathopen\Big}
\DeclareRobustCommand\Bigm{\mathrel\Big}
\DeclareRobustCommand\Bigr{\mathclose\Big}
\DeclareRobustCommand\biggl{\mathopen\bigg}
\DeclareRobustCommand\biggm{\mathrel\bigg}
\DeclareRobustCommand\biggr{\mathclose\bigg}
\DeclareRobustCommand\Biggl{\mathopen\Bigg}
\DeclareRobustCommand\Biggm{\mathrel\Bigg}
\DeclareRobustCommand\Biggr{\mathclose\Bigg}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The UNSORTED Rest}
%
% The other math commands are lifted from plain \TeX.
%
% \begin{macro}{\jot}
%    \begin{macrocode}
\newdimen\jot
\jot=3pt
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\interdisplaylinepenalty}
%    \begin{macrocode}
\newcount\interdisplaylinepenalty
\interdisplaylinepenalty=100
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\choose}
%    \begin{macrocode}
\def\choose{\atopwithdelims()}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\brack}
%    \begin{macrocode}
\def\brack{\atopwithdelims[]}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\brace}
%    \begin{macrocode}
\def\brace{\atopwithdelims\{\}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mathpalette}
%    \begin{macrocode}
\def\mathpalette#1#2{%
  \mathchoice
    {#1\displaystyle{#2}}%
    {#1\textstyle{#2}}%
    {#1\scriptstyle{#2}}%
    {#1\scriptscriptstyle{#2}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\root}
% \changes{v1.1d}{1997/01/08}
%      {(DPC) Remove spurious space tokens from
%              plain \TeX\ definition /2359}
% \begin{macro}{\rootbox}
% \begin{macro}{\r@@t}
% \changes{v1.0r}{1995/05/21}{Use \cs{sqrtsign} instead of
%                             \cs{sqrt}}
%    \begin{macrocode}
\newbox\rootbox
%    \end{macrocode}
%
%    \begin{macrocode}
\def\root#1\of{%
  \setbox\rootbox\hbox{$\m@th\scriptscriptstyle{#1}$}%
  \mathpalette\r@@t}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\r@@t#1#2{%
  \setbox\z@\hbox{$\m@th#1\sqrtsign{#2}$}%
  \dimen@\ht\z@ \advance\dimen@-\dp\z@
  \mkern5mu\raise.6\dimen@\copy\rootbox
  \mkern-10mu\box\z@}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\phantom}
% \changes{v1.0p}{1994/11/18}
%         {(DPC) use \cs{expandafter} instead of \cs{next}}
% \changes{v1.0p}{1994/11/18}
%         {(DPC) colour support}

% \begin{macro}{\hphantom}
% \begin{macro}{\vphantom}
%    \begin{macrocode}
\newif\ifv@
\newif\ifh@
%    \end{macrocode}
%
%
%
%
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2019/10/01}%
%<latexrelease>                 {\vphantom}{Make commands robust}%
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand\vphantom{\v@true\h@false\ph@nt}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand\hphantom{\v@false\h@true\ph@nt}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand\phantom{\v@true\h@true\ph@nt}
%    \end{macrocode}
%
% \begin{macro}{\mathstrut}
%    \begin{macrocode}
\DeclareRobustCommand\mathstrut{\vphantom(}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\vphantom}{Make commands robust}%
%<latexrelease>
%<latexrelease>\kernel@make@fragile\vphantom
%<latexrelease>\kernel@make@fragile\hphantom
%<latexrelease>\kernel@make@fragile\phantom
%<latexrelease>\kernel@make@fragile\mathstrut
%<latexrelease>
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
%
%    \begin{macrocode}
\def\ph@nt{%
  \ifmmode
    \expandafter\mathpalette\expandafter\mathph@nt
  \else
    \expandafter\makeph@nt
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\makeph@nt#1{%
  \setbox\z@\hbox{\color@begingroup#1\color@endgroup}\finph@nt}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\mathph@nt#1#2{%
  \setbox\z@\hbox{$\m@th#1{#2}$}\finph@nt}
%    \end{macrocode}
%
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2018/12/01}%
%<latexrelease>                 {\finph@nt}{Start LR-mode}%
\def\finph@nt{%
  \setbox\tw@\null
  \ifv@ \ht\tw@\ht\z@ \dp\tw@\dp\z@\fi
  \ifh@ \wd\tw@\wd\z@\fi
%    \end{macrocode}
% \changes{v1.2b}{2018/09/24}{Start LR-mode if necessary (git/49)}
%    \begin{macrocode}
  \leavevmode@ifvmode\box\tw@}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\finph@nt}{Start LR-mode}%
%<latexrelease>\def\finph@nt{%
%<latexrelease>  \setbox\tw@\null
%<latexrelease>  \ifv@ \ht\tw@\ht\z@ \dp\tw@\dp\z@\fi
%<latexrelease>  \ifh@ \wd\tw@\wd\z@\fi \box\tw@}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\smash}
% \changes{v1.0p}{1994/11/18}
%         {(DPC) use \cs{expandafter} instead of \cs{next}}
% \changes{v1.0p}{1994/11/18}
%         {(DPC) colour support}
%    \begin{macrocode}
\DeclareRobustCommand\smash{%
  \relax % \relax, in case this comes first in \halign
  \ifmmode
    \expandafter\mathpalette\expandafter\mathsm@sh
  \else
    \expandafter\makesm@sh
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\makesm@sh#1{%
  \setbox\z@\hbox{\color@begingroup#1\color@endgroup}\finsm@sh}
%    \end{macrocode}
%
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2022/11/01}%
%<latexrelease>                 {\mathsm@sh}{Guard against reboxing}%
\def\mathsm@sh#1#2{%
  \setbox\z@\hbox{$\m@th#1{#2}$}%
%    \end{macrocode}
%    The empty brace groups in front of the smashed box (which is
%    placed by \cs{finsm@sh}) ensures that a \cs{smash} in math is not
%    just producing a single box  with its dimensions altered, but a
%    box plus this second ord atom. The reason is that \TeX{} sometimes reboxes a
%    box if its the only thing in a place like the denominator of a
%    fraction. This would then undo the smashing and the additional
%    ord atom prevents that. Two ord atoms in a row do not alter the
%    horizontal spacing in a formula so this is otherwise transparent. 
% \changes{v1.2m}{2022/09/03}{Guard against reboxing in fractions (gh/517)}
%    \begin{macrocode}
  {}\finsm@sh}
%    \end{macrocode}
%    \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\mathsm@sh}{Guard against reboxing}%
%<latexrelease>\def\mathsm@sh#1#2{%
%<latexrelease>  \setbox\z@\hbox{$\m@th#1{#2}$}\finsm@sh}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
%
% \changes{v1.2b}{2018/09/24}{Start LR-mode if necessary (git/49)}
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2018/12/01}%
%<latexrelease>                 {\finsm@sh}{Start LR-mode}%
\def\finsm@sh{\ht\z@\z@ \dp\z@\z@ \leavevmode@ifvmode\box\z@}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\finsm@sh}{Start LR-mode}%
%<latexrelease>\def\finsm@sh{\ht\z@\z@ \dp\z@\z@ \box\z@}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\buildrel}
%    \begin{macrocode}
\def\buildrel#1\over#2{\mathrel{\mathop{\kern\z@#2}\limits^{#1}}}
%    \end{macrocode}
% \end{macro}
%
%
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2019/10/01}%
%<latexrelease>                 {\cases}{Make commands robust}%
%    \end{macrocode}
%
% \begin{macro}{\cases}
% \changes{LaTeX2.09}{1991/08/14}
%         {(RmS) inserted extra braces around entry for NFSS}
% \changes{v1.2g}{2020/07/27}{Don't make the command \cs{long} (gh/354)}
%    \begin{macrocode}
\DeclareRobustCommand*\cases[1]{\left\{\,\vcenter{\normalbaselines\m@th
    \ialign{$##\hfil$&\quad{##}\hfil\crcr#1\crcr}}\right.}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\matrix}
% \changes{v1.2g}{2020/07/27}{Don't make the command \cs{long} (gh/354)}
%    \begin{macrocode}
\DeclareRobustCommand*\matrix[1]{\null\,\vcenter{\normalbaselines\m@th
    \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr
      \mathstrut\crcr\noalign{\kern-\baselineskip}
      #1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}\,}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pmatrix}
% \changes{v1.2g}{2020/07/27}{Don't make the command \cs{long} (gh/354)}
%    \begin{macrocode}
\DeclareRobustCommand*\pmatrix[1]{\left(\matrix{#1}\right)}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\cases}{Make commands robust}%
%<latexrelease>
%<latexrelease>\kernel@make@fragile\cases
%<latexrelease>\kernel@make@fragile\matrix
%<latexrelease>\kernel@make@fragile\pmatrix
%<latexrelease>
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
%
%
% \begin{macro}{\bordermatrix}
% \changes{LaTeX2e}{1994/01/25}{Removed \cs{p@renwd}.}
%    \begin{macrocode}
\def\bordermatrix#1{\begingroup \m@th
  \@tempdima 8.75\p@
  \setbox\z@\vbox{%
    \def\cr{\crcr\noalign{\kern2\p@\global\let\cr\endline}}%
    \ialign{$##$\hfil\kern2\p@\kern\@tempdima&\thinspace\hfil$##$\hfil
      &&\quad\hfil$##$\hfil\crcr
      \omit\strut\hfil\crcr\noalign{\kern-\baselineskip}%
      #1\crcr\omit\strut\cr}}%
  \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
  \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
  \setbox\tw@\hbox{$\kern\wd\@ne\kern-\@tempdima\left(\kern-\wd\@ne
    \global\setbox\@ne\vbox{\box\@ne\kern2\p@}%
    \vcenter{\kern-\ht\@ne\unvbox\z@\kern-\baselineskip}\,\right)$}%
  \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\openup}
% \changes{v1.2k}{2022/04/08}{Make \cs{protected} (gh/123)}
%    \begin{macrocode}
\protected\def\openup{\afterassignment\@penup\dimen@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@penup{\advance\lineskip\dimen@
  \advance\baselineskip\dimen@
  \advance\lineskiplimit\dimen@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\displaylines}
%    \begin{macrocode}
\newif\ifdt@p
%    \end{macrocode}
%
%    \begin{macrocode}
\def\displ@y{\global\dt@ptrue\openup\jot\m@th
  \everycr{\noalign{\ifdt@p \global\dt@pfalse \ifdim\prevdepth>-1000\p@
      \vskip-\lineskiplimit \vskip\normallineskiplimit \fi
      \else \penalty\interdisplaylinepenalty \fi}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lign{\tabskip\z@skip\everycr{}} % restore inside \displ@y
%    \end{macrocode}
%
%    \begin{macrocode}
\def\displaylines#1{\displ@y \tabskip\z@skip
  \halign{\hb@xt@\displaywidth{$\@lign\hfil\displaystyle##\hfil$}\crcr
    #1\crcr}}
%    \end{macrocode}
% \end{macro}
%
% \changes{v1.0r}{1995/05/21}{Remove \cs{mathhexbox} from this file}
%
% \begin{macro}{\sp}
% \begin{macro}{\sb}
%    \begin{macrocode}
\let\sp=^
\let\sb=_
%    \end{macrocode}
% \end{macro}
% \end{macro}
%


%
%    \begin{macro}{\tmspace}
%    \begin{macro}{\,}
%    \begin{macro}{\thinspace}
%    \begin{macro}{\!}
%    \begin{macro}{\negthinspace}
%    \begin{macro}{\:}
%    \begin{macro}{\medspace}
%    \begin{macro}{\negmedspace}
%    \begin{macro}{\;}
%    \begin{macro}{\thickspace}
%    \begin{macro}{\negthickspace}
%
%    Originally \LaTeX{} only provided a small set of spacing commands
%    for use in text and math, some of the commands like \cs{;} were
%    only supported in math mode. \texttt{amsmath} normalized  and
%    provided all of them in text and math. This code has now been
%    moved to the kernel so that it is generally available.
%
%
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2020/10/01}%
%<latexrelease>                 {\tmspace}{amsmath spacing commands}%
%    \end{macrocode}
%    \cs{tmspace} is really meant to be an internal command so it
%    doesn't necessarily has to be robust but it was robust in
%    \texttt{amsmath} so we leave it like that.
% \changes{v1.2e}{2020/03/07}{Add \texttt{amsmath} math/text spacing
%    commands to the kernel (gh/303)}
%    \begin{macrocode}
\DeclareRobustCommand\tmspace[3]{%
  \ifmmode\mskip#1#2\else\leavevmode@ifvmode\kern#1#3\fi\relax}
%    \end{macrocode}
%    In \texttt{amsmath} the text kern is \texttt{.1667em}. For
%    compatibility reasons we keep the longer one.
%    \begin{macrocode}
\DeclareRobustCommand\,{\tmspace+\thinmuskip{.16667em}}
\let\thinspace\,
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand\!{\tmspace-\thinmuskip{.16667em}}
\let\negthinspace\!
%    \end{macrocode}
%    
%    \begin{macrocode}
\DeclareRobustCommand\:{\tmspace+\medmuskip{.2222em}}
\let\medspace\:
%    \end{macrocode}
%    \LaTeX{} has a second name for this in its manual:
%    \begin{macrocode}
\let\>=\:
\DeclareRobustCommand\negmedspace{\tmspace-\medmuskip{.2222em}}
%    \end{macrocode}
%    
%    \begin{macrocode}
\DeclareRobustCommand\;{\tmspace+\thickmuskip{.2777em}}
\let\thickspace\;
\DeclareRobustCommand\negthickspace{\tmspace-\thickmuskip{.2777em}}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%    
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\tmspace}{amsmath spacing commands}%
%<latexrelease>
%<latexrelease>\let\tmspace\@undefined
%<latexrelease>\DeclareRobustCommand{\,}{%
%<latexrelease>   \relax\ifmmode\mskip\thinmuskip\else\thinspace\fi}
%<latexrelease>\DeclareRobustCommand\thinspace{\leavevmode@ifvmode\kern .16667em }
%<latexrelease>\DeclareRobustCommand\negthinspace{\leavevmode@ifvmode\kern-.16667em }
%<latexrelease>\def\>{\mskip\medmuskip}
%<latexrelease>\let\:=\>
%<latexrelease>\def\;{\mskip\thickmuskip}
%<latexrelease>\def\!{\mskip-\thinmuskip}
%<latexrelease>
%    \end{macrocode}
% \changes{v1.2h}{2020/11/09}{\cs{negmedspace} and \cs{negthickspace}
%    have been only in amsmath, so we need to undefine for rollback (gh/423)}
%    \begin{macrocode}
%<latexrelease>\let\negmedspace\@undefined
%<latexrelease>\let\negthickspace\@undefined
%<latexrelease>
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%
%
%
% \begin{macro}{\*}
%    \begin{macrocode}
\DeclareRobustCommand\*{\discretionary{\thinspace\the\textfont2\char2}{}{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\:}
%    Nickname for the medium space since |\>| is not available inside
%    \texttt{tabbing}.
%    \begin{macrocode}
%\let\:=\>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\active@math@prime}
% \changes{v1.1e}{1999/10/09}{Macro added, see PR 3104.}
%    This is the definition of the active math prime.
%    \begin{macrocode}
\def\active@math@prime{^\bgroup\prim@s}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\prime@s}
% \changes{v1.0p}{1994/11/18}
%         {(DPC) use \cs{@let@token} instead of \cs{next}
%           and \cs{expandafter} instead of \cs{nxt}}
% \changes{v1.1e}{1999/10/09}{Introduce \cs{active@math@prime}.}
%    \begin{macrocode}
{\catcode`\'=\active \global\let'\active@math@prime}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\prim@s{%
  \prime\futurelet\@let@token\pr@m@s}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\pr@m@s{%
  \ifx'\@let@token
    \expandafter\pr@@@s
  \else
    \ifx^\@let@token
      \expandafter\expandafter\expandafter\pr@@@t
    \else
      \egroup
    \fi
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\pr@@@s#1{\prim@s}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\pr@@@t#1#2{#2\egroup}
%    \end{macrocode}
% \end{macro}
%
% \changes{v1.0i}{1994/05/17}{Replaced \cs{let} by \cs{gdef}, for
%            indirect definition.}
%    \begin{macrocode}
{\catcode`\_=\active \gdef_{\_}} % _ in math is
                                 % either subscript or \_
%    \end{macrocode}
%
%
% \changes{v1.0m}{1994/10/29}{ASAJ: Removed \cs{dag}, \cs{ddag}.}
% \changes{v1.0m}{1994/10/29}{ASAJ: Renamed \cs{S} and \cs{P} to
%    \cs{mathsection} and \cs{mathparagraph} and made them
%    \cs{mathchardef}s.}
% \changes{v1.0m}{1994/10/29}{ASAJ: Added \cs{mathellipsis},
%    \cs{mathdollar} and \cs{mathsterling}.}
% \changes{v1.0n}{1994/10/30}{ASAJ: Moved the new commands to ltoutenc.}
%
% \subsection{Math Environments}
%
% \changes{1.0m}{1994/10/29}{ASAJ: Tidied up documentation.}
%
% \begin{macro}{\(}
% \begin{macro}{\)}
%    Produces |$...$| with checks that |\(| isn't used in math mode, and
%    that |\)| is only used in math mode begun with |\(|.
% \changes{v1.1h}{2015/01/08}{Make Robust (latexrelease)}
%    \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2015/01/01}{\(}{Make \( robust}%
%<*2ekernel|latexrelease>
\DeclareRobustCommand\({%
  \relax\ifmmode\@badmath\else$\fi}%
\DeclareRobustCommand\){%
  \relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}%
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}{\(}{Make \( robust}%
%<latexrelease>\def\({%
%<latexrelease>  \relax\ifmmode\@badmath\else$\fi}%
%<latexrelease>\expandafter\let\csname\string( \endcsname\@undefined
%<latexrelease>\def\){%
%<latexrelease>  \relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}%
%<latexrelease>\expandafter\let\csname\string) \endcsname\@undefined
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\[}
% \changes{v1.1g}{2005/11/10}
%                {(MH) Fixed potential problem in \cs{[} (pr/3399).}
% \begin{macro}{\]}
%    Produces |$$...$$| with checks that |\[| isn't used in math mode,
%    and that |\]| is only used in display math mode (though there is no
%    real test that this display math started with |\[| and not with |$$|).
% \changes{v1.1h}{2015/01/08}{Make Robust (latexrelease)}
%    \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2015/01/01}{\[}{Make \[ robust}%
%<*2ekernel|latexrelease>
\DeclareRobustCommand\[{%
   \relax\ifmmode
      \@badmath
   \else
      \ifvmode
         \nointerlineskip
         \makebox[.6\linewidth]{}%
      \fi
      $$%%$$ BRACE MATCH HACK
   \fi
}%
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand\]{%
   \relax\ifmmode
      \ifinner
         \@badmath
      \else
         $$%%$$ BRACE MATCH HACK
      \fi
   \else
      \@badmath
   \fi
   \ignorespaces
}%
%    \end{macrocode}
%
%    \begin{macrocode}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}{\[}{Make \[ robust}%
%<latexrelease>\def\[{%
%<latexrelease>   \relax\ifmmode
%<latexrelease>      \@badmath
%<latexrelease>   \else
%<latexrelease>      \ifvmode
%<latexrelease>         \nointerlineskip
%<latexrelease>         \makebox[.6\linewidth]{}%
%<latexrelease>      \fi
%<latexrelease>      $$%%$$ BRACE MATCH HACK
%<latexrelease>   \fi
%<latexrelease>}%
%<latexrelease>\expandafter\let\csname\string[ \endcsname\@undefined
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease>\def\]{%
%<latexrelease>   \relax\ifmmode
%<latexrelease>      \ifinner
%<latexrelease>         \@badmath
%<latexrelease>      \else
%<latexrelease>         $$%%$$ BRACE MATCH HACK
%<latexrelease>      \fi
%<latexrelease>   \else
%<latexrelease>      \@badmath
%<latexrelease>   \fi
%<latexrelease>   \ignorespaces
%<latexrelease>}%
%<latexrelease>\expandafter\let\csname\string] \endcsname\@undefined
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{environment}{math}
% \begin{environment}{displaymath}
%    Disguises for |\(...\)| and |\[...\]|.
%    \begin{macrocode}
\let\math=\(
\let\endmath=\)
%    \end{macrocode}
%
%    \begin{macrocode}
\def\displaymath{\[}
\def\enddisplaymath{\]\@ignoretrue}
%    \end{macrocode}
% \end{environment}
% \end{environment}
%
%
% \begin{environment}{equation}
% \changes{LaTeX2.09}{1992/01/10}{RmS: put \cs{hbox} around \cs{@eqnnum}
%    to typeset the equation number in text mode
%    (as in the eqnarray env.)}
% \begin{macro}{\c@equation}
%  Numbered equations, using the counter |\c@equation|.
%  \emph{Note}: The document style must define |\theequation| etc., and
%  do the appropriate |\@addtoreset|. It should also redefine |\@eqnnum|
%  if another format for the equation number is desired other than the
%  standard (...), or to move the equation numbers to the flushleft.
%   (See comment on the |\def| of |\@eqnnum|.)
%    \begin{macrocode}
\@definecounter{equation}
\def\equation{$$\refstepcounter{equation}}
\def\endequation{\eqno \hbox{\@eqnnum}$$\@ignoretrue}
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
% \begin{macro}{\@eqnnum}
% \changes{LaTeX2.09}{1991/09/29}{RmS: \cs{reset@font} added.}
% \changes{v1.0l}{1994/10/23}{Added \cs{normalcolor} since \cs{eqno}
%    introduces a subgroup of the displayed math group}
%
%     Produces the equation number for equation and
%     eqnarray environments.  The following definition is for
%     flushright numbers; for flushleft numbers, see leqno.clo.
%     The equation number is set in black roman type even
%     if an eqnarray environment appears in an italic environment.
% \changes{v1.0s}{1995/05/26}{Removed \cs{rmfamily} (PR 1578),
% replaced \cs{reset@font} with \cs{normalfont}}
%    \begin{macrocode}
\def\@eqnnum{{\normalfont \normalcolor (\theequation)}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\stackrel}
%    A disguise for plain \TeX's buildrel.
%    \begin{macrocode}
\DeclareRobustCommand\stackrel[2]{\mathrel{\mathop{#2}\limits^{#1}}}
%    \end{macrocode}
% \end{macro}
%
%  \changes{v0.9g}{1993/12/11}{Added a group around the first argument
%    of \cs{frac} to prevent
%    changes (for example font changes) from modifying the contents of
%     the second argument.}
%
%  \begin{macro}{\frac}
%    A disguise for plain \TeX's |\over|.
%    \begin{macrocode}
\DeclareRobustCommand\frac[2]{{\begingroup#1\endgroup\over#2}}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\sqrt}
% \changes{v1.0y}{1995/10/16}{(DPC) Make robust /1808}
% \begin{macro}{\@sqrt}
%    Add an optional argument to plain's |\sqrt| to give the $n$th root
%    of an expression $\sqrt[n]{e}$.
% \changes{v1.0r}{1995/05/21}{Use \cs{sqrtsign}}
%    \begin{macrocode}
\DeclareRobustCommand\sqrt{\@ifnextchar[\@sqrt\sqrtsign}
\def\@sqrt[#1]{\root #1\of}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{LaTeX2.09}{1985/11/04}{produce warning message if line
%      extends into margin.  Doesn't warn about formula
%      overprinting equation number.}
% \changes{LaTeX2.09}{1993/11/02}{RmS:
%        Corrected description of \cs{@eqnsel}, moved \cs{@eqnsel}
%        accordingly and removed extra \cs{tabskip} assignment.}
% \changes{LaTeX2e}{1993/11/03}{RmS: Initialized \cs{everycr} to empty}
% \changes{v0.9i}{1993/12/16}
%     {use \cs{refstepcounter} instead of shortcut}
% \changes{v0.9o}{1994/01/13}{correcting 0.9i}
%
% \begin{environment}{eqnarray}
% \begin{macro}{\@eqcnt}
% \begin{macro}{\@eqpen}
% \begin{macro}{\if@eqnsw}
% \begin{macro}{\@eqnsel}
%    Here's the eqnarray environment:
%    Default is for left-hand side of equations to be flushright.
%    To make them flushleft, |\let\@eqnsel = \hfil|.
%    \begin{macrocode}
\newcount\@eqcnt
\newcount\@eqpen
\newif\if@eqnsw\@eqnswtrue
\newskip\@centering
\@centering = 0pt plus 1000pt
%    \end{macrocode}
%    To get a proper \cs{@currentlabel} we have to redefine it for the
%    whole display. Note that we can't use \cs{refstepcounter} as this
%    results in |\@currentlabel| getting restored at the wrong and
%    thus always writing the first label to the \texttt{.aux} file.
% \changes{v1.2j}{2021/10/14}
%         {Explicitly set \cs{@currentcounter} (gh/687)}
%    \begin{macrocode}
\def\eqnarray{%
   \stepcounter{equation}%
   \def\@currentlabel{\p@equation\theequation}%
   \def\@currentcounter{equation}%
   \global\@eqnswtrue
   \m@th
   \global\@eqcnt\z@
   \tabskip\@centering
   \let\\\@eqncr
   $$\everycr{}\halign to\displaywidth\bgroup
       \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
      &\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
      &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
         $\displaystyle{##}$\hfil\tabskip\@centering
      &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
         \tabskip\z@skip
      \cr
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\endeqnarray{%
      \@@eqncr
      \egroup
      \global\advance\c@equation\m@ne
   $$\@ignoretrue
}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\@eqnsel=\relax
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{environment}
%
% \begin{macro}{\nonumber}
%    Switches off equation numbering.
%    \begin{macrocode}
\def\nonumber{\global\@eqnswfalse}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@eqncr}
% \changes{v1.2i}{2021/04/20}{Use \cs{protected} for \cs{\bslash} variant (gh/548)}
% \begin{macro}{\@xeqncr}
% \begin{macro}{\@yeqncr}
% \changes{v1.0y}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
%    \begin{macrocode}
\protected\def\@eqncr{%
   {\ifnum0=`}\fi
   \@ifstar{%
      \global\@eqpen\@M\@yeqncr
   }{%
      \global\@eqpen\interdisplaylinepenalty \@yeqncr
   }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@yeqncr{\@testopt\@xeqncr\z@skip}
%    \end{macrocode}
%
% \changes{v1.2f}{2020/04/21}{Support calc syntax (gh/152)}
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2020/10/01}%
%<latexrelease>                 {\@xeqncr}{eqnarray support calc syntax}%
\def\@xeqncr[#1]{%
   \ifnum0=`{\fi}%
   \@@eqncr
   \noalign{\penalty\@eqpen\vskip\jot\@vspace@calcify{#1}}%
}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%    
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\@xeqncr}{eqnarray support calc syntax}%
%<latexrelease>
%<latexrelease>\def\@xeqncr[#1]{%
%<latexrelease>   \ifnum0=`{\fi}%
%<latexrelease>   \@@eqncr
%<latexrelease>   \noalign{\penalty\@eqpen\vskip\jot\vskip #1\relax}%
%<latexrelease>}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
%  \begin{macro}{\@@eqncr}
% \changes{v0.9i}{1993/12/16}{use \cs{refstepcounter} instead of shortcut}
% \changes{v0.9o}{1994/01/13}{correcting 0.9i}
%
%    \begin{macrocode}
\def\@@eqncr{\let\reserved@a\relax
    \ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
     \or \def\reserved@a{&}\else
       \let\reserved@a\@empty
       \@latex@error{Too many columns in eqnarray environment}\@ehc\fi
     \reserved@a \if@eqnsw\@eqnnum\stepcounter{equation}\fi
     \global\@eqnswtrue\global\@eqcnt\z@\cr}
%    \end{macrocode}
%  \end{macro}
%
% \begin{environment}{eqnarray*}
% \begin{macro}{\@seqncr}
%    Here's the eqnarray* environment:
%    \begin{macrocode}
\let\@seqncr=\@eqncr
%    \end{macrocode}
%
% \changes{v1.2i}{2021/04/20}{Use \cs{protected} for \cs{\bslash} variant (gh/548)}
%    \begin{macrocode}
\@namedef{eqnarray*}{\protected\def\@eqncr{\nonumber\@seqncr}\eqnarray}
%    \end{macrocode}
%
%    \begin{macrocode}
\@namedef{endeqnarray*}{\nonumber\endeqnarray}
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
% \begin{macro}{\lefteqn}
%  |\lefteqn{FORMULA}| typesets |FORMULA| in display math style
%  flushleft in a box of width zero.
% \changes{v1.0r}{1995/05/21}{Use \cs{rlap}}
%    \begin{macrocode}
\def\lefteqn#1{\rlap{$\displaystyle #1$}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ensuremath}
%   In math mode, |\ensuremath{text}| is equivalent to text; in LR or
%   paragraph mode, it is equivalent to |$|text|$|.
%   |\relax| is not needed
%   in front of the |\ifmmode| as |\protect| will be |\let| to |\relax|.
%   This version (due to Donald Arseneau) avoids duplicating its
%   argument in the `then' and `else' part of the |\ifmath| which is
%   necessary in nested  `tabular' like environments. See amslatex/2104.
% \changes{v1.0k}{1994/05/16}
%     {Use \cs{DeclareRobustCommand} and add extra braces in math mode}
% \changes{v1.0l}{1994/10/23}{Remove extra braces: but see p 168 of
%      Leslie's book}
% \changes{v1.1a}{1996/03/25}{Reimplement for amslatex/2104}
%    \begin{macrocode}
\DeclareRobustCommand{\ensuremath}{%
  \ifmmode
    \expandafter\@firstofone
  \else
    \expandafter\@ensuredmath
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ensuredmath}
% \changes{v1.1a}{1996/03/25}{Macro added for amslatex/2104}
% \changes{v1.1c}{1996/11/09}{Made long, as it was before. /2104}
% The |\relax| stops |\ensuremath{}| starting display math.
%    \begin{macrocode}
\long\def\@ensuredmath#1{$\relax#1$}
%    \end{macrocode}
% \end{macro}
%
% \changes{v1.2l}{2022/05/08}{Use consistent math styles under \LuaTeX}
% \LuaTeX\ contains new math primitives to place expression over or under
% horizontally extensible glyphs. Before \LuaTeX\ 1.14 these did not work
% correctly with the |\mathstyle| primitive and sometimes did not use
% cramped style in consistent ways. For newer version, we opt into the
% corrected behavior.
%    \begin{macrocode}
\ifx\mathdefaultsmode\@undefined\else
  \mathdefaultsmode=1
\fi
%    \end{macrocode}
%
% \begin{macro}{\eqno}
% \begin{macro}{\leqno}
% \changes{v1.2n}{2023/05/13}{add \cs{ignorespaces} gh/1059}
% Ensure the (deprecated) \verb|$$..\eqno 1 $$| ignores spaces.
%    \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{2023/06/01}%
%<latexrelease>                 {\eqno}{add ignorespaces to eqno}%
\let\@kernel@eqno\eqno
\let\@kernel@leqno\leqno
\protected\def\eqno{\@kernel@eqno\aftergroup\ignorespaces}
\protected\def\leqno{\@kernel@leqno\aftergroup\ignorespaces}
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
%<latexrelease>                 {\eqno}{add ignorespaces to eqno}%
%<latexrelease>\let\eqno\@kernel@eqno
%<latexrelease>\let\leqno\@kernel@leqno
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \subsection{External options to the standard document classes}
%
% \changes{v1.0u}{1995/08/09}
%    {Added code for class options leqno and fleqn}
%
% \subsubsection{Left equation numbering}
%
%  \begin{macro}{\@eqnnum}
%    To put the equation number on the left side of an equation we
%    have to use a little trick. The number is shifted |\displaywidth|
%    to the left inside a box of (approximately) zero width. This
%    fails when the equation is too wide, the equation number than may
%    overprint the equation itself.
% \changes{v1.2y classes}{1995/01/12}{Added \cs{normalcolor}}
% \changes{v1.3c classes}{1995/05/25}
%    {replace \cs{reset@font}\cs{rmfamily} with \cs{normalfont}
%      (PR 1578)}
%    \begin{macrocode}
%<*leqno>
\renewcommand\@eqnnum{\hb@xt@.01\p@{}%
                      \rlap{\normalfont\normalcolor
                        \hskip -\displaywidth(\theequation)}}
%</leqno>
%    \end{macrocode}
%  \end{macro}
%
% \subsubsection{Flush left equations}
%
%    To get the displayed math environments to print the contents
%    flush left (with an indentation) we have to redefine all of
%    \LaTeXe's displayed math environments.
%
%  \begin{macro}{\mathindent}
%    The amount of indentation of the equations is stored in a register.
% \changes{v1.2d}{2020/02/18}{Make \cs{mathindent} a skip register to match
%     amsmath (gh/252)}
%    \begin{macrocode}
%<*fleqn>
\newskip\mathindent
%    \end{macrocode}
%    The setting of |\mathindent| has to be deferred until the class
%    file has been processed, because |\leftmargini| is still 0pt
%    wide at the moment \texttt{fleqn.clo} is read in.
% \changes{v1.0n classes}
%    {1994/01/19}{Deferred setting of \cs{mathindent}}
% \changes{v1.2t classes}
%    {1994/06/22}{Set \cs{mathindent} at the end of the
%    class instead of at begin document}
%    \begin{macrocode}
\AtEndOfClass{\mathindent\leftmargini}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\[}
%    Begin display math;
%    \begin{macrocode}
\IncludeInRelease{2015/01/01}{\[}{Make \[ robust}%
\DeclareRobustCommand\[{\relax
                \ifmmode\@badmath
                \else
                  \begin{trivlist}%
                    \@beginparpenalty\predisplaypenalty
                    \@endparpenalty\postdisplaypenalty
                    \item[]\leavevmode
                    \hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
                      \hskip\mathindent\bgroup
                \fi}
\EndIncludeInRelease
%    \end{macrocode}
%
%    \begin{macrocode}
\IncludeInRelease{0000/00/00}{\[}{Make \[ robust}%
\renewcommand\[{\relax
                \ifmmode\@badmath
                \else
                  \begin{trivlist}%
                    \@beginparpenalty\predisplaypenalty
                    \@endparpenalty\postdisplaypenalty
                    \item[]\leavevmode
                    \hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
                      \hskip\mathindent\bgroup
                \fi}
\EndIncludeInRelease
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\]}
%    end display math;
%    \begin{macrocode}
\IncludeInRelease{2015/01/01}{\]}{Make \] robust}%
\DeclareRobustCommand\]{\relax
                \ifmmode
                      \egroup $\hfil% $
                    \egroup
                  \end{trivlist}%
                \else \@badmath
                \fi}
\EndIncludeInRelease
%    \end{macrocode}
%
%    \begin{macrocode}
\IncludeInRelease{0000/00/00}{\]}{Make \] robust}%
\renewcommand\]{\relax
                \ifmmode
                      \egroup $\hfil% $
                    \egroup
                  \end{trivlist}%
                \else \@badmath
                \fi}
\EndIncludeInRelease
%    \end{macrocode}
% \end{macro}
%
%  \begin{environment}{equation}
%    The \textsf{equation} environment
%    \begin{macrocode}
\renewenvironment{equation}%
    {\@beginparpenalty\predisplaypenalty
     \@endparpenalty\postdisplaypenalty
     \refstepcounter{equation}%
     \trivlist \item[]\leavevmode
       \hb@xt@\linewidth\bgroup $\m@th% $
         \displaystyle
         \hskip\mathindent}%
%    \end{macrocode}
%    Ensure that there is at least a space between formula and
%    equation number so that they don't bump in each other.
% \changes{v1.2d}{2020/02/18}{Separate formula and eqn number by at
%    least a space in fleqn option}
%    \begin{macrocode}
        {$\hskip .3em minus.3em\hfil % $
         \displaywidth\linewidth\hbox{\@eqnnum}%
       \egroup
     \endtrivlist}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{eqnarray}
%    The \textsf{eqnarray} environment
% \changes{v1.2j}{2021/10/14}
%         {Explicitly set \cs{@currentcounter} (gh/687)}
%    \begin{macrocode}
\renewenvironment{eqnarray}{%
    \stepcounter{equation}%
    \def\@currentlabel{\p@equation\theequation}%
    \def\@currentcounter{equation}%
    \global\@eqnswtrue\m@th
    \global\@eqcnt\z@
    \tabskip\mathindent
    \let\\=\@eqncr
    \setlength\abovedisplayskip{\topsep}%
    \ifvmode
      \addtolength\abovedisplayskip{\partopsep}%
    \fi
%    \end{macrocode}
%    When the documentclass uses a non-zero |\parskip| setting the
%    |\topsep| might have a negative value to compensate for
%    that. Therefore we add |\parskip| to |\abovedisplayskip|.
% \changes{v1.2v classes}{1994/11/10}{Added value of \cs{parskip} to
%    \cs{abovedisplayskip} to compensate for negative \cs{topsep}}
%    \begin{macrocode}
    \addtolength\abovedisplayskip{\parskip}%
    \setlength\belowdisplayskip{\abovedisplayskip}%
    \setlength\belowdisplayshortskip{\abovedisplayskip}%
    \setlength\abovedisplayshortskip{\abovedisplayskip}%
    $$\everycr{}\halign to\linewidth% $$
    \bgroup
      \hskip\@centering
      $\displaystyle\tabskip\z@skip{##}$\@eqnsel&%
      \global\@eqcnt\@ne \hskip \tw@\arraycolsep \hfil${##}$\hfil&%
      \global\@eqcnt\tw@ \hskip \tw@\arraycolsep
        $\displaystyle{##}$\hfil \tabskip\@centering&%
      \global\@eqcnt\thr@@
        \hb@xt@\z@\bgroup\hss##\egroup\tabskip\z@skip\cr}%
      {\@@eqncr
    \egroup
    \global\advance\c@equation\m@ne$$% $$
    \@ignoretrue
    }
%</fleqn>
%    \end{macrocode}
% \end{environment}
%
%
% \Finale
%