summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/math/math-tricks.tex
blob: 7efcec50bc1c918c9814613234b1ba03d186cb36 (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
\environment math-layout

\startcomponent math-tricks

\startchapter[title=Tricks]

\startsection[title=Introduction]

Math support in \CONTEXT\ is wrapped around basic \TEX\ primitives and
unfortunately not all we want is easy to configure. This is not surprising
because the original ideas behind \TEX\ are that one makes a style per book and a
one macro package \quote {we-can-do-it-all} approach is not what Don Knuth had in
mind at that time.

So, for instance support for configurable spacing per math element, coloring of
specific (sub) elements, simple switching of whatever combination of alignments
and number placement, these all take quite a bit of code and hackery.

Even configuring something seemingly trivial as fractions or top, bottom, left,
middle and right fences take some effort. This is because the engine uses
information from fonts to combine shapes and paste the content and ornaments to
together.

For that reason already in \MKII\ but more extensively in \MKIV\ we did a lot of
these things in wrapper macros. When the math renderer was finalized for
\OPENTYPE\ math some extra control was added that can make these things easier.
However, because we go a bit beyond what is possible using this new functionality
these new mechanisms are not yet used in \MKIV, but they might be eventually.
Here we just show some of the (newer) low level trickery. For details about what
was already possible in pure \TEX, we refer to the ultimate references: the \TeX
book (by Donald Knuth) and \TeX\ by Topic (by Victor Eijkhout).

\stopsection

\startsection[title=Kerning]

Kerning in \OPENTYPE\ math is not the same as in traditional \TEX: instead of a
single value, we have staircase kerns, that is, depending on the location (left
or right) and the vertical position, at discrete distances between depth and
height. In addition there is italic correction but that is only applied in
certain cases, one of which is the script location.

Unfortunately not all fonts follow the same route. Some fonts have a true width
and a moderate italic correction is added to it (of at all), while other fonts
lie about the width and depend on an excessive italic correction to compensate
for that.

\definemeasure[quarter][\dimexpr(\textwidth-3em)/4\relax]

\def\TestKern#1%
  {\scale
     [width=\measure{quarter}]
     {\hbox to 50pt{\hss\showboxes\switchtobodyfont[#1]$V_i^i = W_i^i$\hss}}}

\startlinecorrection
\startcombination[nx=4,ny=2,distance=1em]
    {\TestKern  {modern}} {\infofont  modern}
    {\TestKern {cambria}} {\infofont cambria}
    {\TestKern{lucidaot}} {\infofont  lucida}
    {\TestKern  {dejavu}} {\infofont  dejavu}
    {\TestKern {pagella}} {\infofont pagella}
    {\TestKern  {termes}} {\infofont  termes}
    {\TestKern   {bonum}} {\infofont   bonum}
    {\TestKern  {schola}} {\infofont  schola}
\stopcombination
\stoplinecorrection

I will not discuss the details because when a font gets updated, it might look
better or worse. These fonts were loaded with the following directive set:

\starttyping
\enabledirectives[fontgoodies.mathkerning]
\stoptyping

An example of a fontgoodie that fixed the kerning is \type {pagella-math.lfg}. Here
is the relevant bit:

\starttyping
local kern_200 = { bottomright = { { kern = -200 } } }
local kern_100 = { bottomright = { { kern = -100 } } }

return {
  .....
  mathematics = {
    .....
    kerns = {
      [0x1D449] = kern_200, -- 𝑉
      [0x1D44A] = kern_100, -- 𝑊
    },
    .....
  }
}
\stoptyping

This fixes the real bad kerning of Pagella Math which at least in 2017 was not
(yet) fixed. When the fonts are frozen we can start makling permanent runtime
fixes like this.

\stopsection

\startsection[title=Primes]

Primes are a pain in the butt. The reason for this is that they are independent
characters on the one hand but can be seen as a superscript on the other. Let's
first look at the symbols at the three sizes that are used in math.

\startbuffer[prime]
$
    {\textstyle        \char"2032}
    {\scriptstyle      \char"2032}
    {\scriptscriptstyle\char"2032}
\quad
    {\textstyle        \char"FE931}
    {\scriptstyle      \char"FE931}
    {\scriptscriptstyle\char"FE931}
\quad
    {\textstyle        \char"FE932}
    {\scriptstyle      \char"FE932}
    {\scriptscriptstyle\char"FE932}
$
\stopbuffer

\typebuffer[prime]

We blow up the characters a bit and get this:

\startlinecorrection
\scale[scale=5000]{\showglyphs\inlinebuffer[prime]}
\stoplinecorrection

\def\TestPrime#1%
  {\scale
     [width=\measure{quarter}]
     {\ruledhbox to 65pt{%
       \hss
       \showglyphs
       \switchtobodyfont[#1]%
       \inlinebuffer[prime]%
       \hss}}}

The first set is the normal prime character scaled to the text, script and
scriptscriptsize. The second set shows the characters (at three sizes) as they
are in the font. The largest character is raised while the other two are closer
to the baseline. In some fonts the smaller sizes arenot smaller at all. The last
set is a variant of the the first set but we made them into virtual characters
with a displacement and different dimensions. Those are the ones we use as
primes.

\startlinecorrection
\startcombination[nx=4,ny=2,distance=1em]
    {\TestPrime  {modern}} {\infofont  modern}
    {\TestPrime {cambria}} {\infofont cambria}
    {\TestPrime{lucidaot}} {\infofont  lucida}
    {\TestPrime  {dejavu}} {\infofont  dejavu}
    {\TestPrime {pagella}} {\infofont pagella}
    {\TestPrime  {termes}} {\infofont  termes}
    {\TestPrime   {bonum}} {\infofont   bonum}
    {\TestPrime  {schola}} {\infofont  schola}
\stopcombination
\stoplinecorrection

Next we show how primes show up in real math. The examples
explain themselves.

\startbuffer
{\textstyle         f = g} \quad
{\scriptstyle       f = g} \quad
{\scriptscriptstyle f = g}
\stopbuffer

\typebuffer

\startlinecorrection
\scale[scale=2000]{\showglyphs$\inlinebuffer$}
\stoplinecorrection

\startbuffer
{\textstyle         f_i' = g_i'} \quad
{\scriptstyle       f_i' = g_i'} \quad
{\scriptscriptstyle f_i' = g_i'}
\stopbuffer

\typebuffer

\startlinecorrection
\scale[scale=2000]{\showglyphs$\inlinebuffer$}
\stoplinecorrection

\startbuffer
{\textstyle         f^{\char"2032}(0) = g^{\char"2032}(0)} \quad
{\scriptstyle       f^{\char"2032}(0) = g^{\char"2032}(0)} \quad
{\scriptscriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)}
\stopbuffer

\typebuffer

\startlinecorrection
\scale[scale=2000]{\showglyphs$\inlinebuffer$}
\stoplinecorrection

\startbuffer
{\textstyle         f'(0) = g'(0)} \quad
{\scriptstyle       f'(0) = g'(0)} \quad
{\scriptscriptstyle f'(0) = g'(0)}
\stopbuffer

\typebuffer

\startlinecorrection
\scale[scale=2000]{\showglyphs$\inlinebuffer$}
\stoplinecorrection

\startbuffer
{\textstyle         f^{\char"2032}(0) = g^{\char"2032}(0)} \quad
{\scriptstyle       f^{\char"2032}(0) = g^{\char"2032}(0)} \quad
{\scriptscriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)}
\stopbuffer

\typebuffer

\startlinecorrection
\scale[scale=2000]{\showglyphs$\inlinebuffer$}
\stoplinecorrection

\startbuffer
{\textstyle         f^{\char"2032}(0) = g^{\char"2032}(0)} \quad
{\scriptstyle       f^{\char"2032}(0) = g^{\char"2032}(0)} \quad
{\scriptscriptstyle f^{\char"2032}(0) = g^{\char"2032}(0)}
\stopbuffer

\typebuffer

\startlinecorrection
\scale[scale=2000]{\showglyphs$\inlinebuffer$}
\stoplinecorrection

The prime analyzer can deal with sizes, subscripts but also converts a sequence
of upright quotes into one unicode symbol. So,

\startbuffer
f'_i \neq f''_i \neq f'''_i \neq f''''_i
\stopbuffer

\typebuffer

becomes:

\startlinecorrection
\scale[scale=4000]{\showglyphs$\inlinebuffer$}
\stoplinecorrection

\stopsection

\startsection[title=Radicals]

Sometimes users complain about the look of a radical symbol. This is however a matter
of design. Some fonts let the shape start more below the baseline than others. Soem go
more straight up than relatives in another font. When largers sizes are needed, some
fonts offer smaller than others. Just look at the different desings:

\def\TestRadical#1%
  {\NC
     \type{#1}\blackrule[width=0pt,height=2.5ex,depth=2ex]\NC
     \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\surd   $}\NC
     \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\sqrt{} $}\NC
     \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\sqrt{.}$}\NC
     \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\sqrt{x}$}\NC
     \switchtobodyfont[#1]\scale[scale=2000]{\showglyphs$\surd \sqrt{} \sqrt{.} \sqrt{x}$}\NC
   \NR}

\starttabulate[|l|c|c|c|c|c|]
    \NC \NC \type{\surd} \NC \type{\sqrt{}} \NC \type{\sqrt{.}} \NC \type{\sqrt{x}} \NC \NR
    \TestRadical{modern}
    \TestRadical{cambria}
    \TestRadical{lucidaot}
    \TestRadical{dejavu}
    \TestRadical{pagella}
    \TestRadical{termes}
    \TestRadical{bonum}
    \TestRadical{schola}
\stoptabulate

The automatic scaling doesn't always work out as expected but on the average is
okay. Keep in mind that often the content is not that extreme.

\def\TestRadical#1%
  {\NC
     \type{#1}\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=1.0ex,color=darkgray]}$\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=1.5ex,color=darkgray]}$\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=2.0ex,color=darkgray]}$\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=2.5ex,color=darkgray]}$\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=3.0ex,color=darkgray]}$\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=3.5ex,color=darkgray]}$\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=4.0ex,color=darkgray]}$\NC
     \switchtobodyfont[#1]\showglyphs$\sqrt{\blackrule[width=1em,height=4.5ex,color=darkgray]}$\NC
   \NR}

\starttabulate[|l|c|c|c|c|c|c|c|c|]
    \NC \NC 1.0ex \NC 1.5ex \NC 2.0ex \NC 2.5ex \NC 3.0ex \NC 3.5ex \NC 4.0ex \NC 4.5ex \NC \NR
    \TestRadical{modern}
    \TestRadical{cambria}
    \TestRadical{lucidaot}
    \TestRadical{dejavu}
    \TestRadical{pagella}
    \TestRadical{termes}
    \TestRadical{bonum}
    \TestRadical{schola}
\stoptabulate

In Lucida (the version at the time of writing this) we have to correct the threshold
a bit in the goodie file:

\starttyping
local function FixRadicalDisplayStyleVerticalGap(value,target,original)
  local o = original.mathparameters.RadicalVerticalGap -- 50
  return 2 * o * target.parameters.factor
end

return {
  .....
  mathematics = {
    .....
    parameters = {
      RadicalDisplayStyleVerticalGap =
        FixRadicalDisplayStyleVerticalGap,
    },
    .....
  },
}
\stoptyping

\stopsection

\startsection[title=Integrals]

A curious exception in the math system is the integral sign. Its companions are
the summation and product signs, but integral has as extra property that it has a
slant. In \LUATEX\ there is rather advanced control over how the (optional)
scripts are positioned (which relates to italic correction) but in \CONTEXT\ we
only make limited use of that. The main reason is that we also need to support
additional features like color. Therefore integrals are handled by the extensible
mechanism.

The size of an integral is more of less fixed but you can enlarge to your
liking. One reason for this is that you might want a consistent size across
formulas. Let's use the following setup:

\startbuffer[setup]
\setupmathextensible
  [integral]
  [rightoffset=-1mu,
   exact=yes,
   factor=2]

\let\int\integral
\stopbuffer

\typebuffer[setup]

We use the following exmaple:

\startbuffer[demo]
\ruledhbox{$\integral                  f\frac{1}{2}           $}\quad
\ruledhbox{$\integral[rightoffset=3mu] f\frac{1}{2}           $}\quad
\ruledhbox{$\integral[exact=no]        f\frac{1}{2}           $}\quad
\ruledhbox{$\integral                  f\frac{\frac{1}{2}}{x} $}\quad
\ruledhbox{$\integral[exact=no]        f\frac{\frac{1}{2}}{x} $}\quad
\ruledhbox{$\integral[factor=1]        f\frac{1}{2}           $}\quad
\ruledhbox{$\integral[factor=3]        f\frac{\frac{1}{2}}{x} $}\quad
\ruledhbox{$\integral[factor=3]        f\frac{1}{2}           $}\quad
\ruledhbox{$\int                       f\frac{1}{2}           $}% bonus
\stopbuffer

\typebuffer[demo]

This renders as:

\dontleavehmode\hbox{\getbuffer[setup,demo]}

\stopsection

\startsection[title=Fancy fences]

Here I only show an example of fences drawn by \METAPOST. For the implementation
you can consult the library file \type {meta-imp-mat.mkiv} in the \CONTEXT\
distribution.

\startbuffer[setup]
\useMPlibrary[mat]

\setupmathstackers
  [both] % vfenced]
  [color=darkred,
   alternative=mp]

\setupmathstackers
  [top]
  [color=darkred,
   alternative=mp]

\setupmathstackers
  [bottom]
  [color=darkred,
   alternative=mp]
\stopbuffer

\typebuffer[setup]

We keep the demo simple:

\startbuffer[demo]
$ \overbracket     {a+b+c+d} \quad
  \underbracket    {a+b+c+d} \quad
  \doublebracket   {a+b+c+d} \quad
  \overparent      {a+b+c+d} \quad
  \underparent     {a+b+c+d} \quad
  \doubleparent    {a+b+c+d} $ \blank
$ \overbrace       {a+b+c+d} \quad
  \underbrace      {a+b+c+d} \quad
  \doublebrace     {a+b+c+d} \quad
  \overbar         {a+b+c+d} \quad
  \underbar        {a+b+c+d} \quad
  \doublebar       {a+b+c+d} $ \blank
$ \overleftarrow   {a+b+c+d} \quad
  \overrightarrow  {a+b+c+d} \quad
  \underleftarrow  {a+b+c+d} \quad
  \underrightarrow {a+b+c+d} $ \blank
\stopbuffer

\typebuffer[demo]

Or visualized:

\start
\getbuffer[setup,demo]
\stop

\stopsection

\startsection[title=Combined characters]

We have some magic built with respect to sequences of characters. They are derived
from information in the character database that ships with \CONTEXT\ and are
implemented as a sort of ligatures. Some are defined in \UNICODE, others are
defined explicitly.

\usemodule[math-ligatures]

\start
    \switchtobodyfont[small]
    \showmathligatures
\stop

\stopsection

\startsection[title=Middle class fences]

The next examples are somewhat obscure. They are a side effect of some extensions
to the engine that were introduced to control spacing around the \type {\middle}
class fences. Actually there is no real middle class and spacing was somewhat
hard codes when \type {\middle} was added to \ETEX. In \LUATEX\ we have
introduced keywords to some primitives that control spacing and other properties.
This permits better control over spacing than messing around with (for instance)
injected \type {\mathrel} commands that can have their own side effects.

\startbuffer
\def\Middle{\middle|}
\def\Riddle{\Umiddle class 5 |}
\def\Left  {\left  (}
\def\Right {\right )}
\def\Rel   {\mathrel{}}
\def\Per   {\mathrel{.}}
\stopbuffer

\startbuffer[1a]
$          a                b          $
\stopbuffer
\startbuffer[1b]
$     \Rel a\Rel            b\Rel      $
\stopbuffer

\startbuffer[2a]
$          a                b          $
\stopbuffer
\startbuffer[2b]
$     \Per a\Per            b\Per      $
\stopbuffer

\startbuffer[3a]
$\Left     a    \Middle     b    \Right$
\stopbuffer
\startbuffer[3b]
$\Left\Rel a    \Middle\Rel b\Rel\Right$
\stopbuffer

\startbuffer[4a]
$\Left     a    \Middle     b    \Right$
\stopbuffer
\startbuffer[4b]
$\Left\Rel a    \Middle\Per b\Per\Right$
\stopbuffer

\startbuffer[5a]
$\Left     a    \Middle     b    \Right$
\stopbuffer
\startbuffer[5b]
$\Left\Rel a\Rel\Middle\Rel b\Rel\Right$
\stopbuffer

\startbuffer[6a]
$\Left     a    \Middle     b    \Right$
\stopbuffer
\startbuffer[6b]
$\Left\Per a\Per\Middle\Per b\Per\Right$
\stopbuffer

\startbuffer[7a]
$\Left     a    \Riddle     b    \Right$
\stopbuffer
\startbuffer[7b]
$\Left\Rel a    \Riddle\Rel b\Rel\Right$
\stopbuffer

\startbuffer[8a]
$\Left     a    \Riddle     b    \Right$
\stopbuffer
\startbuffer[8b]
$\Left\Rel a    \Riddle\Per b\Per\Right$
\stopbuffer

\startbuffer[9a]
$\Left     a    \Riddle     b    \Right$
\stopbuffer
\startbuffer[9b]
$\Left\Rel a\Rel\Riddle\Rel b\Rel\Right$
\stopbuffer

\startbuffer[10a]
$\Left     a    \Riddle     b    \Right$
\stopbuffer
\startbuffer[10b]
$\Left\Per a\Per\Riddle\Per b\Per\Right$
\stopbuffer

We use the following definitions:

\typebuffer

Applied to samples these give the following outcome and spacing:

\start
    \getbuffer

    \starttabulate
        \NC \ruledhbox{\typeinlinebuffer[1a]}  \NC \showglyphs \inlinebuffer[1a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[1b]}  \NC \showglyphs \inlinebuffer[1b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[2a]}  \NC \showglyphs \inlinebuffer[2a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[2b]}  \NC \showglyphs \inlinebuffer[2b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[3a]}  \NC \showglyphs \inlinebuffer[3a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[3b]}  \NC \showglyphs \inlinebuffer[3b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[4a]}  \NC \showglyphs \inlinebuffer[4a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[4b]}  \NC \showglyphs \inlinebuffer[4b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[5a]}  \NC \showglyphs \inlinebuffer[5a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[5b]}  \NC \showglyphs \inlinebuffer[5b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[6a]}  \NC \showglyphs \inlinebuffer[6a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[6b]}  \NC \showglyphs \inlinebuffer[6b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[7a]}  \NC \showglyphs \inlinebuffer[7a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[7b]}  \NC \showglyphs \inlinebuffer[7b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[8a]}  \NC \showglyphs \inlinebuffer[8a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[8b]}  \NC \showglyphs \inlinebuffer[8b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[9a]}  \NC \showglyphs \inlinebuffer[9a]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[9b]}  \NC \showglyphs \inlinebuffer[9b]  \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[10a]} \NC \showglyphs \inlinebuffer[10a] \NC \NR
        \NC \ruledhbox{\typeinlinebuffer[10b]} \NC \showglyphs \inlinebuffer[10b] \NC \NR
    \stoptabulate
\stop

\stopsection

\startsection[title=Auto|-|punctuation]

\def\TestA#1#2#3%
  {\ifnum#1=0 \type{#2}\else\setupmathematics[autopunctuation={#2}]$#3$\fi}

\def\TestB#1#2%
  {\NC \TestA{#1}{no}           {#2}
   \NC \TestA{#1}{yes}          {#2}
   \NC \TestA{#1}{yes,semicolon}{#2}
   \NC \TestA{#1}{all}          {#2}
   \NC \TestA{#1}{all,semicolon}{#2}
   \NC \NR}

The \type {\setupmathematics} command has an option \type {autopunctuation} that
influences the way spacing after punctuatuon is handled, especially in cases like
the following (coordinates and such):

\starttabulate[|c|c|c|c|c|]
   \TestB{0}{}
   \TestB{1}{(1,2)=(1, 2)}
   \TestB{1}{(1.2)=(1. 2)}
   \TestB{1}{(1;2)=(1; 2)}
\stoptabulate

\stopsection

\stopcomponent

% \enabletrackers[math.makeup=boxes]

% \startTEXpage[offset=10pt]
%     $\displaystyle      {{1}\normalover{2}}+x$\quad $\crampeddisplaystyle     {{1}\normalover{2}}+x$\blank
%     $\textstyle         {{1}\normalover{2}}+x$\quad $\crampedtextstyle        {{1}\normalover{2}}+x$\blank
%     $\scriptstyle       {{1}\normalover{2}}+x$\quad $\crampedscriptstyle      {{1}\normalover{2}}+x$\blank
%     $\scriptscriptstyle {{1}\normalover{2}}+x$\quad $\crampedscriptscriptstyle{{1}\normalover{2}}+x$\blank
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     $e=mc^2$
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     $\sqrt{\frac{1}{2}+x}$
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     $\int^0_1{\frac{1}{2}+x}$
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     $\displaystyle\the\everydisplay\int^0_1{\frac{1}{2}+x}$
% \stopTEXpage

% \startbuffer
% ${}^2_2x^3_4 {}^2x_4$
% \stopbuffer

% % d : \Umathsubshiftdown
% % u : \Umathsupshiftup
% % s : \Umathsubsupshiftdown

% \startTEXpage[offset=10pt]
%     \starttabulate[|T||cT|cT|]
%         \NC 0 \NC \mathscriptsmode 0 \inlinebuffer \NC dynamic       \NC dynamic       \NC \NR \TB
%         \NC 1 \NC \mathscriptsmode 1 \inlinebuffer \NC d             \NC u             \NC \NR \TB
%         \NC 2 \NC \mathscriptsmode 2 \inlinebuffer \NC s             \NC u             \NC \NR \TB
%         \NC 3 \NC \mathscriptsmode 3 \inlinebuffer \NC s             \NC u + s − d     \NC \NR \TB
%         \NC 4 \NC \mathscriptsmode 4 \inlinebuffer \NC d + (s − d)/2 \NC u + (s − d)/2 \NC \NR \TB
%         \NC 5 \NC \mathscriptsmode 5 \inlinebuffer \NC d             \NC u + s − d     \NC \NR
%     \stoptabulate
% \stopTEXpage

% \startTEXpage[offset=10pt] \tt
%     \starttabulate[|l|ck1|ck1|ck1|ck1|ck1|ck1|]
%         \NC
%             \NC \mathnolimitsmode0    $\displaystyle\int\nolimits^0_1$
%             \NC \mathnolimitsmode1    $\displaystyle\int\nolimits^0_1$
%             \NC \mathnolimitsmode2    $\displaystyle\int\nolimits^0_1$
%             \NC \mathnolimitsmode3    $\displaystyle\int\nolimits^0_1$
%             \NC \mathnolimitsmode4    $\displaystyle\int\nolimits^0_1$
%             \NC \mathnolimitsmode8000 $\displaystyle\int\nolimits^0_1$
%         \NC \NR
%         \TB
%         \NC \bf mode
%             \NC 0
%             \NC 1
%             \NC 2
%             \NC 3
%             \NC 4
%             \NC 8000
%         \NC \NR
%         \NC \bf superscript
%             \NC 0
%             \NC font
%             \NC 0
%             \NC 0
%             \NC +ic/2
%             \NC 0
%         \NC \NR
%         \NC \bf subscript
%             \NC -ic
%             \NC font
%             \NC 0
%             \NC -ic/2
%             \NC -ic/2
%             \NC 8000ic/1000
%         \NC \NR
%     \stoptabulate
% \stopTEXpage

{ } \bgroup \egroup \begingroup \endgroup

\startbuffer[1]
    [a:\mathstyle]\quad
    \bgroup
    \mathchoice
        {\bf \scriptstyle       (x:d :\mathstyle)}
        {\bf \scriptscriptstyle (x:t :\mathstyle)}
        {\bf \scriptscriptstyle (x:s :\mathstyle)}
        {\bf \scriptscriptstyle (x:ss:\mathstyle)}
    \egroup
    \quad[b:\mathstyle]\quad
    \mathchoice
        {\bf \scriptstyle       (y:d :\mathstyle)}
        {\bf \scriptscriptstyle (y:t :\mathstyle)}
        {\bf \scriptscriptstyle (y:s :\mathstyle)}
        {\bf \scriptscriptstyle (y:ss:\mathstyle)}
    \quad[c:\mathstyle]\quad
    \bgroup
    \mathchoice
        {\bf \scriptstyle       (z:d :\mathstyle)}
        {\bf \scriptscriptstyle (z:t :\mathstyle)}
        {\bf \scriptscriptstyle (z:s :\mathstyle)}
        {\bf \scriptscriptstyle (z:ss:\mathstyle)}
    \egroup
    \quad[d:\mathstyle]
\stopbuffer

\startbuffer[2]
    [a:\mathstyle]\quad
    \begingroup
    \mathchoice
        {\bf \scriptstyle       (x:d :\mathstyle)}
        {\bf \scriptscriptstyle (x:t :\mathstyle)}
        {\bf \scriptscriptstyle (x:s :\mathstyle)}
        {\bf \scriptscriptstyle (x:ss:\mathstyle)}
    \endgroup
    \quad[b:\mathstyle]\quad
    \mathchoice
        {\bf \scriptstyle       (y:d :\mathstyle)}
        {\bf \scriptscriptstyle (y:t :\mathstyle)}
        {\bf \scriptscriptstyle (y:s :\mathstyle)}
        {\bf \scriptscriptstyle (y:ss:\mathstyle)}
    \quad[c:\mathstyle]\quad
    \begingroup
    \mathchoice
        {\bf \scriptstyle       (z:d :\mathstyle)}
        {\bf \scriptscriptstyle (z:t :\mathstyle)}
        {\bf \scriptscriptstyle (z:s :\mathstyle)}
        {\bf \scriptscriptstyle (z:ss:\mathstyle)}
    \endgroup
    \quad[d:\mathstyle]
\stopbuffer

% % \bgroup .. \egroup

% \startTEXpage[offset=10pt]
%     $\displaystyle \getbuffer[1]$ \blank
%     $\textstyle    \getbuffer[1]$
% \stopTEXpage

% % \begingroup .. \endgroup

% \startTEXpage[offset=10pt]
%     $\displaystyle \getbuffer[2]$ \blank
%     $\textstyle    \getbuffer[2]$
% \stopTEXpage


% \startTEXpage[offset=10pt]
%     $\Uleft                           ( x \Umiddle\| \Uright                           )$
%     $\Uleft height 3ex                ( x \Umiddle\| \Uright height 3ex                )$
%     $\Uleft axis height 3ex           ( x \Umiddle\| \Uright axis height 3ex           )$
%     $\Uleft axis height 3ex depth 1ex ( x \Umiddle\| \Uright axis height 3ex depth 1ex )$
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     $\Uvextensible                                 ( \frac{1}{x}$
%     $\Uvextensible height 3ex                      ( \frac{1}{x}$
%     $\Uvextensible axis height 3ex                 ( \frac{1}{x}$
%     $\Uvextensible axis height 3ex depth 1ex       ( \frac{1}{x}$
%     $\Uvextensible exact axis height 3ex depth 1ex ( \frac{1}{x}$
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     \ruledhbox{$\Uhextensible                  "0 "23DE$}
%     \ruledhbox{$\Uhextensible        width 3ex "0 "23DE$}
%     \ruledhbox{$\Uhextensible middle width 3ex "0 "23DE$}
%     \ruledhbox{$\Uhextensible left   width 3ex "0 "23DE$}
%     \ruledhbox{$\Uhextensible right  width 3ex "0 "23DE$}
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     \ruledhbox{$\Umathaccent         "0 "0 "23DE                          {1+x}$}
%     \ruledhbox{$\Umathaccent fixed   "0 "0 "23DE                          {1+x}$}
%     \ruledhbox{$\Umathaccent top     "0 "0 "23DE                          {1+x}$}
%     \ruledhbox{$\Umathaccent bottom              "0 "0 "23DF              {1+x}$}
%     \ruledhbox{$\Umathaccent both    "0 "0 "23DE "0 "0 "23DF              {1+x}$}
%     \ruledhbox{$\Umathaccent overlay "0 "0 "23DE                          {1+x}$}
%     \ruledhbox{$\Umathaccent top     "0 "0 "23DE             fraction 800 {1+x}$}
% \stopTEXpage

% \startTEXpage[offset=10pt]
%     ${ {1} \Uskewed           /                   {2} }$
%     ${ {1} \Uskewed           /     exact         {2} }$
%     ${ {1} \Uskewed           /     noaxis        {2} }$
%     ${ {1} \Uskewed           /     exact noaxis  {2} }$
%     ${ {1} \Uskewedwithdelims / ()                {2} }$
%     ${ {1} \Uskewedwithdelims / ()  exact         {2} }$
%     ${ {1} \Uskewedwithdelims / ()  noaxis        {2} }$
%     ${ {1} \Uskewedwithdelims / ()  exact noaxis  {2} }$
% \stopTEXpage

% \disabletrackers[math.makeup]

% \stopchapter
%
% \stopcomponent

% A \type {\matheqnogapstep} factor that determines the gap between formula and
% equation number.
%
% A \type {\mathdisplayskipmode} directive that controls display skips: 1 = always,
% 2 = only when not zero, 3 = never.
%
% \mathstyle
%
% \suppressmathparerror