math-input.tex /size: 3461 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/math
2
3\environment math-layout
4
5\startcomponent math-input
6
7\startchapter[title=Inputting math]
8
9\startsection[title=Collapsing]
10
11When in text mode you enter a combination of combining accent and character, a
12composed character is assumed and often you then get one shape in your document.
13A similar feature is available in math mode. After some discussion and analysis
14of the potential clashes and confusion (thanks to Aditya Mahajan) we settled on a
15combination of methods: so called math lists entries that we entered in the
16character database and|/|or so called special sequences that are part of
17\UNICODE. In the next tables we use \type {ml} for math list and \type {sp} for
18specials. Collapsing mode \type {1} only uses the specials, while \type {2} first
19checks the specials and then the math lists, and \type {3} does the reverse.
20
21In the database you can find this (a few fields have been omitted):
22
23\starttyping
24[0x2260] = {
25    adobename   = "notequal",
26    category    = "sm",
27    description = "NOT EQUAL TO",
28    mathlist    = { 0x2F, 0x3D },
29    mathspec    = {
30        {
31            class = "relation",
32            name  = "neq",
33        },
34        {
35            class = "relation",
36            name  = "ne",
37        },
38    },
39    specials    = { "char", 0x3D, 0x338 },
40    unicodeslot = 0x2260,
41}
42\stoptyping
43
44and
45
46\starttyping
47[0x2261] = {
48    adobename      = "equivalence",
49    category       = "sm",
50    description    = "IDENTICAL TO",
51    mathclass      = "relation",
52    mathextensible = "h",
53    mathname       = "equiv",
54    mathlist       = { 0x3D, 0x3D },
55    unicodeslot    = 0x2261,
56}
57\stoptyping
58
59Here are a few examples:
60
61\def\Test#1%
62  {\NC \bf \type{$#1$}
63   \NC \setupmathematics[collapsing=0] $#1$
64   \NC \setupmathematics[collapsing=1] $#1$
65   \NC \setupmathematics[collapsing=2] $#1$
66   \NC \setupmathematics[collapsing=3] $#1$ \NC \NR}
67
68\starttabulate[|c|cp|cp|cp|cp|]
69    \NC \BC \ttbf 0 \BC \ttbf 1 (sp) \BC \ttbf 2 (sp ml) \BC \ttbf 3 (ml sp) \BC \NR
70    \Test{==}
71    \Test{/=}
72    \Test{>=}
73\stoptabulate
74
75A complete list of collapses can be generated after loading one of the tracing
76modules:
77
78\startbuffer
79\usemodule[math-ligatures]
80\stopbuffer
81
82\typebuffer \getbuffer
83
84This provides the command:
85
86\startbuffer
87\showmathligatures
88\stopbuffer
89
90\typebuffer
91
92which gives:
93
94\start \switchtobodyfont[8pt] \getbuffer \stop
95
96\stopsection
97
98\startsection [title=Scripts]
99
100With \UNICODE\ providing math symbols and a limited set of super- and subscripts,
101it made sense to add yet another feature. The scripts were already supported for
102a long time, but at some point on the mailing list sequential scripts were
103mentioned. So here is an example of both (some fonts, like the one used for
104verbatim, don't have all symbols but you get the idea anyway):
105
106\startbuffer
107\startformula
108    ๐‘ทโ‚‚โ‚€(0), โˆ€ยฒ๐‘ฅโฐโบยฒโ‚‚โ‚€: ๐‘ทโ‚‚โ‚€(๐‘ฅโฐโบยฒโ‚‚โ‚€) โ‡’ ๐‘ทโ‚‚โ‚€(s(๐‘ฅโฐโบยฒโ‚‚โ‚€)) โŠข โˆ€ยน๐‘ฆโฐโบยนโ‚‚โ‚€ ๐‘ทโ‚‚โ‚€(๐‘ฆโฐโบยนโ‚‚โ‚€)
109\stopformula
110
111\startformula
112    \unstackscripts
113    ๐‘ทโ‚‚โ‚€(0), โˆ€ยฒ๐‘ฅโฐโบยฒโ‚‚โ‚€: ๐‘ทโ‚‚โ‚€(๐‘ฅโฐโบยฒโ‚‚โ‚€) โ‡’ ๐‘ทโ‚‚โ‚€(s(๐‘ฅโฐโบยฒโ‚‚โ‚€)) โŠข โˆ€ยน๐‘ฆโฐโบยนโ‚‚โ‚€ ๐‘ทโ‚‚โ‚€(๐‘ฆโฐโบยนโ‚‚โ‚€)
114\stopformula
115\stopbuffer
116
117\typebuffer
118
119which renders the clueless formulas:
120
121\getbuffer
122
123The \type {\unstackscripts} macro triggers the unstacking of super and
124subscripts.
125
126\stopsection
127
128\stopchapter
129
130\stopcomponent
131