math-pln.mkiv /size: 5947 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=math-pln,
3%D        version=2001.11.16,
4%D          title=\CONTEXT\ Math Macros,
5%D       subtitle=Plain Helpers,
6%D         author=Hans Hagen,
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%D Here we collect some Plain \TEX\ leftovers.
15
16\writestatus{loading}{ConTeXt Math Macros / Plain Helpers}
17
18\unprotect
19
20% we need proper unicode:
21
22\def\relbar{\mathrel{\smash-}} % - has the same height as + .. no clue what this refers to
23
24% might change
25
26\unexpanded\def\hrulefill{\leaders\hrule\hfill}
27\unexpanded\def\dotfill  {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill}
28
29% will move
30
31\def\oalign#1%
32  {\leavevmode % plain tex uses this
33   \vtop
34     {\baselineskip\zeroskip
35      \lineskip.25\exheight
36      \ialign{\alignmark\alignmark\crcr#1\crcr}}}
37
38\def\ooalign % chars over each other
39  {\lineskiplimit-\maxdimen
40   \oalign}
41
42% needs checking
43
44\def\choose{\atopwithdelims()}
45\def\brack {\atopwithdelims[]}
46\def\brace {\atopwithdelims\{\}}
47
48% needs checking
49
50\unexpanded\def\buildrel#1\over#2%
51  {\mathrel{\mathop{\kern\zeropoint#2}\limits^{#1}}}
52
53\unexpanded\def\bmod
54  {\nonscript
55   \mskip-\medmuskip
56   \mkern5mu
57   \mfunction{mod}%
58   \penalty900
59   \mkern5mu
60   \nonscript
61   \mskip-\medmuskip}
62
63\unexpanded\def\pmod#1%
64  {\allowbreak
65   \mkern18mu
66   (\mfunction{mod}\mskip\medmuskip#1)}
67
68\unexpanded\def\cases#1%
69  {\left\{%
70   \mskip\thinmuskip
71   \vcenter
72     {\normalbaselines
73      \mathsurround\zeropoint
74      \ialign{%
75        \normalstartimath\alignmark\alignmark\hfil\normalstopimath
76        \aligntab
77        \quad\alignmark\alignmark\hfil
78        \crcr
79        #1%
80        \crcr}}%
81   \right.}
82
83\unexpanded\def\matrix#1%
84  {\emptyhbox
85   \mskip\thinmuskip
86   \vcenter
87     {\normalbaselines
88      \mathsurround\zeropoint
89      \ialign{%
90        \hfil\normalstartimath\alignmark\alignmark\normalstopimath\hfil
91        \aligntab
92        \aligntab
93        \quad\hfil\normalstartimath\alignmark\alignmark\normalstopimath\hfil
94        \crcr
95        \mathstrut
96        \crcr
97        \noalign{\kern-\baselineskip}
98        #1\crcr
99        \mathstrut
100        \crcr
101        \noalign{\kern-\baselineskip}}}%
102   \mskip\thinmuskip}
103
104\unexpanded\def\pmatrix#1%
105  {\left(\matrix{#1}\right)}
106
107% \unexpanded\def\openup
108%   {\afterassignment\math_openup\scratchdimen=}
109%
110% \def\math_openup
111%   {\advance\lineskip     \scratchdimen
112%    \advance\baselineskip \scratchdimen
113%    \advance\lineskiplimit\scratchdimen}
114
115\let\math_closeup\relax
116
117\unexpanded\def\math_openup
118  {\afterassignment\math_openup_indeed\scratchdimen}
119
120\def\math_openup_indeed
121  {\unexpanded\edef\math_closeup
122     {\lineskip     \the\lineskip
123      \baselineskip \the\baselineskip
124      \lineskiplimit\the\lineskiplimit
125      \relax}%
126   \advance \lineskip      \scratchdimen
127   \advance \baselineskip  \scratchdimen
128   \advance \lineskiplimit \scratchdimen}
129
130\let\openup  \math_openup
131\def\closeup{\math_closeup} % dynamic
132
133\unexpanded\def\displaylines#1%
134  {\the\mathdisplayaligntweaks
135   \tabskip\zeroskip
136   \halign
137     {\hbox to \displaywidth{%
138        \normalstartimath\tabskip\zeroskip\everycr\emptytoks\hfil\displaystyle\alignmark\alignmark\hfil\normalstopimath}\crcr
139        #1\crcr}}
140
141%D This comes from plain but I gave it a \CONTEXT\ touch:
142
143\def\math_border_NC_indeed
144  {\gdef\math_border_NC{\aligntab}}
145
146\let\math_border_NC\math_border_NC_indeed
147
148\def\math_border_NR
149  {\glet\math_border_NC\math_border_NC_indeed
150   \cr}
151
152\unexpanded\def\math_border_matrix#1#2#3% adapted plain
153  {\begingroup
154   %
155   \pushmacro\cr
156   %
157   \setbox\scratchbox\hbox\bgroup
158     \mr B%
159   \egroup
160   \scratchdimenone\wd\scratchbox
161   %
162   \scratchdimentwo.2\bodyfontsize
163   %
164   \mathsurround\zeropoint
165   %
166   \def\NC{\math_border_NC}%
167   \def\NR{\math_border_NR}%
168   %
169   \setbox\scratchboxone\vbox\bgroup
170     \def\cr{%
171       \crcr
172       \noalign\bgroup
173         \kern\scratchdimentwo
174         \glet\cr\endline
175       \egroup
176     }%
177     \ialign{%
178       \startimath\alignmark\alignmark\stopimath
179       \hfil
180       \kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
181       \aligntab
182       \thinspace
183       \hfil
184       \startimath\alignmark\alignmark\stopimath
185       \hfil
186       \aligntab
187       \aligntab
188       \quad
189       \hfil
190       \startimath\alignmark\alignmark\stopimath
191       \hfil
192       \crcr
193       \omit
194       \strut
195       \hfil
196       \crcr
197       \noalign{\kern-\baselineskip}%
198       #3\crcr
199       \omit
200       \strut
201       \cr
202     }%
203   \egroup
204   \setbox\scratchboxtwo\vbox\bgroup
205     \unvcopy\scratchboxone
206     \global\setbox\globalscratchbox\lastbox
207   \egroup
208   \setbox\scratchboxtwo\hbox\bgroup
209     \unhbox\globalscratchbox
210     \unskip
211     \global\setbox\globalscratchbox\lastbox
212   \egroup
213   \setbox\scratchboxtwo\hbox\bgroup
214     \startimath
215     \kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
216     \left#1\relax
217     \kern-\wd\globalscratchbox
218     \global\setbox\globalscratchbox\vbox\bgroup
219       \box\globalscratchbox
220       \kern\scratchdimentwo
221     \egroup
222     \vcenter\bgroup
223       \kern-\ht\globalscratchbox
224       \unvbox\scratchboxone
225       \kern-\baselineskip
226     \egroup
227     \thinspace
228     \right#2\relax
229     \stopimath
230   \egroup
231   \null
232   \thickspace
233   \vbox\bgroup
234     \kern\ht\globalscratchbox
235     \box\scratchboxtwo
236   \egroup
237   %
238   \popmacro\cr
239   %
240   \endgroup}
241
242\unexpanded\def\bordermatrix {\math_border_matrix()}
243\unexpanded\def\bbordermatrix{\math_border_matrix[]}
244
245\unexpanded\def\startbordermatrix #1\stopbordermatrix {\math_border_matrix(){#1}}
246\unexpanded\def\startbbordermatrix#1\stopbbordermatrix{\math_border_matrix[]{#1}}
247
248\let\stopbordermatrix \relax
249\let\stopbbordermatrix\relax
250
251\protect \endinput
252