math-def.mkxl /size: 7691 b    last modification: 2025-02-21 11:03
1
    %D \module
2%D   [       file=math-tex,
3%D        version=2001.04.12,
4%D          title=\CONTEXT\ Math Macros,
5%D       subtitle=Definitions,
6%D         author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan},
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Math Macros / Definitions}
15
16\unprotect
17
18\pushoverloadmode % cap etc
19
20\startluacode
21    mathematics.define()
22 -- mathematics.xml.registerentities()
23\stopluacode
24
25\popoverloadmode
26
27% \activatemathcharacters
28
29%D The \mfunction macro is an alternative for \hbox with a controlable font switch.
30
31\definemathfunction [arccos]
32\definemathfunction [arcsin]
33\definemathfunction [arctan]
34\definemathfunction [arccosh]
35\definemathfunction [arcsinh]
36\definemathfunction [arctanh]
37\definemathfunction [acos]
38\definemathfunction [asin]
39\definemathfunction [atan]
40\definemathfunction [arg]
41\definemathfunction [cosh]
42\definemathfunction [cos]
43\definemathfunction [coth]
44\definemathfunction [cot]
45\definemathfunction [csc]
46\definemathfunction [deg]
47\definemathfunction [det]     [\c!mathlimits=\v!yes]
48\definemathfunction [dim]
49\definemathfunction [erf]
50\definemathfunction [erfc]
51\definemathfunction [erfi]
52\definemathfunction [exp]
53\definemathfunction [gcd]     [\c!mathlimits=\v!yes]
54\definemathfunction [hom]
55\definemathfunction [inf]     [\c!mathlimits=\v!auto]
56\definemathfunction [inv]     [\c!mathlimits=\v!auto]
57\definemathfunction [injlim]  [\c!mathlimits=\v!auto]
58\definemathfunction [ker]
59\definemathfunction [lg]
60\definemathfunction [liminf]  [\c!mathlimits=\v!auto,\c!method=limits]
61\definemathfunction [limsup]  [\c!mathlimits=\v!auto,\c!method=limits]
62\definemathfunction [lim]     [\c!mathlimits=\v!auto,\c!method=limits]
63\definemathfunction [ln]
64\definemathfunction [log]
65\definemathfunction [median]  [\c!mathlimits=\v!yes]
66\definemathfunction [max]     [\c!mathlimits=\v!auto]
67\definemathfunction [min]     [\c!mathlimits=\v!auto]
68\definemathfunction [mod]     [\c!mathlimits=\v!yes]
69%definemathfunction [div]     [\c!mathlimits=\v!yes]
70\definemathfunction [projlim] [\c!mathlimits=\v!auto]
71\definemathfunction [Pr]      [\c!mathlimits=\v!yes]
72\definemathfunction [sec]
73\definemathfunction [sinh]
74\definemathfunction [sin]
75\definemathfunction [sup]     [\c!mathlimits=\v!auto]
76\definemathfunction [tanh]
77\definemathfunction [tan]
78\definemathfunction [diff]
79
80\definemathfunction [adj]
81\definemathfunction [coker]
82
83% When [\c!command=] the label kicks in:
84
85\definemathfunction [cs:median] [\c!command=\widetilde]
86\definemathfunction [sk:median] [\c!command=\widetilde]
87
88% Maybe set a method as well to signal the order
89
90%definemathfunction[partial]              [class=differential]
91%definemathfunction[gradient]             [class=differential]
92\definemathfunction[adjoint]              [right=\adjointsymbol]
93\definemathfunction[orthogonalcomplement] [right=\orthogonalcomplementsymbol]
94\definemathfunction[transpose]            [right=\transposesymbol]
95\definemathfunction[derivative]           [right=\derivativesymbol]
96\definemathfunction[secondderivative]     [right=\secondderivativesymbol]
97\definemathfunction[thirdderivative]      [right=\thirdderivativesymbol]
98\definemathfunction[fourthderivative]     [right=\fourthderivativesymbol]
99\definemathfunction[preimage]             [right=\preimagesymbol]
100\definemathfunction[inverse]              [right=\inversesymbol]
101
102% \definemathfunction[laplace]      [class=differential]
103% \definemathfunction[crossproduct] [class=binary]
104% \definemathfunction[scalarproduct][class=binary]
105% \definemathfunction[complement]
106\definemathfunction[neg]
107
108\aliased\let\normalmatharg\arg % todo: maybe automatically
109
110%D \macros
111%D   {centercolon, colonminus, minuscolon, colonequals, equalscolon,
112%D    colonapprox, approxcolon, colonsim, simcolon, coloncolon,
113%D    coloncolonminus, minuscoloncolon, coloncolonequals,
114%D    equalscoloncolon, coloncolonapprox, approxcoloncolon,
115%D    colonsim, simcoloncolon}
116%D
117%D The following colon related definitions are provided by Aditya Mahajan who
118%D derived them from \type {mathtools.sty} and \type {colonequals.sty}. This will be
119%D redone as part of the overhaul and font updates.
120%D
121%D In $a := b$ the colon is not vertically centered with the equal to. Also the
122%D distance between colon and equal to is a bit large. So, we define a vertically
123%D centered colon \tex {centercolon} and a few macros for colon and double colon
124%D relation symbols.
125%D
126%D \startlines
127%D \formula {A \centercolon       B}
128%D \formula {A \colonminus        B}
129%D \formula {A \minuscolon        B}
130%D \formula {A \colonequals       B}
131%D \formula {A \equalscolon       B}
132%D \formula {A \colonapprox       B}
133%D \formula {A \approxcolon       B}
134%D \formula {A \colonsim          B}
135%D \formula {A \simcolon          B}
136%D \formula {A \coloncolon        B}
137%D \formula {A \coloncolonminus   B}
138%D \formula {A \minuscoloncolon   B}
139%D \formula {A \coloncolonequals  B}
140%D \formula {A \equalscoloncolon  B}
141%D \formula {A \coloncolonapprox  B}
142%D \formula {A \approxcoloncolon  B}
143%D \formula {A \colonsim          B}
144%D \formula {A \simcoloncolon     B}
145%D \stoplines
146%D
147%D The next macros take care of the space between the colon and the relation symbol,
148%D but they are kind of weird and not in \UNICODE. Either we define them virtual or
149%D we just keep these as bonus.
150
151\pushoverloadmode
152
153\protected\def\math_relation_atom_ordinary{\mathatom \s!class \mathrelationcode \s!all \mathordcode}
154
155\definemathcommand [centercolon]      {\math_relation_atom_ordinary{\colon}}
156\definemathcommand [colonminus]       {\math_relation_atom_ordinary{\colon\minus}}
157\definemathcommand [colonapprox]      {\math_relation_atom_ordinary{\colon\approx}}
158\definemathcommand [approxcolon]      {\math_relation_atom_ordinary{\approx\colon}}
159\definemathcommand [colonsim]         {\math_relation_atom_ordinary{\colon\sim}}
160\definemathcommand [simcolon]         {\math_relation_atom_ordinary{\sim\colon}}
161
162\definemathcommand [coloncolon]       {\math_relation_atom_ordinary{\colon\colon}}
163\definemathcommand [coloncolonminus]  {\math_relation_atom_ordinary{\colon\colon\minus}}
164\definemathcommand [minuscoloncolon]  {\math_relation_atom_ordinary{\minus\colon\colon}}
165\definemathcommand [coloncolonequals] {\math_relation_atom_ordinary{\colon\colon\eq}} % native char
166\definemathcommand [equalscoloncolon] {\math_relation_atom_ordinary{\eq\colon\colon}}
167\definemathcommand [coloncolonapprox] {\math_relation_atom_ordinary{\colon\colon\approx}}
168\definemathcommand [approxcoloncolon] {\math_relation_atom_ordinary{\approx\colon\colon}}
169\definemathcommand [coloncolonsim]    {\math_relation_atom_ordinary{\colon\colon\sim}}
170\definemathcommand [simcoloncolon]    {\math_relation_atom_ordinary{\sim\colon\colon}}
171
172% \definemathcommand [manycolons] [relation] [ordinary] {\colon\colon\colon\colon\colon\colon\colon}
173
174\popoverloadmode
175
176%D \macros
177%D   {amedian}
178%D
179%D Something language specific, the arithmic median:
180%D
181%D \starttyping
182%D                   \im {x + \amedian {x - a} + x}
183%D \mainlanguage[cs] \im {x + \amedian {x - a} + x}
184%D \stoptyping
185
186\defcsname \s!en:amedian\endcsname#1{\widebar  {#1}}
187\defcsname \s!cs:amedian\endcsname#1{\widetilde{#1}}
188\defcsname \s!sk:amedian\endcsname#1{\widetilde{#1}}
189
190\permanent\protected\def\amedian
191  {\csname
192     \ifcsname\currentmainlanguage:amedian\endcsname
193       \currentmainlanguage\else\s!en
194     \fi
195     :amedian%
196   \endcsname}
197
198% \appendtoks
199%     \def\over{\primitive\over}%
200% \to \everymathematics
201
202\protect \endinput
203