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
|
%D \module
%D [ file=math-stc,
%D version=2012.12.29,
%D title=\CONTEXT\ Math Macros,
%D subtitle=Stackers,
%D comment=This replaces math-arr and friends,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Math Macros / Stackers}
\unprotect
%D WARNING: If the code here changes, the export needs to be checked! Stackers are
%D rather special because the order in mathml matters, so we flush in [base under
%D over] order. We also do some analysis at the \TEX\ end (passing the right
%D variant). It's easy in the export to deal with it but in the pdf stream less
%D trivial as we don't actually analyze there.
%D
%D At some point the \MKII\ arrow mechanism has been converted to \MKIV, but we kept
%D most of the logic. We now have a more generic variant dealing with extensibles.
%D There are a few demands than we need to meet:
%D
%D \startitemize
%D \startitem
%D The width of the extensible need to adapt itself automatically.
%D \stopitem
%D \startitem
%D We need to be able to control horizontal and vertical offsets.
%D \stopitem
%D \startitem
%D We best have a math as well as a text variant (which is handy for chemistry).
%D \stopitem
%D \startitem
%D For historic reasons we need to deal with optional arguments in a special
%D (reverse) way.
%D \stopitem
%D \startitem
%D We need alternatives for extensibles on top, in the middle and at the bottom.
%D \stopitem
%D \stopitemize
%D
%D After I had experimented a bit with virtual characters for two headed arrows I
%D discussed the issue with the Gyre folks and we came to the conclusion that it
%D made sense to have real extensibles instead of constructing them out of snippets.
%D After all, \OPENTYPE\ math provides for it. So, in December 2013 beta versions of
%D Latin Modern and Gyre fonts came available that had these! Because we still want
%D to support the traditional Latin Modern Virtual math font those were extended
%D with a couple of virtual extensibles as well.
%D
%D {\em For the moment we still have some mess here: we can deal with known
%D dimensions, but fillers (like \type {\rightarrowfil} don't work with \OPENTYPE\
%D extensibles yet because there is no way to let them stretch like leaders. At some
%D point \LUATEX\ might provide a auto||fit||to||encapsulated||box and if not I will
%D cook up a \LUA\ based variant.}
%D
%D We could mess with something like \type {$mid\limits^{top}_{bottom}$} but we like
%D a bit more control. At some point we need to add some hacks to get exports
%D working well.
%D
%D In the end we have a more flexible mechanism which also handles text variants.
%D When wrapping up some math developments I decided to add mp support here as well.
%D A nice evening job with Joe Bonamassa performing live on the big screen (real
%D nice bluray's). See meta-imp-mat.mkiv for examples.
% possible improvements:
%
% - we could skip the left/right offsets when offset=normal, this saves some access time
% at the lua end and some checking: use \mathhorizontalcode or \mathextensiblecode
% but in practice arrows etc are not used that often
\installcorenamespace {mathextensiblefallbacks}
% currently no italic correction ... problem is that we don't know yet if we have an italic
% below so we we need to postpone
% \def\math_stackers_fallback
% {\hbox to \scratchwidth{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname}}
% %{\csname\??mathextensiblefallbacks\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname\number\scratchunicode\fi\endcsname }
\def\math_stackers_fallback
{\mathstylehbox to \scratchwidth{\usemathstackerscolorparameter\c!color
\hss
\hskip\mathstackersparameter\c!topoffset\relax % for manual italic correction
\ifcsname\??mathextensiblefallbacks\number\scratchunicode\endcsname
\lastnamedcs
\else
\Umathchar \fam \zerocount \scratchunicode
\fi
\hss}}
\def\math_stackers_regular
{\mathstylehbox{\usemathstackerscolorparameter\c!color
\hskip\d_math_stackers_offset_l
\Umathaccent\fam\zerocount\scratchunicode
{\hskip\dimexpr\scratchwidth-\d_math_stackers_offset_l-\d_math_stackers_offset_r}%
\hskip\d_math_stackers_offset_r
}}
\def\math_stackers_stretch % we don't have that one yet
{\mathstylehbox{\usemathstackerscolorparameter\c!color
\hskip\d_math_stackers_offset_l
\Umathaccent\fam\zerocount\scratchunicode
{\hskip\dimexpr\hsize-\d_math_stackers_offset_l-\d_math_stackers_offset_r}%
\hskip\d_math_stackers_offset_r
}}
% these delimiters are a unuseable as they don't center for small arguments:
%
% $\Umathaccent 0 0 "2190{x}$ \par $\Umathaccent 0 0 "27F8{x}$\par
% $\Udelimiterunder 0 "2190{x}$ \par $\Udelimiterunder 0 "27F8{x}$\par
\setvalue{\??mathextensiblefallbacks}%
{\hpack{\vrule\s!width\scratchwidth\s!height.1\mathexheight\s!depth\zeropoint}}
% \def\math_stackers_with_fallback#codepoint%
% {\begingroup
% \scratchunicode#codepoint\relax
% \ifcase\mathextensiblecode\fam\scratchunicode\relax
% \math_stackers_fallback
% \else
% \math_stackers_stretch
% \fi
% \endgroup}
%D We don't really need this because we can assume that fonts have the right
%D extensibles. If needed I will make a general virtual extender for \OPENTYPE\
%D fonts.
%D
%D Because we have quite some control over positioning, we have somewhat extensive
%D tracing built in.
\let\math_stackers_top \relax
\let\math_stackers_middle\relax
\let\math_stackers_bottom\relax
\let\math_stackers_skip \hskip
\installtextracker
{math.stackers.texts}
{\let\math_stackers_top \filledhboxb
\let\math_stackers_middle\filledhboxr
\let\math_stackers_bottom\filledhboxg
\let\math_stackers_skip \math_stackers_skip_indeed}
{\let\math_stackers_top \relax
\let\math_stackers_middle\relax
\let\math_stackers_bottom\relax
\let\math_stackers_skip \hskip}
\def\math_stackers_skip_indeed#amount%
{\filledhboxk{\unsetteststrut\strut\hskip#amount}} % \dontshowstruts
\let\math_stackers_start_tagged_mid\relax
\let\math_stackers_start_tagged_top\relax
\let\math_stackers_start_tagged_bot\relax
\let\math_stackers_stop_tagged \relax
\appendtoks
\def\math_stackers_start_tagged_mid{\dostarttagged\t!mstackermid\empty\hbox\bgroup}%
\def\math_stackers_start_tagged_top{\dostarttagged\t!mstackertop\empty\hbox\bgroup}%
\def\math_stackers_start_tagged_bot{\dostarttagged\t!mstackerbot\empty\hbox\bgroup}%
\def\math_stackers_stop_tagged {\egroup\dostoptagged}%
\to \everysetuptagging
%D We define a full featured command handler.
\installcorenamespace {mathstackers}
\installcommandhandler \??mathstackers {mathstackers} \??mathstackers
\setupmathstackers
[%c!alternative=\v!text, % text | mathematics
\c!left=,
\c!right=,
\c!mathclass=\s!rel,
\c!alternative=\v!normal,
\c!voffset=.25\mathexheight,
\c!hoffset=\zeropoint,
\c!topoffset=\zeropoint, % for manual italic correction
\c!distance=\mathstackersparameter\c!voffset, % distance between symbol and base (can be different from voffset)
\c!minheight=\mathexheight,
\c!mindepth=\zeropoint,
\c!minwidth=.5\mathemwidth,
\c!order=\v!normal,
\c!strut=,
\c!color=, % todo: when I need it
\c!topcommand=,
\c!middlecommand=,
\c!bottomcommand=,
\c!offset=\v!normal, % normal | min | max
\c!location=\v!top] % none | normal | small | medium | big
%D We assume that the middle characters (that can be an extensible) to sit on
%D top of the baseline by default.
\installcorenamespace {mathstackerslocation}
\installcorenamespace {mathstackersalternative}
\letvalue{\??mathstackerslocation\v!top }\plusone % on top of baseline
\letvalue{\??mathstackerslocation\v!high }\plustwo % 25 % down
\letvalue{\??mathstackerslocation\v!middle }\plusthree % centered
\letvalue{\??mathstackerslocation\v!low }\plusfour % 75 % down
\letvalue{\??mathstackerslocation\v!bottom }\plusfive % below baseline
\letvalue{\??mathstackerslocation }\zerocount
%D First we implement the helper that deals with an extensible in the middle and
%D top and|/|or bottom texts:
\let\m_math_stackers_text_top \empty
\let\m_math_stackers_text_bottom\empty
\let\m_math_stackers_text_middle\empty
\def\math_stackers_flushtext#command#text%
{\ifdim\scratchleftoffset >\zeropoint\math_stackers_skip\scratchleftoffset \fi
\ifx\p_strut\v!no \else
\strut
\fi
\mathstackersparameter#command#text%
\ifdim\scratchrightoffset>\zeropoint\math_stackers_skip\scratchrightoffset\fi}
\def\math_stackers_toptext {\math_stackers_flushtext\c!topcommand \m_math_stackers_text_top }
\def\math_stackers_bottomtext{\math_stackers_flushtext\c!bottomcommand\m_math_stackers_text_bottom}
\def\math_stackers_middletext{\math_stackers_flushtext\c!middlecommand\m_math_stackers_text_middle}
\def\math_stackers_content
{\ifcase\scratchcounter
\math_stackers_fallback
\or % left
\math_stackers_regular
\or % right
\math_stackers_regular
\or % horizontal
\math_stackers_regular
\else
\math_stackers_fallback
\fi}
% no checking, we assume sane use
\letvalue{\??mathstackersalternative\v!normal }\math_stackers_content
\letvalue{\??mathstackersalternative\v!default}\math_stackers_content
\setupmathstackers
[\c!mp=math:stacker:\number\scratchunicode,
\c!mpheight=\mathcharht\scratchunicode,
\c!mpdepth=\mathchardp\scratchunicode,
\c!mpoffset=.25\mathexheight]
\setvalue{\??mathstackersalternative\v!mp}%
{\normalexpanded{\math_stackers_mp_box
{\the\dimexpr\mathstackersparameter\c!mpheight}%
{\the\dimexpr\mathstackersparameter\c!mpdepth}%
{\the\dimexpr\mathstackersparameter\c!mpoffset}%
{\the\dimexpr\triggeredmathstyleparameter\Umathfractionrule}%
{\the\dimexpr\triggeredmathstyleparameter\Umathaxis}%
{\the\mathexheight}%
{\the\mathemwidth}%
}}
\protected\def\math_stackers_mp_box#1#2#3#4#5#6#7%
{\hpack\bgroup % todo: add code key + tag
% we can speed up \mathexheight expansion a bit
\d_overlay_width \scratchwidth
\d_overlay_height #1\relax
\d_overlay_depth #2\relax
\d_overlay_offset #3\relax
\d_overlay_linewidth#4\relax
\edef\overlaylinecolor{\mathstackersparameter\c!color}%
\edef\p_mp{\mathstackersparameter\c!mp}%
\uniqueMPgraphic{\p_mp}{axis=#5,ex=#6,em=#7}%
\egroup}
\def\math_stackers_check_unicode#codepoint%
{\scratchunicode#codepoint\relax
\scratchhoffset\mathstackersparameter\c!hoffset\relax
\scratchvoffset\mathstackersparameter\c!voffset\relax
\scratchcounter\mathhorizontalcode\fam\scratchunicode\relax % also sets \leftscratchoffset and \rightscratchoffset
\ifx\p_offset\v!max
% heads/tails + hoffset
\orelse\ifx\p_offset\v!min
% heads/tails - hoffset
\advance\scratchleftoffset -\scratchhoffset
\advance\scratchrightoffset-\scratchhoffset
\else % \v!normal
% hoffset
\scratchleftoffset\zeropoint
\scratchrightoffset\zeropoint
\fi
\ifdim\scratchleftoffset<\zeropoint
\scratchleftoffset\zeropoint
\fi
\ifdim\scratchrightoffset<\zeropoint
\scratchrightoffset\zeropoint
\fi}
\def\math_stackers_normalize_three
{\scratchheight\ht\scratchboxthree
\scratchdepth \dp\scratchboxthree
\scratchtopoffset \scratchheight
\scratchbottomoffset\scratchdepth
\scratchdimen\mathstackersparameter\c!minheight\relax
\ifdim\scratchheight<\scratchdimen
\scratchheight\scratchdimen
\ht\scratchboxthree\scratchheight
\fi
\scratchdimen\mathstackersparameter\c!mindepth\relax
\ifdim\scratchdepth<\scratchdimen
\scratchdepth\scratchdimen
\dp\scratchboxthree\scratchdepth
\fi
\advance\scratchtopoffset -\scratchheight
\advance\scratchbottomoffset-\scratchdepth
\ifdim\scratchtopoffset<\zeropoint
\scratchtopoffset\zeropoint
\fi
\ifdim\scratchbottomoffset<\zeropoint
\scratchbottomoffset\zeropoint
\fi}
\protected\def\math_stackers_triplet#method#category#codepoint#toptext#bottomtext%
%{\math_stackers_start_group{#category}%
{\begingroup
\edef\currentmathstackers{#category}%
\mathstackersparameter\c!left\relax
\dostarttagged\t!mstacker\currentmathstackers
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\edef\p_offset {\mathstackersparameter\c!offset}%
\edef\p_location {\mathstackersparameter\c!location}%
\edef\p_strut {\mathstackersparameter\c!strut}%
\edef\p_alternative{\mathstackersparameter\c!alternative}%
% \ifx\p_order\v!reverse
% \ifsecondargument
% \edef\m_math_stackers_text_top {#bottomtext}%
% \edef\m_math_stackers_text_bottom{#toptext}%
% \else
% \edef\m_math_stackers_text_top {#toptext}%
% \let\m_math_stackers_text_bottom \empty
% \fi
% \else
% \edef\m_math_stackers_text_top {#toptext}%
% \edef\m_math_stackers_text_bottom{#bottomtext}%
% \fi
\edef\m_math_stackers_text_top {#toptext}%
\edef\m_math_stackers_text_bottom{#bottomtext}%
\ifparameter#bottomtext\or
\edef\p_order{\mathstackersparameter\c!order}%
\ifx\p_order\v!reverse
\swapmacros\m_math_stackers_text_top\m_math_stackers_text_bottom
\fi
\fi
\scratchleftoffset \zeropoint
\scratchrightoffset\zeropoint
\ifcase#method\relax
\math_stackers_check_unicode{#codepoint}%
\else
\edef\m_math_stackers_text_middle{#codepoint}%
\fi
\ifempty\m_math_stackers_text_top
\setbox\scratchboxone\emptyhbox
\else
\setmathsmalltextbox\scratchboxone\hbox{\math_stackers_toptext}%
\fi
\ifempty\m_math_stackers_text_bottom
\setbox\scratchboxtwo\emptyhbox
\else
\setmathsmalltextbox\scratchboxtwo\hbox{\math_stackers_bottomtext}%
\fi
%
\ifcase#method\relax
% e.g. extensible
%\scratchwidth\wd
% \ifdim\wd\scratchboxone>\wd\scratchboxtwo
% \scratchboxone
% \else
% \scratchboxtwo
% \fi
%\relax
\scratchwidth\mathcharwd\scratchunicode
\ifdim\wd\scratchboxone>\scratchwidth
\scratchwidth\wd\scratchboxone
\orelse\ifdim\wd\scratchboxtwo>\scratchwidth
\scratchwidth\wd\scratchboxtwo
\fi
\else
\ifempty\m_math_stackers_text_middle
\setbox\scratchboxthree\emptyhbox
\else
\setmathtextbox\scratchboxthree\hbox{\math_stackers_middletext}%
\fi
\scratchwidth\wd
\ifdim\wd\scratchboxone>\wd\scratchboxtwo
\ifdim\wd\scratchboxone>\wd\scratchboxthree
\scratchboxone
\else
\scratchboxthree
\fi
\orelse\ifdim\wd\scratchboxtwo>\wd\scratchboxthree
\scratchboxtwo
\else
\scratchboxthree
\fi
\relax
\fi
%
\scratchdimen\mathstackersparameter\c!minwidth\relax
\ifdim\scratchwidth<\scratchdimen
\scratchwidth\scratchdimen
\fi
\advance\scratchwidth2\scratchhoffset
%
\ifcase#method\relax
\dostarttagged\t!mstackermid\empty
\setbox\scratchboxthree\csname\??mathstackersalternative\p_alternative\endcsname
\dostoptagged
\fi
%
\ifdim\wd\scratchboxone<\scratchwidth
\setbox\scratchboxone\hpack to \scratchwidth{\hss\unhbox\scratchboxone\hss}% unhboxing makes leaders work
\fi
\ifdim\wd\scratchboxtwo<\scratchwidth
\setbox\scratchboxtwo\hpack to \scratchwidth{\hss\unhbox\scratchboxtwo\hss}%
\fi
\ifdim\wd\scratchboxthree<\scratchwidth
\setbox\scratchboxthree\hpack to \scratchwidth{\hss\unhbox\scratchboxthree\hss}%
\fi
%
\ifcsname\??mathstackerslocation\p_location\endcsname
\ifcase\csname\??mathstackerslocation\p_location\endcsname\relax
\scratchdistance\zeropoint
\or % top
\scratchdistance\zeropoint
\or % high
\scratchdistance.25\htdp\scratchboxthree
\or % centered
\scratchdistance.5\htdp\scratchboxthree
\or % low
\scratchdistance.75\htdp\scratchboxthree
\or % bottom
\scratchdistance\htdp\scratchboxthree
\else
\scratchdistance\zeropoint
\fi
\else
\scratchdistance\p_location\htdp\scratchboxthree
\fi
%
\ifzeropt\scratchdistance\else
\setbox\scratchboxthree\hpack{\lower\scratchdistance\box\scratchboxthree}%
\fi
%
\math_stackers_normalize_three
% analysis
\ifdim\htdp\scratchboxtwo>\zeropoint
\ifdim\htdp\scratchboxone>\zeropoint
\dosettagproperty\s!subtype\t!munderover
\else
\dosettagproperty\s!subtype\t!munder
\fi
\else
\ifdim\htdp\scratchboxone>\zeropoint
\dosettagproperty\s!subtype\t!mover
\else
% brrr
\fi
\fi
% base
\math_stackers_start_tagged_mid
\math_stackers_middle\bgroup
\box\scratchboxthree
\egroup
\math_stackers_stop_tagged
% under
\ifdim\htdp\scratchboxtwo>\zeropoint
\math_stackers_start_tagged_bot
\scratchoffset\scratchvoffset
\kern-\scratchwidth
\math_stackers_bottom\bgroup
\lower\dimexpr\ht\scratchboxtwo+\scratchdepth+\scratchoffset+\scratchbottomoffset\relax
\box\scratchboxtwo
\egroup
\math_stackers_stop_tagged
\fi
% over
\ifdim\htdp\scratchboxone>\zeropoint
\math_stackers_start_tagged_top
\scratchoffset\scratchvoffset
\kern-\scratchwidth
\math_stackers_top\bgroup
\raise\dimexpr\dp\scratchboxone+\scratchheight+\scratchoffset+\scratchtopoffset\relax
\box\scratchboxone
\egroup
\math_stackers_stop_tagged
\fi
%
}%
\dostoptagged
\mathstackersparameter\c!right\relax
\endgroup}
%\math_stackers_stop_group}
\permanent\tolerant\protected\def\definemathextensible[#1]#*[#2]#*[#3]% category name unicode
{\ifarguments\or\or
\frozen\setuevalue{#1}{\math_stackers_auto_normal\noexpand\currentmathstackers{\number#2}}%
\or
\frozen\setuevalue{#2}{\math_stackers_auto_normal{#1}{\number#3}}%
\fi}
\tolerant\protected\def\math_stackers_auto_normal#1#2#*[#3]#:#=#*#=%
{\begingroup
\scratchcounter#2\relax
\edef\currentmathstackers{\ifparameter#3\or#3\else#1\fi}%
\math_stackers_triplet\zerocount\currentmathstackers\scratchcounter{#4}{#5}%
\endgroup}
%D A few direct accessors (in the meantime we redefined \mathextensible so we renamed the
%D following):
\permanent\tolerant\protected\def\directmathextensible[#category]%
{\begingroup
\math_stackers_handle_extensible{\ifparameter#category\or#category\else\v!mathematics\fi}} % will be defined later on
\permanent\tolerant\protected\def\directtextextensible[#category]%
{\begingroup
\math_stackers_handle_extensible{\ifparameter#category\or#category\else\v!text\fi}} % will be defined later on
\aliased\let\mathstacker\directmathextensible
\aliased\let\textstacker\directtextextensible
\def\math_stackers_handle_extensible#category#codepoint#toptext#bottomtext%
{\math_stackers_triplet\zerocount{#category}{#codepoint}{#toptext}{#bottomtext}%
\endgroup}
%D The next one deals with under and over extensibles (arrows mostly):
\installcorenamespace {mathclasses}
\letvalue{\??mathclasses }\mathord
\letvalue{\??mathclasses rel}\mathrel
\letvalue{\??mathclasses ord}\mathord
\def\math_class_by_parameter#1%
{\normalexpanded{\noexpand\math_class_by_parameter_indeed{#1\c!mathclass}}}
\def\math_class_by_parameter_indeed#1%
{\csname\??mathclasses\ifcsname\??mathclasses#1\endcsname#1\fi\endcsname}
% 1 0 name n 0 | 0 1 name n 0 | 1 1 name n n
\protected\def\math_stackers_start_group#category%
{\begingroup
\edef\currentmathstackers{#category}%
\edef\p_limits{\mathstackersparameter\c!mathlimits}%
\ifx\p_limits\v!yes
\def\math_stackers_stop_group{\egroup\endgroup\ordlimits}%
\mathop\bgroup
\else
\let\math_stackers_stop_group\endgroup
\fi}
\newconstant\c_math_stackers_top
\newconstant\c_math_stackers_bottom
\newconstant\c_math_stackers_codepoint
\newconstant\c_math_stackers_extracode
\newdimen \d_math_stackers_offset_l
\newdimen \d_math_stackers_offset_r
\setupmathstackers[lt=\zeropoint,rt=\zeropoint,lb=\zeropoint,rb=\zeropoint]
\tolerant\protected\def\math_stackers_make_double#top#bottom#category#codepoint#codeextra#spacer[#settings]#:#text%
{\math_stackers_start_group{#category}%
\c_math_stackers_top #top\relax
\c_math_stackers_bottom #bottom\relax
\c_math_stackers_codepoint#codepoint\relax
\c_math_stackers_extracode#codeextra\relax
\ifparameter#settings\or
\setupcurrentmathstackers[#settings]%
\fi
\mathstackersparameter\c!left\relax
\dostarttagged\t!mstacker\currentmathstackers
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\edef\m_math_stackers_text_middle {#text}%
%
\edef\p_offset {\mathstackersparameter\c!offset}%
\edef\p_location {\mathstackersparameter\c!location}%
\edef\p_strut {\mathstackersparameter\c!strut}%
\edef\p_alternative{\mathstackersparameter\c!alternative}%
%
\scratchleftoffset \zeropoint
\scratchrightoffset\zeropoint
%
\math_stackers_check_unicode\c_math_stackers_codepoint
%
\ifempty\math_stackers_middle
\setbox\scratchboxthree\emptyhbox
\else
\setmathtextbox\scratchboxthree\hbox{\math_stackers_middletext}%
\fi
\scratchwidth\wd\scratchboxthree
%
\scratchdimen\mathstackersparameter\c!minwidth\relax
\ifdim\scratchwidth<\scratchdimen
\scratchwidth\scratchdimen
\fi
\advance\scratchwidth2\scratchhoffset
%
%\scratchunicode\c_math_stackers_codepoint
\ifcase\c_math_stackers_bottom
\d_math_stackers_offset_l\mathstackersparameter{lt}%
\d_math_stackers_offset_r\mathstackersparameter{rt}%
\orelse\ifcase\c_math_stackers_top
\d_math_stackers_offset_l\mathstackersparameter{lb}%
\d_math_stackers_offset_r\mathstackersparameter{rb}%
\else
\d_math_stackers_offset_l\mathstackersparameter{lt}%
\d_math_stackers_offset_r\mathstackersparameter{rt}%
\fi
\setbox\scratchboxtwo\csname\??mathstackersalternative\p_alternative\endcsname
\setbox\scratchboxthree\hpack to \scratchwidth{\hss\box\scratchboxthree\hss}%
%
\ifcase\c_math_stackers_extracode\else
\scratchunicode\c_math_stackers_extracode
\d_math_stackers_offset_l\mathstackersparameter{lb}%
\d_math_stackers_offset_r\mathstackersparameter{rb}%
\setbox\scratchboxone\csname\??mathstackersalternative\p_alternative\endcsname
\fi
%
\math_stackers_normalize_three
% analysis
\ifcase\c_math_stackers_bottom
\ifcase\c_math_stackers_top
\dosettagproperty\s!subtype\t!munderover
\else
\dosettagproperty\s!subtype\t!mover
\fi
\else
\ifcase\c_math_stackers_top
\dosettagproperty\s!subtype\t!munder
\else
% brrr
\fi
\fi
% base
\math_stackers_start_tagged_mid
\math_stackers_middle\bgroup
\box\scratchboxthree
\egroup
\math_stackers_stop_tagged
%
\ifdim\htdp\scratchboxtwo>\zeropoint
\ifcase\c_math_stackers_bottom\else
\kern-\scratchwidth
% under
\math_stackers_start_tagged_bot
\math_stackers_bottom\bgroup
\lower\dimexpr
\scratchdepth
+\ht\scratchboxtwo
+\mathstackersparameter\c!distance % was \c!voffset
\relax
\ifcase\c_math_stackers_top
\box\scratchboxtwo
\else
\box\scratchboxone
\fi
\egroup
\math_stackers_stop_tagged
\fi
\ifcase\c_math_stackers_top\else
\kern-\scratchwidth
% over
\math_stackers_start_tagged_top
\math_stackers_top\bgroup
\raise\dimexpr
\scratchheight
+\dp\scratchboxtwo % new
+\mathstackersparameter\c!distance % was \c!voffset
\relax
\box\scratchboxtwo
\egroup
\math_stackers_stop_tagged
\fi
\fi}%
\dostoptagged
\mathstackersparameter\c!right\relax
\math_stackers_stop_group}
\permanent\tolerant\protected\def\definemathoverextensible[#1]#*[#2]#*[#3]%
{\ifparameter#3\or
\frozen\setuevalue{#2}{\math_stackers_make_double\plusone \zerocount{#1}{\number#3}{0}}%
\else
\frozen\setuevalue{#1}{\math_stackers_make_double\plusone \zerocount\noexpand\currentmathstackers{\number#2}{0}}%
\fi}
\permanent\tolerant\protected\def\definemathunderextensible[#1]#*[#2]#*[#3]%
{\ifparameter#3\or
\frozen\setuevalue{#2}{\math_stackers_make_double\zerocount\plusone{#1}{\number#3}{0}}%
\else
\frozen\setuevalue{#1}{\math_stackers_make_double\zerocount\plusone\noexpand\currentmathstackers{\number#2}{0}}%
\fi}
\permanent\tolerant\protected\def\definemathdoubleextensible[#1]#*[#2]#*[#3]#*[#4]%
{\ifparameter#4\or
\frozen\setuevalue{#2}{\math_stackers_make_double\plusone \plusone{#1}{\number#3}{\number#4}}%
\else
\frozen\setuevalue{#1}{\math_stackers_make_double\plusone \plusone\noexpand\currentmathstackers{\number#2}{\number#3}}%
\fi}
\permanent\tolerant\protected\def\definemathover[#category]#spacer[#command]#spacer[#topcode]%
{\frozen\setuvalue{#command}{\math_stackers_handle_direct\plusone\zerocount{#category}{#topcode}{0}}}
\permanent\tolerant\protected\def\definemathunder[#category]#spacer[#command]#spacer[#bottomcode]%
{\frozen\setuvalue{#command}{\math_stackers_handle_direct\zerocount\plusone{#category}{#bottomcode}{0}}}
\permanent\tolerant\protected\def\definemathdouble[#category]#spacer[#command]#spacer[#topcode]#spacer[#bottomcode]%
{\frozen\setuvalue{#command}{\math_stackers_handle_direct\plusone\plusone{#category}{#topcode}{#bottomcode}}}
\permanent\tolerant\protected\def\mathover[#category]#spacer[#settings]#:#topcode#text%
{\begingroup
\edef\currentmathstackers{\ifparameter#category\or#category\else\v!top\fi}%
\ifparameter#settings\or
\setupcurrentmathstackers[#settings]%
\fi
\math_stackers_make_double\plusone\zerocount
{\currentmathstackers}%
{#topcode}%
{0}%
{#text}%
\endgroup}
\permanent\tolerant\protected\def\mathunder[#category]#spacer[#settings]#:#bottomcode#text%
{\begingroup
\edef\currentmathstackers{\ifparameter#category\or#category\else\v!bottom\fi}%
\ifparameter#settings\or
\setupcurrentmathstackers[#settings]%
\fi
\math_stackers_make_double\zerocount\plusone
{\currentmathstackers}%
{#bottomcode}%
{0}%
{#text}%
\endgroup}
\permanent\tolerant\protected\def\mathdouble[#category]#spacer[#settings]#:#topcode#bottomcode#text%
{\begingroup
\edef\currentmathstackers{\ifparameter#category\or#category\else\v!both\fi}%
\ifparameter#settings\or
\setupcurrentmathstackers[#settings]%
\fi
\math_stackers_make_double\plusone\plusone
{\currentmathstackers}%
{#topcode}%
{#bottomcode}%
{#text}%
\endgroup}
\def\math_stackers_handle_direct#top#bottom#category#topcode#bottomcode#text%
{\begingroup
\math_stackers_make_double#top#bottom{#category}{#topcode}{#bottomcode}{#text}%
\endgroup}
%D A relative new one is a combination of accents and text (as needed in mathml):
\protected\def\math_stackers_make_double_text#where#category#codepoint#text#extra%
{\math_stackers_start_group{#category}%
\mathstackersparameter\c!left\relax
\dostarttagged\t!mstacker\currentmathstackers
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\edef\currentmathstackers{#category}%
%
\edef\p_offset {\mathstackersparameter\c!offset}%
\edef\p_location {\mathstackersparameter\c!location}%
\edef\p_strut {\mathstackersparameter\c!strut}%
\edef\p_alternative{\mathstackersparameter\c!alternative}%
%
\scratchleftoffset \zeropoint
\scratchrightoffset\zeropoint
%
\edef\m_math_stackers_text_middle{#text}%
\math_stackers_check_unicode{#codepoint}%
\scratchunicode#codepoint\relax
%
\ifempty\math_stackers_middle
\setbox\scratchboxthree\emptyhbox
\else
\setmathtextbox\scratchboxthree\hbox{\math_stackers_middletext}%
\fi
%
\ifcase#where\relax
\edef\m_math_stackers_text_top{#extra}%
\ifempty\math_stackers_top
\setbox\scratchboxone\emptyhbox
\else
\setmathsmalltextbox\scratchboxone\hbox{\math_stackers_toptext}%
\fi
\else
\edef\m_math_stackers_text_bottom{#extra}%
\ifempty\math_stackers_bottom
\setbox\scratchboxone\emptyhbox
\else
\setmathsmalltextbox\scratchboxone\hbox{\math_stackers_bottomtext}%
\fi
\fi
%
\scratchwidth\wd
\ifdim\wd\scratchboxone>\wd\scratchboxthree
\scratchboxone
\else
\scratchboxthree
\fi
\relax
\scratchdimen\mathstackersparameter\c!minwidth\relax
\ifdim\scratchwidth<\scratchdimen
\scratchwidth\scratchdimen
\fi
\advance\scratchwidth2\scratchhoffset
%
\ifdim\wd\scratchboxone<\scratchwidth
\setbox\scratchboxone\hpack to \scratchwidth{\hss\unhbox\scratchboxone\hss}%
\fi
\ifdim\wd\scratchboxthree<\scratchwidth
\setbox\scratchboxthree\hpack to \scratchwidth{\hss\unhbox\scratchboxthree\hss}%
\fi
%
\math_stackers_normalize_three
% analysis
\dosettagproperty\s!subtype\t!munderover
% base
\math_stackers_start_tagged_mid
\math_stackers_middle\bgroup
\box\scratchboxthree
\egroup
\math_stackers_stop_tagged
%
\setbox\scratchboxtwo\csname\??mathstackersalternative\p_alternative\endcsname
\kern-\scratchwidth
\ifcase#where\relax
% under
\math_stackers_start_tagged_bot
\math_stackers_bottom\bgroup
\lower\dimexpr
\scratchdepth
+\ht\scratchboxtwo
+\mathstackersparameter\c!distance
\relax
\box\scratchboxtwo % accent
\egroup
\math_stackers_stop_tagged
\kern-\scratchwidth
% over
\math_stackers_start_tagged_top
\math_stackers_top\bgroup
\raise\dimexpr
\scratchheight
+\dp\scratchboxone
+\mathstackersparameter\c!voffset
\relax
\box\scratchboxone % toptext
\egroup
\math_stackers_stop_tagged
\else
% under
\math_stackers_start_tagged_bot
\math_stackers_bottom\bgroup
\lower\dimexpr
\scratchdepth
+\ht\scratchboxone
+\mathstackersparameter\c!voffset
\relax
\box\scratchboxone % bottext
\egroup
\math_stackers_stop_tagged
\kern-\scratchwidth
% over
\math_stackers_start_tagged_top
\math_stackers_top\bgroup
\raise\dimexpr
\scratchheight
+\dp\scratchboxtwo % new
+\mathstackersparameter\c!distance
\relax
\box\scratchboxtwo % accent
\egroup
\math_stackers_stop_tagged
\fi
}%
\dostoptagged
\mathstackersparameter\c!right\relax
\math_stackers_stop_group}
\permanent\tolerant\protected\def\definemathovertextextensible[#1]#*[#2]#*[#3]%
{\ifparameter#3\or
\frozen\setuevalue{#2}{\math_stackers_make_double_text\plusone{#1}{\number#3}}%
\else
\frozen\setuevalue{#1}{\math_stackers_make_double_text\plusone\noexpand\currentmathstackers{\number#2}}%
\fi}
\permanent\tolerant\protected\def\definemathundertextextensible[#1]#*[#2]#*[#3]%
{\ifparameter#3\or
\frozen\setuevalue{#2}{\math_stackers_make_double_text\zerocount{#1}{\number#3}}%
\else
\frozen\setuevalue{#1}{\math_stackers_make_double_text\zerocount\noexpand\currentmathstackers{\number#2}}%
\fi}
\permanent\tolerant\protected\def\mathovertext[#category]%
{\begingroup
\math_stackers_direct_double_text\plusone {\ifargument#category\or#category\else\v!top\fi}}
\permanent\tolerant\protected\def\mathundertext[#category]%
{\begingroup
\math_stackers_direct_double_text\zerocount{\ifargument#category\or#category\else\v!bottom\fi}}
\def\math_stackers_direct_double_text#where#category#codepoint#text#extra%%
{\math_stackers_make_double_text#where{#category}{#codepoint}{#text}{#extra}%
\endgroup}
%D Here is a bonus macro that takes three texts. It can be used to get consistent
%D mixed usage.
\permanent\tolerant\protected\def\mathtriplet[#category]#:#middletext#toptext#bottomtext%
{\begingroup
\math_stackers_triplet\plusone{\ifargument#category\or#category\else\currentmathstackers\fi}{#middletext}{#toptext}{#bottomtext}%
\endgroup}
\permanent\tolerant\protected\def\definemathtriplet[#1]#*[#2]#*[#3]% category name default
{\ifarguments\or
\frozen\setuevalue{#1}{\math_stackers_auto_triplet_nop[\noexpand\currentmathstackers]}%
\or
\frozen\setuevalue{#2}{\math_stackers_auto_triplet_nop[#1]}%
\or
\frozen\setuevalue{#2}{\math_stackers_auto_triplet_yes[#1][#3]}%
\fi}
\tolerant\protected\def\math_stackers_auto_triplet_yes[#1][#2]#*[#3]#:#=#*#=% [#2]% #2 gobble spaces
{\begingroup
\edef\currentmathstackers{#1}%
\def \m_math_stackers_text_middle{#2}%
\ifarguments#3\or\edef\currentmathstackers{#3}\fi
\math_stackers_triplet\plusone\currentmathstackers\m_math_stackers_text_middle{#4}{#5}%
\endgroup}
\tolerant\protected\def\math_stackers_auto_triplet_nop[#1]#*[#2]#:#=#*#=#*#=% [#2]% #2 gobble spaces%
{\begingroup
\edef\currentmathstackers{#1}%
\ifarguments#2\or\edef\currentmathstackers{#2}\fi
\math_stackers_triplet\plusone\currentmathstackers{#3}{#4}{#5}%
\endgroup}
%D Definitions:
\definemathstackers
[\v!mathematics]
[\c!topcommand=\mathematics,
\c!middlecommand=\mathematics,
\c!bottomcommand=\mathematics]
\definemathstackers
[\s!math]
[\v!mathematics]
\definemathstackers
[\v!text]
[\v!mathematics]
[\c!topcommand=,
\c!middlecommand=\mathematics,
\c!bottomcommand=]
\definemathstackers
[\v!reverse]
[\v!mathematics]
[\c!order=\v!reverse]
\definemathstackers
[\v!both]
[\v!mathematics]
[\c!location=\v!top, % ?
\c!strut=\v!no,
\c!middlecommand=\mathematics,
\c!hoffset=\zeropoint]
\definemathstackers
[\v!top]
[\v!both]
\definemathstackers
[\v!bottom]
[\v!both]
\definemathstackers
[\v!vfenced]
[\v!both]
[\c!mathclass=\s!ord,
\c!mathlimits=\v!yes]
% these are needed for mathml:
% \setupmathstackers
% [\v!both]
% [\c!hoffset=1pt,
% \c!voffset=1pt]
\definemathstackers
[\v!bothtext]
[\v!both]
[\c!strut=\v!yes]
% These are compatibity definitions, math only.
% todo: top= bottom= middle= is nicer (compare math-fen)
%D We save a few definitions that we automatically got from the \type {char-def.lua}
%D database.
% Be careful in choosing what accents you take (the code below uses a combining
% one):
%
% \startbuffer
% % $\Umathaccent top 0 0 "20D7 {example}$
% % $\Umathaccent top fixed 0 0 "20D7 {example}$
% $\Umathaccent 0 0 "20D7 {example}$
% $\Umathaccent fixed 0 0 "20D7 {example}$
% $\Umathaccent bottom 0 0 "20D7 {example}$
% $\Umathaccent bottom fixed 0 0 "20D7 {example}$
% $\Umathaccent both 0 0 "20D7
% 0 0 "20D7 {example}$
% $\Umathaccent both fixed 0 0 "20D7
% fixed 0 0 "20D7 {example}$
% $\Umathaccent both 0 0 "20D7
% fixed 0 0 "20D7 {example}$
% $\Umathaccent both fixed 0 0 "20D7
% 0 0 "20D7 {example}$
% \stopbuffer
%
% \setupbodyfont[modern] \getbuffer
% \setupbodyfont[xits] \getbuffer
% \setupbodyfont[cambria] \getbuffer
\immutable\protected\def\normaldoublebrace {\Umathaccents 0 \defaultmathfamily "23DE 0 \defaultmathfamily "23DF }
\immutable\protected\def\normaldoubleparent{\Umathaccents 0 \defaultmathfamily "23DC 0 \defaultmathfamily "23DD }
% let's keep this
\aliased\let\normaloverbrace \overbrace
\aliased\let\normalunderbrace \underbrace
\aliased\let\normaloverparent \overparent
\aliased\let\normalunderparent \underparent
\aliased\let\normaloverbracket \overbracket
\aliased\let\normalunderbracket \underbracket
\aliased\let\normalunderleftarrow \underleftarrow
\aliased\let\normaloverleftarrow \overleftarrow
\aliased\let\normalunderrightarrow\underrightarrow
\aliased\let\normaloverrightarrow \overrightarrow
%D Here come the new ones:
\definemathstackers [\v!none] [\v!mathematics] [\c!hoffset=\zeropoint]
\definemathstackers [\v!normal] [\v!mathematics] [\c!hoffset=0.5\mathemwidth] % the default
\definemathstackers [\v!small] [\v!mathematics] [\c!hoffset=1\mathemwidth]
\definemathstackers [\v!medium] [\v!mathematics] [\c!hoffset=1.5\mathemwidth]
\definemathstackers [\v!big] [\v!mathematics] [\c!hoffset=2\mathemwidth]
\definemathextensible [\v!reverse] [xrel] ["002D]
\definemathextensible [\v!reverse] [xequal] ["003D]
\definemathextensible [\v!reverse] [xleftarrow] ["2190] % ["27F5]
\definemathextensible [\v!reverse] [xrightarrow] ["2192] % ["27F6]
\definemathextensible [\v!reverse] [xleftrightarrow] ["27F7]
\definemathextensible [\v!reverse] [xLeftarrow] ["27F8]
\definemathextensible [\v!reverse] [xRightarrow] ["27F9]
\definemathextensible [\v!reverse] [xLeftrightarrow] ["27FA]
\definemathextensible [\v!reverse] [xtwoheadleftarrow] ["219E]
\definemathextensible [\v!reverse] [xtwoheadrightarrow] ["21A0]
\definemathextensible [\v!reverse] [xmapsto] ["21A6]
\definemathextensible [\v!reverse] [xhookleftarrow] ["21A9]
\definemathextensible [\v!reverse] [xhookrightarrow] ["21AA]
\definemathextensible [\v!reverse] [xleftharpoondown] ["21BD]
\definemathextensible [\v!reverse] [xleftharpoonup] ["21BC]
\definemathextensible [\v!reverse] [xrightharpoondown] ["21C1]
\definemathextensible [\v!reverse] [xrightharpoonup] ["21C0]
\definemathextensible [\v!reverse] [xrightoverleftarrow] ["21C4]
\definemathextensible [\v!reverse] [xleftrightharpoons] ["21CB]
\definemathextensible [\v!reverse] [xrightleftharpoons] ["21CC]
\definemathextensible [\v!reverse] [xtriplerel] ["2261]
\definemathextensible [\v!mathematics] [mrel] ["002D]
\definemathextensible [\v!mathematics] [mequal] ["003D]
\definemathextensible [\v!mathematics] [mleftarrow] ["2190] % ["27F5]
\definemathextensible [\v!mathematics] [mrightarrow] ["2192] % ["27F6]
\definemathextensible [\v!mathematics] [mleftrightarrow] ["27F7]
\definemathextensible [\v!mathematics] [mLeftarrow] ["27F8]
\definemathextensible [\v!mathematics] [mRightarrow] ["27F9]
\definemathextensible [\v!mathematics] [mLeftrightarrow] ["27FA]
\definemathextensible [\v!mathematics] [mtwoheadleftarrow] ["219E]
\definemathextensible [\v!mathematics] [mtwoheadrightarrow] ["21A0]
\definemathextensible [\v!mathematics] [mmapsto] ["21A6]
\definemathextensible [\v!mathematics] [mhookleftarrow] ["21A9]
\definemathextensible [\v!mathematics] [mhookrightarrow] ["21AA]
\definemathextensible [\v!mathematics] [mleftharpoondown] ["21BD]
\definemathextensible [\v!mathematics] [mleftharpoonup] ["21BC]
\definemathextensible [\v!mathematics] [mrightharpoondown] ["21C1]
\definemathextensible [\v!mathematics] [mrightharpoonup] ["21C0]
\definemathextensible [\v!mathematics] [mrightoverleftarrow] ["21C4]
\definemathextensible [\v!mathematics] [mleftrightharpoons] ["21CB]
\definemathextensible [\v!mathematics] [mrightleftharpoons] ["21CC]
\definemathextensible [\v!mathematics] [mtriplerel] ["2261]
\definemathextensible [\v!mathematics] [eleftarrowfill] ["2190] % ["27F5]
\definemathextensible [\v!mathematics] [erightarrowfill] ["2192] % ["27F6]
\definemathextensible [\v!mathematics] [eleftrightarrowfill] ["27F7]
\definemathextensible [\v!mathematics] [etwoheadrightarrowfill] ["27F9]
\definemathextensible [\v!mathematics] [eleftharpoondownfill] ["21BD]
\definemathextensible [\v!mathematics] [eleftharpoonupfill] ["21BC]
\definemathextensible [\v!mathematics] [erightharpoondownfill] ["21C1]
\definemathextensible [\v!mathematics] [erightharpoonupfill] ["21C0]
\definemathextensible [\v!mathematics] [eoverbarfill] ["FE33E]
\definemathextensible [\v!mathematics] [eunderbarfill] ["FE33F]
\definemathextensible [\v!mathematics] [eoverbracefill] ["FE3DE]
\definemathextensible [\v!mathematics] [eunderbracefill] ["FE3DF]
\definemathextensible [\v!mathematics] [eoverparentfill] ["FE3DC]
\definemathextensible [\v!mathematics] [eunderparentfill] ["FE3DD]
\definemathextensible [\v!mathematics] [eoverbracketfill] ["FE3B4]
\definemathextensible [\v!mathematics] [eunderbracketfill] ["FE3B5]
\definemathextensible [\v!text] [trel] ["002D]
\definemathextensible [\v!text] [tequal] ["003D]
\definemathextensible [\v!text] [tmapsto] ["21A6]
\definemathextensible [\v!text] [tleftarrow] ["2190] % ["27F5]
\definemathextensible [\v!text] [trightarrow] ["2192] % ["27F6]
\definemathextensible [\v!text] [tleftrightarrow] ["27F7]
\definemathextensible [\v!text] [tLeftarrow] ["27F8]
\definemathextensible [\v!text] [tRightarrow] ["27F9]
\definemathextensible [\v!text] [tLeftrightarrow] ["27FA]
\definemathextensible [\v!text] [ttwoheadleftarrow] ["219E]
\definemathextensible [\v!text] [ttwoheadrightarrow] ["21A0]
\definemathextensible [\v!text] [thookleftarrow] ["21A9]
\definemathextensible [\v!text] [thookrightarrow] ["21AA]
\definemathextensible [\v!text] [tleftharpoondown] ["21BD]
\definemathextensible [\v!text] [tleftharpoonup] ["21BC]
\definemathextensible [\v!text] [trightharpoondown] ["21C1]
\definemathextensible [\v!text] [trightharpoonup] ["21C0]
\definemathextensible [\v!text] [trightoverleftarrow] ["21C4]
\definemathextensible [\v!text] [tleftrightharpoons] ["21CB]
\definemathextensible [\v!text] [trightleftharpoons] ["21CC]
\definemathextensible [\v!text] [ttriplerel] ["2261]
\definemathoverextensible [\v!top] [overleftarrow] ["2190] % ["27F5]
\definemathoverextensible [\v!top] [overrightarrow] ["2192] % ["27F6]
\definemathoverextensible [\v!top] [overleftrightarrow] ["27F7]
\definemathoverextensible [\v!top] [overtwoheadleftarrow] ["27F8]
\definemathoverextensible [\v!top] [overtwoheadrightarrow] ["27F9]
\definemathoverextensible [\v!top] [overleftharpoondown] ["21BD]
\definemathoverextensible [\v!top] [overleftharpoonup] ["21BC]
\definemathoverextensible [\v!top] [overrightharpoondown] ["21C1]
\definemathoverextensible [\v!top] [overrightharpoonup] ["21C0]
\definemathunderextensible [\v!bottom] [underleftarrow] ["2190] % ["27F5]
\definemathunderextensible [\v!bottom] [underrightarrow] ["2192] % ["27F6]
\definemathunderextensible [\v!bottom] [underleftrightarrow] ["27F7]
\definemathunderextensible [\v!bottom] [undertwoheadleftarrow] ["27F8]
\definemathunderextensible [\v!bottom] [undertwoheadrightarrow] ["27F9]
\definemathunderextensible [\v!bottom] [underleftharpoondown] ["21BD]
\definemathunderextensible [\v!bottom] [underleftharpoonup] ["21BC]
\definemathunderextensible [\v!bottom] [underrightharpoondown] ["21C1]
\definemathunderextensible [\v!bottom] [underrightharpoonup] ["21C0]
%D We don't use overline and underline. This is one of the overlooked aspects of
%D unicode cq. opentype math: why treat rules different than e.g. arrows and
%D accents. It is a bit unfortunate that the opportunity to move math to new
%D technologies happened outside the tex domain (and/or some aspects were kept while
%D in fact they were side effects of limitations of traditional fonts). From the
%D unicode aware tex engines' implementation point of view things could have been
%D done a bit nicer but then: the community didn't seem to care too much and just
%D has to follow now.
%D
%D Anyhow, we use a character based approach so that at least we get unicode stuff
%D in the backend (okay, we still need to deal with some cut and paste issues but at
%D least we now know what we deal with.
% alternatively we can move the original to FE*
\definemathoverextensible [\v!vfenced] [overbar] ["FE33E] % ["203E]
\definemathunderextensible [\v!vfenced] [underbar] ["FE33F] % ["203E]
\definemathdoubleextensible [\v!vfenced] [doublebar] ["FE33E] ["FE33F]
\definemathoverextensible [\v!vfenced] [overbrace] ["FE3DE] % ["023DE]
\definemathunderextensible [\v!vfenced] [underbrace] ["FE3DF] % ["023DF]
\definemathdoubleextensible [\v!vfenced] [doublebrace] ["FE3DE] ["FE3DF]
\definemathoverextensible [\v!vfenced] [overparent] ["FE3DC] % ["023DC]
\definemathunderextensible [\v!vfenced] [underparent] ["FE3DD] % ["023DD]
\definemathdoubleextensible [\v!vfenced] [doubleparent] ["FE3DC] ["FE3DD]
\definemathoverextensible [\v!vfenced] [overbracket] ["FE3B4] % ["023B4]
\definemathunderextensible [\v!vfenced] [underbracket] ["FE3B5] % ["023B5]
\definemathdoubleextensible [\v!vfenced] [doublebracket] ["FE3B4] ["FE3B5]
% \protected\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits}
%D For mathml:
\definemathdoubleextensible [\v!both] [overbarunderbar] ["FE33E] ["FE33F]
\definemathdoubleextensible [\v!both] [overbraceunderbrace] ["FE3DE] ["FE3DF]
\definemathdoubleextensible [\v!both] [overparentunderparent] ["FE3DC] ["FE3DD]
\definemathdoubleextensible [\v!both] [overbracketunderbracket] ["FE3B4] ["FE3B5]
\definemathovertextextensible [\v!bothtext] [overbartext] ["FE33E]
\definemathundertextextensible [\v!bothtext] [underbartext] ["FE33F]
\definemathovertextextensible [\v!bothtext] [overbracetext] ["FE3DE]
\definemathundertextextensible [\v!bothtext] [underbracetext] ["FE3DF]
\definemathovertextextensible [\v!bothtext] [overparenttext] ["FE3DC]
\definemathundertextextensible [\v!bothtext] [underparenttext] ["FE3DD]
\definemathovertextextensible [\v!bothtext] [overbrackettext] ["FE3B4]
\definemathundertextextensible [\v!bothtext] [underbrackettext] ["FE3B5]
%D Some bonus ones (for the moment here):
\definemathstackers
[\v!chemistry]
[\c!offset=\v!max,
\c!left=\enspace,
\c!right=\enspace,
\c!hoffset=.5\mathemwidth]
\definemathextensible [\v!chemistry] [cleftarrow] ["2190]
\definemathextensible [\v!chemistry] [crightarrow] ["2192]
\definemathextensible [\v!chemistry] [crightoverleftarrow] ["21C4]
% for the moment:
\def\math_stackers_hacked_fill#1#2#3%
{\mathematics
{\begingroup
\mathsurround\zeropoint
\thickmuskip \zeromuskip
\medmuskip \zeromuskip
\thinmuskip \zeromuskip
#1%
\mkern-7\onemuskip
\cleaders\mathstylehbox{\mkern-2\onemuskip#2\mkern-2\onemuskip}\hfill
\mkern-7\onemuskip
#3%
\endgroup}}
% These will be defined in char-def as well once we have \leaders<number>
\immutable\protected\def\rightarrowfill {\math_stackers_hacked_fill \relbar \relbar \rightarrow}
\immutable\protected\def\leftarrowfill {\math_stackers_hacked_fill \leftarrow \relbar \relbar }
\immutable\protected\def\rightoverleftarrowfill{\math_stackers_hacked_fill \ctxdoublearrowfillleftend\ctxdoublearrowfillmiddlepart\ctxdoublearrowfillrightend}
\immutable\protected\def\equalfill {\math_stackers_hacked_fill \Relbar \Relbar \Relbar}
\immutable\protected\def\Rightarrowfill {\math_stackers_hacked_fill \Relbar \Relbar \Rightarrow}
\immutable\protected\def\Leftarrowfill {\math_stackers_hacked_fill \Leftarrow \Relbar \Relbar}
\immutable\protected\def\Leftrightarrowfill {\math_stackers_hacked_fill \Leftarrow \Relbar \Rightarrow}
\immutable\protected\def\leftrightarrowfill {\math_stackers_hacked_fill \leftarrow \relbar \rightarrow}
\immutable\protected\def\mapstofill {\math_stackers_hacked_fill{\mapstochar\relbar} \relbar \rightarrow}
\immutable\protected\def\twoheadrightarrowfill {\math_stackers_hacked_fill \relbar \relbar \twoheadrightarrow}
\immutable\protected\def\twoheadleftarrowfill {\math_stackers_hacked_fill \twoheadleftarrow \relbar \relbar}
\immutable\protected\def\rightharpoondownfill {\math_stackers_hacked_fill \relbar \relbar \rightharpoondown}
\immutable\protected\def\rightharpoonupfill {\math_stackers_hacked_fill \relbar \relbar \rightharpoonup}
\immutable\protected\def\leftharpoondownfill {\math_stackers_hacked_fill \leftharpoondown \relbar \relbar}
\immutable\protected\def\leftharpoonupfill {\math_stackers_hacked_fill \leftharpoonup \relbar \relbar}
\immutable\protected\def\hookleftfill {\math_stackers_hacked_fill \leftarrow \relbar {\relbar\joinrel\rhook}}
\immutable\protected\def\hookrightfill {\math_stackers_hacked_fill{\lhook\joinrel\relbar} \relbar \rightarrow}
\immutable\protected\def\relfill {\math_stackers_hacked_fill \relbar \relbar \relbar}
\immutable\protected\def\triplerelfill {\math_stackers_hacked_fill \equiv \equiv \equiv}
% \permanent\protected\def\singlebond{{\xrel}} % or \def\singlebond{{\xrel[2]}}
% \permanent\protected\def\doublebond{{\xequal}}
% \permanent\protected\def\triplebond{{\xtriplerel}}
%D For the moment (needs checking):
\permanent\tolerant\protected\def\defineextensiblefiller[#1]#*[#2]%
{\immutable\letcsname\??mathextensiblefallbacks\number#2\expandafter\endcsname\csname#1\endcsname
%\immutable\letcsname#1\expandafter\endcsname\csname#1\endcsname
} % huh?
\defineextensiblefiller [barfill] ["203E]
\defineextensiblefiller [relfill] ["002D]
\defineextensiblefiller [equalfill] ["003D]
\defineextensiblefiller [leftarrowfill] ["2190]
\defineextensiblefiller [rightarrowfill] ["2192]
\defineextensiblefiller [twoheadleftarrowfill] ["219E]
\defineextensiblefiller [twoheadrightarrowfill] ["21A0]
\defineextensiblefiller [mapstofill] ["21A6]
\defineextensiblefiller [hookleftarrowfill] ["21A9]
\defineextensiblefiller [hookrightarrowfill] ["21AA]
\defineextensiblefiller [leftharpoondownfill] ["21BD]
\defineextensiblefiller [leftharpoonupfill] ["21BC]
\defineextensiblefiller [rightharpoondownfill] ["21C1]
\defineextensiblefiller [rightharpoonupfill] ["21C0]
\defineextensiblefiller [rightoverleftarrowfill] ["21C4]
\defineextensiblefiller [leftrightharpoonsfill] ["21CB]
\defineextensiblefiller [rightleftharpoonsfill] ["21CC]
\defineextensiblefiller [triplerelfill] ["2261]
\defineextensiblefiller [leftrightarrowfill] ["27F7]
\defineextensiblefiller [Leftarrowfill] ["27F8]
\defineextensiblefiller [Rightarrowfill] ["27F9]
\defineextensiblefiller [Leftrightarrowfill] ["27FA]
%\defineextensiblefiller[Rightleftarrowfill] [.....]
% These are fishy ... we need to check this because now these commands relax (there
% are some entries in char-def.)
%
% %definemathoverextensible [overbarfill] ["FE33E]
% %definemathunderextensible [underbarfill] ["FE33F]
% \definemathoverextensible [overbracefill] ["FE3DE]
% \definemathunderextensible [underbracefill] ["FE3DF]
% \definemathoverextensible [overparentfill] ["FE3DC]
% \definemathunderextensible [underparentfill] ["FE3DD]
% \definemathoverextensible [overbracketfill] ["FE3B4]
% \definemathunderextensible [underbracketfill] ["FE3B5]
%
% %defineextensiblefiller [overbarfill] ["FE33E]
% %defineextensiblefiller [underbarfill] ["FE33F]
% \defineextensiblefiller [overbracefill] ["FE3DE]
% \defineextensiblefiller [underbracefill] ["FE3DF]
% \defineextensiblefiller [overparentfill] ["FE3DC]
% \defineextensiblefiller [underparentfill] ["FE3DD]
% \defineextensiblefiller [overbracketfill] ["FE3B4]
% \defineextensiblefiller [underbracketfill] ["FE3B5]
%D Extra:
\permanent\protected\edef\singlebond{\mathematics{\mathsurround\zeropoint\char\number"002D\relax}}
\permanent\protected\edef\doublebond{\mathematics{\mathsurround\zeropoint\char\number"003D\relax}}
\permanent\protected\edef\triplebond{\mathematics{\mathsurround\zeropoint\char\number"2261\relax}}
% \mathchardef\singlebond"002D
% \mathchardef\doublebond"003D
% \mathchardef\triplebond"2261
%D Also handy:
\permanent\tolerant\protected\def\definemathunstacked[#1]#*[#2]#*[#3]% category name unicode
{\ifarguments\or\or
\frozen\setuevalue{#1}{\math_stackers_unstacked_normal\noexpand\currentmathstackers{\number#2}}%
\else
\frozen\setuevalue{#2}{\math_stackers_unstacked_normal{#1}{\number#3}}%
\fi}
\protected\def\math_stackers_unstacked_normal#category#codepoint%
{\begingroup
\edef\currentmathstackers{#category}%
\edef\p_moffset{\mathstackersparameter\c!moffset}%
\ifempty\p_moffset \else
\mskip\p_moffset\relax
\fi
\ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
{\usemathstackerscolorparameter\c!color
\Umathchar\zerocount\defaultmathfamily#codepoint}%
\ifempty\p_moffset \else
\mskip\p_moffset\relax
\fi
\endgroup}
\definemathstackers [\v!wide] [\c!moffset=\thickmuskip,\c!mathclass=\s!rel]
\definemathunstacked [\v!wide] [And] ["0026] % \mathrel{\;&\;}
\definemathunstacked [\v!wide] [impliedby] ["27F8] % \mathrel{\;\Longleftarrow\;}
\definemathunstacked [\v!wide] [implies] ["27F9] % \mathrel{\;\Longrightarrow\;}
\definemathunstacked [\v!wide] [iff] ["27FA] % \mathrel{\;\Longleftrightarrow\;}
% New (an example of using \mathexheight):
\definemathstackers
[\v!symbol]
[\c!voffset=-.3\mathexheight,
\c!hoffset=\zeropoint,
\c!mathclass=ord,
\c!topoffset=.4\mathemwidth, % poor man's italic correction
\c!middlecommand=\mathematics]
\definemathover[\v!symbol][interiorset]["2218]
\protect \endinput
% \mathrel{\mathop{\hbox to \dimen0{\hss\copy4\hss}}
% \limits\normalsuperscript{\box0}\normalsubscript{\box2}}%
% $\Uoverdelimiter \defaultmathfamily "2194 {xxxx}$
% $\Uunderdelimiter\defaultmathfamily "2194 {xxxx}$
% $\Udelimiterover \defaultmathfamily "2194 {xxxx}$
% $\Udelimiterunder\defaultmathfamily "2194 {xxxx}$
% $\Udelimiterover \defaultmathfamily "219A {\Udelimiterunder \defaultmathfamily "219B {xxxx}}$
% $a \mathrel{\mathop{\filledhboxr{mid}}}\limits^{\filledhboxg{\strut top}}_{\filledhboxb{\strut bottom}} b$
|