summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/mathfont/mathfont.dtx
blob: 9c723e6f553a12d09dbe0078e9df66dd99dec106 (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
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
% \iffalse meta-comment
% 
% This file is  mathfont.dtx. It is used to typeset documentation and
% files for the LaTeX2e package "mathfont," to be used in conjunction
% with the XeTeX or LuaTeX engine. Users should run this file through
% LaTeX to generate the files and documentation.
% 
% Copyright 2018-2019 by Conrad Kosowsky
% 
% This work may be distributed and modified under the terms
% of the LaTeX Public Project License, version 1.3c or any later version.
% The most recent version of this license is available online at
% 
%          https://www.latex-project.org/lppl/.
% 
% This work has the LPPL status "maintained," and the current maintainer
% is the package author, Conrad Kosowsky. He can be reached at 
% kosowsky.latex@gmail.com.  The work consists of the file mathfont.dtx,
% the derived files mathfont.sty, mathfont_greek.tex, and
% mathfont_example.tex, and all other files created through the configuration
% process such as mathfont.pdf, mathfont.idx, and mathfont.ind.
% 
% To install mathfont, run mathfont.dtx through LaTeX and move
% the generated file mathfont.sty into a directory searchable by TeX.
% 
% \fi
% 
% \iffalse
% 
% The installation and driver files are incorporated into mathfont.dtx,
% so we do not need to generate them separately. The <batchfile> and
% <driver> tags are for reference.
% 
%<*batchfile>
\begingroup
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble

Copyright 2018-2019 by Conrad Kosowsky

This file may be distributed and modified under the terms
of the LaTeX Public Project License, version 1.3c or any later version.
The most recent version of this license is available online at

         https://www.latex-project.org/lppl/.

This work has the LPPL status "maintained," and the current maintainer
is the package author, Conrad Kosowsky. He can be reached at 
kosowsky.latex@gmail.com. The work consists of the file mathfont.dtx,
the derived files mathfont.sty, mathfont_greek.tex, and 
mathfont_example.tex, and all other files created through the configuration
process such as mathfont.pdf, mathfont.idx, and mathfont.ind. For more
information, see the original mathfont.dtx file.

\endpreamble
\generate{
  \file{mathfont.sty}{\from{mathfont.dtx}{package}}
  \file{mathfont_greek.tex}{\from{mathfont.dtx}{greek}}
  \file{mathfont_example.tex}{\from{mathfont.dtx}{example}}}
\bgroup
\catcode`\ =\active
\def {\space}
\message{^^J^^J
******************************************^^J
*                                        *^^J
* To finish the installation, move the   *^^J
* following file into a directory        *^^J
* searchable by TeX once mathfont.dtx    *^^J
* finishes compiling:                    *^^J
*                                        *^^J
*              mathfont.sty              *^^J
*                                        *^^J
******************************************^^J^^J}
\egroup\endgroup
%</batchfile>
% 
%<*driver>
\documentclass[12pt]{ltxdoc}
\makeatletter
\usepackage[margin=72.27pt]{geometry}
\usepackage[factor=600,stretch=14,shrink=14,step=1]{microtype}
\usepackage[bottom]{footmisc}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{tabularx}
\hyphenpenalty=10
\exhyphenpenalty=5
\pretolerance=30
\finalhyphendemerits=300
\c@IndexColumns=2
\renewcommand\textfraction{0}
\EnableCrossrefs
\CodelineIndex
\begin{document}
  \DocInput{mathfont.dtx}\eject
  \PrintIndex
\end{document}
%</driver>
%<*package>
% 
% \fi
% 
% \CheckSum{2653}
% \init@checksum
% 
% \makeatother\CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation     \!      Double quote   \"      Hash (number)   \#
%   Dollar          \$      Percent        \%      Ampersand       \&
%   Acute accent    \'      Left paren     \(      Right paren     \)
%   Asterisk        \*      Plus           \+      Comma           \,
%   Minus           \-      Point          \.      Solidus         \/
%   Colon           \:      Semicolon      \;      Less than       \<
%   Equals          \=      Greater than   \>      Question mark   \?
%   Commercial at   \@      Left bracket   \[      Backslash       \\
%   Right bracket   \]      Circumflex     \^      Underscore      \_
%   Grave accent    \`      Left brace     \{      Vertical bar    \|
%   Right brace     \}      Tilde          \~}
% \makeatletter
% 
% 
% \DoNotIndex{\NeedsTeXFormat,\ProvidesPackage,\DeclareOption,\ProcessOptions}
% \DoNotIndex{\def,\edef,\global,\let,\csname,\endcsname,\expandafter,\relax,\advance}
% \DoNotIndex{\newcount,\newif,\z@,\@ne,\m@ne,\ifx,\ifcat,\ifnum,\ifmmode,\else,\fi}
% \DoNotIndex{\PackageInfo,\PackageWarning,\PackageError,\message,\@undefined}
% \DoNotIndex{\space,\MessageBreak,\string,\M@count,\count@,\noexpand,\protect}
% \DoNotIndex{\@tempa,\@tempb,\@tempc,\@i,\@j,\@k,\count,\tw@,\@empty}
% \DoNotIndex{\do,\DeclareMathSymbol,\the,\mathalpha,\mathord,\protect,\multiply}
% \DoNotIndex{\M@symbols,\mathop,\mathbin,\mathrel,\mathopen,\mathclose,\mathpunct}
% \DoNotIndex{\M@lower,\M@upper,\M@greeklower,\M@greekupper,\M@digits}
% \DoNotIndex{\M@bb,\M@cal,\M@frak,\M@bcal,\M@bfrak,\mathinner}
% \DoNotIndex{\DeclareRobustCommand,\joinrel,\smash,\newtoks,\if,\\,\@nil,\leavevmode}
% \DoNotIndex{\begingroup,\endgroup,\+,\active,\@gobbletwo,\GenericError,\catcode}
% \DoNotIndex{\M@bb@A,\M@bb@B,\M@bb@C,\M@bb@D,\M@bb@E,\M@bb@F}
% \DoNotIndex{\M@bb@G,\M@bb@H,\M@bb@I,\M@bb@J,\M@bb@K,\M@bb@L}
% \DoNotIndex{\M@bb@M,\M@bb@N,\M@bb@O,\M@bb@P,\M@bb@Q,\M@bb@R}
% \DoNotIndex{\M@bb@S,\M@bb@T,\M@bb@U,\M@bb@V,\M@bb@W,\M@bb@X}
% \DoNotIndex{\M@bb@Y,\M@bb@Z,\M@bb@a,\M@bb@b,\M@bb@c,\M@bb@d}
% \DoNotIndex{\M@bb@e,\M@bb@f,\M@bb@g,\M@bb@h,\M@bb@i,\M@bb@j}
% \DoNotIndex{\M@bb@k,\M@bb@l,\M@bb@m,\M@bb@n,\M@bb@o,\M@bb@p}
% \DoNotIndex{\M@bb@q,\M@bb@r,\M@bb@s,\M@bb@t,\M@bb@u,\M@bb@v}
% \DoNotIndex{\M@bb@w,\M@bb@x,\M@bb@y,\M@bb@z}
% \DoNotIndex{\M@cal@A,\M@cal@B,\M@cal@C,\M@cal@D,\M@cal@E,\M@cal@F}
% \DoNotIndex{\M@cal@G,\M@cal@H,\M@cal@I,\M@cal@J,\M@cal@K,\M@cal@L}
% \DoNotIndex{\M@cal@M,\M@cal@N,\M@cal@O,\M@cal@P,\M@cal@Q,\M@cal@R}
% \DoNotIndex{\M@cal@S,\M@cal@T,\M@cal@U,\M@cal@V,\M@cal@W,\M@cal@X}
% \DoNotIndex{\M@cal@Y,\M@cal@Z,\M@cal@a,\M@cal@b,\M@cal@c,\M@cal@d}
% \DoNotIndex{\M@cal@e,\M@cal@f,\M@cal@g,\M@cal@h,\M@cal@i,\M@cal@j}
% \DoNotIndex{\M@cal@k,\M@cal@l,\M@cal@m,\M@cal@n,\M@cal@o,\M@cal@p}
% \DoNotIndex{\M@cal@q,\M@cal@r,\M@cal@s,\M@cal@t,\M@cal@u,\M@cal@v}
% \DoNotIndex{\M@cal@w,\M@cal@x,\M@cal@y,\M@cal@z}
% \DoNotIndex{\M@frak@A,\M@frak@B,\M@frak@C,\M@frak@D,\M@frak@E,\M@frak@F}
% \DoNotIndex{\M@frak@G,\M@frak@H,\M@frak@I,\M@frak@J,\M@frak@K,\M@frak@L}
% \DoNotIndex{\M@frak@M,\M@frak@N,\M@frak@O,\M@frak@P,\M@frak@Q,\M@frak@R}
% \DoNotIndex{\M@frak@S,\M@frak@T,\M@frak@U,\M@frak@V,\M@frak@W,\M@frak@X}
% \DoNotIndex{\M@frak@Y,\M@frak@Z,\M@frak@a,\M@frak@b,\M@frak@c,\M@frak@d}
% \DoNotIndex{\M@frak@e,\M@frak@f,\M@frak@g,\M@frak@h,\M@frak@i,\M@frak@j}
% \DoNotIndex{\M@frak@k,\M@frak@l,\M@frak@m,\M@frak@n,\M@frak@o,\M@frak@p}
% \DoNotIndex{\M@frak@q,\M@frak@r,\M@frak@s,\M@frak@t,\M@frak@u,\M@frak@v}
% \DoNotIndex{\M@frak@w,\M@frak@x,\M@frak@y,\M@frak@z}
% \DoNotIndex{\M@bcal@A,\M@bcal@B,\M@bcal@C,\M@bcal@D,\M@bcal@E,\M@bcal@F}
% \DoNotIndex{\M@bcal@G,\M@bcal@H,\M@bcal@I,\M@bcal@J,\M@bcal@K,\M@bcal@L}
% \DoNotIndex{\M@bcal@M,\M@bcal@N,\M@bcal@O,\M@bcal@P,\M@bcal@Q,\M@bcal@R}
% \DoNotIndex{\M@bcal@S,\M@bcal@T,\M@bcal@U,\M@bcal@V,\M@bcal@W,\M@bcal@X}
% \DoNotIndex{\M@bcal@Y,\M@bcal@Z,\M@bcal@a,\M@bcal@b,\M@bcal@c,\M@bcal@d}
% \DoNotIndex{\M@bcal@e,\M@bcal@f,\M@bcal@g,\M@bcal@h,\M@bcal@i,\M@bcal@j}
% \DoNotIndex{\M@bcal@k,\M@bcal@l,\M@bcal@m,\M@bcal@n,\M@bcal@o,\M@bcal@p}
% \DoNotIndex{\M@bcal@q,\M@bcal@r,\M@bcal@s,\M@bcal@t,\M@bcal@u,\M@bcal@v}
% \DoNotIndex{\M@bcal@w,\M@bcal@x,\M@bcal@y,\M@bcal@z}
% \DoNotIndex{\M@bfrak@A,\M@bfrak@B,\M@bfrak@C,\M@bfrak@D,\M@bfrak@E}
% \DoNotIndex{\M@bfrak@F,\M@bfrak@G,\M@bfrak@H,\M@bfrak@I,\M@bfrak@J}
% \DoNotIndex{\M@bfrak@K,\M@bfrak@L,\M@bfrak@M,\M@bfrak@N,\M@bfrak@O}
% \DoNotIndex{\M@bfrak@P,\M@bfrak@Q,\M@bfrak@R,\M@bfrak@S,\M@bfrak@T}
% \DoNotIndex{\M@bfrak@U,\M@bfrak@V,\M@bfrak@W,\M@bfrak@X,\M@bfrak@Y}
% \DoNotIndex{\M@bfrak@Z,\M@bfrak@a,\M@bfrak@b,\M@bfrak@c,\M@bfrak@d}
% \DoNotIndex{\M@bfrak@e,\M@bfrak@f,\M@bfrak@g,\M@bfrak@h,\M@bfrak@i}
% \DoNotIndex{\M@bfrak@j,\M@bfrak@k,\M@bfrak@l,\M@bfrak@m,\M@bfrak@n}
% \DoNotIndex{\M@bfrak@o,\M@bfrak@p,\M@bfrak@q,\M@bfrak@r,\M@bfrak@s}
% \DoNotIndex{\M@bfrak@t,\M@bfrak@u,\M@bfrak@v,\M@bfrak@w,\M@bfrak@x}
% \DoNotIndex{\M@bfrak@y,\M@bfrak@z}
% 
% 
% \newenvironment{code}
%   {\strut\vadjust\bgroup\medskip\parindent=4em\relax\indent\strut\ignorespaces}
%   {\strut\par\medskip\egroup\hfill\break\strut\ignorespacesafterend}
% \def\argtext#1{\ensuremath{\langle$\textit{#1}$\rangle}}
% 
% \def\XeTeX{X\kern-0.1em
%   \raise-0.5ex\hbox{\rotatebox[origin=c]{180}{E}}\kern-0.15em
%   \TeX}
% \def\XeLaTeX{X\kern-0.1em
%   \raise-0.5ex\hbox{\rotatebox[origin=c]{180}{E}}\kern-0.13em
%    \LaTeX}
% \renewcommand\topfraction{1}
% \renewcommand\bottomfraction{1}
% 
% {\large
% \centerline{\Large Package \textsf{mathfont} v.\ 1.5 Documentation}\par
% \centerline{Conrad Kosowsky}\par
% \centerline{April 2019}\par
% \centerline{\ttfamily kosowsky.latex@gmail.com}\par}
% 
% \bigskip
%  
% \begin{abstract}
% The \textsf{mathfont} package provides a flexible interface for changing the font of math-mode characters. The package allows the user to specify a default unicode font for each of six basic classes of Latin and Greek characters, and it provides additional support for unicode math and alphanumeric symbols, including punctuation. Crucially, \textsf{mathfont} is compatible with both \XeLaTeX\ and Lua\LaTeX, and it provides several font-loading commands that allow the user to change fonts locally or for individual characters within math mode.
% \end{abstract}
% 
% \begin{figure}[hb]
% \hrule height \p@\hbox{\vrule width \p@\kern-\p@\relax\vbox{\medskip\relax
% {\leftskip=4em\rightskip=4em
% \noindent\strut For easy, ``off-the-shelf'' use, type the following in your document preamble and compile using \XeLaTeX\ or Lua\LaTeX:\par}
% 
% \medskip
% 
% \noindent\hfil\vbox{\hbox{|\usepackage{mathfont}|}
% \hbox{|\setfont{|\argtext{font name}|}|}}
% 
% \medskip}\kern-\p@\vrule width \p@}\hrule height \p@
% \end{figure}
% 
% 
% 
%  
% Handling fonts in \TeX\ and \LaTeX\ is a notoriously difficult task. Donald Knuth originally designed \TeX\ to support fonts created with Metafont, and while subsequent versions of \TeX\ extended this functionality to postscript fonts, Plain \TeX's font-loading capabilities remain limited. Many, if not most, \LaTeX\ users are unfamiliar with the |.fd| files that must be used in font declaration, and the minutiae of \TeX's |\font| primitive can be esoteric and confusing. \LaTeXe's New Font Selection System (\textsc{nfss}) implemented a straightforward syntax for loading and managing fonts, but \LaTeX\ macros overlaying a \TeX\ core face the same versatility issues as Plain \TeX\ itself. Fonts in math mode present a double challenge: even if the user successfully loads a font either in Plain \TeX\ or through the \textsc{nfss}, defining math symbols can be unintuitive for users who are unfamiliar with \TeX's |\mathcode| primitive. Again, \LaTeXe\ simplifies much of the coding challenges with its |\DeclareMathSymbol| macro, but from the computer's perspective, the fundamental aspects of the task remain the same.
%  
% More recent engines such as Jonathan Kew's \XeTeX\ and Hans Hagen, et al.'s Lua\TeX\ significantly extend the font-loading capabilities of \TeX.\footnote{Information on \XeTeX\ is available at \texttt{https://tug.org/xetex/}, and information on Lua\TeX\ is available at the official website for Lua\TeX: \texttt{http://www.luatex.org/}.} Both support TrueType and OpenType font formats and provide many additional primitives for managing fonts. The \textsf{fontspec} package by Will Robertson and Khaled Hosny acts as a front-end for the font management built into these two engines.\footnote{Will Robertson and Khaled Hosny, ``\textsf{fontspec}---Advanced font selection in \XeLaTeX\ and Lua\LaTeX,'' \texttt{https://ctan.org/pkg/fontspec}.} It allows users to easily load new fonts and transition between those ones already in memory, and users who are interested in changing text fonts should consult the documentation for that package. Notably, \textsf{fontspec} provides users with the tools to manually adjust OpenType features of the fonts they load, so the package gives equivalent or in some cases superior font management capabilities to a modern WYSIWYG word processor. (Of course, the efficiency depends on the skill of the \LaTeX\ user.) In situations where a font's OpenType features are unclear or difficult to access, \textsf{fontspec}'s typographical advantages can significantly outweigh the accessibility of a word processor.
%
% The \textsf{mathfont} package applies \textsf{fontspec}'s advances in font selection to math-mode typesetting, and this documentation explains \textsf{mathfont} as follows. Section~1 presents the basic functionality and related packages. Sections~2 and 3 explain how to use the default and local font-change commands, and users in a hurry will find the most important information here. Sections~4 and 5 discuss the Greek characters and mathematical symbols that \textsf{mathfont} provides, and section~6 describes the more complicated error messages that \textsf{mathfont} may throw. The remaining five sections detail the implementation. Section~7 lays out the initial implementation for the package, and sections~8 and 9 lay out the \LaTeX\ code for default and local font changes, respectively. Section~10 covers the code for the unicode alphanumeric letterlike symbols, and the final section~11 contains the unicode hex values for every character supported by \textsf{mathfont}. Version history occurs on page p.~\pageref{version}. For an example of the package in action, see |mathfont_example.pdf|, which is included with the \textsf{mathfont} installation and is available on \textsc{ctan}.
%  
%  \section{Basic Functionality}
%  
%  The \textsf{mathfont} package uses \textsf{fontspec} as a back end to load fonts for use in math mode, and it provides two ways to do this: (1) changing the default font for certain classes of math mode characters; and (2) defining new commands that change the font locally for the so-called ``math alphabet'' characters. (The math alphabet characters are all Latin letters, all Arabic numerals, and any Greek letters that \textsf{mathfont} has set the font for.) The package can change the default math font for Latin and Greek letters, Arabic numerals, and unicode alphanumeric symbols to any unicode OpenType or TrueType font. Tables~1 and 2 display the specific classes of characters that \textsf{mathfont}'s default font-change command acts on.
%  
%  The package can be loaded with the standard |\usepackage| syntax, and it has three optional arguments: \texttt{packages}, \texttt{operators}, and \texttt{no-operators}. During loading, \textsf{mathfont} redefines two \LaTeX\ internal macros to make symbol declaration compatible with unicode fonts, and the |packages| option determines when \textsf{mathfont} resets the two internal commands. If the user loads the package without the |packages| option, \textsf{mathfont} will reset the internal commands at the next |\usepackage| declaration, but with the argument, \textsf{mathfont} does not reset them at all. In practice, using this option should be harmless in most situations, and the issue is primarily one of convenience. The |\mathfont| command works only with these redefinitions, so once the package has reset the \LaTeX\ kernel, it will not adjust the default font for any class of characters. Thus the \texttt{packages} option allows users to sprinkle |\mathfont| declarations throughout their preamble, and doing so may be advantageous depending on the situation. However, leaving the kernel modified could induce clashes with other packages, so proceed at your own risk! For users who provided the \texttt{packages} argument or are loading packages before the |\documentclass| declaration, the control sequence |\restoremathinternals| manually returns the internal commands to their default definitions. It should be considered best practice to load \textsf{mathfont} without \texttt{packages} and put all |\mathfont| commands as soon after loading as possible.
% 
% The package arguments \texttt{operators} and \texttt{no-operators} determine \textsf{mathfont}'s behavior regarding the integral, summation, and product signs. The \texttt{operators} argument tells the package to adjust the font for these three symbols, and the \texttt{no-operators} argument does the opposite. As of version 1.4, the package executes the \texttt{no-operators} option by default, but users may want to enable this behavior depending on the desired math font and other symbols being used. See sections~2 and 5 for more information.
%  
% The package loads \textsf{fontspec} with the |no-math| option if and only if the user has not already loaded \textsf{fontspec}. Users who want \textsf{fontspec} without |no-math| or with other options in place can manually load it before requiring \textsf{mathfont}, and I strongly recommend that users who do so load \textsf{fontspec} with |no-math|. Alternatively, users who want to pass options to \textsf{fontspec} without loading it themselves can use \LaTeX's |\PassOptionsToPackage| command before loading \textsf{mathfont}.
%  
%  Compatibility with Lua\LaTeX\ comes at the expense of \textsf{mathspec}'s convenient space-adjustment character |"|, and spacing-conscientious users can either manually add |\kern| or |\muskip| to their equations or redefine an active version of |"|.\footnote{The problem isn't one of ability---Lua\TeX's programming capabilities tend to outweigh those of \XeTeX. Rather, I'm unfamiliar with most of the workings of Lua\TeX. One of my eventual goals for this package is a Lua script that could automatically adjust spacing in math mode for any combination of two characters, but I don't know if or when I will be able to do that.} For example, the code\label{code-example}
%  \begin{code}
%  \begingroup\obeylines|\catcode`\"=\active|
%  |\def"#1{\ifmmode|
%  |    \kern|\argtext{dimension}|\relax #1\kern|\argtext{other dimension}|\relax|
%  |  \else|
%  |    \char`\"#1%|
%  |  \fi}|\endgroup
%  \end{code}
%  will serve as a hack that very roughly approximates \textsf{mathspec}'s |"|. This code will redefine |"| to typeset a right double quotation mark in horizontal mode, but in math mode, the character will insert \textit{dimension} and \textit{other dimension} of white space on either side respectively of the following character. More advanced users can automate the dimensions by using \TeX's |\if| conditional to test whether the following character needs a particular spacing adjustment. (For example, Computer Modern's math-mode $f$ is notorious for being significantly wider than its italic counterpart.) Future versions of \textsf{mathfont} may provide an automated space-adjustment command, but it is not one of my priorities.
%  
%  The functionality of \textsf{mathfont} is most closely related to that of the \textsf{mathspec} package by Andrew Gilbert Moschou.\footnote{Andrew Gilbert Moschou, ``\textsf{mathspec}---Specify arbitrary fonts for mathematics in \XeTeX,''\hfil\break\texttt{https://ctan.org/pkg/mathspec}.} These two packages incorporate the use of individual unicode characters into math mode, and their symbol declaration process is similar. Both use \textsf{fontspec} as a back end, and both create font-changing commands for math-mode characters. However, the functionality differs in three crucial respects: \textsf{mathfont} is compatible with Lua\LaTeX; it can adjust the font of basic mathematical symbols such as those in tables~5 and 6; and its local math-font-changing mechanisms provide a slightly greater level of flexibility than what users can achieve with \textsf{mathspec}. Further, as far as I am aware, this package is the first to provide support for the unicode alphanumeric symbols listed in Table~2, even in the context of fonts without built-in math support. (Please let me know if this is incorrect!) In this way \textsf{mathfont}, like \textsf{mathspec}, is more versatile than the \textsf{unicode-math} package, although potentially less far-reaching.\footnote{Will Robertson, ``\textsf{unicode-math}---Unicode mathematics support for \XeTeX\ and Lua\TeX,''\hfil\break\texttt{https://ctan.org/pkg/unicode-math}.}
% 
% Users who want to stick with pdf\LaTeX\ should consider Jean-Fran\c cois Burnol's \textsf{mathastext} as a useful alternative to \textsf{mathfont}.\footnote{Jean-Fran\c cois Burnol, ``\textsf{mathastext}---Use the text font in maths mode,''\hfil\break\texttt{https://ctan.org/pkg/mathastext}. In several previous versions of this documentation, I mistakenly stated that \textsf{mathastext} distorts \TeX's internal mathematics spacing. In fact the opposite is true: \textsf{mathastext} preserves and in some cases extends rules for space between various math-mode characters.} This package allows the user to specify the math-mode font for a large subset of the ASCII characters and is the most closely related package to \textsf{mathfont} among those packages designed specifically for pdf\LaTeX. Whereas \textsf{mathfont} works exclusively in the context of unicode fonts, \textsf{mathastext} was designed for the T1 and related encodings of Plain \TeX\ and \LaTeX, and \textsf{mathfont} provides support for a larger class of symbols. However, the \textsf{mathastext} functionality extends beyond that of \textsf{mathfont} in two notable aspects: (1) \textsf{mathastext} makes use of math versions, extra spacing, and italic corrections; and (2) \textsf{mathastext} allows users to change the font for the twenty-five non-alphanumeric characters supported by that package multiple times. After setting the default font for a class of characters, \textsf{mathfont} allows for that class only the local font changes outlined in section~3.
% 
%  \section{Setting the Default Font}
%  
%  The |\mathfont| command sets the default font for certain classes of characters. Its structure is given by
%  \begin{code}
%  |\mathfont[|\argtext{optional character classes}|]{|\argtext{font name}|}|,
%  \end{code}
%  where the \textit{optional character classes} can be any set of keywords from Tables~1 and 2 separated by commas, and the \textit{font name} can be any OpenType or TrueType font in a directory searchable by \TeX. When specifying the \textit{font name}, users need to input a name that \textsf{fontspec} will recognize and be able to load. Advanced users will note that |\mathfont| uses |\fontspec_set_family:Nnn| and therefore loads fonts in the same way as |\fontspec| and related macros from that package. Currently, \textsf{mathfont} does not support OpenType features in math mode. To change both math and text fonts simultaneously, the package provides the command
% \begin{code}
% |\setfont{|\argtext{font name}|}|,
% \end{code}
% which calls both |\mathfont| and \textsf{fontspec}'s |\setmainfont| using the \textit{font name} as arguments. Most users will probably find this command sufficient for most applications. Both |\mathfont| and |\setfont| should appear only in the document preamble.
%  
%  The user should specify any keyword optional arguments for |\mathfont| as entries in a comma-separated list. The order is irrelevant, and spaces between entries are permitted. For each item in the list, the package will change the math-mode font for that class of characters to the mandatory argument. Leaving out the optional argument will cause the command to revert to its default behavior, and for most applications, that will be sufficient. If the user does not specify an optional argument for |\mathfont|, e.g.\ writes
% \begin{code}
% |\mathfont{Helvetica}|,
% \end{code}
% the package will change all math-mode Latin characters, Greek characters, digits, operators such as $\log$ or $\sin$, and all symbols from Tables~5 and 6 to the font in the mandatory argument. (Specifically, all keywords from Table~1 and the |symbol| keyword from Table~2.) In this example, the new font would be Helvetica.
% 
%  \begin{figure}[tb]
%  \centering
%  Table~1: Math Alphabet Characters\par\penalty\@M\smallskip
%  \begin{tabular}{lll}
%  \toprule
%  Keyword & Meaning & Default shape\\
%  \midrule
%  |upper| & Capital Latin letters & Italic\\
%  |lower| & Minuscule Latin letters & Italic\\
%  |greekupper| & Capital Greek letters & Upright\\
%  |greeklower| & Minuscule Greek letters & Italic\\
%  |digits| & Arabic numerals & Upright\\
%  |operator| & Operator font & Upright\\
%  \bottomrule
%  \end{tabular}
%  \end{figure}
% 
% By default, \textsf{mathfont} will use either an upright or italic shape corresponding to each character-class keyword, but the user can override this setting by writing an equals sign next to the keyword and a shape suboption---either |roman| or |italic|---following that. Table~1 contains the default shapes for the keywords listed there, while the default shape for all classes of characters in Table~2 is upright. The package interprets the |roman| suboption as specifying an upright shape---normal shape in the language of the \textsc{nfss}---and the |italic| suboption as specifying an italic shape. Currently \textsf{mathfont} does not support default font shapes beyond these two. For example, the command
%  \begin{code}
%  |\mathfont[upper=roman,lower=roman]{Times New Roman}|
%  \end{code}
%  would change all math-mode Latin letters to Times New Roman with upright shape. As of version 1.4, |\mathfont| ignores all spaces in its optional argument, so the above code snippet is equivalent to
% \begin{code}
% |\mathfont[ upper = roman , lower = roman ]{Times New Roman}|.
% \end{code}
% Technical point: |\mathfont| expands its optional argument inside an |\edef|, so the argument can contain any number of fully expandable control sequences. Users should also be aware that, in order to limit the number of symbol fonts in memory, |\mathfont| will not change the default font for a class of symbols once it has already done so.
% 
%  \begin{figure}[b]
%  \centering
%  Table~2: Other Math Symbols\par\penalty\@M\smallskip
%  \begin{tabular}{ll}
%  \toprule
%  Keyword & Meaning\\
%  \midrule
%  |symbols| & Basic mathematical symbols (includes punctuation)\\
%  |bb| & Blackboard Bold (double-struck)\\
%  |cal| & Caligraphic\\
%  |frak| & Fraktur\\
%  |bcal| & Bold Caligraphic\\
%  |bfrak| & Bold Fraktur\\
%  \bottomrule
%  \end{tabular}
%  \end{figure}
%  
%  The Unicode Consortium designates the Mathematical Alphanumeric Symbols (U+1D400--U+1D7FF) code block for several classes of letters and letterlike symbols that appear frequently in mathematical writing. The \textsf{mathfont} package provides easy access to these symbols through the |\mathfont| command, and Table~2 lists the corresponding keywords that should be used with |\mathfont| to do so. When the user calls |\mathfont| with any of the last five keywords from Table~2 in its optional argument, \textsf{mathfont} both declares the appropriate unicode characters as math symbols and defines the macro
%  \begin{code}
%  |\math|\argtext{keyword}|{|\argtext{argument}|}|.
%  \end{code}
%  This control sequence takes one argument, and it converts the characters in its argument into the corresponding style. For example, 
%  \begin{code}
%  |\mathfont[bcal]{STIXGeneral}|
%  \end{code}
%  will set STIXGeneral as the font for bold caligraphic characters and define the command |\mathbcal| to access them in math mode. The argument of the macro produced this way must be a single string of Latin letters without braces or control sequences, although in somewhat idiosyncratic fashion, the |\mathbb| command can also accept Arabic numerals in its argument. Spaces and any character of catcode 12 will be ignored. 
%  
%  Because these commands can handle capital and minuscule Latin letters, the \textsf{mathfont} package significantly extends the functionality of \TeX's standard |\mathcal| command and the |\mathbb| command from the \textsf{amssymb} package. Users should note that typesetting symbols from a letterlike class of characters in Table~2 will require a unicode font that actually contains those characters, such as Symbola or STIXGeneral. That being said, users who need only a few alphanumeric symbols may be able to use a less specialized font that contains for example the characters from the Letterlike Symbols (U+2100--U+214F) code block. This block contains the blackboard bold versions of C, N, Q, R, and Z, and the fonts providing these characters are significantly more common than those that contain the full blackboard bold alphabet.
%  
%  \section{Local Font Changes}
%  
%  With \textsf{mathfont}, users can locally change the font in math mode by creating a new control sequence for each new font desired. The commands created this way function analogously to the standard math font macros from the \LaTeX\ kernel such as |\mathrm|, |\mathit|, and |\mathnormal|, and the package includes four basic commands to produce new control sequences. Table~3 lists these commands, and they all have the same argument structure: a control sequence as the first mandatory argument and a font name as the second. For example, the macro |\newmathrm| looks like
%  \begin{code}
%  |\newmathrm{|\argtext{control sequence}|}{|\argtext{font name}|}|.
%  \end{code}
%  It defines the \textit{control sequence} in its first argument to accept a string of characters that it then converts to the \textit{font name} in the second argument with upright shape and medium weight. Writing 
%  \begin{code}
%  |\newmathrm{\matharial}{Arial}|
%  \end{code}
%  would create the macro
%  \begin{code}
%  |\matharial{|\argtext{argument}|}|,
%  \end{code}
%  which can be used only in math mode and which converts the math alphabet characters in its \textit{argument} into the Arial font with upright shape and medium weight. The other three commands in Table~3 function in the same way except that they select different series or shape values for the font in question, and Table~3 lists this information. 
%
% Unlike the traditional |\mathrm| and company, \textsf{mathfont}'s local font change commands create macros that can act on Greek characters. If the user specifies the font for Greek letters using |\mathfont|, macros created with the commands from Table~3 will affect those characters; otherwise, they will not. Specifically, \LaTeXe\ defines Greek letters as |\mathord| characters, and \textsf{mathfont} changes this classification to |\mathalpha| type when it declares them as symbols. The local font change commands here act only on characters of class |\mathalpha|, so if the user doesn't set the font for |greekupper| or |greeklower| characters in a |\mathfont| command, any macro from this section will not be able to act on any Greek letters. Instead, they will still be typeset as |\mathord| characters in Computer Modern.
%  
%  \begin{figure}
%  \centering
%  Table 3: Font-changing Commands\par\penalty\@M\smallskip
%  \begin{tabular}{ll}
%  \toprule
%  Command & Font Characteristics\\
%  \midrule
%  |\newmathrm| & Upright shape; medium weight\\
%  |\newmathit| & Italic shape; medium weight\\
%  |\newmathbold| & Upright shape; bold weight\\
%  |\newmathboldit| & Italic shape; bold weight\\
%  \bottomrule
%  \end{tabular}
%  \end{figure}
%  
%  Together these four commands will provide users with the tools for almost all desired local font changes, but they inevitably will be insufficient for some particular case. Accordingly, \textsf{mathfont} provides the more general |\newmathfontcommand| macro that functions similarly to the commands from Table~3 but allows the user to specify certain font characteristics. Its argument structure is
%  \begin{code}
%  |\newmathfontcommand{|\argtext{control sequence}|}{|\argtext{font name}|}{|\argtext{series}|}{|\argtext{shape}|}|,
%  \end{code}
%  where the font name again means any OpenType or TrueType font in a directory searchable by \TeX. The series and shape information refers to the \textsc{nfss} codes for these attributes, and the control sequence in the first argument becomes the command that allows the user to access the specified font. Advanced users will note that these five macros are essentially wrapped versions of \LaTeX's |\DeclareMathAlphabet|, and like |\mathfont|, they must be used in the document preamble.
%  
%  \section{Greek Characters}
%  
%  \begin{figure}[t]
%  \centerline{Table 4: Greek Character Control Sequences}\penalty\@M\smallskip
%  \begin{tabularx}{\textwidth}{XXXX}
%  \toprule
%  \multicolumn{2}{c}{Modern Greek Characters} & \multicolumn{2}{c}{Ancient Greek Characters}\\
% \cmidrule(r{4pt}){1-2}\cmidrule(l{4pt}){3-4}
%  Capital & Minuscule & Capital & Minuscule\\
% \midrule
%  |\Alpha|* & |\alpha| &  |\Heta| & |\heta| \\
%  |\Beta|* & |\beta| &  |\Sampi| & |\sampi| \\
%  |\Gamma| & |\gamma| & |\Diagamma| & |\diagama| \\
%  |\Delta| & |\delta| &  |\Koppa| & |\koppa| \\
%  |\Epsilon|* & |\epsilon| & |\Stigma| & |\stigma| \\ 
%  |\Zeta|* & |\zeta| &  |\Sho| & |\sho| \\
%  |\Eta|* & |\eta| &  |\San| & |\san| \\
%  |\Theta| & |\theta| &  |\varSampi | & |\varsampi| \\
%  |\Iota|* & |\iota| &  |\varDiagamma| & |\vardiagamma| \\
%  |\Kappa|* & |\kappa| & |\varKoppa| & |\varkoppa| \\ 
%  |\Lambda| & |\lambda| & & \\
%  |\Mu|* & |\mu| &  & \\
%  |\Nu|* & |\nu| &  & \\
%  |\Xi| & |\xi| &  & \\
%  |\Omicron|* & |\omicron|* &  & \\
%  |\Pi| & |\pi| &  & \\
%  |\Rho|* & |\rho| &  & \\
%  |\Sigma| & |\sigma| &  & \\
%  |\Tau|* & |\tau| &  & \\
%  |\Upsilon| & |\upsilon| &  & \\
%  |\Phi| & |\phi| &  & \\
%  |\Chi|* & |\chi| &  & \\
%  |\Psi| & |\psi| &  & \\
%  |\Omega| & |\omega| &  & \\
%  |\varTheta|* & |\varbeta|* &  & \\
%   & |\varepsilon| &  & \\
%   & |\vartheta| &  & \\
%   & |\varrho| &  & \\
%   & |\varsigma| &  & \\
%   & |\varphi| &  & \\
%  \bottomrule
%  \end{tabularx}
% \par\penalty\@M\medskip\small
% \noindent*Starred Modern Greek and all Ancient Greek letters are not provided by default and are defined only when the user calls |\mathfont| for |greekupper| and/or |greeklower| characters.
%  \end{figure}
%  
%  Unlike Plain \TeX\ and \LaTeXe, \textsf{mathfont} defines control sequences for all characters in the Greek alphabet. (\TeX's OT encodings do not include the capital Greek characters that resemble Latin letters. Presumably Donald Knuth made this decision to conserve encoding slots.) All such control sequences instruct \LaTeX\ to typeset the corresponding unicode Greek character, and \textsf{mathfont} also provides control sequences for several ancient Greek letters. This package's additional Greek character control sequences will become available once the user calls |\mathfont| for the corresponding class of Greek characters. Table~4 lists all such control sequences. I do not include typeset versions of these characters in this documentation because I wanted to avoid potential compilation problems regarding \texttt{mathfont.dtx}. However, see the file \texttt{mathfont\char`\_greek.pdf}, which is included with the \textsf{mathfont} installation and is available on \textsc{ctan}. As with the unicode letterlike symbols, not all fonts contain ancient Greek or even modern Greek characters, and setting \texttt{greekupper} and \texttt{greeklower} to a font without these symbols will produce a document with missing characters.
% 
% \begin{figure}[bt]
% 
% \centerline{Table 5: Characters Corresponding to the |symbols| Keyword}\penalty\@M\smallskip
% \begin{tabularx}{\textwidth}{Xp{9em}XXX}
% \toprule
% Character & Control Sequence & Class & Punctuation & Class \\\cmidrule(r{4pt}){1-3}\cmidrule(l{4pt}){4-5}
% $\#$ & |\#| & |\mathord| & |.| & |\mathord|\\
% $\$$ & |\$| & |\mathord| & |@| & |\mathord|\\
% $\%$ & |\%| & |\mathord| & \texttt{\string|} & |\mathord|\\
% $\&$ & |\&| & |\mathord| & |'| & |\mathord|\\
% $\P$ & |\P| & |\mathord| & |"| & |\mathord|\\
% $\S$ & |\S| & |\mathord| & |+| & |\mathbin|\\
% $\pounds$ & |\pounds| & |\mathord| & |-| & |\mathbin|\\
% $\neg$ & |\neg| & |\mathord| & |*| & |\mathbin|\\
% $\infty$ & |\infty| & |\mathord| & |/| & |\mathbin|\\
% $\partial$ & |\partial| & |\mathord| & |=| & |\mathrel|\\ 
% $\sum$* & |\sum| & |\mathop| & |<| & |\mathrel|\\
% $\prod$* & |\prod| & |\mathop| & |>| & |\mathrel|\\
% $\int$* & |\int| & |\mathop| & |:| & |\mathrel|\\
% $\times$ & |\times| & |\mathbin| & |(| & |\mathopen|\\
% $\div$ & |\div| & |\mathbin| & |)| & |\mathclose|\\
% $\pm$ & |\pm| & |\mathbin| & |[| & |\mathopen|\\
% $\cdot$ & |\cdot| & |\mathbin| & |]| & |\mathclose|\\
% $\bullet$ & |\bullet| & |\mathbin| & |!| & |\mathclose|\\
% $\dagger$ & |\dag| & |\mathbin| & |?| & |\mathclose|\\
% $\ddagger$ & |\ddag| & |\mathbin| & |,| & |\mathpunct|\\
% $\setminus$ & |\setminus| & |\mathbin| & |;| & |\mathpunct|\\
% $\leq$ & |\leq| & |\mathrel| & & \\
% $\geq$ & |\geq| & |\mathrel| & & \\
% $\sim$ & |\sim| & |\mathrel| & & \\
% $\approx$ & |\approx| & |\mathrel| & & \\
% $\equiv$ & |\equiv| & |\mathrel| & & \\
% $\mid$ & |\mid| & |\mathrel| & & \\
% $\parallel$ & |\parallel| & |\mathrel| & &\\
% $\colon$ & |\colon| & |\mathpunct| & & \\
% $\dots$ & |\dots| & |\mathinner| & & \\
% \bottomrule
% \end{tabularx}
% \par\small\penalty\@M\medskip
% \noindent*If the package option |operators| is enabled.\par
% \end{figure}
% 
% \begin{figure}[t]
% \centerline{Table 6: Extra Macros Created with the |symbols| Keyword}\penalty\@M\smallskip
% \begin{tabularx}{\textwidth}{XllXll}
% \toprule
% Character & Control Sequence & Class & Character & Control Sequence & Class\\\cmidrule(r{4pt}){1-3}\cmidrule(l{4pt}){4-6}
% $\backslash$ & |\mathbackslash| & |\mathord| & $\{$ & |\leftbrace| & |\mathopen|\\
% $^\circ$ & |\degree| & |\mathord| & $\}$ & |\rightbrace| & |\mathclose|\\
% $\Delta$* & |\increment| & |\mathord| & & \\
% , & |\comma| & |\mathord| & & & \\
% \bottomrule
% \end{tabularx}
% \par\small\penalty\@M\medskip
% \noindent*As of version 1.5, |\Delta| typesets the Greek letter and |\increment| typesets the increment symbol. The difference will become significant in several situations: (1) when a font contains only one of the symbols or contains two glyphs that appear different; (2) when using local font change commands, which can act on |\Delta| but not |\increment|; or (3) when the user wants to change the font for only one of the Greek letter or increment character. Note that most major unicode fonts contain separate Delta and increment symbols.
% \end{figure}
% 
% \section{Math Symbols}
% 
%  With the |symbols| keyword, the |\mathfont| command will change the default math-mode font for all characters in Table~5. For the control sequences on the left half of the table that function in both math and horizontal modes, \textsf{mathfont} acts on the character only when it appears in math mode, so the character will be unaffected when used in regular text. The same is true for the punctuation marks on the right side. By default the package does not act on the integral, summation, and product symbols. As stated previously, users can enable or disable this behavior with the optional package arguments |operators| and |no-operators| respectively, and doing so may be desirable depending on which math symbols the user wants and the math font in use. Finally, a technical point: when \textsf{mathfont} acts on the |symbols| characters, it redefines the four macros |\#|, |\$|, |\%|, and |\&| as robust commands more complicated than a single |\char|, so constructs like |\number\#| will need to be rewritten as |\number`\#|.
%  
%  Choosing which unicode characters to recode is something of a delicate task because so few unicode fonts contain more than the most basic mathematics symbols. In designing this portion of \textsf{mathfont}, I attempted to find the largest set of characters that reliably appears in every or nearly every major unicode font, and that's why Table~5 contains no arrows, subset and element symbols, quantifiers, and complicated operation and grouping symbols. Most standard unicode fonts don't contain those glyphs, and I wanted \textsf{mathfont} to be useful for as many fonts as possible. That being said, the package provides the five new control sequences listed in Table~6. The |\degree| command functions as the unicode alternative to the |$^\circ$| construction, and the other four control sequences print the associated unicode character. None of these characters are coded as delimiters, so they will not respond to \LaTeX's |\left| and |\right| sizing commands.\footnote{Because of time constraints, I couldn't figure out how to use Lua\TeX's \texttt{\string\Udelimiter} primitive to code the backslash and braces properly. Any suggestions in this area are welcome.} The package also provides an additional comma character to typeset large integers. \TeX\ users have likely noticed the extra space after commas in math mode, e.g.\ $10,000$ versus $10\mathord,000$, and \textsf{mathfont}'s |\comma| solves this problem. Here the first ten thousand uses a standard~|,|~while the second uses |\comma|. In other words, the control sequence typesets a comma in math mode but does not insert the extra space following it. I recommend using |\comma| basically only for large integers, but I leave the ultimate decision to the user.
%  
% 
% \section{Handling Errors}
%  
% Most of \textsf{mathfont}'s error messages are self-explanatory, and the help text will contain instructions for how to resolve the message. Nevertheless, some of the possible error messages warrant additional explanation.
%  
% The most salient error is the ``Missing \XeTeX\ or Lua\TeX'' message. If a user tries to load \textsf{mathfont} without one of these two engines, \TeX\ will crash, either through \textsf{mathfont}'s fatal error message or when \textsf{fontspec} performs its own engine checks. Advanced users should note that \textsf{mathfont} doesn't actually determine the typesetting engine. Rather, it checks whether the \XeTeX\ and Lua\TeX\ primitives |\Umathcode| and |\Umathchardef| are defined, so if for some reason these control sequences have definitions when the user loads \textsf{mathfont}, \textsf{fontspec}'s more robust engine checks will cause \TeX\ to abort. The reasoning here is straightforward: \textsf{mathfont} verifies only that the current typesetting engine provides the commands that it directly needs, so its potential functionality remains as broad as possible. If \textsf{fontspec} becomes compatible with a third engine that also provides (analogues of) |\Umathcode| and |\Umathchardef|, there is no reason to prevent \textsf{mathfont} from working with that engine as well. The obvious corollary to this setup is that users with very old \XeTeX\ or Lua\TeX\ distributions may see this fatal error even when running one of these engines, and the solution is probably to upgrade to a more recent version of the engine in question. Unfortunately, I do not know when \XeTeX\ and Lua\TeX\ introduced these primitives.\footnote{However, the manual for a beta version of Lua\TeX, v.\ 0.70.1, includes both primitives, so they are at least as old as May 2011. See\hfill\break \texttt{https://osl.ugr.es/CTAN/obsolete/systems/luatex/base/manual/luatexref-t.pdf}}
%  
% The \textsf{fontspec} package includes a ``|no-math|'' option, and \textsf{mathfont} expects \textsf{fontspec} to be loaded with this option. As mentioned previously, \textsf{mathfont} loads \textsf{fontspec} by default, but users can load \textsf{fontspec} before \textsf{mathfont} if they want to manually specify the package options. Alternatively, \LaTeX's |\PassOptionsToPackage| may be an even better way to proceed. If \textsf{mathfont} detects that \textsf{fontspec} was loaded without the |no-math| option, it will issue an error message saying so. This error is not paramount in the sense that the document will compile almost normally if a user ignores it, but \textsf{mathfont} will probably have trouble changing the font of certain math-mode characters in this situation. During development, Arabic numerals posed a particular challenge in this regard.
%  
% The ``internal commands restored'' error arises when the user calls |\mathfont| in a situation where the package already restored the small portion of the \LaTeX\ kernel that it adjusts when loaded. Unless the user loads \textsf{mathfont} with the |packages| option, this process happens when the user next calls |\usepackage|, and \textsf{mathfont} will not carry out any calls to |\mathfont| at that point. As mentioned previously, users who want to manually restore the \LaTeX\ kernel can do so with the |\restoremathinternals| command. It is also worth pointing out if the user tries to reset the default font for some characters with |\mathfont|, the package will issue a warning but will not halt the compilation process.  
%  
% What should you do if you can't resolve an error? First, always, always make sure that you spelled all of your commands correctly and closed all braces and brackets. Then check the \textsf{mathfont} documentation---you may be trying to do something outside the scope of the package, or you may be dealing with a special case. In particular, read all the sections of the documentation that relate to the command or commands you are having trouble with. The internet is a great resource, and websites such as the \TeX\ StackExchange, Share\LaTeX, and Wikibooks's \LaTeX\ wiki are often invaluable in dealing with \TeX-related issues. Definitely ask another human as well! At that point you should email the author about your code---you might have identified a bug. I welcome emails about \textsf{mathfont} and will make every effort to write back to correspondence about the package, but I cannot guarantee a timely response.
%  
%  
% 
% \section{Implementation}
% 
% First and foremost, the package needs to declare itself. The \texttt{packages} option changes the |\if@packages| boolean from false to true. Ditto for |operators|.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mathfont}[2019/04/07 v. 1.5 Package mathfont]
\newif\if@packages
\newif\if@operators
\DeclareOption{packages}{\@packagestrue}
\DeclareOption{operators}{\@operatorstrue}
\DeclareOption{no-operators}{\@operatorsfalse}
\DeclareOption*{\PackageError{mathfont}
  {Option "\CurrentOption" unknown}
  {I'm ignoring that option because\MessageBreak
  I don't know what it means.}}
\ProcessOptions*
%    \end{macrocode}
% Some error and informational messages.
%    \begin{macrocode}
\def\M@FontChangeInfo#1{\PackageInfo{mathfont}
  {Changing math-mode #1\MessageBreak
  characters to \csname M@font\the\M@count\endcsname\MessageBreak
  with \csname @#1shape\endcsname\space shape}}
\def\M@NewFontCommandInfo#1#2#3#4{\PackageInfo{mathfont}
  {Creating math alphabet\MessageBreak
  command \string#1 using #2\MessageBreak
  with series #3 and shape\MessageBreak
  #4}}
\def\M@CommandInitializeInfo#1{\PackageInfo{mathfont}
  {Initializing #1 font-change\MessageBreak
  command}}
\def\M@SetInternalsInfo{\PackageInfo{mathfont}
  {Adjusting \string\set@mathchar\space and\MessageBreak
  \string\set@mathsymbol}}
\def\M@RestoreInternalsInfo{\PackageInfo{mathfont}
  {Restoring \string\set@mathchar\space and\MessageBreak
  \string\set@mathsymbol}}
\def\M@CharsSetWarning#1{\PackageWarning{mathfont}
  {Font for #1 chars has already\MessageBreak
  been set}}
\def\M@NoMathError{\PackageError{mathfont}
  {Package fontspec was loaded\MessageBreak
  without the "no-math" option}
  {This isn't really an error--\MessageBreak
  it's fine to load fontspec\MessageBreak
  without "no-math." However,\MessageBreak
  strange things could happen,\MessageBreak
  so beware of any sudden and\MessageBreak
  unexpected font changes. To\MessageBreak
  resolve this error message,\MessageBreak
  load fontspec with the "no-\MessageBreak
  math" option. If you haven't\MessageBreak
  loaded fontspec manually, try\MessageBreak
  loading mathfont earlier in\MessageBreak
  your preamble.}}
\def\M@InvalidOptionError#1{\PackageError{mathfont}
  {Invalid option "#1"\MessageBreak for \string\mathfont}
  {Hm. Check that you spelled the\MessageBreak
  option correctly. Otherwise, I'm\MessageBreak
  not sure what's wrong. Is this\MessageBreak
  option listed in the package\MessageBreak
  documentation?}}
\def\M@MissingOptionError{\PackageError{mathfont}
  {Missing option for \string\mathfont}
  {It looks like you included a , or = in\MessageBreak
  the optional argument of \string\mathfont\space\MessageBreak
  but didn't put anything before it.}}
\def\M@MissingSuboptionError{\PackageError{mathfont}
  {Missing suboption for \string\mathfont}
  {It looks like you included an = somewhere\MessageBreak
  but didn't put the suboption after it. Either\MessageBreak
  that or you typed == instead of = in the\MessageBreak
  optional argument of \string\mathfont.}}
\def\M@InternalsRestoredError{\PackageError{mathfont}
  {Internal commands restored}
  {This package slightly changes two LaTeX\MessageBreak
  internal commands, and you really shouldn't\MessageBreak
  be loading new math fonts without those\MessageBreak
  adjustments. What happened here is that you\MessageBreak
  used \string\mathfont\space in a situation
  where those\MessageBreak
  two commands retain their original defini-\MessageBreak
  tions. Presumably you used
  \string\mathfont\space after\MessageBreak
  loading another package or calling the\MessageBreak
  \string\restoremathinternals\space
  command, and in any\MessageBreak
  event, I'm going to ignore this call to\MessageBreak
  \string\mathfont. Try retypesetting this document\MessageBreak
  with all \string\mathfont\space
  commands immediately\MessageBreak
  after \string\usepackage{mathfont}.}}
\def\M@MissingControlSequenceError#1{\PackageError{mathfont}
  {Improper argument\MessageBreak
  for \string#1}
  {Please use a control sequence as the\MessageBreak
  first argument of \string#1.}}
\def\M@HModeError#1{\PackageError{mathfont}
  {Missing \string$ inserted.\MessageBreak
  Command \string#1 must be used in\MessageBreak
  math mode}
  {I generated an error because\MessageBreak
  you used \string#1 outside of\MessageBreak
  math mode. I've inserted a \string$\MessageBreak
  just before your \string#1, so\MessageBreak
  we should be all good now.}}
%    \end{macrocode}
% We want to create a salient error message if the engine doesn't define the required \XeTeX\ or Lua\TeX\ primitives. We change |+| to active to force \TeX\ to print the required spaces in the message, and we put the entire production inside a group to make this change local. The |\@gobbletwo| eats the extra period and return that \LaTeX\ adds to the error message.
%    \begin{macrocode}
\begingroup
\catcode`\+=\active
\def+{\space}
\def\M@XeTeXLuaTeXError{\GenericError{}
  {\MessageBreak\MessageBreak
  Package mathfont fatal error:
  \MessageBreak\MessageBreak
  +*********************\MessageBreak
  +*+++++++++++++++++++*\MessageBreak
  +*++!!FATAL ERROR!!++*\MessageBreak
  +*+++++++++++++++++++*\MessageBreak
  +*+++Missing XeTeX+++*\MessageBreak
  +*+++++or LuaTeX+++++*\MessageBreak
  +*+++++++++++++++++++*\MessageBreak
  +*********************\MessageBreak\@gobbletwo}
  {See the mathfont package documentation for explanation.}
  {This package requires either\MessageBreak
  XeLaTeX or LuaLaTeX. Please\MessageBreak
  retypeset your document with\MessageBreak
  one of those two engines. This\MessageBreak
  error is fatal, so I'm going\MessageBreak
  to stop processing once you\MessageBreak
  push enter.}\@@end}
%    \end{macrocode}
% Check that the engine has defined the necessary primitives.
%    \begin{macrocode}
\ifx\Umathcode\@undefined
\else
  \ifx\Umathchardef\@undefined
  \else
    \let\M@XeTeXLuaTeXError\relax
  \fi
\fi
\M@XeTeXLuaTeXError
\endgroup
%    \end{macrocode}
% We load the \textsf{fontspec} package in order to use
% its main font loading mechanism, and we |\let| the
% macro |\@newfont| take on this function.
% We also make sure that \textsf{fontspec} was loaded
% with the |no-math| option because without it, \textsf{fontspec} may cause trouble
% with some of the math characters. If |\g__fontspec_math_bool|
% is equal to 1, \textsf{mathfont} will issue an error message.
%    \begin{macrocode}
\@ifpackageloaded{fontspec}
  {\ifnum\csname g__fontspec_math_bool\endcsname=1
    \M@NoMathError
  \fi}{\RequirePackage[no-math]{fontspec}}
\expandafter\let\expandafter\@newfont
  \csname fontspec_set_family:Nnn\endcsname
%    \end{macrocode}
% We save |\set@mathchar| and |\set@mathsymbol| from the \LaTeX\ kernel 
% so we can change their
% definitions. We need to adapt these macros for use with unicode fonts, and we
% replace |\mathcode| and |\mathchardef| respectively
% with the \XeTeX\ and Lua\TeX\ primitives |\Umathcode| and |\Umathchardef|.
% The unicode primitives support decimal input using 
% a |+| sign, and we take advantage of that feature to avoid hexadecimal conversions.
%    \begin{macrocode}
\M@SetInternalsInfo
\let\@@set@mathchar\set@mathchar
\let\@@set@mathsymbol\set@mathsymbol
\def\set@mathchar#1#2#3#4{%
  \multiply\count\z@ by 16\relax
  \advance\count\z@\count\tw@
  \global\Umathcode`#2=\mathchar@type#3+#1+\count\z@}
\def\set@mathsymbol#1#2#3#4{%
  \multiply\count\z@ by 16\relax
  \advance\count\z@\count\tw@
  \global\Umathchardef#2\mathchar@type#3+#1+\count\z@}
%    \end{macrocode}
% We need to keep track of the number of times we have loaded a font, and the count |\M@count| fulfills this role. We will use the |\M@toks| object to record a message that displays when the user calls |\mathfont|.
%    \begin{macrocode}
\newcount\M@count
\M@count\z@
\newtoks\M@toks
%    \end{macrocode}
% We create necessary booleans and the default math font shapes.
%    \begin{macrocode}
\newif\if@upper
\newif\if@lower
\newif\if@greekupper
\newif\if@greeklower
\newif\if@operator
\newif\if@digits
\newif\if@symbols
\newif\if@bb
\newif\if@cal
\newif\if@frak
\newif\if@bcal
\newif\if@bfrak
\newif\if@suboptionpresent
\newif\if@mathfont@firstoption
\def\@uppershape{italic}
\def\@lowershape{italic}
\def\@greekuppershape{roman}
\def\@greeklowershape{italic}
\def\@digitsshape{roman}
\def\@symbolsshape{roman}
\def\@operatorshape{roman}
\def\@bbshape{roman}
\def\@calshape{roman}
\def\@frakshape{roman}
\def\@bcalshape{roman}
\def\@bfrakshape{roman}
%    \end{macrocode}
% The command |\check@option@valid| confirms that a user's keyword option is legitimate. The macro defines |\@temperror| to be an invalid option error and loops through all possible options. If the command argument matches one of the correct possibilities, the package changes |\@temperror| to |\relax|. The macro ends this process with a call to |\@temperror|, so the package issues an error if and only if the specified option is invalid. We have to initialize the blackboard, calligraphic, and fraktur commands separately because they don't use the same encoding-alphabet system as the regular letters and digits. The |\define@|\argtext{keyword} macro does this.
%    \begin{macrocode}
\def\check@option@valid#1{%
  \def\@temperror{\M@InvalidOptionError{#1}}
  \@for\@j:=upper,lower,greekupper,greeklower,digits,symbols,operator\do{%
    \ifx\@j#1
      \let\@temperror\relax
    \fi}
  \@for\@j:=bb,cal,frak,bcal,bfrak\do{%
    \ifx\@j#1
      \let\@temperror\relax
      \csname define@\@j\endcsname
    \fi}
  \@temperror}
%    \end{macrocode}
% Do the same thing for the suboption.
%    \begin{macrocode}
\def\check@suboption@valid#1{%
  \def\@temperror{\M@InvalidOptionError{#1}}
  \@for\@j:=roman,italic\do{%
    \ifx\@j#1
      \let\@temperror\relax
    \fi}
  \@temperror}
%    \end{macrocode}
% We want to allow the user to specify options using an \textsf{xkeyval}-type syntax. However, we do not need the full package; a slim 24 lines of code will suffice. We use the next three macros to parse the optional argument of |\mathfont|. The control sequence
% \begin{code}
% |\@gobblesp |\argtext{text}|\@nil|\argtext{macro}
% \end{code}
% takes the first string of consecutive non-space tokens in \textit{text} and sets it to be the contents of \textit{macro}. We remove initial spaces with |\@ifnextchar| and use delimiters in the definition of |\g@bblesp@def| for the token selection and final storage.
%   \begin{macrocode}
\def\@gobble@equals#1=#2\@nil{#1}
\def\@gobblesp{\@ifnextchar\@empty\relax\g@bblesp@def}
\def\g@bblesp@def#1 #2\@nil#3{\def#3{#1}}
%    \end{macrocode}
% Parse the option and suboption. When |\mathfont| expands, it loops through its optional argument with |\@for|, and for each option-suboption token string, it calls |\parse@suboption| on the token string followed by |=\@nil|. Doing so splits the option and suboption, and |\parse@suboption| handles each separately. All tokens before the first |=| become the option, and all tokens after become the suboption. The macro removes any extra spaces with |\@gobblesp| and puts the option in |\@tempa|. We include the extra |\\| in the argument of |\@gobblesp| because we need to check that the option portion of the token string contains non-space characters. If not, |\@tempa| will become |\\|, and the package issues an error. (If yes, |\g@bblesp@def| will gobble the |\\| and following space, so it won't matter.)
%    \begin{macrocode}
\def\parse@suboption#1=#2\@nil{%
  \@gobblesp#1 \\ \@nil\@tempa
  \def\@tempb{\\}
  \ifx\@tempa\@tempb
    \M@MissingOptionError
  \else
    \check@option@valid\@tempa
  \fi
%    \end{macrocode}
% Adding the |=\@nil| to the token string allows us to see immediately whether the user specified a suboption by checking if |#2| is empty. If not, the macro again removes extra spaces with |\@gobblesp|, and we check whether |\@let@token| from the |\@ifnextchar| is the extra~|=|. That would mean the user typed |=| but didn't follow it with a suboption, and in that case, \textsf{mathfont} issues an error. If the suboption is valid, the macro gobbles the last |=| with |\@gobble@equals| and stores the result in |\@tempb|.
%    \begin{macrocode}
  \def\@tempb{#2}
  \ifx\@tempb\@empty
    \@suboptionpresentfalse
  \else
    \@gobblesp#2 \@nil\@tempb
    \if\@let@token=
      \M@MissingSuboptionError
    \else
      \edef\@tempb{\expandafter\@gobble@equals\@tempb=\@nil}
      \check@suboption@valid\@tempb
    \fi
    \@suboptionpresenttrue
  \fi}
%    \end{macrocode}
% 
% \section{Implementation of Default Font Changes}
% 
% The user-level command |\mathfont| passes its mandatory argument to |\@newfont| through the |\@mathfont| command. If the user includes |\mathfont| with an optional argument, |\@mathfont| will loop througheach item in the optional argumentusing |\@for| and set the math font for each of those classes of characters. If the user does not specify an optional argument, |\mathfont| calls |\@mathfont| with the list of entries from Table~1 in brackets. The |\@mathfont| macro proceeds in several steps. First, it checks if |\set@mathchar| has been reset, and if so, the current call to |\mathfont| will do nothing. If not, the macro loads the user's font with |\@newfont| and checks its keyword optional arguments. The command declares the appropriate symbol fonts if necessary, actually sets the math font by calling |\M@|\argtext{keyword}|@set| command, and records that the font change occurred by switching the appropriate boolean to true. Finally, |\@mathfont| increments |\M@count| by one.
% 
% The package stores each new font in a macro of the form |\M@font|\argtext{number}, where \textit{number} is given by the  current value of |\M@count|. The name of the corresponding symbol fonts is |M|\argtext{shape}\argtext{number}, where \textit{shape} is either \texttt{roman} or \texttt{italic} and \textit{number} is again the value of |\M@count|. For each keyword from Tables~1 and 2, the package originally defines |\@|\argtext{keyword}|shape| as the default shape for that collection of characters. If the user specifies a suboption for any keyword in the  optional argument of |\mathfont|, the package overrides the default shape by redefining |\@|\argtext{keyword}|shape| to the value of the suboption. For example, suppose the user loads \textsf{mathfont} and then immediately writes
% \begin{code}
% |\mathfont[upper=roman]{Helvetica}|.
% \end{code}
% In this situation, \textsf{mathfont} would define |\M@font0| to be the internal name of Helvetica, and the corresponding symbol font names would be |Mroman0| and |Mitalic0|. Because the user specified a suboption, |\@mathfont| would redefine |\M@uppershape| to the token string ``\texttt{roman},'' and the package will use |\M@uppershape| later to specify the  symbol font for capital Latin characters.
%    \begin{macrocode}
\def\mathfont{\@ifnextchar[{\@mathfont}
  {\@mathfont[upper,lower,greekupper,greeklower,digits,symbols,operator]}}
\def\@mathfont[#1]#2{%
  \ifx\@@set@mathchar\set@mathchar
    \M@InternalsRestoredError
  \else
    \M@toks{}
    \@mathfont@firstoptiontrue
    \expandafter\@newfont\csname M@font\the\M@count\endcsname{}{#2}
    \edef\@tempa{#1}
    \@for\@i:=\@tempa\do{\expandafter\parse@suboption\@i=\@nil
%    \end{macrocode}
% If the user calls |\mathfont| and tries to reset the font for a certain class of characters, \textsf{mathfont} will issue a warning,  and the package will not adjust the font for those characters. Notice the particularly awkward syntax with the |\csname|-|\endcsname| pairs. Without this construct, \TeX\ wouldn't realize that |\csname if@\@tempa\endcsname| matches the eventual |\fi|, and the |\@for| loop would break. (\TeX\ does not have a smart if-parser!)
%    \begin{macrocode}
      \expandafter\ifx\csname if@\@tempa\expandafter\endcsname
                  \csname iftrue\endcsname
        \M@CharsSetWarning{\@tempa}
      \else
        \if@mathfont@firstoption
          \@mathfont@firstoptionfalse
        \else
          \expandafter\M@toks\expandafter{\the\M@toks, }
        \fi
        \edef\@tempc{\the\M@toks\@tempa}
        \expandafter\M@toks\expandafter{\@tempc}
%    \end{macrocode}
% Handle the case with a suboption.
%    \begin{macrocode}
        \if@suboptionpresent
          \expandafter\edef\csname @\@tempa shape\endcsname{\@tempb}
          \edef\@tempc{\the\M@toks\space(\@tempb)}
          \expandafter\M@toks\expandafter{\@tempc}
        \fi
%    \end{macrocode}
% For both possible shapes, check whether the package has already declared that version of the current font for use in math mode using |\@ifundefined|. If not, do so.
%    \begin{macrocode}
        \def\@tempb{roman}
        \expandafter\ifx\csname @\@tempa shape\endcsname\@tempb
          \@ifundefined{symMroman\the\M@count}{%
            \DeclareSymbolFont{Mroman\the\M@count}{TU}
              {\csname M@font\the\M@count\endcsname}{m}{n}}{}
        \fi
        \def\@tempb{italic}
        \expandafter\ifx\csname @\@tempa shape\endcsname\@tempb
          \@ifundefined{symMitalic\the\M@count}{%
            \DeclareSymbolFont{Mitalic\the\M@count}{TU}
              {\csname M@font\the\M@count\endcsname}{m}{it}}{}
        \fi
%    \end{macrocode}
% And now the magic happens.
%    \begin{macrocode}
        \M@FontChangeInfo{\@tempa}
        \csname M@\@tempa @set\endcsname
        \csname @\@tempa true\endcsname
      \fi}
    \advance\M@count\@ne\relax
    \message{:: mathfont :: following keyword(s) changed to #2:^^J%
      --\the\M@toks.^^J}
  \fi}
\@onlypreamble\mathfont
%    \end{macrocode}
% We end the section by coding |\setfont|.
%    \begin{macrocode}
\def\setfont#1{\mathfont{#1}\setmainfont[Ligatures=TeX]{#1}}
\@onlypreamble\setfont
%    \end{macrocode}
% 
% \section{Implementation of Local Font Changes}
% 
% The general |\newmathfontcommand| macro creates commands that locally change the math font. This macro creates a new math alphabet, and it stores that alphabet in the user-provided control sequence. First, we check to make sure that the user provided a control sequence for the first argument of |\newmathfontcommand|, and if the user did not, |\check@csarg| issues an error.
%    \begin{macrocode}
\def\check@csarg#1#2#3{%
  \ifcat\relax\noexpand#2
    \def\@tempa{#2}
    \@newfont\@tempb{}{#3}
    \expandafter\@newmathfontcommand
  \else
    \M@MissingControlSequenceError#1
  \fi}
%    \end{macrocode}
% Now declare the math alphabet.
%    \begin{macrocode}
\def\@newmathfontcommand#1#2{\expandafter
  \DeclareMathAlphabet\expandafter{\@tempa}{TU}{\@tempb}{#1}{#2}}
\def\newmathfontcommand{\check@csarg\newmathfontcommand}
\@onlypreamble\newmathfontcommand
%    \end{macrocode}
% Then provide the four default versions.
%    \begin{macrocode}
\def\newmathrm#1#2{\check@csarg\newmathrm{#1}{#2}{m}{n}}
\def\newmathit#1#2{\check@csarg\newmathit{#1}{#2}{m}{it}}
\def\newmathbold#1#2{\check@csarg\newmathbold{#1}{#2}{b}{n}}
\def\newmathboldit#1#2{\check@csarg\newmathboldit{#1}{#2}{b}{it}}
\@onlypreamble\newmathrm
\@onlypreamble\newmathit
\@onlypreamble\newmathbold
\@onlypreamble\newmathboldit
%    \end{macrocode}
%
% \section{Implementation of Alphanumeric Symbols}
% 
% Each |\define@|\argtext{keyword} macro redefines one of the standard |\math|\argtext{keyword} commands. The new versions first check if they are in math mode using |\check@mmode| and then scan all tokens of their argument using |\@tfor|. For each token, the macro calls  |\M@|\argtext{keyword}|@|\argtext{token}, which evaluates to a |\mathord| symbol in the desired style. 
%    \begin{macrocode}
\def\check@mmode#1#2{%
  \let\@tempa#2%
  \ifmmode
    \expandafter\@tempa
  \else
    \M@HModeError#1%
    \leavevmode\expandafter$\expandafter\@tempa
  \fi}
\def\process@tokens#1#2{\@tfor\@k:=#1\do{\csname M@#2@\@k\endcsname}}
\def\define@bb{%
  \M@CommandInitializeInfo{blackboard bold}
  \def\mathbb{\check@mmode\mathbb\@mathbb}
  \def\@mathbb##1{\process@tokens{##1}{bb}}}
\def\define@cal{%
  \M@CommandInitializeInfo{calligraphic}
  \def\mathcal{\check@mmode\mathcal\@mathcal}
  \def\@mathcal##1{\process@tokens{##1}{cal}}}
\def\define@frak{%
  \M@CommandInitializeInfo{fraktur}
  \def\mathfrak{\check@mmode\mathfrak\@mathfrak}
  \def\@mathfrak##1{\process@tokens{##1}{frak}}}
\def\define@bcal{%
  \M@CommandInitializeInfo{bold calligraphic}
  \def\mathbcal{\check@mmode\mathbcal\@mathbcal}
  \def\@mathbcal##1{\process@tokens{##1}{bcal}}}
\def\define@bfrak{%
  \M@CommandInitializeInfo{bold fraktur}
  \def\mathbfrak{\check@mmode\mathbfrak\@mathbfrak}
  \def\@mathbfrak##1{\process@tokens{##1}{bfrak}}}
%    \end{macrocode}
% 
% \section{Unicode Hex Values}
% 
% Set capital Latin characters. We use an |\edef| for |\M@upper| because
% every expansion now will save \LaTeX\ twenty-six expansions later when it 
% evaluates each |\DeclareMathSymbol|.
%    \begin{macrocode}
\def\M@upper@set{%
  \edef\M@upper{M\@uppershape\the\M@count}
  \DeclareMathSymbol{A}{\mathalpha}{\M@upper}{`A}
  \DeclareMathSymbol{B}{\mathalpha}{\M@upper}{`B}
  \DeclareMathSymbol{C}{\mathalpha}{\M@upper}{`C}
  \DeclareMathSymbol{D}{\mathalpha}{\M@upper}{`D}
  \DeclareMathSymbol{E}{\mathalpha}{\M@upper}{`E}
  \DeclareMathSymbol{F}{\mathalpha}{\M@upper}{`F}
  \DeclareMathSymbol{G}{\mathalpha}{\M@upper}{`G}
  \DeclareMathSymbol{H}{\mathalpha}{\M@upper}{`H}
  \DeclareMathSymbol{I}{\mathalpha}{\M@upper}{`I}
  \DeclareMathSymbol{J}{\mathalpha}{\M@upper}{`J}
  \DeclareMathSymbol{K}{\mathalpha}{\M@upper}{`K}
  \DeclareMathSymbol{L}{\mathalpha}{\M@upper}{`L}
  \DeclareMathSymbol{M}{\mathalpha}{\M@upper}{`M}
  \DeclareMathSymbol{N}{\mathalpha}{\M@upper}{`N}
  \DeclareMathSymbol{O}{\mathalpha}{\M@upper}{`O}
  \DeclareMathSymbol{P}{\mathalpha}{\M@upper}{`P}
  \DeclareMathSymbol{Q}{\mathalpha}{\M@upper}{`Q}
  \DeclareMathSymbol{R}{\mathalpha}{\M@upper}{`R}
  \DeclareMathSymbol{S}{\mathalpha}{\M@upper}{`S}
  \DeclareMathSymbol{T}{\mathalpha}{\M@upper}{`T}
  \DeclareMathSymbol{U}{\mathalpha}{\M@upper}{`U}
  \DeclareMathSymbol{V}{\mathalpha}{\M@upper}{`V}
  \DeclareMathSymbol{W}{\mathalpha}{\M@upper}{`W}
  \DeclareMathSymbol{X}{\mathalpha}{\M@upper}{`X}
  \DeclareMathSymbol{Y}{\mathalpha}{\M@upper}{`Y}
  \DeclareMathSymbol{Z}{\mathalpha}{\M@upper}{`Z}}
%    \end{macrocode}
% Set minuscule Latin characters.
%    \begin{macrocode}
\def\M@lower@set{%
  \edef\M@lower{M\@lowershape\the\M@count}
  \DeclareMathSymbol{a}{\mathalpha}{\M@lower}{`a}
  \DeclareMathSymbol{b}{\mathalpha}{\M@lower}{`b}
  \DeclareMathSymbol{c}{\mathalpha}{\M@lower}{`c}
  \DeclareMathSymbol{d}{\mathalpha}{\M@lower}{`d}
  \DeclareMathSymbol{e}{\mathalpha}{\M@lower}{`e}
  \DeclareMathSymbol{f}{\mathalpha}{\M@lower}{`f}
  \DeclareMathSymbol{g}{\mathalpha}{\M@lower}{`g}
  \DeclareMathSymbol{h}{\mathalpha}{\M@lower}{`h}
  \DeclareMathSymbol{i}{\mathalpha}{\M@lower}{`i}
  \DeclareMathSymbol{j}{\mathalpha}{\M@lower}{`j}
  \DeclareMathSymbol{k}{\mathalpha}{\M@lower}{`k}
  \DeclareMathSymbol{l}{\mathalpha}{\M@lower}{`l}
  \DeclareMathSymbol{m}{\mathalpha}{\M@lower}{`m}
  \DeclareMathSymbol{n}{\mathalpha}{\M@lower}{`n}
  \DeclareMathSymbol{o}{\mathalpha}{\M@lower}{`o}
  \DeclareMathSymbol{p}{\mathalpha}{\M@lower}{`p}
  \DeclareMathSymbol{q}{\mathalpha}{\M@lower}{`q}
  \DeclareMathSymbol{r}{\mathalpha}{\M@lower}{`r}
  \DeclareMathSymbol{s}{\mathalpha}{\M@lower}{`s}
  \DeclareMathSymbol{t}{\mathalpha}{\M@lower}{`t}
  \DeclareMathSymbol{u}{\mathalpha}{\M@lower}{`u}
  \DeclareMathSymbol{v}{\mathalpha}{\M@lower}{`v}
  \DeclareMathSymbol{w}{\mathalpha}{\M@lower}{`w}
  \DeclareMathSymbol{x}{\mathalpha}{\M@lower}{`x}
  \DeclareMathSymbol{y}{\mathalpha}{\M@lower}{`y}
  \DeclareMathSymbol{z}{\mathalpha}{\M@lower}{`z}}
%    \end{macrocode}
% Set capital Greek characters.
%    \begin{macrocode}
\def\M@greekupper@set{%
  \edef\M@greekupper{M\@greekuppershape\the\M@count}
  \DeclareMathSymbol{\Alpha}{\mathalpha}{\M@greekupper}{"391}
  \DeclareMathSymbol{\Beta}{\mathalpha}{\M@greekupper}{"392}
  \DeclareMathSymbol{\Gamma}{\mathalpha}{\M@greekupper}{"393}
  \DeclareMathSymbol{\Delta}{\mathalpha}{\M@greekupper}{"394}
  \DeclareMathSymbol{\Epsilon}{\mathalpha}{\M@greekupper}{"395}
  \DeclareMathSymbol{\Zeta}{\mathalpha}{\M@greekupper}{"396}
  \DeclareMathSymbol{\Eta}{\mathalpha}{\M@greekupper}{"397}
  \DeclareMathSymbol{\Theta}{\mathalpha}{\M@greekupper}{"398}
  \DeclareMathSymbol{\Iota}{\mathalpha}{\M@greekupper}{"399}
  \DeclareMathSymbol{\Kappa}{\mathalpha}{\M@greekupper}{"39A}
  \DeclareMathSymbol{\Lambda}{\mathalpha}{\M@greekupper}{"39B}
  \DeclareMathSymbol{\Mu}{\mathalpha}{\M@greekupper}{"39C}
  \DeclareMathSymbol{\Nu}{\mathalpha}{\M@greekupper}{"39D}
  \DeclareMathSymbol{\Xi}{\mathalpha}{\M@greekupper}{"39E}
  \DeclareMathSymbol{\Omicron}{\mathalpha}{\M@greekupper}{"39F}
  \DeclareMathSymbol{\Pi}{\mathalpha}{\M@greekupper}{"3A0}
  \DeclareMathSymbol{\Rho}{\mathalpha}{\M@greekupper}{"3A1}
  \DeclareMathSymbol{\Sigma}{\mathalpha}{\M@greekupper}{"3A3}
  \DeclareMathSymbol{\Tau}{\mathalpha}{\M@greekupper}{"3A4}
  \DeclareMathSymbol{\Upsilon}{\mathalpha}{\M@greekupper}{"3A5}
  \DeclareMathSymbol{\Phi}{\mathalpha}{\M@greekupper}{"3A6}
  \DeclareMathSymbol{\Chi}{\mathalpha}{\M@greekupper}{"3A7}
  \DeclareMathSymbol{\Psi}{\mathalpha}{\M@greekupper}{"3A8}
  \DeclareMathSymbol{\Omega}{\mathalpha}{\M@greekupper}{"3A9}
  \DeclareMathSymbol{\varTheta}{\mathalpha}{\M@greekupper}{"3F4}
  \DeclareMathSymbol{\Heta}{\mathalpha}{\M@greekupper}{"370}
  \DeclareMathSymbol{\Sampi}{\mathalpha}{\M@greekupper}{"3E0}
  \DeclareMathSymbol{\Diagamma}{\mathalpha}{\M@greekupper}{"3DC}
  \DeclareMathSymbol{\Koppa}{\mathalpha}{\M@greekupper}{"3D8}
  \DeclareMathSymbol{\Stigma}{\mathalpha}{\M@greekupper}{"3DA}
  \DeclareMathSymbol{\Sho}{\mathalpha}{\M@greekupper}{"3F7}
  \DeclareMathSymbol{\San}{\mathalpha}{\M@greekupper}{"3FA}
  \DeclareMathSymbol{\varSampi}{\mathalpha}{\M@greekupper}{"372}
  \DeclareMathSymbol{\varDiagamma}{\mathalpha}{\M@greekupper}{"376}
  \DeclareMathSymbol{\varKoppa}{\mathalpha}{\M@greekupper}{"3DE}}
%    \end{macrocode}
% Set minuscule Greek characters.
%    \begin{macrocode}
\def\M@greeklower@set{%
  \edef\M@greeklower{M\@greeklowershape\the\M@count}
  \DeclareMathSymbol{\alpha}{\mathalpha}{\M@greeklower}{"3B1}
  \DeclareMathSymbol{\beta}{\mathalpha}{\M@greeklower}{"3B2}
  \DeclareMathSymbol{\gamma}{\mathalpha}{\M@greeklower}{"3B3}
  \DeclareMathSymbol{\delta}{\mathalpha}{\M@greeklower}{"3B4}
  \DeclareMathSymbol{\epsilon}{\mathalpha}{\M@greeklower}{"3F5}
  \DeclareMathSymbol{\zeta}{\mathalpha}{\M@greeklower}{"3B6}
  \DeclareMathSymbol{\eta}{\mathalpha}{\M@greeklower}{"3B7}
  \DeclareMathSymbol{\theta}{\mathalpha}{\M@greeklower}{"3B8}
  \DeclareMathSymbol{\iota}{\mathalpha}{\M@greeklower}{"3B9}
  \DeclareMathSymbol{\kappa}{\mathalpha}{\M@greeklower}{"3BA}
  \DeclareMathSymbol{\lambda}{\mathalpha}{\M@greeklower}{"3BB}
  \DeclareMathSymbol{\mu}{\mathalpha}{\M@greeklower}{"3BC}
  \DeclareMathSymbol{\nu}{\mathalpha}{\M@greeklower}{"3BD}
  \DeclareMathSymbol{\xi}{\mathalpha}{\M@greeklower}{"3BE}
  \DeclareMathSymbol{\omicron}{\mathalpha}{\M@greeklower}{"3BF}
  \DeclareMathSymbol{\pi}{\mathalpha}{\M@greeklower}{"3C0}
  \DeclareMathSymbol{\rho}{\mathalpha}{\M@greeklower}{"3C1}
  \DeclareMathSymbol{\sigma}{\mathalpha}{\M@greeklower}{"3C3}
  \DeclareMathSymbol{\tau}{\mathalpha}{\M@greeklower}{"3C4}
  \DeclareMathSymbol{\upsilon}{\mathalpha}{\M@greeklower}{"3C5}
  \DeclareMathSymbol{\phi}{\mathalpha}{\M@greeklower}{"3D5}
  \DeclareMathSymbol{\chi}{\mathalpha}{\M@greeklower}{"3C7}
  \DeclareMathSymbol{\psi}{\mathalpha}{\M@greeklower}{"3C8}
  \DeclareMathSymbol{\omega}{\mathalpha}{\M@greeklower}{"3C9}
  \DeclareMathSymbol{\varbeta}{\mathalpha}{\M@greeklower}{"3D0}
  \DeclareMathSymbol{\varepsilon}{\mathalpha}{\M@greeklower}{"3B5}
  \DeclareMathSymbol{\vartheta}{\mathalpha}{\M@greeklower}{"3D1}
  \DeclareMathSymbol{\varrho}{\mathalpha}{\M@greeklower}{"3F1}
  \DeclareMathSymbol{\varsigma}{\mathalpha}{\M@greeklower}{"3C2}
  \DeclareMathSymbol{\varphi}{\mathalpha}{\M@greeklower}{"3C6}
  \DeclareMathSymbol{\heta}{\mathalpha}{\M@greeklower}{"371}
  \DeclareMathSymbol{\sampi}{\mathalpha}{\M@greeklower}{"3E1}
  \DeclareMathSymbol{\diagamma}{\mathalpha}{\M@greeklower}{"3DD}
  \DeclareMathSymbol{\koppa}{\mathalpha}{\M@greeklower}{"3D9}
  \DeclareMathSymbol{\stigma}{\mathalpha}{\M@greeklower}{"3DB}
  \DeclareMathSymbol{\sho}{\mathalpha}{\M@greeklower}{"3F8}
  \DeclareMathSymbol{\san}{\mathalpha}{\M@greeklower}{"3FB}
  \DeclareMathSymbol{\varsampi}{\mathalpha}{\M@greeklower}{"373}
  \DeclareMathSymbol{\vardiagamma}{\mathalpha}{\M@greeklower}{"377}
  \DeclareMathSymbol{\varkoppa}{\mathalpha}{\M@greeklower}{"3DF}}
%    \end{macrocode}
% Set digits.
%    \begin{macrocode}
\def\M@digits@set{%
  \edef\M@digits{M\@digitsshape\the\M@count}
  \DeclareMathSymbol{0}{\mathalpha}{\M@digits}{`0}
  \DeclareMathSymbol{1}{\mathalpha}{\M@digits}{`1}
  \DeclareMathSymbol{2}{\mathalpha}{\M@digits}{`2}
  \DeclareMathSymbol{3}{\mathalpha}{\M@digits}{`3}
  \DeclareMathSymbol{4}{\mathalpha}{\M@digits}{`4}
  \DeclareMathSymbol{5}{\mathalpha}{\M@digits}{`5}
  \DeclareMathSymbol{6}{\mathalpha}{\M@digits}{`6}
  \DeclareMathSymbol{7}{\mathalpha}{\M@digits}{`7}
  \DeclareMathSymbol{8}{\mathalpha}{\M@digits}{`8}
  \DeclareMathSymbol{9}{\mathalpha}{\M@digits}{`9}}
%    \end{macrocode}
% Set symbols.
%    \begin{macrocode}
\def\M@symbols@set{%
  \edef\M@symbols{M\@symbolsshape\the\M@count}
  \DeclareMathSymbol{.}{\mathord}{\M@symbols}{"2E}
  \DeclareMathSymbol{@}{\mathord}{\M@symbols}{"40}
  \DeclareMathSymbol{\mathhash}{\mathord}{\M@symbols}{"23}
  \DeclareMathSymbol{\mathdollar}{\mathord}{\M@symbols}{"24}
  \DeclareMathSymbol{\mathpercent}{\mathord}{\M@symbols}{"25}
  \DeclareMathSymbol{\mathand}{\mathord}{\M@symbols}{"26}
  \DeclareMathSymbol{\mathparagraph}{\mathord}{\M@symbols}{"B6}
  \DeclareMathSymbol{\mathsection}{\mathord}{\M@symbols}{"A7}
  \DeclareMathSymbol{\mathsterling}{\mathord}{\M@symbols}{"A3}
  \DeclareMathSymbol{|}{\mathord}{\M@symbols}{"7C}
  \DeclareMathSymbol{\neg}{\mathord}{\M@symbols}{"AC}
  \DeclareMathSymbol{\infty}{\mathord}{\M@symbols}{"221E}
  \DeclareMathSymbol{\partial}{\mathord}{\M@symbols}{"2202}
  \DeclareMathSymbol{\mathbackslash}{\mathord}{\M@symbols}{"5C}
  \DeclareMathSymbol{\degree}{\mathord}{\M@symbols}{"B0}
  \DeclareMathSymbol{\increment}{\mathord}{\M@symbols}{"2206}
  \DeclareMathSymbol{'}{\mathord}{\M@symbols}{"2032}
  \DeclareMathSymbol{"}{\mathord}{\M@symbols}{"2033}
  \DeclareMathSymbol{\comma}{\mathord}{\M@symbols}{"2C}
  \if@operators
    \DeclareMathSymbol{\sum}{\mathop}{\M@symbols}{"2211}
    \DeclareMathSymbol{\prod}{\mathop}{\M@symbols}{"220F}
    \DeclareMathSymbol{\intop}{\mathop}{\M@symbols}{"222B}
  \fi
  \DeclareMathSymbol{+}{\mathbin}{\M@symbols}{"2B}
  \DeclareMathSymbol{-}{\mathbin}{\M@symbols}{"2212}
  \DeclareMathSymbol{*}{\mathbin}{\M@symbols}{"2A}
  \DeclareMathSymbol{\times}{\mathbin}{\M@symbols}{"D7}
  \DeclareMathSymbol{/}{\mathbin}{\M@symbols}{"2215}
  \DeclareMathSymbol{\div}{\mathbin}{\M@symbols}{"F7}
  \DeclareMathSymbol{\pm}{\mathbin}{\M@symbols}{"B1}
  \DeclareMathSymbol{\cdot}{\mathbin}{\M@symbols}{"2219}
  \DeclareMathSymbol{\bullet}{\mathbin}{\M@symbols}{"2022}
  \DeclareMathSymbol{\dagger}{\mathbin}{\M@symbols}{"2020}
  \DeclareMathSymbol{\ddagger}{\mathbin}{\M@symbols}{"2021}
  \DeclareMathSymbol{\setminus}{\mathbin}{\M@symbols}{"5C}
  \DeclareMathSymbol{=}{\mathrel}{\M@symbols}{"3D}
  \DeclareMathSymbol{<}{\mathrel}{\M@symbols}{"3C}
  \DeclareMathSymbol{>}{\mathrel}{\M@symbols}{"3E}
  \DeclareMathSymbol{\leq}{\mathrel}{\M@symbols}{"2264}
  \DeclareMathSymbol{\geq}{\mathrel}{\M@symbols}{"2265}
  \DeclareMathSymbol{\sim}{\mathrel}{\M@symbols}{"7E}
  \DeclareMathSymbol{\approx}{\mathrel}{\M@symbols}{"2248}
  \DeclareMathSymbol{\equiv}{\mathrel}{\M@symbols}{"2261}
  \DeclareMathSymbol{\mid}{\mathrel}{\M@symbols}{"7C}
  \DeclareMathSymbol{\parallel}{\mathrel}{\M@symbols}{"2016}
  \DeclareMathSymbol{:}{\mathrel}{\M@symbols}{"3A}
  \DeclareMathSymbol{(}{\mathopen}{\M@symbols}{"28}
  \DeclareMathSymbol{)}{\mathclose}{\M@symbols}{"29}
  \DeclareMathSymbol{[}{\mathopen}{\M@symbols}{"5B}
  \DeclareMathSymbol{]}{\mathclose}{\M@symbols}{"5D}
  \DeclareMathSymbol{\leftbrace}{\mathopen}{\M@symbols}{"7B}
  \DeclareMathSymbol{\rightbrace}{\mathclose}{\M@symbols}{"7D}
  \DeclareMathSymbol{?}{\mathclose}{\M@symbols}{"3F}
  \DeclareMathSymbol{!}{\mathclose}{\M@symbols}{"21}
  \DeclareMathSymbol{,}{\mathpunct}{\M@symbols}{"2C}
  \DeclareMathSymbol{;}{\mathpunct}{\M@symbols}{"3B}
  \DeclareMathSymbol{\colon}{\mathpunct}{\M@symbols}{"3A}
  \let\mathellipsis\@undefined
  \DeclareMathSymbol{\mathellipsis}{\mathinner}{\M@symbols}{"2026}
%    \end{macrocode}
% Finally a bit of housekeeping. We redefine |\#|, |\$|, |\%|, and |\&| as robust commands that expand to previously declared |\mathhash|, etc.\ commands in math mode and retain their standard |\char| definitions otherwise. Other commands that function in both math and horizontal modes such as |\S| or |\dag| also use this technique. The last three commands defined here preserve the Computer Modern font for charcters used in several math-mode symbols.
%    \begin{macrocode}
  \DeclareRobustCommand\#{\ifmmode\mathhash\else\char"23\fi}
  \DeclareRobustCommand\${\ifmmode\mathdollar\else\char"24\fi}
  \DeclareRobustCommand\%{\ifmmode\mathpercent\else\char"25\fi}
  \DeclareRobustCommand\&{\ifmmode\mathand\else\char"26\fi}
  \DeclareMathSymbol{\@relbar}{\mathbin}{symbols}{"00}
  \DeclareMathSymbol{\@Relbar}{\mathrel}{operators}{"3D}
  \DeclareMathSymbol{\@verticalbar}{\mathord}{symbols}{"6A}
  \DeclareRobustCommand\relbar{\mathrel{\smash\@relbar}}
  \DeclareRobustCommand\Relbar{\mathrel{\@Relbar}}
  \DeclareRobustCommand\models{\mathrel{\@verticalbar}\joinrel\Relbar}}
%    \end{macrocode}
% Set new operator font.
%    \begin{macrocode}
\def\M@operator@set{%
  \edef\operator@font{\noexpand\mathgroup
  \expandafter\noexpand\csname symM\@operatorshape\the\M@count\endcsname}}
%    \end{macrocode}
% Set blackboard bold characters.
%    \begin{macrocode}
\def\M@bb@set{%
  \edef\M@bb{M\@bbshape\the\M@count}
  \DeclareMathSymbol{\M@bb@A}{\mathord}{\M@bb}{"1D538}
  \DeclareMathSymbol{\M@bb@B}{\mathord}{\M@bb}{"1D539}
  \DeclareMathSymbol{\M@bb@C}{\mathord}{\M@bb}{"2102}
  \DeclareMathSymbol{\M@bb@D}{\mathord}{\M@bb}{"1D53B}
  \DeclareMathSymbol{\M@bb@E}{\mathord}{\M@bb}{"1D53C}
  \DeclareMathSymbol{\M@bb@F}{\mathord}{\M@bb}{"1D53D}
  \DeclareMathSymbol{\M@bb@G}{\mathord}{\M@bb}{"1D53E}
  \DeclareMathSymbol{\M@bb@H}{\mathord}{\M@bb}{"210D}
  \DeclareMathSymbol{\M@bb@I}{\mathord}{\M@bb}{"1D540}
  \DeclareMathSymbol{\M@bb@J}{\mathord}{\M@bb}{"1D541}
  \DeclareMathSymbol{\M@bb@K}{\mathord}{\M@bb}{"1D542}
  \DeclareMathSymbol{\M@bb@L}{\mathord}{\M@bb}{"1D543}
  \DeclareMathSymbol{\M@bb@M}{\mathord}{\M@bb}{"1D544}
  \DeclareMathSymbol{\M@bb@N}{\mathord}{\M@bb}{"2115}
  \DeclareMathSymbol{\M@bb@O}{\mathord}{\M@bb}{"1D546}
  \DeclareMathSymbol{\M@bb@P}{\mathord}{\M@bb}{"2119}
  \DeclareMathSymbol{\M@bb@Q}{\mathord}{\M@bb}{"211A}
  \DeclareMathSymbol{\M@bb@R}{\mathord}{\M@bb}{"211D}
  \DeclareMathSymbol{\M@bb@S}{\mathord}{\M@bb}{"1D54A}
  \DeclareMathSymbol{\M@bb@T}{\mathord}{\M@bb}{"1D54B}
  \DeclareMathSymbol{\M@bb@U}{\mathord}{\M@bb}{"1D54C}
  \DeclareMathSymbol{\M@bb@V}{\mathord}{\M@bb}{"1D54D}
  \DeclareMathSymbol{\M@bb@W}{\mathord}{\M@bb}{"1D54E}
  \DeclareMathSymbol{\M@bb@X}{\mathord}{\M@bb}{"1D43F}
  \DeclareMathSymbol{\M@bb@Y}{\mathord}{\M@bb}{"1D550}
  \DeclareMathSymbol{\M@bb@Z}{\mathord}{\M@bb}{"2124}
  \DeclareMathSymbol{\M@bb@a}{\mathord}{\M@bb}{"1D552}
  \DeclareMathSymbol{\M@bb@b}{\mathord}{\M@bb}{"1D553}
  \DeclareMathSymbol{\M@bb@c}{\mathord}{\M@bb}{"1D554}
  \DeclareMathSymbol{\M@bb@d}{\mathord}{\M@bb}{"1D555}
  \DeclareMathSymbol{\M@bb@e}{\mathord}{\M@bb}{"1D556}
  \DeclareMathSymbol{\M@bb@f}{\mathord}{\M@bb}{"1D557}
  \DeclareMathSymbol{\M@bb@g}{\mathord}{\M@bb}{"1D558}
  \DeclareMathSymbol{\M@bb@h}{\mathord}{\M@bb}{"1D559}
  \DeclareMathSymbol{\M@bb@i}{\mathord}{\M@bb}{"1D55A}
  \DeclareMathSymbol{\M@bb@j}{\mathord}{\M@bb}{"1D55B}
  \DeclareMathSymbol{\M@bb@k}{\mathord}{\M@bb}{"1D55C}
  \DeclareMathSymbol{\M@bb@l}{\mathord}{\M@bb}{"1D55D}
  \DeclareMathSymbol{\M@bb@m}{\mathord}{\M@bb}{"1D55E}
  \DeclareMathSymbol{\M@bb@n}{\mathord}{\M@bb}{"1D55F}
  \DeclareMathSymbol{\M@bb@o}{\mathord}{\M@bb}{"1D560}
  \DeclareMathSymbol{\M@bb@p}{\mathord}{\M@bb}{"1D561}
  \DeclareMathSymbol{\M@bb@q}{\mathord}{\M@bb}{"1D562}
  \DeclareMathSymbol{\M@bb@r}{\mathord}{\M@bb}{"1D563}
  \DeclareMathSymbol{\M@bb@s}{\mathord}{\M@bb}{"1D564}
  \DeclareMathSymbol{\M@bb@t}{\mathord}{\M@bb}{"1D565}
  \DeclareMathSymbol{\M@bb@u}{\mathord}{\M@bb}{"1D566}
  \DeclareMathSymbol{\M@bb@v}{\mathord}{\M@bb}{"1D567}
  \DeclareMathSymbol{\M@bb@w}{\mathord}{\M@bb}{"1D568}
  \DeclareMathSymbol{\M@bb@x}{\mathord}{\M@bb}{"1D569}
  \DeclareMathSymbol{\M@bb@y}{\mathord}{\M@bb}{"1D56A}
  \DeclareMathSymbol{\M@bb@z}{\mathord}{\M@bb}{"1D56B}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@0\endcsname}{\mathord}{\M@bb}{"1D7D8}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@1\endcsname}{\mathord}{\M@bb}{"1D7D9}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@2\endcsname}{\mathord}{\M@bb}{"1D7DA}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@3\endcsname}{\mathord}{\M@bb}{"1D7DB}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@4\endcsname}{\mathord}{\M@bb}{"1D7DC}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@5\endcsname}{\mathord}{\M@bb}{"1D7DD}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@6\endcsname}{\mathord}{\M@bb}{"1D7DE}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@7\endcsname}{\mathord}{\M@bb}{"1D7DF}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@8\endcsname}{\mathord}{\M@bb}{"1D7E0}
  \expandafter\DeclareMathSymbol\expandafter
    {\csname M@bb@9\endcsname}{\mathord}{\M@bb}{"1D7E1}}
%    \end{macrocode}
% Set caligraphic characters.
%    \begin{macrocode}
\def\M@cal@set{%
  \edef\M@cal{M\@calshape\the\M@count}
  \DeclareMathSymbol{\M@cal@A}{\mathord}{\M@cal}{"1D49C}
  \DeclareMathSymbol{\M@cal@B}{\mathord}{\M@cal}{"212C}
  \DeclareMathSymbol{\M@cal@C}{\mathord}{\M@cal}{"1D49E}
  \DeclareMathSymbol{\M@cal@D}{\mathord}{\M@cal}{"1D49F}
  \DeclareMathSymbol{\M@cal@E}{\mathord}{\M@cal}{"2130}
  \DeclareMathSymbol{\M@cal@F}{\mathord}{\M@cal}{"2131}
  \DeclareMathSymbol{\M@cal@G}{\mathord}{\M@cal}{"1D4A2}
  \DeclareMathSymbol{\M@cal@H}{\mathord}{\M@cal}{"210B}
  \DeclareMathSymbol{\M@cal@I}{\mathord}{\M@cal}{"2110}
  \DeclareMathSymbol{\M@cal@J}{\mathord}{\M@cal}{"1D4A5}
  \DeclareMathSymbol{\M@cal@K}{\mathord}{\M@cal}{"1D4A6}
  \DeclareMathSymbol{\M@cal@L}{\mathord}{\M@cal}{"2112}
  \DeclareMathSymbol{\M@cal@M}{\mathord}{\M@cal}{"2133}
  \DeclareMathSymbol{\M@cal@N}{\mathord}{\M@cal}{"1D4A9}
  \DeclareMathSymbol{\M@cal@O}{\mathord}{\M@cal}{"1D4AA}
  \DeclareMathSymbol{\M@cal@P}{\mathord}{\M@cal}{"1D4AB}
  \DeclareMathSymbol{\M@cal@Q}{\mathord}{\M@cal}{"1D4AC}
  \DeclareMathSymbol{\M@cal@R}{\mathord}{\M@cal}{"211B}
  \DeclareMathSymbol{\M@cal@S}{\mathord}{\M@cal}{"1D4AE}
  \DeclareMathSymbol{\M@cal@T}{\mathord}{\M@cal}{"1D4AF}
  \DeclareMathSymbol{\M@cal@U}{\mathord}{\M@cal}{"1D4B0}
  \DeclareMathSymbol{\M@cal@V}{\mathord}{\M@cal}{"1D4B1}
  \DeclareMathSymbol{\M@cal@W}{\mathord}{\M@cal}{"1D4B2}
  \DeclareMathSymbol{\M@cal@X}{\mathord}{\M@cal}{"1D4B3}
  \DeclareMathSymbol{\M@cal@Y}{\mathord}{\M@cal}{"1D4B4}
  \DeclareMathSymbol{\M@cal@Z}{\mathord}{\M@cal}{"1D4B5}
  \DeclareMathSymbol{\M@cal@a}{\mathord}{\M@cal}{"1D4B6}
  \DeclareMathSymbol{\M@cal@b}{\mathord}{\M@cal}{"1D4B7}
  \DeclareMathSymbol{\M@cal@c}{\mathord}{\M@cal}{"1D4B8}
  \DeclareMathSymbol{\M@cal@d}{\mathord}{\M@cal}{"1D4B9}
  \DeclareMathSymbol{\M@cal@e}{\mathord}{\M@cal}{"212F}
  \DeclareMathSymbol{\M@cal@f}{\mathord}{\M@cal}{"1D4BB}
  \DeclareMathSymbol{\M@cal@g}{\mathord}{\M@cal}{"210A}
  \DeclareMathSymbol{\M@cal@h}{\mathord}{\M@cal}{"1D4BD}
  \DeclareMathSymbol{\M@cal@i}{\mathord}{\M@cal}{"1D4BE}
  \DeclareMathSymbol{\M@cal@j}{\mathord}{\M@cal}{"1D4BF}
  \DeclareMathSymbol{\M@cal@k}{\mathord}{\M@cal}{"1D4C0}
  \DeclareMathSymbol{\M@cal@l}{\mathord}{\M@cal}{"1D4C1}
  \DeclareMathSymbol{\M@cal@m}{\mathord}{\M@cal}{"1D4C2}
  \DeclareMathSymbol{\M@cal@n}{\mathord}{\M@cal}{"1D4C3}
  \DeclareMathSymbol{\M@cal@o}{\mathord}{\M@cal}{"2134}
  \DeclareMathSymbol{\M@cal@p}{\mathord}{\M@cal}{"1D4C5}
  \DeclareMathSymbol{\M@cal@q}{\mathord}{\M@cal}{"1D4C6}
  \DeclareMathSymbol{\M@cal@r}{\mathord}{\M@cal}{"1D4C7}
  \DeclareMathSymbol{\M@cal@s}{\mathord}{\M@cal}{"1D4C8}
  \DeclareMathSymbol{\M@cal@t}{\mathord}{\M@cal}{"1D4C9}
  \DeclareMathSymbol{\M@cal@u}{\mathord}{\M@cal}{"1D4CA}
  \DeclareMathSymbol{\M@cal@v}{\mathord}{\M@cal}{"1D4CB}
  \DeclareMathSymbol{\M@cal@w}{\mathord}{\M@cal}{"1D4CC}
  \DeclareMathSymbol{\M@cal@x}{\mathord}{\M@cal}{"1D4CD}
  \DeclareMathSymbol{\M@cal@y}{\mathord}{\M@cal}{"1D4CE}
  \DeclareMathSymbol{\M@cal@z}{\mathord}{\M@cal}{"1D4CF}}
%    \end{macrocode}
% Set fraktur characters.
%    \begin{macrocode}
\def\M@frak@set{%
  \edef\M@frak{M\@frakshape\the\M@count}
  \DeclareMathSymbol{\M@frak@A}{\mathord}{\M@frak}{"1D504}
  \DeclareMathSymbol{\M@frak@B}{\mathord}{\M@frak}{"1D505}
  \DeclareMathSymbol{\M@frak@C}{\mathord}{\M@frak}{"212D}
  \DeclareMathSymbol{\M@frak@D}{\mathord}{\M@frak}{"1D507}
  \DeclareMathSymbol{\M@frak@E}{\mathord}{\M@frak}{"1D508}
  \DeclareMathSymbol{\M@frak@F}{\mathord}{\M@frak}{"1D509}
  \DeclareMathSymbol{\M@frak@G}{\mathord}{\M@frak}{"1D50A}
  \DeclareMathSymbol{\M@frak@H}{\mathord}{\M@frak}{"210C}
  \DeclareMathSymbol{\M@frak@I}{\mathord}{\M@frak}{"2111}
  \DeclareMathSymbol{\M@frak@J}{\mathord}{\M@frak}{"1D50D}
  \DeclareMathSymbol{\M@frak@K}{\mathord}{\M@frak}{"1D50E}
  \DeclareMathSymbol{\M@frak@L}{\mathord}{\M@frak}{"1D50F}
  \DeclareMathSymbol{\M@frak@M}{\mathord}{\M@frak}{"1D510}
  \DeclareMathSymbol{\M@frak@N}{\mathord}{\M@frak}{"1D511}
  \DeclareMathSymbol{\M@frak@O}{\mathord}{\M@frak}{"1D512}
  \DeclareMathSymbol{\M@frak@P}{\mathord}{\M@frak}{"1D513}
  \DeclareMathSymbol{\M@frak@Q}{\mathord}{\M@frak}{"1D514}
  \DeclareMathSymbol{\M@frak@R}{\mathord}{\M@frak}{"212C}
  \DeclareMathSymbol{\M@frak@S}{\mathord}{\M@frak}{"1D516}
  \DeclareMathSymbol{\M@frak@T}{\mathord}{\M@frak}{"1D517}
  \DeclareMathSymbol{\M@frak@U}{\mathord}{\M@frak}{"1D518}
  \DeclareMathSymbol{\M@frak@V}{\mathord}{\M@frak}{"1D519}
  \DeclareMathSymbol{\M@frak@W}{\mathord}{\M@frak}{"1D51A}
  \DeclareMathSymbol{\M@frak@X}{\mathord}{\M@frak}{"1D51B}
  \DeclareMathSymbol{\M@frak@Y}{\mathord}{\M@frak}{"1D51C}
  \DeclareMathSymbol{\M@frak@Z}{\mathord}{\M@frak}{"2128}
  \DeclareMathSymbol{\M@frak@a}{\mathord}{\M@frak}{"1D51E}
  \DeclareMathSymbol{\M@frak@b}{\mathord}{\M@frak}{"1D51F}
  \DeclareMathSymbol{\M@frak@c}{\mathord}{\M@frak}{"1D520}
  \DeclareMathSymbol{\M@frak@d}{\mathord}{\M@frak}{"1D521}
  \DeclareMathSymbol{\M@frak@e}{\mathord}{\M@frak}{"1D522}
  \DeclareMathSymbol{\M@frak@f}{\mathord}{\M@frak}{"1D523}
  \DeclareMathSymbol{\M@frak@g}{\mathord}{\M@frak}{"1D524}
  \DeclareMathSymbol{\M@frak@h}{\mathord}{\M@frak}{"1D525}
  \DeclareMathSymbol{\M@frak@i}{\mathord}{\M@frak}{"1D526}
  \DeclareMathSymbol{\M@frak@j}{\mathord}{\M@frak}{"1D527}
  \DeclareMathSymbol{\M@frak@k}{\mathord}{\M@frak}{"1D528}
  \DeclareMathSymbol{\M@frak@l}{\mathord}{\M@frak}{"1D529}
  \DeclareMathSymbol{\M@frak@m}{\mathord}{\M@frak}{"1D52A}
  \DeclareMathSymbol{\M@frak@n}{\mathord}{\M@frak}{"1D52B}
  \DeclareMathSymbol{\M@frak@o}{\mathord}{\M@frak}{"1D52C}
  \DeclareMathSymbol{\M@frak@p}{\mathord}{\M@frak}{"1D52D}
  \DeclareMathSymbol{\M@frak@q}{\mathord}{\M@frak}{"1D52E}
  \DeclareMathSymbol{\M@frak@r}{\mathord}{\M@frak}{"1D52F}
  \DeclareMathSymbol{\M@frak@s}{\mathord}{\M@frak}{"1D530}
  \DeclareMathSymbol{\M@frak@t}{\mathord}{\M@frak}{"1D531}
  \DeclareMathSymbol{\M@frak@u}{\mathord}{\M@frak}{"1D532}
  \DeclareMathSymbol{\M@frak@v}{\mathord}{\M@frak}{"1D533}
  \DeclareMathSymbol{\M@frak@w}{\mathord}{\M@frak}{"1D534}
  \DeclareMathSymbol{\M@frak@x}{\mathord}{\M@frak}{"1D535}
  \DeclareMathSymbol{\M@frak@y}{\mathord}{\M@frak}{"1D536}
  \DeclareMathSymbol{\M@frak@z}{\mathord}{\M@frak}{"1D537}}
%    \end{macrocode}
% Set bold caligraphic characters.
%    \begin{macrocode}
\def\M@bcal@set{%
  \edef\M@bcal{M\@bcalshape\the\M@count}
  \DeclareMathSymbol{\M@bcal@A}{\mathord}{\M@bcal}{"1D4D0}
  \DeclareMathSymbol{\M@bcal@B}{\mathord}{\M@bcal}{"1D4D1}
  \DeclareMathSymbol{\M@bcal@C}{\mathord}{\M@bcal}{"1D4D2}
  \DeclareMathSymbol{\M@bcal@D}{\mathord}{\M@bcal}{"1D4D3}
  \DeclareMathSymbol{\M@bcal@E}{\mathord}{\M@bcal}{"1D4D4}
  \DeclareMathSymbol{\M@bcal@F}{\mathord}{\M@bcal}{"1D4D5}
  \DeclareMathSymbol{\M@bcal@G}{\mathord}{\M@bcal}{"1D4D6}
  \DeclareMathSymbol{\M@bcal@H}{\mathord}{\M@bcal}{"1D4D7}
  \DeclareMathSymbol{\M@bcal@I}{\mathord}{\M@bcal}{"1D4D8}
  \DeclareMathSymbol{\M@bcal@J}{\mathord}{\M@bcal}{"1D4D9}
  \DeclareMathSymbol{\M@bcal@K}{\mathord}{\M@bcal}{"1D4DA}
  \DeclareMathSymbol{\M@bcal@L}{\mathord}{\M@bcal}{"1D4DB}
  \DeclareMathSymbol{\M@bcal@M}{\mathord}{\M@bcal}{"1D4DC}
  \DeclareMathSymbol{\M@bcal@N}{\mathord}{\M@bcal}{"1D4DD}
  \DeclareMathSymbol{\M@bcal@O}{\mathord}{\M@bcal}{"1D4DE}
  \DeclareMathSymbol{\M@bcal@P}{\mathord}{\M@bcal}{"1D4DF}
  \DeclareMathSymbol{\M@bcal@Q}{\mathord}{\M@bcal}{"1D4E0}
  \DeclareMathSymbol{\M@bcal@R}{\mathord}{\M@bcal}{"1D4E1}
  \DeclareMathSymbol{\M@bcal@S}{\mathord}{\M@bcal}{"1D4E2}
  \DeclareMathSymbol{\M@bcal@T}{\mathord}{\M@bcal}{"1D4E3}
  \DeclareMathSymbol{\M@bcal@U}{\mathord}{\M@bcal}{"1D4E4}
  \DeclareMathSymbol{\M@bcal@V}{\mathord}{\M@bcal}{"1D4E5}
  \DeclareMathSymbol{\M@bcal@W}{\mathord}{\M@bcal}{"1D4E6}
  \DeclareMathSymbol{\M@bcal@X}{\mathord}{\M@bcal}{"1D4E7}
  \DeclareMathSymbol{\M@bcal@Y}{\mathord}{\M@bcal}{"1D4E8}
  \DeclareMathSymbol{\M@bcal@Z}{\mathord}{\M@bcal}{"1D4E9}
  \DeclareMathSymbol{\M@bcal@a}{\mathord}{\M@bcal}{"1D4EA}
  \DeclareMathSymbol{\M@bcal@b}{\mathord}{\M@bcal}{"1D4EB}
  \DeclareMathSymbol{\M@bcal@c}{\mathord}{\M@bcal}{"1D4EC}
  \DeclareMathSymbol{\M@bcal@d}{\mathord}{\M@bcal}{"1D4ED}
  \DeclareMathSymbol{\M@bcal@e}{\mathord}{\M@bcal}{"1D4EE}
  \DeclareMathSymbol{\M@bcal@f}{\mathord}{\M@bcal}{"1D4EF}
  \DeclareMathSymbol{\M@bcal@g}{\mathord}{\M@bcal}{"1D4F0}
  \DeclareMathSymbol{\M@bcal@h}{\mathord}{\M@bcal}{"1D4F1}
  \DeclareMathSymbol{\M@bcal@i}{\mathord}{\M@bcal}{"1D4F2}
  \DeclareMathSymbol{\M@bcal@j}{\mathord}{\M@bcal}{"1D4F3}
  \DeclareMathSymbol{\M@bcal@k}{\mathord}{\M@bcal}{"1D4F4}
  \DeclareMathSymbol{\M@bcal@l}{\mathord}{\M@bcal}{"1D4F5}
  \DeclareMathSymbol{\M@bcal@m}{\mathord}{\M@bcal}{"1D4F6}
  \DeclareMathSymbol{\M@bcal@n}{\mathord}{\M@bcal}{"1D4F7}
  \DeclareMathSymbol{\M@bcal@o}{\mathord}{\M@bcal}{"1D4F8}
  \DeclareMathSymbol{\M@bcal@p}{\mathord}{\M@bcal}{"1D4F9}
  \DeclareMathSymbol{\M@bcal@q}{\mathord}{\M@bcal}{"1D4FA}
  \DeclareMathSymbol{\M@bcal@r}{\mathord}{\M@bcal}{"1D4FB}
  \DeclareMathSymbol{\M@bcal@s}{\mathord}{\M@bcal}{"1D4FC}
  \DeclareMathSymbol{\M@bcal@t}{\mathord}{\M@bcal}{"1D4FD}
  \DeclareMathSymbol{\M@bcal@u}{\mathord}{\M@bcal}{"1D4FE}
  \DeclareMathSymbol{\M@bcal@v}{\mathord}{\M@bcal}{"1D4FF}
  \DeclareMathSymbol{\M@bcal@w}{\mathord}{\M@bcal}{"1D500}
  \DeclareMathSymbol{\M@bcal@x}{\mathord}{\M@bcal}{"1D501}
  \DeclareMathSymbol{\M@bcal@y}{\mathord}{\M@bcal}{"1D502}
  \DeclareMathSymbol{\M@bcal@z}{\mathord}{\M@bcal}{"1D503}}
%    \end{macrocode}
% Set bold fraktur characters.
%    \begin{macrocode}
\def\M@bfrak@set{%
  \edef\M@bfrak{M\@bfrakshape\the\M@count}
  \DeclareMathSymbol{\M@bfrak@A}{\mathord}{\M@bfrak}{"1D56C}
  \DeclareMathSymbol{\M@bfrak@B}{\mathord}{\M@bfrak}{"1D56D}
  \DeclareMathSymbol{\M@bfrak@C}{\mathord}{\M@bfrak}{"1D56E}
  \DeclareMathSymbol{\M@bfrak@D}{\mathord}{\M@bfrak}{"1D56F}
  \DeclareMathSymbol{\M@bfrak@E}{\mathord}{\M@bfrak}{"1D570}
  \DeclareMathSymbol{\M@bfrak@F}{\mathord}{\M@bfrak}{"1D571}
  \DeclareMathSymbol{\M@bfrak@G}{\mathord}{\M@bfrak}{"1D572}
  \DeclareMathSymbol{\M@bfrak@H}{\mathord}{\M@bfrak}{"1D573}
  \DeclareMathSymbol{\M@bfrak@I}{\mathord}{\M@bfrak}{"1D574}
  \DeclareMathSymbol{\M@bfrak@J}{\mathord}{\M@bfrak}{"1D575}
  \DeclareMathSymbol{\M@bfrak@K}{\mathord}{\M@bfrak}{"1D576}
  \DeclareMathSymbol{\M@bfrak@L}{\mathord}{\M@bfrak}{"1D577}
  \DeclareMathSymbol{\M@bfrak@M}{\mathord}{\M@bfrak}{"1D578}
  \DeclareMathSymbol{\M@bfrak@N}{\mathord}{\M@bfrak}{"1D579}
  \DeclareMathSymbol{\M@bfrak@O}{\mathord}{\M@bfrak}{"1D57A}
  \DeclareMathSymbol{\M@bfrak@P}{\mathord}{\M@bfrak}{"1D57B}
  \DeclareMathSymbol{\M@bfrak@Q}{\mathord}{\M@bfrak}{"1D57C}
  \DeclareMathSymbol{\M@bfrak@R}{\mathord}{\M@bfrak}{"1D57D}
  \DeclareMathSymbol{\M@bfrak@S}{\mathord}{\M@bfrak}{"1D57E}
  \DeclareMathSymbol{\M@bfrak@T}{\mathord}{\M@bfrak}{"1D57F}
  \DeclareMathSymbol{\M@bfrak@U}{\mathord}{\M@bfrak}{"1D580}
  \DeclareMathSymbol{\M@bfrak@V}{\mathord}{\M@bfrak}{"1D581}
  \DeclareMathSymbol{\M@bfrak@W}{\mathord}{\M@bfrak}{"1D582}
  \DeclareMathSymbol{\M@bfrak@X}{\mathord}{\M@bfrak}{"1D583}
  \DeclareMathSymbol{\M@bfrak@Y}{\mathord}{\M@bfrak}{"1D584}
  \DeclareMathSymbol{\M@bfrak@Z}{\mathord}{\M@bfrak}{"1D585}
  \DeclareMathSymbol{\M@bfrak@a}{\mathord}{\M@bfrak}{"1D586}
  \DeclareMathSymbol{\M@bfrak@b}{\mathord}{\M@bfrak}{"1D587}
  \DeclareMathSymbol{\M@bfrak@c}{\mathord}{\M@bfrak}{"1D588}
  \DeclareMathSymbol{\M@bfrak@d}{\mathord}{\M@bfrak}{"1D589}
  \DeclareMathSymbol{\M@bfrak@e}{\mathord}{\M@bfrak}{"1D58A}
  \DeclareMathSymbol{\M@bfrak@f}{\mathord}{\M@bfrak}{"1D58B}
  \DeclareMathSymbol{\M@bfrak@g}{\mathord}{\M@bfrak}{"1D58C}
  \DeclareMathSymbol{\M@bfrak@h}{\mathord}{\M@bfrak}{"1D58D}
  \DeclareMathSymbol{\M@bfrak@i}{\mathord}{\M@bfrak}{"1D58E}
  \DeclareMathSymbol{\M@bfrak@j}{\mathord}{\M@bfrak}{"1D58F}
  \DeclareMathSymbol{\M@bfrak@k}{\mathord}{\M@bfrak}{"1D590}
  \DeclareMathSymbol{\M@bfrak@l}{\mathord}{\M@bfrak}{"1D591}
  \DeclareMathSymbol{\M@bfrak@m}{\mathord}{\M@bfrak}{"1D592}
  \DeclareMathSymbol{\M@bfrak@n}{\mathord}{\M@bfrak}{"1D593}
  \DeclareMathSymbol{\M@bfrak@o}{\mathord}{\M@bfrak}{"1D594}
  \DeclareMathSymbol{\M@bfrak@p}{\mathord}{\M@bfrak}{"1D595}
  \DeclareMathSymbol{\M@bfrak@q}{\mathord}{\M@bfrak}{"1D596}
  \DeclareMathSymbol{\M@bfrak@r}{\mathord}{\M@bfrak}{"1D597}
  \DeclareMathSymbol{\M@bfrak@s}{\mathord}{\M@bfrak}{"1D598}
  \DeclareMathSymbol{\M@bfrak@t}{\mathord}{\M@bfrak}{"1D599}
  \DeclareMathSymbol{\M@bfrak@u}{\mathord}{\M@bfrak}{"1D59A}
  \DeclareMathSymbol{\M@bfrak@v}{\mathord}{\M@bfrak}{"1D59B}
  \DeclareMathSymbol{\M@bfrak@w}{\mathord}{\M@bfrak}{"1D59C}
  \DeclareMathSymbol{\M@bfrak@x}{\mathord}{\M@bfrak}{"1D59D}
  \DeclareMathSymbol{\M@bfrak@y}{\mathord}{\M@bfrak}{"1D59E}
  \DeclareMathSymbol{\M@bfrak@z}{\mathord}{\M@bfrak}{"1D59F}}
%    \end{macrocode}
% Provide the command to reset macros and conclude. 
%    \begin{macrocode}
\def\restoremathinternals{%
  \M@RestoreInternalsInfo
  \let\set@mathchar\@@set@mathchar
  \let\set@mathsymbol\@@set@mathsymbol}
%    \end{macrocode}
% Unless the user specified the \texttt{packages} option,
% \textsf{mathfont} will reset the internal math symbol commands when the user
% loads another package.
%    \begin{macrocode}
\if@packages
\else
  \let\@@usepackage\usepackage
  \def\usepackage{\restoremathinternals
    \let\usepackage\@@usepackage
    \usepackage}
\fi
%    \end{macrocode}
% 
% \eject
% 
% \section*{Version History}\label{version}
% 
% 
% \begin{multicols*}{2}
% \bgroup\raggedright\parskip\z@\parindent\z@\leftskip1em\obeylines
% \setbox0\hbox{\hskip 1pt.\hskip 1pt}
% \def\version#1#2{\bigskip\hbox to \hsize{\textbf{#1} \cleaders\copy0\hfill\ #2}\par}
% \def\item{\leavevmode\raise0.5ex\hbox{\vrule height 1pt width 0.5em}\kern1pt}
% 
% 
% \version{1.1b}{July 2018}
% \item initial release
% 
% \version{1.2}{August 2018}
% \item minor bug fix for |\mathfrak|
% \item eliminated redundant batchfile
% 
% \version{1.3}{January 2019}
% \item added |symbols| keyword\par
% \item created |mathfont_example.pdf|
% \item corrected the description of the \textsf{mathastext} package
% \item font-change |\message| added to |\mathfont|
% 
% \version{1.4}{April 2019}
% \item |\setfont| command added
% \item |\mathfont| optional argument can parse spaces
% \item |no-operators| now default package optional argument
% \item added |\comma| command
% \item new fancy fatal error message
% \item improved messaging for |\mathfont|
% \item internal command |\mathpound| changed to |\mathhash|
% \item added a missing |#1| after |\char`\"| in the example code on p.~\pageref{code-example}
% 
% \version{1.5}{April 2019}
% \item separated |\increment| and |\Delta|
% \item version history added
% \item initial ``off-the-shelf'' use insert added
% 
% 
% 
% \egroup
% \end{multicols*}
% 
% \iffalse
% 
%</package>
%<*greek>
\documentclass[12pt]{article}
\usepackage[margin=72.27pt]{geometry}
\usepackage{booktabs}
\usepackage{mathfont}
\mathfont{Symbola}
\usepackage{shortvrb}
\MakeShortVerb{|}
\pagestyle{empty}
\begin{document}

\topskip=0pt

\centering

\vbox to 0pt{}\vfil\nointerlineskip

Greek Characters Provided by \textsf{mathfont}, Rendered in Symbola\par\penalty10000\smallskip
\begin{tabular}{llllllll}
\toprule
\multicolumn{4}{c}{Modern Greek Characters} & \multicolumn{4}{c}{Ancient Greek Characters}\\
\cmidrule(r{4pt}){1-4}\cmidrule(l{4pt}){5-8}
\multicolumn{2}{c}{Capital} & \multicolumn{2}{c}{Minuscule} & \multicolumn{2}{c}{Capital} & \multicolumn{2}{c}{Minuscule}\\
\midrule
|\Alpha| & $\Alpha$ & |\alpha| & $\alpha$ & |\Heta| & $\Heta$ & |\heta| & $\heta$ \\
|\Beta| & $\Beta$ & |\beta| & $\beta$ & |\Sampi| & $\Sampi$ & |\sampi| & $\sampi$ \\
|\Gamma| & $\Gamma$ & |\gamma| & $\gamma$ & |\Diagamma| & $\Diagamma$ & |\diagamma| & $\diagamma$ \\
|\Delta| & $\Delta$ & |\delta| & $\delta$ & |\Koppa| & $\Koppa$ & |\koppa| & $\koppa$ \\
|\Epsilon| & $\Epsilon$ & |\epsilon| & $\epsilon$ & |\Stigma| & $\Stigma$ & |\stigma| & $\stigma$ \\
|\Zeta| & $\Zeta$ & |\zeta| & $\zeta$ & |\Sho| & $\Sho$ & |\sho| & $\sho$ \\
|\Eta| & $\Eta$ & |\eta| & $\eta$ & |\San| & $\San$ & |\san| & $\san$ \\
|\Theta| & $\Theta$ & |\theta| & $\theta$ & |\varSampi | & $\varSampi$ & |\varsampi| & $\varsampi$ \\
|\Iota| & $\Iota$ & |\iota| & $\iota$ & |\varDiagamma| & $\varDiagamma$ & |\vardiagamma| & $\vardiagamma$ \\
|\Kappa| & $\Kappa$ & |\kappa| & $\kappa$ & |\varKoppa| & $\varKoppa$ & |\varkoppa| & $\varkoppa$ \\
|\Lambda| & $\Lambda$ & |\lambda| & $\lambda$ & & & & \\
|\Mu| & $\Mu$ & |\mu| & $\mu$ & & & & \\
|\Nu| & $\Nu$ & |\nu| & $\nu$ & & & & \\
|\Xi| & $\Xi$ & |\xi| & $\xi$ & & & & \\
|\Omicron| & $\Omicron$ & |\omicron| & $\omicron$ & & & & \\
|\Pi| & $\Pi$ & |\pi| & $\pi$ & & & & \\
|\Rho| & $\Rho$ & |\rho| & $\rho$ & & & & \\
|\Sigma| & $\Sigma$ & |\sigma| & $\sigma$ & & & & \\
|\Tau| & $\Tau$ & |\tau| & $\tau$ & & & & \\
|\Upsilon| & $\Upsilon$ & |\upsilon| & $\upsilon$ & & & & \\
|\Phi| & $\Phi$ & |\phi| & $\phi$ & & & & \\
|\Chi| & $\Chi$ & |\chi| & $\chi$ & & & & \\
|\Psi| & $\Psi$ & |\psi| & $\psi$ & & & & \\
|\Omega| & $\Omega$ & |\omega| & $\omega$ & & & & \\
|\varTheta| & $\varTheta$ & |\varbeta| & $\varbeta$ & & & & \\
 & & |\varepsilon| & $\varepsilon$ & & & & \\
 & & |\vartheta| & $\vartheta$ & & & & \\
 & & |\varrho| & $\varrho$ & & & & \\
 & & |\varsigma| & $\varsigma$ & & & & \\
 & & |\varphi| & $\varphi$ & & & & \\
\bottomrule
\end{tabular}

\end{document}
%</greek>
%<*example>
\documentclass[12pt]{article}
\usepackage[margin=72.27pt]{geometry}
\usepackage[factor=600,stretch=14,shrink=14,step=1]{microtype}
\usepackage{mathfont}
\setfont{Times New Roman}
\mathfont[bb]{Symbola}
\restoremathinternals
\hyphenpenalty=10
\exhyphenpenalty=5
\pretolerance=30
\finalhyphendemerits=300
\pagestyle{empty}
\begin{document}

\centerline{The \textsf{mathfont} Package in Action: Two Mathematical Snippets Rendered in Times New Roman}
\centerline{Conrad Kosowsky}

\bigskip

Mathematicians usually define $e$ in one of two ways: as the horizontal asymptote of a certain function or as the limit of an infinite series. Specifically, it's most common to see $e$ defined as either
\[
e=\lim_{x\to\infty}\left(1+\frac1x\right)^x
\]
or
\[
e=\sum_{k=0}^\infty\frac1{k!}.
\]
The first definition is simpler in that involves a limit of a single expression, not a limit of partial sums, but in practice, the second tends to be more tractable. The power series expression of $e^x$ is given by
\[
\sum_{n=0}^\infty\frac{x^n}{n!},
\]
and the relationship between this expression and the series definition is much more apparent than it is for the first limit. This relationship arises in a variety of different mathematical contexts, for example the famous Euler's formula $e^{i\theta}=\cos\theta+i\sin\theta$ or the related definition of the characteristic function for a random variable $X$:
\[
\phi_X(t)=\mathbb E\left(e^{iX}\right).
\]
Expanding $e^{iX}$ as a power series gives an expression for $\phi_X$ that we can differentiate term by term.

\vfil

A smooth manifold consists of a topological space $M$ equipped with a smooth maximal atlas $\leftbrace \phi_i\rightbrace$. The maps $\phi_i\colon U_i\longrightarrow\mathbb R$ are continuous, and their compositions $\phi_i^{}\circ\phi_j^{-1}$ are diffeomorphisms on subsets of $\mathbb R^n$. If we have a map $f\colon M\longrightarrow N$ between manifolds, this structure allows us to talk about differentiability of $f$. Specifically, we say that $f$ is smooth if for any $i$ and $j$, the composition
\[
\psi_j^{}\circ f\circ\phi_i^{-1}
\]
is itself smooth, where $\leftbrace\psi_i\rightbrace$ is a smooth atlas for $N$. Differentiating $f$ produces the associated tangent map $Df$. The function $Df$ maps the tangent bundle $TM$ to the tangent bundle $TN$ and is linear when restricted to individual tangent spaces $T_pM$. If $M$ can be written as a product $M_1\times M_2$, we can consider the partial tangent maps $\partial_1f$ and $\partial_2f$ by considering the compositions $f\circ\iota_1$ and $f\circ\iota_2$, where $\iota_1$ and $\iota_2$ are inclusion maps with respect to a particular point. Combining both maps, we have the equation
\[
Df(u,v)=\partial_1f(u)+\partial_2f(v),
\]
and this relationship can be thought of as an adaption of the standard product rule.

\end{document}
%</example>
% 
% \fi
% 
% \check@checksum
% 
\endinput