ontarget-alsomath.tex /size: 3257 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/ontarget
2
3\startcomponent ontarget-alsomath
4
5\environment ontarget-style
6
7\startchapter[title={The curious case of \type {\over}}]
8
9Normally \TEX\ scans forward but there are a few special cases. First of all,
10\TEX\ is either scanning regular content or it is scanning alignments. That
11results in intercepts in all kind of places. When a row ends, scanning for
12inter|-|row actions happens. When the preamble is scanned there is some lookahead
13with partial expansion. This has side effects but these can be avoided in
14\LUAMETATEX\ by several options. Another special case is math mode. Normally
15curly braces indicate grouping but not in math mode: there they construct an
16atom, ordinary by default. Although most math constructs actually pick up some
17following atom, in which case we get a wrapped construct that actually is
18processed in a nested cal to the math processing routine. That whole has a class
19and although in \LUAMETATEX\ we can make atoms with a different left end right
20class, normally what is inside is hidden stays hidden. \footnote {We can think of
21optionally exposing the edge classes but although it is easy to implement we see
22no reason to do that now. After all, the information is actually available
23already via variables.}
24
25Fraction commands like \type {\over} and \type {\above} are used like this:
26
27\starttyping
28a + 1 \over 2 + b
29\stoptyping
30
31and as there can be more than for instance single digits we can do:
32
33\starttyping
34a + {12} \over {34} + b
35\stoptyping
36
37but it doesn't end there because you actually need to wrap:
38
39\starttyping
40a + {{12} \over {34}} + b
41\stoptyping
42
43If you don't do this $b$ will become part of the fraction. The curly braces here
44make the $12$, $34$ and the whole fraction made from them ordinary atoms. Because
45that also influences spacing one should be aware of side effects.
46
47\starttyping
48a + {{12} \over {34}} + b
49\stoptyping
50
51The argument of \type {simplicity} of input is easily defeated by using
52
53\starttyping
54a + \frac{12}{34} + b
55\stoptyping
56
57because it also reads sequential, is in sync with other commands like \type
58{\sqrt} and actually uses less tokens. It used more runtime, also because
59\CONTEXT\ adds plenty of control and extras but you won't notice it.
60
61Because in \CONTEXT\ we assume users to use \type {\frac} it made sense to see if
62we can make curly braces act like groups. In \LUAMETATEX\ we already have \type
63{\beginmathgroup} and \type {\endmathgroup} that provide grouping with mathstyle
64recovery, and by setting \type {\mathgroupingmode} to a non|-|zero value curly
65braces will act like these.
66
67The effects are subtle:
68
69\showmakeup[mathglue]
70
71\startbuffer
72$ a + { \bf x } ^ 2  +  {\bf 1} + {\red 123} +
73\frac{1}{2} + {\scriptstyle 123} + \dd $
74\stopbuffer
75
76\typebuffer
77
78\startcombination[1*2]
79  {\scale[scale=2500]{\showmakeup[mathglue] \mathgroupingmode 0 \getbuffer}} {\type {\mathgroupingmode 0}}
80  {\scale[scale=2500]{\showmakeup[mathglue] \mathgroupingmode 1 \getbuffer}} {\type {\mathgroupingmode 1}}
81\stopcombination
82
83If you see the differences you might be happy with this new trick, if not, you
84probably are not that much into optimal math spacing anyway and you can forget
85about what you just read.
86
87\stopchapter
88
89\stopcomponent
90
91