1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20\unprotect
21
22\setupmathstackers
23 [\c!mp=minifun::math:stacker:\number\scratchunicode]
24
25\protect
26
27\startMPextensions
28 vardef math_stacker_bracket_shape(expr delta, rotate) =
29 image (
30 draw
31 (0,OverlayOffset) --
32 (0,deltaOverlayOffset) --
33 (OverlayWidth,deltaOverlayOffset) --
34 (OverlayWidth,OverlayOffset)
35 withcolor
36 OverlayLineColor ;
37 setbounds currentpicture to boundingbox currentpicture bottomenlarged OverlayOffset ;
38 if rotate :
39 currentpicture := currentpicture rotated 180 ;
40 fi ;
41 )
42 enddef ;
43 vardef math_stacker_parent_shape(expr delta, rotate) =
44 image (
45 draw
46 (0,OverlayOffset) ...
47 (OverlayWidth2,deltaOverlayOffset) ...
48 (OverlayWidth,OverlayOffset)
49 withcolor
50 OverlayLineColor ;
51 setbounds currentpicture to boundingbox currentpicture bottomenlarged OverlayOffset ;
52 if rotate :
53 currentpicture := currentpicture rotated 180 ;
54 fi ;
55 )
56 enddef ;
57 vardef math_stacker_brace_shape(expr delta, rotate) =
58 image (
59 draw
60 (0,OverlayOffset) ...
61 (OverlayWidth4OverlayOffset,deltaOverlayOffset) ...
62 (OverlayWidth2OverlayOffset,deltaOverlayOffset) ...
63 (OverlayWidth2,delta) &
64 (OverlayWidth2,delta) ...
65 (OverlayWidth2OverlayOffset,deltaOverlayOffset) ...
66 (3OverlayWidth4OverlayOffset,deltaOverlayOffset) ...
67 (OverlayWidth,OverlayOffset)
68 withcolor
69 OverlayLineColor ;
70 setbounds currentpicture to boundingbox currentpicture bottomenlarged OverlayOffset ;
71 if rotate :
72 currentpicture := currentpicture rotated 180 ;
73 fi ;
74 )
75 enddef ;
76 vardef math_stacker_bar_shape(expr rotate) =
77 image (
78 draw
79 (0,OverlayOffset) -- (OverlayWidth,OverlayOffset)
80 withcolor
81 OverlayLineColor ;
82 setbounds currentpicture to boundingbox currentpicture bottomenlarged OverlayOffset ;
83 if rotate :
84 currentpicture := currentpicture rotated 180 ;
85 fi ;
86 )
87 enddef ;
88
89 vardef math_stacker_arrow_shape(expr axis, ex, em, rotate) =
90 image (
91 interim ahlength := ex2;
92 drawarrow
93 ((OverlayWidth,ex2) -- (0,ex2))
94 withcolor
95 OverlayLineColor ;
96 setbounds currentpicture to unitsquare xysized(OverlayWidth,ex) ;
97 if rotate :
98 currentpicture := currentpicture rotated 180 ;
99 fi ;
100 )
101 enddef ;
102 vardef math_stacker_leftrightarrow_shape(expr axis, ex, em, rotate) =
103 image (
104 interim ahlength := ex2;
105 drawdblarrow
106 ((OverlayWidth,ex2) -- (0,ex2))
107 withcolor
108 OverlayLineColor ;
109 setbounds currentpicture to unitsquare xysized(OverlayWidth,ex) ;
110 if rotate :
111 currentpicture := currentpicture rotated 180 ;
112 fi ;
113 )
114 enddef ;
115 vardef math_stacker_rightoverleftarrow_shape(expr axis, ex, em, rotate) =
116 image (
117 interim ahlength := ex2;
118 drawdoublearrows
119 ((OverlayWidth,ex2) -- (0,ex2))
120 withcolor
121 OverlayLineColor ;
122 setbounds currentpicture to unitsquare xysized(OverlayWidth,ex) ;
123 if rotate :
124 currentpicture := currentpicture rotated 180 ;
125 fi ;
126 )
127 enddef ;
128
129
130
131 def math_stacker_draw_accent(expr p) =
132
133
134 draw p withpen pencircle scaled OverlayLineWidth ;
135 enddef ;
136
137 def math_stacker_draw_arrow(expr p) =
138 draw p withpen pencircle scaled OverlayLineWidth ;
139 enddef ;
140\stopMPextensions
141
142\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE3B4\else23B4\fi}{axis,ex,em}
143 math_stacker_draw_accent(math_stacker_bracket_shape(OverlayHeight,false)) ;
144\stopuniqueMPgraphic
145
146\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE3B5\else23B5\fi}{axis,ex,em}
147 math_stacker_draw_accent(math_stacker_bracket_shape(OverlayDepth,true)) ;
148\stopuniqueMPgraphic
149
150\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE3DC\else23DC\fi}{axis,ex,em}
151 math_stacker_draw_accent(math_stacker_parent_shape(OverlayHeight,false)) ;
152\stopuniqueMPgraphic
153
154\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE3DD\else23DD\fi}{axis,ex,em}
155 math_stacker_draw_accent(math_stacker_parent_shape(OverlayDepth,true)) ;
156\stopuniqueMPgraphic
157
158\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE3DE\else23DE\fi}{axis,ex,em}
159 math_stacker_draw_accent(math_stacker_brace_shape(OverlayHeight,false)) ;
160\stopuniqueMPgraphic
161
162\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE3DF\else23DF\fi}{axis,ex,em}
163 math_stacker_draw_accent(math_stacker_brace_shape(OverlayDepth,true)) ;
164\stopuniqueMPgraphic
165
166\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE33E\else203E\fi}{axis,ex,em}
167 math_stacker_draw_accent(math_stacker_bar_shape(false)) ;
168\stopuniqueMPgraphic
169
170\startuniqueMPgraphic{minifun::math:stacker:\number"\ifcase\contextlmtxmode FE33F\else203F\fi}{axis,ex,em}
171 math_stacker_draw_accent(math_stacker_bar_shape(true)) ;
172\stopuniqueMPgraphic
173
174\startuniqueMPgraphic{minifun::math:stacker:\number"2190}{axis,ex,em}
175 math_stacker_draw_arrow(math_stacker_arrow_shape(\MPvar{axis},\MPvar{ex},\MPvar{em},false)) ;
176\stopuniqueMPgraphic
177
178\startuniqueMPgraphic{minifun::math:stacker:\number"2192}{axis,ex,em}
179 math_stacker_draw_arrow(math_stacker_arrow_shape(\MPvar{axis},\MPvar{ex},\MPvar{em},true)) ;
180\stopuniqueMPgraphic
181
182\startuniqueMPgraphic{minifun::math:stacker:\number"2194}{axis,ex,em}
183 math_stacker_draw_arrow(math_stacker_leftrightarrow_shape(\MPvar{axis},\MPvar{ex},\MPvar{em},false)) ;
184\stopuniqueMPgraphic
185
186\startuniqueMPgraphic{minifun::math:stacker:\number"27F7}{axis,ex,em}
187 math_stacker_draw_arrow(math_stacker_leftrightarrow_shape(\MPvar{axis},\MPvar{ex},\MPvar{em},false)) ;
188\stopuniqueMPgraphic
189
190\startuniqueMPgraphic{minifun::math:stacker:\number"21C4}{axis,ex,em}
191 math_stacker_draw_arrow(math_stacker_rightoverleftarrow_shape(\MPvar{axis},\MPvar{ex},\MPvar{em},false)) ;
192\stopuniqueMPgraphic
193
194
195
196\startMPextensions
197 vardef math_radical_simple(expr w,h,d,o) =
198 (h2o,h2o) --
199 (h4o,do) --
200 (o,ho) --
201 (wo,ho) --
202 (wo,hh10o)
203 enddef ;
204\stopMPextensions
205
206\startuniqueMPgraphic{minifun::math:radical:default}{axis,ex,em}
207 draw
208 math_radical_simple(OverlayWidth,OverlayHeight,OverlayDepth,OverlayOffset)
209
210 withpen pencircle scaled OverlayLineWidth
211
212 withcolor OverlayLineColor ;
213\stopuniqueMPgraphic
214
215
216
217
218
219\continueifinputfile{metaimpmat.mkiv}
220
221\setupmathstackers [both] [color=darkred,alternative=mp]
222\setupmathstackers [top] [color=darkred,alternative=mp]
223\setupmathstackers [bottom] [color=darkred,alternative=mp]
224
225\startTEXpage[offset=10pt]
226
227$
228 \overbracket {abcd} \quad
229 \underbracket {abcd} \quad
230 \doublebracket {abcd}
231$
232\blank[2*big]
233$
234 \overparent {abcd} \quad
235 \underparent {abcd} \quad
236 \doubleparent {abcd}
237$
238\blank[2*big]
239$
240 \overbrace {abcd} \quad
241 \underbrace {abcd} \quad
242 \doublebrace {abcd}
243$
244\blank[2*big]
245$
246 \overbar {abcd} \quad
247 \underbar {abcd} \quad
248 \doublebar {abcd}
249$
250\blank[2*big]
251$
252 \overleftarrow {abcd} \quad
253 \overrightarrow {abcd}
254$
255\blank[2*big]
256$
257 \underleftarrow {abcd} \quad
258 \underrightarrow {abcd}
259$
260\blank[2*big]
261\setupmathradical[sqrt][alternative=mp,color=darkgreen]
262$
263 \sqrt[2]{abcd} \quad
264$
265
266\stopTEXpage
267 |