summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/math/math-input.tex
blob: 9b14057d0c1c963dc2614c4ca5529609e66a303f (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
% language=uk

\environment math-layout

\startcomponent math-input

\startchapter[title=Inputting math]

\startsection[title=Collapsing]

When in text mode you enter a combination of combining accent and character, a
composed character is assumed and often you then get one shape in your document.
A similar feature is available in math mode. After some discussion and analysis
of the potential clashes and confusion (thanks to Aditya Mahajan) we settled on a
combination of methods: so called math lists entries that we entered in the
character database and|/|or so called special sequences that are part of
\UNICODE. In the next tables we use \type {ml} for math list and \type {sp} for
specials. Collapsing mode \type {1} only uses the specials, while \type {2} first
checks the specials and then the math lists, and \type {3} does the reverse.

In the database you can find this (a few fields have been omitted):

\starttyping
[0x2260] = {
    adobename   = "notequal",
    category    = "sm",
    description = "NOT EQUAL TO",
    mathlist    = { 0x2F, 0x3D },
    mathspec    = {
        {
            class = "relation",
            name  = "neq",
        },
        {
            class = "relation",
            name  = "ne",
        },
    },
    specials    = { "char", 0x3D, 0x338 },
    unicodeslot = 0x2260,
}
\stoptyping

and

\starttyping
[0x2261] = {
    adobename      = "equivalence",
    category       = "sm",
    description    = "IDENTICAL TO",
    mathclass      = "relation",
    mathextensible = "h",
    mathname       = "equiv",
    mathlist       = { 0x3D, 0x3D },
    unicodeslot    = 0x2261,
}
\stoptyping

Here are a few examples:

\def\Test#1%
  {\NC \bf \type{$#1$}
   \NC \setupmathematics[collapsing=0] $#1$
   \NC \setupmathematics[collapsing=1] $#1$
   \NC \setupmathematics[collapsing=2] $#1$
   \NC \setupmathematics[collapsing=3] $#1$ \NC \NR}

\starttabulate[|c|cp|cp|cp|cp|]
    \NC \BC \ttbf 0 \BC \ttbf 1 (sp) \BC \ttbf 2 (sp ml) \BC \ttbf 3 (ml sp) \BC \NR
    \Test{==}
    \Test{/=}
    \Test{>=}
\stoptabulate

A complete list of collapses can be generated after loading one of the tracing
modules:

\startbuffer
\usemodule[math-ligatures]
\stopbuffer

\typebuffer \getbuffer

This provides the command:

\startbuffer
\showmathligatures
\stopbuffer

\typebuffer

which gives:

\start \switchtobodyfont[8pt] \getbuffer \stop

\stopsection

\startsection [title=Scripts]

With \UNICODE\ providing math symbols and a limited set of super- and subscripts,
it made sense to add yet another feature. The scripts were already supported for
a long time, but at some point on the mailing list sequential scripts were
mentioned. So here is an example of both (some fonts, like the one used for
verbatim, don't have all symbols but you get the idea anyway):

\startbuffer
\startformula
    𝑷₂₀(0), ∀²𝑥⁰⁺²₂₀: 𝑷₂₀(𝑥⁰⁺²₂₀) ⇒ 𝑷₂₀(s(𝑥⁰⁺²₂₀)) ⊢ ∀¹𝑦⁰⁺¹₂₀ 𝑷₂₀(𝑦⁰⁺¹₂₀)
\stopformula

\startformula
    \unstackscripts
    𝑷₂₀(0), ∀²𝑥⁰⁺²₂₀: 𝑷₂₀(𝑥⁰⁺²₂₀) ⇒ 𝑷₂₀(s(𝑥⁰⁺²₂₀)) ⊢ ∀¹𝑦⁰⁺¹₂₀ 𝑷₂₀(𝑦⁰⁺¹₂₀)
\stopformula
\stopbuffer

\typebuffer

which renders the clueless formulas:

\getbuffer

The \type {\unstackscripts} macro triggers the unstacking of super and
subscripts.

\stopsection

\stopchapter

\stopcomponent