1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Math Macros Radicals}
15
16\registerctxluafile{mathrad}{autosuffix}
17
18\unprotect
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\installcorenamespace{mathradical}
70\installcorenamespace{mathradicalalternative}
71
72\installcommandhandler \??mathradical {mathradical} \??mathradical
73
74\setupmathradical
75 [\c!alternative=\v!normal,
76 \c!mpoffset=.25\exheight,
77 \c!height=\zeropoint,
78 \c!depth=\zeropoint,
79 \c!strut=\v!height,
80
81 \c!mindepth=.20\exheight,
82 \c!source=\zerocount,
83 \c!left="221A,
84 \c!symbolcolor=\mathradicalparameter\c!color,
85 \c!textcolor=\mathradicalparameter\c!color,
86 \c!numbercolor=\mathradicalparameter\c!color,
87 \c!mathstyle=\v!normal,
88 \c!right=\zerocount,
89 \c!leftmargin=\zeropoint,
90 \c!rightmargin=\zeropoint]
91
92\appendtoks
93 \frozen\protected\instance\edefcsname\currentmathradical\endcsname{\math_radical_handle{\currentmathradical}}
94\to \everydefinemathradical
95
96\mutable\lettonothing\currentmathradical
97\mutable\lettonothing\currentmathradicaldegree
98
99\setmathignore\Umathradicaldegreebefore\plusone
100
101\installcorenamespace{mathwhateverstrut}
102
103\defcsname\??mathwhateverstrut\v!height\endcsname{\mathheightstrut}
104\defcsname\??mathwhateverstrut\v!depth \endcsname{\mathdepthstrut}
105\defcsname\??mathwhateverstrut\v!math \endcsname{\mathstrut}
106\defcsname\??mathwhateverstrut\v!yes \endcsname{\strut}
107
108
109\tolerant\protected\def\math_radical_handle#tag#*[#S#settings]#*[#degree]#:#body
110 {\begingroup
111 \cdef\currentmathradical{#tag}
112 \ifhastok={#settings}
113 \lettonothing\currentmathradicaldegree
114 \setupcurrentmathradical[#settings]
115 \ifparameter#degree\or
116 \edef\currentmathradicaldegree{#degree}
117 \else
118 \edef\currentmathradicaldegree{\mathradicalparameter\c!n}
119 \fi
120 \else
121 \edef\currentmathradicaldegree{#settings}
122 \fi
123 \ifempty\currentmathradicaldegree
124 \let\currentmathradicaldegree\m_math_no_degree
125 \fi
126 \ifcase\mathradicalparameter\c!right\else
127 \let\currentmathradicaldegree\m_math_no_degree
128 \fi
129 \edef\p_mp{\mathradicalparameter\c!mp}
130 \ifcstok{\mathradicalparameter\c!plugin}\v!mp
131 \ifempty\p_mp\else
132 \clf_set_extensible_data
133 mp {\p_mp}
134 left {\mathradicalparameter\c!left}
135 right {\mathradicalparameter\c!left}
136 \relax
137 \fi
138 \scratchcounter\zerocount
139 \orelse\ifcstok{\mathradicalparameter\c!rule}\v!symbol
140 \lettonothing\p_mp
141 \scratchcounter\mathradicalparameter\c!top\relax
142 \else
143 \lettonothing\p_mp
144 \scratchcounter\zerocount
145 \fi
146 \ifcstok{\mathradicalparameter\c!mathstyle}\s!identity
147 \frozen\Umathradicalvariant\allmathstyles\mathstylevariantidentity
148
149 \resetmathradicalparameter\c!mathstyle
150 \fi
151 \Urooted
152 \s!height{\ifcstok{\mathradicalparameter\c!height}\v!none\scaledpoint\else\mathradicalparameter\c!height\fi}
153 \s!depth {\ifcstok{\mathradicalparameter\c!depth }\v!none\scaledpoint\else\mathradicalparameter\c!depth \fi}
154 \s!source{\namedboxanchor{\mathradicalparameter\c!source}}
155 \s!style \normalmathstyle
156 \ifzeronum\scratchcounter\else
157 \s!top\relaxedspace
158 \fi
159 \usedsymbolcolorparameterattributes{\mathradicalparameter\c!symbolcolor}
160 \ifempty\p_mp\else
161 \s!usecallback\relaxedspace
162 \fi
163 \ifcstok{\mathradicalparameter\c!rule}\v!no
164 \s!norule\relaxedspace
165 \orelse\ifcstok{\lastnamedcs}\v!bottom
166 \s!reflected\relaxedspace
167 \fi
168 \zerocount \mathradicalparameter\c!left
169 \zerocount \mathradicalparameter\c!right
170 \ifzeronum\scratchcounter\else
171 \zerocount\scratchcounter
172 \fi
173 \relax
174 {\usemathradicalcolorparameter\c!numbercolor
175 \mathstrut\currentmathradicaldegree}
176 {\usemathradicalcolorparameter\c!textcolor
177
178 \usemathstyleparameter\mathradicalparameter\c!mathstyle
179 \begincsname\??mathwhateverstrut\mathradicalparameter\c!strut\endcsname
180 \scratchdimen{\mathradicalparameter\c!leftmargin}
181 \ifzeropt\scratchdimen\else
182 \kern\scratchdimen
183 \fi
184 \scratchdepth{\mathradicalparameter\c!mindepth}
185 \ifzerodim\scratchdepth\else
186 \srule
187 \s!depth \scratchdepth
188 \s!height\zeropoint
189 \s!width \zeropoint
190 \relax
191 \fi
192 #body
193 \scratchdimen{\mathradicalparameter\c!rightmargin}
194 \ifzeropt\scratchdimen\else
195 \kern\scratchdimen
196 \fi}
197 \endgroup}
198
199\def\m_math_no_degree{{}}
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238\pushoverloadmode
239
240\definemathradical[root]
241\definemathradical[sqrt][root]
242
243\popoverloadmode
244
245
246
247
248
249
250
251
252\installcorenamespace{mathornament}
253\installcorenamespace{mathornamentalternative}
254
255\installcommandhandler \??mathornament {mathornament} \??mathornament
256
257\setupmathornament
258 [\c!alternative=\v!mp,
259 \c!mpoffset=.25\exheight]
260
261\appendtoks
262 \frozen\protected\instance\edefcsname\currentmathornament\endcsname
263 {\math_ornament_handle{\currentmathornament}}
264\to \everydefinemathornament
265
266\protected\def\math_ornament_handle#tag#body
267 {\begingroup
268 \cdef\currentmathornament{#tag}
269 \csname\??mathornamentalternative\mathornamentparameter\c!alternative\endcsname{#body}
270 \endgroup}
271
272\defcsname\??mathornamentalternative\v!mp\endcsname#body
273 {\begingroup
274 \scratchoffset{\mathornamentparameter\c!mpoffset}
275 \setbox\nextbox\mathstylehbox{#body}
276 \d_overlay_width \wd\nextbox
277 \d_overlay_height \ht\nextbox
278 \d_overlay_depth \dp\nextbox
279 \d_overlay_offset \scratchoffset
280 \d_overlay_linewidth\linewidth
281 \edef\overlaylinecolor{\mathornamentparameter\c!color}
282 \edef\p_mp{\mathornamentparameter\c!mp}
283
284 \setbox\scratchbox\hpack{\uniqueMPgraphic{\p_mp}}
285 \hpack to \wd\scratchbox{\hss\box\nextbox\hss}
286 \kern\wd\scratchbox
287 \box\scratchbox
288 \endgroup}
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329\integerdef\radicalbarextenderuc\privatecharactercode{radical bar extender}
330
331\integerdef\delimitedleftannuitylonguc \privatecharactercode{delimited left annuity long}
332\integerdef\delimitedleftannuityshortuc \privatecharactercode{delimited left annuity short}
333\integerdef\delimitedrightannuitylonguc \privatecharactercode{delimited right annuity long}
334\integerdef\delimitedrightannuityshortuc\privatecharactercode{delimited right annuity short}
335
336\integerdef\delimitedbottomleftannuitylonguc \privatecharactercode{delimited bottom left annuity long}
337\integerdef\delimitedbottomleftannuityshortuc \privatecharactercode{delimited bottom left annuity short}
338\integerdef\delimitedbottomrightannuitylonguc \privatecharactercode{delimited bottom right annuity long}
339\integerdef\delimitedbottomrightannuityshortuc\privatecharactercode{delimited bottom right annuity short}
340
341
342
343\setupmathradical
344 [\c!rule=\v!symbol,
345 \c!top=\radicalbarextenderuc]
346
347\definemathradical
348 [rannuity]
349 [\c!rule=\v!yes,
350 \c!left=\zerocount,
351 \c!right=\delimitedrightannuitylonguc,
352 \c!rightmargin=.05\emwidth]
353
354\definemathradical
355 [lannuity]
356 [\c!rule=\v!yes,
357 \c!left=\delimitedleftannuitylonguc,
358 \c!right=\zerocount,
359 \c!leftmargin=.05\emwidth]
360
361\definemathradical
362 [lrannuity]
363 [\c!rule=\v!yes,
364 \c!left=\delimitedleftannuityshortuc,
365 \c!right=\delimitedrightannuitylonguc,
366 \c!leftmargin=.05\emwidth,
367 \c!rightmargin=.05\emwidth]
368
369\definemathradical
370 [rlannuity]
371 [\c!rule=\v!yes,
372 \c!left=\delimitedleftannuitylonguc,
373 \c!right=\delimitedrightannuityshortuc,
374 \c!leftmargin=.05\emwidth,
375 \c!rightmargin=.05\emwidth]
376
377\definemathradical
378 [annuity]
379 [rannuity]
380
381\definemathradical
382 [lbannuity]
383 [lannuity]
384 [\c!rule=\v!bottom,
385 \c!left=\delimitedbottomleftannuitylonguc]
386
387\definemathradical
388 [rbannuity]
389 [rannuity]
390 [\c!rule=\v!bottom,
391 \c!right=\delimitedbottomrightannuitylonguc]
392
393\definemathradical
394 [rlbannuity]
395 [rlannuity]
396 [\c!rule=\v!bottom,
397 \c!left=\delimitedbottomleftannuityshortuc,
398 \c!right=\delimitedbottomrightannuitylonguc]
399
400\definemathradical
401 [lrbannuity]
402 [lrannuity]
403 [\c!rule=\v!bottom,
404 \c!left=\delimitedbottomleftannuitylonguc,
405 \c!right=\delimitedbottomrightannuityshortuc]
406
407\protect \endinput
408 |