1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Math Macros Fences}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32\installcorenamespace{mathfences}
33
34\installcommandhandler \??mathfences {mathfence} \??mathfences
35
36\aliased\let\setupmathfences\setupmathfence
37
38\setupmathfences
39 [\c!method=,
40 \c!left=,
41 \c!right=,
42 \c!middle=,
43 \c!mathstyle=,
44 \c!color=,
45 \c!define=,
46 \c!mathclass=,
47 \c!leftclass=\mathopencode,
48 \c!rightclass=\mathclosecode,
49 \c!middleclass=\mathmiddlecode,
50 \c!leftsource=\zerocount,
51 \c!middlesource=\zerocount,
52 \c!rightsource=\mathfenceparameter\c!source,
53 \c!source=\zerocount,
54 \c!height=\zeropoint,
55 \c!depth=\zeropoint,
56 \c!distance=\zerocount,
57 \c!topspace=\zeropoint,
58 \c!bottomspace=\zeropoint,
59
60 \c!overflow=\v!auto,
61 \c!factor=\v!auto,
62 \c!snap=\mathematicsparameter\c!snap]
63
64\appendtoks
65 \ifcstok{\mathfenceparameter\c!define}\v!yes
66 \protected\edefcsname\currentmathfence\endcsname{\math_fenced_fenced{\currentmathfence}}
67 \fi
68\to \everydefinemathfence
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\newconditional\c_math_fenced_mirror \c_math_fenced_mirror\conditionaltrue
103\newconditional\c_math_fenced_sized \c_math_fenced_sized\conditionalfalse
104\newinteger \c_math_fence_nesting
105
106\installcorenamespace {mathfencesize}
107
108\defcsname\??mathfencesize big\endcsname{1}
109\defcsname\??mathfencesize Big\endcsname{2}
110\defcsname\??mathfencesize bigg\endcsname{3}
111\defcsname\??mathfencesize Bigg\endcsname{4}
112
113\let\math_fenced_trace\donothing
114
115\def\math_fenced_force_size#1#2
116 {\c_attr_mathsize\numexpr
117 #1*\plushundred
118 \ifcsname\??mathfencesize#2\endcsname\lastnamedcs\else#2\fi
119 \relax}
120
121\def\math_fenced_common_factor_none
122 {\math_fenced_force_size\bigmathdelimitervariant\c_math_fence_nesting\relax
123 \Uvextensible
124 \s!axis
125 \s!exact}
126
127\def\math_fenced_common_factor_fixed
128 {\Uvextensible
129 \s!axis
130 \s!exact}
131
132\def\math_fenced_common_factor_unknown
133 {\scratchdimen\dimexpr\p_factor\bodyfontsize2\relax
134 \Uvextensible
135 \s!height\scratchdimen
136 \s!depth\scratchdimen
137 \s!axis
138 \s!exact}
139
140\def\math_fenced_common_factor_force
141 {\Uvextensible
142 \s!height\mathfenceparameter\c!height
143 \s!depth\mathfenceparameter\c!depth
144 \s!axis
145 \s!exact}
146
147
148
149
150
151
152
153
154\newconstant\c_math_fenced_class
155\newinteger \c_math_fence_check
156
157\integerdef\c_math_factor_fenced\zerocount
158
159\installglobalmacrostack\c_math_factor_fenced
160
161\protected\def\math_fenced_common#1#2#3#4
162 {\c_math_fenced_class\math_class_by_parameter\mathfenceparameter#2
163 \math_fenced_check_size_mismatch
164 \ifconditional\c_math_fenced_sized
165 \orelse\ifconditional\c_math_fenced_level_mode
166 \ifnum\c_math_fenced_class=\mathopencode
167
168 \integerdef\c_math_fenced_stack\c_attr_mathsize
169 \push_macro_c_math_fenced_stack
170 \orelse\ifnum\c_math_fenced_class=\mathclosecode
171 \pop_macro_c_math_fenced_stack
172 \c_attr_mathsize\c_math_fenced_stack
173
174 \fi
175 \fi
176 \edef\p_fence{#3}
177 \ifempty\p_fence
178 \ifnum\c_math_fenced_class=\mathmiddlecode\else#1.\relax\fi
179 \else
180 \edef\p_factor {\mathfenceparameter\c!factor}
181 \edef\p_overflow {\mathfenceparameter\c!overflow}
182 \edef\p_size {\mathfenceparameter\c!size}
183 \edef\p_mathclass{\mathfenceparameter\c!mathclass}
184 \edef\p_inline_factor{\ifconditional\indisplaymath\mathfenceparameter\c!displayfactor\else\mathfenceparameter\c!inlinefactor\fi}
185 \ifempty\p_inline_factor
186
187 \orelse\ifx#1\Uleft
188 \push_macro_c_math_factor_fenced
189 \integerdef\c_math_factor_fenced\p_inline_factor\relax
190 \orelse\ifx#1\Uright
191 \pop_macro_c_math_factor_fenced
192 \fi
193 \ifnum\c_math_fenced_level>\zerocount
194 \math_fenced_common_factor_fixed
195 \orelse\ifconditional\c_math_fenced_sized
196 \math_fenced_common_factor_fixed
197 \orelse\ifempty\p_factor
198 \ifconditional\c_math_fenced_level_mode
199 \Uvextensible
200 \else
201 #1
202 \ifx#1\Umiddle
203 \ifx\p_overflow\v!auto
204 middle
205 nooverflow
206 \orelse\ifx\p_overflow\v!no
207 nooverflow
208 \fi
209 \fi
210 \fi
211 \orelse\ifx\p_factor\v!auto
212 \ifconditional\c_math_fenced_level_mode
213 \Uvextensible
214 \else
215 #1
216 \ifx#1\Umiddle
217 \ifx\p_overflow\v!auto
218 middle
219 nooverflow
220 \orelse\ifx\p_overflow\v!no
221 nooverflow
222 \fi
223 \fi
224 \fi
225 \orelse\ifx\p_factor\v!none
226 \math_fenced_common_factor_none
227 \orelse\ifx\p_factor\v!fixed
228 \math_fenced_common_factor_fixed
229 \orelse\ifx\p_factor\v!force
230 \math_fenced_common_factor_force
231 \else
232 \math_fenced_common_factor_unknown
233 \fi
234 \usedcolorparameterattributes{\mathfenceparameter\c!color}
235 \s!class
236 \ifx\p_fence\v!none
237 \mathghostcode
238 \orelse\ifempty\p_mathclass
239 \c_math_fenced_class
240 \else
241 \mathcodechecked\p_mathclass
242 \fi
243 \s!source
244 \numexpr\namedboxanchor{\mathfenceparameter#4}\relax
245
246 \s!top \mathfenceparameter\c!topspace
247 \s!bottom \mathfenceparameter\c!bottomspace
248
249 \ifzero\c_math_factor_fenced\else
250 \s!factor \c_math_factor_fenced
251 \fi
252
253 \ifcstok{\mathfenceparameter\c!snap}\v!yes
254 \s!single\space
255 \fi
256
257 \math_fenced_trace
258 \ifx\p_fence\v!none
259 \Udelimiter\mathghostcode\fam\zerocount
260 \orelse\ifchknumber\p_fence\or
261 \Udelimiter\mathghostcode\fam\lastchknumber
262 \else
263 \p_fence
264 \fi
265 \fi
266
267 \ifconditional\c_math_fenced_sized
268 \orelse\ifcase\c_math_fenced_level
269 \c_attr_mathsize\attributeunsetvalue
270 \fi}
271
272\def\math_fenced_left
273 {\advanceby\c_math_fence_nesting\plusone
274 \math_fenced_common\Uleft\c!leftclass\math_fenced_p_left\c!leftsource}
275
276\def\math_fenced_right
277 {\math_fenced_common\Uright\c!rightclass\math_fenced_p_right\c!rightsource
278 \advanceby\c_math_fence_nesting\minusone}
279
280\def\math_fenced_middle_normal
281 {\math_fenced_common\Umiddle\c!middleclass\math_fenced_p_middle\c!middlesource}
282
283\def\math_fenced_middle_sized
284 {\c_math_fenced_sized\conditionaltrue
285 \math_fenced_middle_normal
286 \c_math_fenced_sized\conditionalfalse}
287
288\appendtoks
289 \let\math_fenced_middle\math_fenced_middle_normal
290 \enforced\let\fence\math_fenced_direct
291\to \everymathatom
292
293\let\math_fenced_middle\math_fenced_middle_normal
294
295\def\math_fenced_p_left
296 {\ifconditional\c_math_fenced_mirror
297 \ifconditional\c_math_right_to_left
298 \mathfenceparameter\c!right
299 \else
300 \mathfenceparameter\c!left
301 \fi
302 \else
303 \mathfenceparameter\c!left
304 \fi}
305
306\def\math_fenced_p_middle
307 {\mathfenceparameter\c!middle}
308
309\def\math_fenced_p_right
310 {\ifconditional\c_math_fenced_mirror
311 \ifconditional\c_math_right_to_left
312 \mathfenceparameter\c!left
313 \else
314 \mathfenceparameter\c!right
315 \fi
316 \else
317 \mathfenceparameter\c!right
318 \fi}
319
320\aliased\let\fence \relax
321\aliased\let\fenced\relax
322
323\protected\def\math_fenced_middle_bar {\mfence \relax}
324\protected\def\math_fenced_middle_colon{\mfence :\relax}
325\protected\def\math_fenced_middle_comma{\mathatom \s!leftclass \mathpunctuationcode \s!rightclass \mathmiddlecode {,}}
326
327\startsetups math:fence:set:bar
328 \aliased\let\suchthat\math_fenced_middle_bar
329 \aliased\let\where \math_fenced_middle_comma
330 \aliased\let\and \math_fenced_middle_comma
331\stopsetups
332
333\startsetups math:fence:set:colon
334 \aliased\let\suchthat\math_fenced_middle_colon
335 \aliased\let\where \math_fenced_middle_comma
336 \aliased\let\and \math_fenced_middle_comma
337\stopsetups
338
339\startsetups math:fence:set
340 \directsetup{math:fence:set:bar}
341\stopsetups
342
343\mutable\lettonothing\suchthat
344
345
346\protected\def\math_fenced_middle_common
347 {\math_fenced_middle}
348
349\protected\def\math_fenced_fenced_common
350 {\startusemathstyleparameter\mathfenceparameter\c!mathstyle
351 \usesetupsparameter\mathfenceparameter
352 \enforced\let\fence\math_fenced_middle_common}
353
354\protected\def\math_fenced_fenced_start#1
355 {\begingroup
356
357 \cdef\currentmathfence{#1}
358 \math_fenced_fenced_common
359 \math_fenced_left}
360
361\protected\def\math_fenced_fenced_stop#1
362 {\cdef\currentmathfence{#1}
363 \math_fenced_right
364 \stopusemathstyleparameter
365 \endgroup}
366
367
368\installlocalcurrenthandler \??mathfences {mathfence}
369
370
371
372
373
374
375
376
377\def\math_fenced_check#1
378 {\ifempty{\mathfenceparameter#1}\letmathfenceparameter#1\v!none\fi}
379
380\appendtoks
381 \math_fenced_check\c!left
382 \math_fenced_check\c!right
383\to \everysetupmathfence
384
385\appendtoks
386 \math_fenced_check\c!left
387 \math_fenced_check\c!right
388\to \everydefinemathfence
389
390\protected\def\math_fenced_horizontal_common#1#2#3#4
391 {\c_math_fenced_class\math_class_by_parameter\mathfenceparameter#2\relax
392 \edef\p_fence{#3}
393 #1
394 \usedcolorparameterattributes{\mathfenceparameter\c!color}
395 \s!leftclass \mathunspacedcode
396 \s!rightclass \mathunspacedcode
397 \s!class \mathunspacedcode
398 \s!source \numexpr\namedboxanchor{\mathfenceparameter#4}\relax
399 \Udelimiter\mathghostcode\fam\p_fence}
400
401\tolerant\protected\def\math_fenced_horizontal#1#*[#S#2]#:#*#3#4
402 {
403 \mathord \bgroup
404 \setlocalmathfencecurrent{#1}
405 \setupcurrentmathfence[#2]
406
407 \setmathsmalltextbox\scratchboxone\hbox{\usemathfencestyleandcolor\c!leftstyle \c!leftcolor #3}
408 \setmathsmalltextbox\scratchboxtwo\hbox{\usemathfencestyleandcolor\c!rightstyle\c!rightcolor#4}
409 \let\math_fenced_common\math_fenced_horizontal_common
410 \edef\p_fenced_middle{\mathfenceparameter\c!middle}
411 \ifempty\p_fenced_middle\else
412 \letmathfenceparameter\c!left \p_fenced_middle
413 \letmathfenceparameter\c!right\zerocount
414 \fi
415 \scratchdistance\mathfenceparameter\c!distance
416 \box\scratchboxone
417 \kern\scratchdistance
418 \math_fenced_fenced_start\currentmathfence
419 \math_fenced_fenced_stop \currentmathfence
420 \kern\scratchdistance
421 \box\scratchboxtwo
422 \egroup}
423
424\tolerant\protected\def\math_fenced_fenced#1
425 {\ifcstok{\namedmathfenceparameter{#1}\c!text}\v!yes
426 \expandafter\math_fenced_horizontal
427 \else
428 \expandafter\math_fenced_vertical
429 \fi{#1}}
430
431
432
433\definemathfence
434 [\v!text]
435
436\setupmathfence
437 [\v!text]
438 [\c!text=\v!yes,
439 \c!define=\v!yes,
440 \c!distance=.125\emwidth]
441
442\tolerant\protected\def\math_fenced_vertical#1#*[#S#2]
443 {\begingroup
444
445 \setlocalmathfencecurrent{#1}
446
447 \c_math_fenced_level_mode\conditionalfalse
448 \c_attr_mathsize\attributeunsetvalue
449
450 \resetmathfenceparameter\c!size
451 \letmathfenceparameter\c!factor\v!auto
452
453 \ifparameter#2\or
454 \setupcurrentmathfence[#2]
455 \bigmathdelimitervariant\mathfenceparameter\c!alternative\relax
456 \fi
457 \math_fenced_fenced_common
458 \edef\p_size{\mathfenceparameter\c!size}
459 \ifempty\p_size
460 \expandafter\math_fenced_fenced_indeed_adapt
461 \else
462 \expandafter\math_fenced_fenced_indeed_fixed
463 \fi}
464
465\protected\def\math_fenced_fenced_indeed_finish
466 {\stopusemathstyleparameter
467 \endgroup}
468
469
470\protected\def\math_fenced_fenced_indeed_fixed#1
471 {\math_fenced_force_size\bigmathdelimitervariant\p_size
472 \c_math_fenced_sized\conditionaltrue
473 \math_fenced_left
474 \c_math_fenced_sized\conditionalfalse
475 \let\math_fenced_middle\math_fenced_middle_sized
476
477\begingroup
478 #1
479\endgroup
480 \c_math_fenced_sized\conditionaltrue
481 \math_fenced_right
482 \c_math_fenced_sized\conditionalfalse
483 \math_fenced_fenced_indeed_finish}
484
485\protected\def\math_fenced_fenced_indeed_adapt#1
486 {\c_math_fenced_sized\conditionalfalse
487 \math_fenced_left
488 #1
489 \c_math_fenced_sized\conditionalfalse
490 \math_fenced_right
491 \math_fenced_fenced_indeed_finish}
492
493\protected\def\math_fenced_direct[#1]
494 {\math_fenced_fenced{#1}}
495
496\appendtoks
497 \enforced\let\fenced\math_fenced_direct
498\to \everymathematics
499
500\permanent\tolerant\protected\def\startmathfenced[#1]#*[#S#2]
501 {\begingroup
502 \cdef\currentmathfence{#1}
503 \setupcurrentmathfence[#2]
504 \math_fenced_fenced_start{#1}}
505
506\permanent\protected\def\stopmathfenced
507 {\math_fenced_fenced_stop\currentmathfence
508 \endgroup}
509
510\protected\def\math_fenced_start_wrap#1
511 {\begingroup
512 \edef\m_math_fenced_wrap{#1}
513 \ifempty\m_math_fenced_wrap \else
514 \math_fenced_fenced_start\m_math_fenced_wrap
515 \fi}
516
517\protected\def\math_fenced_stop_wrap
518 {\ifempty\m_math_fenced_wrap \else
519 \math_fenced_fenced_stop\m_math_fenced_wrap
520 \fi
521 \endgroup}
522
523
524
525
526
527
528
529
530
531\aliased\let\normalmid\mid
532
533\protected\def\mid{\ifcase\c_math_fence_nesting\normalmid\else\middle\vert\fi}
534
535
536
537\definemathfence [cases] [\c!left="007B,\c!right=\v!none]
538\definemathfence [sesac] [\c!left=\v!none,\c!right="007D]
539\definemathfence [tekcarb] [\c!left="005D,\c!right="005B]
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583\newinteger \c_math_fenced_level
584\newconditional\c_math_fenced_level_mode
585
586\integerdef\c_math_fenced_stack \zerocount
587
588\installmacrostack \c_math_fenced_stack
589
590\installcorenamespace{fencelevels}
591\installcorenamespace{fencestack}
592
593\defcsname\??fencelevels\endcsname{\advanceby\c_math_fenced_level\plusone }
594\defcsname\??fencelevels\endcsname{\advanceby\c_math_fenced_level\minusone }
595\defcsname\??fencelevels=\endcsname {\c_math_fenced_level\zerocount}
596
597\letcsname\??fencelevels*\endcsname\donothing
598
599\def\math_fenced_check_size_mismatch
600 {\ifnum\c_math_fence_check=\c_math_fence_nesting
601 \c_attr_mathsize\attributeunsetvalue
602 \c_math_fenced_level_mode\conditionalfalse
603 \c_math_fenced_level\zerocount
604 \fi}
605
606\permanent\protected\def\F#1
607 {\ifconditional\c_math_fenced_level_mode\else
608 \c_math_fence_check\c_math_fence_nesting
609 \fi
610 \c_math_fenced_level_mode\conditionaltrue
611 \ifchknum#1\or
612 \c_math_fenced_level#1\relax
613 \orelse\ifcsname\??fencelevels#1\endcsname
614 \lastnamedcs
615 \else
616 \c_math_fenced_level\zerocount
617 \fi
618 \math_fenced_force_size\bigmathdelimitervariant\c_math_fenced_level\relax}
619
620
621
622
623
624
625\definemathfence [parenthesis] [\c!left="0028,\c!right="0029]
626\definemathfence [bracket] [\c!left="005B,\c!right="005D]
627\definemathfence [brace] [\c!left="007B,\c!right="007D]
628\definemathfence [bar] [\c!left="007C,\c!right="007C]
629\definemathfence [doublebar] [\c!left="2016,\c!right="2016]
630\definemathfence [triplebar] [\c!left="2980,\c!right="2980]
631\definemathfence [angle] [\c!left="27E8,\c!right="27E9]
632\definemathfence [doubleangle] [\c!left="27EA,\c!right="27EB]
633\definemathfence [solidus] [\c!left="2044,\c!right="2044]
634\definemathfence [ceiling] [\c!left="2308,\c!right="2309]
635\definemathfence [floor] [\c!left="230A,\c!right="230B]
636\definemathfence [moustache] [\c!left="23B0,\c!right="23B1]
637\definemathfence [uppercorner] [\c!left="231C,\c!right="231D]
638\definemathfence [lowercorner] [\c!left="231E,\c!right="231F]
639\definemathfence [group] [\c!left="27EE,\c!right="27EF]
640\definemathfence [openbracket] [\c!left="27E6,\c!right="27E7]
641
642\definemathfence [nothing]
643
644\definemathfence [mirrored]
645
646\definemathfence [mirroredparenthesis] [mirrored] [\c!right="0028,\c!left="0029]
647\definemathfence [mirroredbracket] [mirrored] [\c!right="005B,\c!left="005D]
648\definemathfence [mirroredbrace] [mirrored] [\c!right="007B,\c!left="007D]
649\definemathfence [mirroredbar] [mirrored] [\c!right="007C,\c!left="007C]
650\definemathfence [mirroreddoublebar] [mirrored] [\c!right="2016,\c!left="2016]
651\definemathfence [mirroredtriplebar] [mirrored] [\c!right="2980,\c!left="2980]
652\definemathfence [mirroredangle] [mirrored] [\c!right="27E8,\c!left="27E9]
653\definemathfence [mirroreddoubleangle] [mirrored] [\c!right="27EA,\c!left="27EB]
654\definemathfence [mirroredsolidus] [mirrored] [\c!right="2044,\c!left="2044]
655\definemathfence [mirroredceiling] [mirrored] [\c!right="2308,\c!left="2309]
656\definemathfence [mirroredfloor] [mirrored] [\c!right="230A,\c!left="230B]
657\definemathfence [mirroredmoustache] [mirrored] [\c!right="23B0,\c!left="23B1]
658\definemathfence [mirroreduppercorner] [mirrored] [\c!right="231C,\c!left="231D]
659\definemathfence [mirroredlowercorner] [mirrored] [\c!right="231E,\c!left="231F]
660\definemathfence [mirroredgroup] [mirrored] [\c!right="27EE,\c!left="27EF]
661\definemathfence [mirroredopenbracket] [mirrored] [\c!right="27E6,\c!left="27E7]
662
663\definemathfence [mirrorednothing] [mirrored]
664
665
666
667\pushoverloadmode
668
669\immutable\protected\def\Lparenthesis {\math_fenced_fenced_start{parenthesis}} \immutable\protected\def\Rparenthesis {\math_fenced_fenced_stop {parenthesis}}
670\immutable\protected\def\Lbracket {\math_fenced_fenced_start{bracket}} \immutable\protected\def\Rbracket {\math_fenced_fenced_stop {bracket}}
671\immutable\protected\def\Lbrace {\math_fenced_fenced_start{brace}} \immutable\protected\def\Rbrace {\math_fenced_fenced_stop {brace}}
672\immutable\protected\def\Langle {\math_fenced_fenced_start{angle}} \immutable\protected\def\Rangle {\math_fenced_fenced_stop {angle}}
673\immutable\protected\def\Ldoubleangle {\math_fenced_fenced_start{doubleangle}} \immutable\protected\def\Rdoubleangle {\math_fenced_fenced_stop {doubleangle}}
674\immutable\protected\def\Lbar {\math_fenced_fenced_start{bar}} \immutable\protected\def\Rbar {\math_fenced_fenced_stop {bar}}
675\immutable\protected\def\Ldoublebar {\math_fenced_fenced_start{doublebar}} \immutable\protected\def\Rdoublebar {\math_fenced_fenced_stop {doublebar}}
676\immutable\protected\def\Ltriplebar {\math_fenced_fenced_start{triplebar}} \immutable\protected\def\Rtriplebar {\math_fenced_fenced_stop {triplebar}}
677\immutable\protected\def\Lsolidus {\math_fenced_fenced_start{solidus}} \immutable\protected\def\Rsolidus {\math_fenced_fenced_stop {solidus}}
678\immutable\protected\def\Lfloor {\math_fenced_fenced_start{floor}} \immutable\protected\def\Rfloor {\math_fenced_fenced_stop {floor}}
679\immutable\protected\def\Lceiling {\math_fenced_fenced_start{ceiling}} \immutable\protected\def\Rceiling {\math_fenced_fenced_stop {ceiling}}
680\immutable\protected\def\Lmoustache {\math_fenced_fenced_start{moustache}} \immutable\protected\def\Rmoustache {\math_fenced_fenced_stop {moustache}}
681\immutable\protected\def\Luppercorner {\math_fenced_fenced_start{uppercorner}} \immutable\protected\def\Ruppercorner {\math_fenced_fenced_stop {uppercorner}}
682\immutable\protected\def\Llowercorner {\math_fenced_fenced_start{lowercorner}} \immutable\protected\def\Rlowercorner {\math_fenced_fenced_stop {lowercorner}}
683\immutable\protected\def\Lgroup {\math_fenced_fenced_start{group}} \immutable\protected\def\Rgroup {\math_fenced_fenced_stop {group}}
684\immutable\protected\def\Lopenbracket {\math_fenced_fenced_start{openbracket}} \immutable\protected\def\Ropenbracket {\math_fenced_fenced_stop {openbracket}}
685\immutable\protected\def\Lnothing {\math_fenced_fenced_start{nothing}} \immutable\protected\def\Rnothing {\math_fenced_fenced_stop {nothing}}
686
687\immutable\protected\def\Lparenthesismirrored {\math_fenced_fenced_stop {mirroredparenthesis}} \immutable\protected\def\Rparenthesismirrored {\math_fenced_fenced_start{mirroredparenthesis}}
688\immutable\protected\def\Lbracketmirrored {\math_fenced_fenced_stop {mirroredbracket}} \immutable\protected\def\Rbracketmirrored {\math_fenced_fenced_start{mirroredbracket}}
689\immutable\protected\def\Lbracemirrored {\math_fenced_fenced_stop {mirroredbrace}} \immutable\protected\def\Rbracemirrored {\math_fenced_fenced_start{mirroredbrace}}
690\immutable\protected\def\Langlemirrored {\math_fenced_fenced_stop {mirroredangle}} \immutable\protected\def\Ranglemirrored {\math_fenced_fenced_start{mirroredangle}}
691\immutable\protected\def\Ldoubleanglemirrored {\math_fenced_fenced_stop {mirroreddoubleangle}} \immutable\protected\def\Rdoubleanglemirrored {\math_fenced_fenced_start{mirroreddoubleangle}}
692\immutable\protected\def\Lbarmirrored {\math_fenced_fenced_stop {mirroredbar}} \immutable\protected\def\Rbarmirrored {\math_fenced_fenced_start{mirroredbar}}
693\immutable\protected\def\Ldoublebarmirrored {\math_fenced_fenced_stop {mirroreddoublebar}} \immutable\protected\def\Rdoublebarmirrored {\math_fenced_fenced_start{mirroreddoublebar}}
694\immutable\protected\def\Ltriplebarmirrored {\math_fenced_fenced_stop {mirroredtriplebar}} \immutable\protected\def\Rtriplebarmirrored {\math_fenced_fenced_start{mirroredtriplebar}}
695\immutable\protected\def\Lsolidusmirrored {\math_fenced_fenced_stop {mirroredsolidus}} \immutable\protected\def\Rsolidusmirrored {\math_fenced_fenced_start{mirroredsolidus}}
696\immutable\protected\def\Lfloormirrored {\math_fenced_fenced_stop {mirroredfloor}} \immutable\protected\def\Rfloormirrored {\math_fenced_fenced_start{mirroredfloor}}
697\immutable\protected\def\Lceilingmirrored {\math_fenced_fenced_stop {mirroredceiling}} \immutable\protected\def\Rceilingmirrored {\math_fenced_fenced_start{mirroredceiling}}
698\immutable\protected\def\Lmoustachemirrored {\math_fenced_fenced_stop {mirroredmoustache}} \immutable\protected\def\Rmoustachemirrored {\math_fenced_fenced_start{mirroredmoustache}}
699\immutable\protected\def\Luppercornermirrored {\math_fenced_fenced_stop {mirroreduppercorner}} \immutable\protected\def\Ruppercornermirrored {\math_fenced_fenced_start{mirroreduppercorner}}
700\immutable\protected\def\Llowercornermirrored {\math_fenced_fenced_stop {mirroredlowercorner}} \immutable\protected\def\Rlowercornermirrored {\math_fenced_fenced_start{mirroredlowercorner}}
701\immutable\protected\def\Lgroupmirrored {\math_fenced_fenced_stop {mirroredgroup}} \immutable\protected\def\Rgroupmirrored {\math_fenced_fenced_start{mirroredgroup}}
702\immutable\protected\def\Lopenbracketmirrored {\math_fenced_fenced_stop {mirroredopenbracket}} \immutable\protected\def\Ropenbracketmirrored {\math_fenced_fenced_start{mirroredopenbracket}}
703\immutable\protected\def\Lnothingmirrored {\math_fenced_fenced_stop {mirrorednothing}} \immutable\protected\def\Rnothingmirrored {\math_fenced_fenced_start{mirrorednothing}}
704
705
706
707
708
709
710
711
712
713
714\definemathfence [interval] [\c!left="005B,\c!right="005D]
715\definemathfence [openinterval] [interval] [\c!left="0028,\c!right="0029]
716\definemathfence [closedinterval] [interval] [\c!left="005B,\c!right="005D]
717\definemathfence [leftopeninterval] [interval] [\c!left="0028,\c!right="005D]
718\definemathfence [rightopeninterval] [interval] [\c!left="005B,\c!right="0029]
719\definemathfence [varopeninterval] [interval] [\c!left="005D,\c!right="005B]
720\definemathfence [varleftopeninterval] [interval] [\c!left="005D,\c!right="005D]
721\definemathfence [varrightopeninterval] [interval] [\c!left="005B,\c!right="005B]
722
723\immutable\protected\def\Linterval {\math_fenced_fenced_start{interval}}
724\immutable\protected\def\Lointerval {\math_fenced_fenced_start{openinterval}}
725\immutable\protected\def\Llointerval {\math_fenced_fenced_start{leftopeninterval}}
726\immutable\protected\def\Lrointerval {\math_fenced_fenced_start{rightopeninterval}}
727
728\immutable\protected\def\Rinterval {\math_fenced_fenced_stop {interval}}
729\immutable\protected\def\Rointerval {\math_fenced_fenced_stop {openinterval}}
730\immutable\protected\def\Rlointerval {\math_fenced_fenced_stop {leftopeninterval}}
731\immutable\protected\def\Rrointerval {\math_fenced_fenced_stop {rightopeninterval}}
732
733
734
735
736
737
738
739
740
741\popoverloadmode
742
743\installcorenamespace{mathleft}
744\installcorenamespace{mathright}
745\installcorenamespace{mathmiddle}
746
747\pushoverloadmode
748
749
750
751
752
753
754
755
756
757
758\lettonothing\math_fenced_x_p_left
759\lettonothing\math_fenced_x_p_right
760\lettonothing\math_fenced_x_p_middle
761
762\def\math_fenced_x_left
763 {\advanceby\c_math_fence_nesting\plusone
764 \ifx\math_fenced_x_p_left\bgroup\let\math_fenced_x_p_left\letterleftbrace\fi
765 \math_fenced_common\Uleft\c!leftclass\math_fenced_x_p_left\c!leftsource}
766
767\def\math_fenced_x_right
768 {\ifx\math_fenced_x_p_right\egroup\let\math_fenced_x_p_right\letterrightbrace\fi
769 \math_fenced_common\Uright\c!rightclass\math_fenced_x_p_right\c!rightsource
770 \advanceby\c_math_fence_nesting\minusone}
771
772\def\math_fenced_x_middle
773 {\math_fenced_common\Umiddle\c!middleclass\math_fenced_x_p_middle\c!middlesource}
774
775
776
777\protected\def\lfence{\afterassignment\math_fenced_x_left \expandafter\let\expandafter\math_fenced_x_p_left}
778\protected\def\rfence{\afterassignment\math_fenced_x_right \expandafter\let\expandafter\math_fenced_x_p_right}
779\protected\def\mfence{\afterassignment\math_fenced_x_middle\expandafter\let\expandafter\math_fenced_x_p_middle}
780
781\aliased\let\left \lfence
782\aliased\let\right \rfence
783\aliased\let\middle\mfence
784
785\popoverloadmode
786
787
788
789\newconditional\c_math_fenced_unknown \c_math_fenced_unknown\conditionaltrue
790
791
792
793
794
795\permanent\protected\def\installmathfencepair#1#2#3#4
796 {}
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919\pushoverloadmode
920
921\aliased\let\lbrack \lbracket
922\aliased\let\rbrack \rbracket
923\aliased\let\lceiling \lceil
924\aliased\let\rceiling \rceil
925\aliased\let\lparenthesis\lparent
926\aliased\let\rparenthesis\rparent
927\aliased\let\lparen \lparent
928\aliased\let\rparen \rparent
929
930
931
932\aliased\let\Lceil \Lceiling
933\aliased\let\Rceil \Rceiling
934\aliased\let\Lparent\Lparenthesis
935\aliased\let\Rparent\Rparenthesis
936\aliased\let\Lparen \Lparenthesis
937\aliased\let\Rparen \Rparenthesis
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967\aliased\let\textlbar\lbar \aliased\let\mathlbar\Lbar
968\aliased\let\textrbar\lbar \aliased\let\mathrbar\Rbar
969
970\immutable\protected\def\lbar{\mathortext\mathlbar\textlbar}
971\immutable\protected\def\rbar{\mathortext\mathrbar\textrbar}
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992\aliased\let\{\letterleftbrace
993\aliased\let\}\letterrightbrace
994\aliased\let\[\letterleftbracket
995\aliased\let\]\letterrightbracket
996\aliased\let\(\letterleftparenthesis
997\aliased\let\)\letterrightparenthesis
998\aliased\let\|\letterbar
999
1000
1001\popoverloadmode
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013\setnewconstant\bigmathdelimitervariant\plusthree
1014
1015\appendtoks
1016 \bigmathdelimitervariant\mathfenceparameter\c!alternative\relax
1017\to \everysetupmathfence
1018
1019\setupmathfence[\c!alternative=5]
1020
1021\permanent\protected\def\choosemathbig
1022 {\mathortext\math_choosemathbig_math\math_choosemathbig_text}
1023
1024\protected\def\math_choosemathbig_math#1#2
1025 {\math_fenced_force_size\bigmathdelimitervariant{#1}\relax
1026 \Uvextensible
1027 \s!axis
1028 \s!exact
1029 #2
1030 \relax
1031 \c_attr_mathsize\attributeunsetvalue}
1032
1033\protected\def\math_choosemathbig_text#1#2
1034 {\naturalhbox\bgroup
1035 \startimath
1036 \math_choosemathbig_math{#1}{#2}
1037 \nulldelimiterspace\zeropoint
1038 \mathsurround\zeropoint
1039 \stopimath
1040 \egroup}
1041
1042\permanent\protected\def\mathdelimiterstep#1#2
1043 {\begingroup
1044 \math_fenced_force_size\plusone{#1}
1045 \Uvextensible
1046 \s!axis
1047 \s!exact
1048 #2
1049 \relax
1050 \endgroup}
1051
1052\definemathcommand [big] {\choosemathbig1}
1053\definemathcommand [Big] {\choosemathbig2}
1054\definemathcommand [bigg] {\choosemathbig3}
1055\definemathcommand [Bigg] {\choosemathbig4}
1056
1057\definemathcommand [bigl] [\s!open] [one] {\big}
1058\definemathcommand [bigm] [\s!relation] [one] {\big}
1059\definemathcommand [bigr] [\s!close] [one] {\big}
1060\definemathcommand [Bigl] [\s!open] [one] {\Big}
1061\definemathcommand [Bigm] [\s!relation] [one] {\Big}
1062\definemathcommand [Bigr] [\s!close] [one] {\Big}
1063\definemathcommand [biggl] [\s!open] [one] {\bigg}
1064\definemathcommand [biggm] [\s!relation] [one] {\bigg}
1065\definemathcommand [biggr] [\s!close] [one] {\bigg}
1066\definemathcommand [Biggl] [\s!open] [one] {\Bigg}
1067\definemathcommand [Biggm] [\s!relation] [one] {\Bigg}
1068\definemathcommand [Biggr] [\s!close] [one] {\Bigg}
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086\definesystemattribute[mathautofence][public]
1087
1088\let\math_fences_normal_left \left
1089\let\math_fences_normal_right \right
1090\let\math_fences_normal_middle\middle
1091\let\math_fences_normal_both \relax
1092
1093\protected\def\math_fences_auto_left #1{\c_attr_mathautofence\plusone #1\c_attr_mathautofence\attributeunsetvalue}
1094\protected\def\math_fences_auto_right #1{\c_attr_mathautofence\plustwo #1\c_attr_mathautofence\attributeunsetvalue}
1095\protected\def\math_fences_auto_middle#1{\c_attr_mathautofence\plusthree#1\c_attr_mathautofence\attributeunsetvalue}
1096\protected\def\math_fences_auto_both #1{\c_attr_mathautofence\plusfour #1\c_attr_mathautofence\attributeunsetvalue}
1097
1098\permanent\let\autofenceopen \math_fences_auto_left
1099\permanent\let\autofenceclose \math_fences_auto_right
1100\permanent\let\autofenceleft \math_fences_auto_left
1101\permanent\let\autofenceright \math_fences_auto_right
1102\permanent\let\autofencemiddle\math_fences_auto_middle
1103\permanent\let\autofenceboth \math_fences_auto_both
1104
1105
1106
1107
1108\newconditional\c_math_fences_auto
1109
1110\permanent\protected\def\enableautofences
1111 {\clf_enableautofences
1112 \c_math_fences_auto\conditionalfalse
1113 \glet\clf_enableautofences\relax
1114 \enforced\permanent\protected\gdef\enableautofences{\c_math_fences_auto\conditionaltrue}
1115 \enableautofences}
1116
1117\permanent\protected\def\disableautofences
1118 {\c_math_fences_auto\conditionalfalse}
1119
1120\permanent\protected\def\math_fences_used_left
1121 {\ifconditional\c_math_fences_auto
1122 \expandafter\math_fences_auto_left
1123 \else
1124 \expandafter\math_fences_normal_left
1125 \fi}
1126
1127\permanent\protected\def\math_fences_used_right
1128 {\ifconditional\c_math_fences_auto
1129 \expandafter\math_fences_auto_right
1130 \else
1131 \expandafter\math_fences_normal_right
1132 \fi}
1133
1134\permanent\protected\def\math_fences_used_middle
1135 {\ifconditional\c_math_fences_auto
1136 \expandafter\math_fences_auto_middle
1137 \else
1138 \expandafter\math_fences_normal_middle
1139 \fi}
1140
1141\permanent\protected\def\math_fences_used_both
1142 {\ifconditional\c_math_fences_auto
1143 \expandafter\math_fences_auto_both
1144 \else
1145 \expandafter\math_fences_normal_both
1146 \fi}
1147
1148\aliased\let\left \math_fences_used_left
1149\aliased\let\right \math_fences_used_right
1150\aliased\let\middle \math_fences_used_middle
1151\aliased\let\leftorright\math_fences_used_both
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162\permanent\protected\def\startcheckedfences
1163 {\begingroup
1164 \enableautofences}
1165
1166\permanent\protected\def\stopcheckedfences
1167 {\endgroup}
1168
1169\appendtoks
1170 \ifempty\currentmathfence
1171 \ifcstok{\mathfenceparameter\c!state}\v!auto\enableautofences\else\disableautofences\fi
1172 \fi
1173\to \everysetupmathfence
1174
1175\permanent\protected\def\enableautofencemode {\mathcheckfencesmode\plusone}
1176\permanent\protected\def\disableautofencemode{\mathcheckfencesmode\zerocount}
1177
1178\appendtoks
1179 \ifempty\currentmathfence
1180 \ifcstok{\mathfenceparameter\c!method}\v!auto\enableautofencemode\else\disableautofencemode\fi
1181 \fi
1182\to \everysetupmathfence
1183
1184
1185
1186
1187
1188
1189\immutable\Umathchardef\braceld\zerocount \zerocount "FF07A
1190\immutable\Umathchardef\bracerd\zerocount \zerocount "FF07B
1191\immutable\Umathchardef\bracelu\zerocount \zerocount "FF07C
1192\immutable\Umathchardef\braceru\zerocount \zerocount "FF07D
1193
1194
1195
1196\definefont[mathindexfont][Mono sa .2]
1197
1198\def\math_fenced_trace_indeed
1199 {
1200 \beginlocalcontrol
1201 \registerboxanchor
1202 \registeranchorbox
1203 \registeredboxanchor
1204 \plusone
1205 \hbox
1206 \s!anchors \boxanchorpresetcode{depth} \boxanchorpresetcode{height}
1207 \s!yoffset .1\exheight
1208 \s!target \registeredboxanchor
1209 \s!to \zeropoint
1210 {\darkblue\hss\mathindexfont\ruledhbox{\the\c_math_fence_nesting}\hss}
1211 \endlocalcontrol
1212 \s!source \registeredboxanchor
1213 }
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259\installtextracker
1260 {math.fencenesting}
1261 {\let\math_fenced_trace\math_fenced_trace_indeed}
1262 {\let\math_fenced_trace\donothing}
1263
1264\mutable\integerdef\c_math_fence_level\minusone
1265
1266\appendtoks
1267 \integerdef\c_math_fence_level\minusone
1268 \c_math_fence_nesting\zerocount
1269\to \everymathematics
1270
1271
1272
1273\permanent\protected\def\autofences
1274 {\setmathoptions\mathopencode\numexpression
1275 \setmathoptions\mathopencode bor \autoinjectclassoptioncode
1276 \relax
1277 \setmathoptions\mathclosecode\numexpression
1278 \setmathoptions\mathclosecode bor \autoinjectclassoptioncode
1279 \relax
1280 \setmathoptions\mathmiddlecode\numexpression
1281 \setmathoptions\mathmiddlecode bor \autoinjectclassoptioncode
1282 \relax}
1283
1284
1285
1286
1287
1288
1289
1290\definemathfence [tupanddownarrows][\v!text][\c!left="2191,\c!right="2193]
1291\definemathfence [tupdownarrows] [\v!text][\c!left="21C5,\c!right=0]
1292\definemathfence [tdownuparrows] [\v!text][\c!middle="21F5]
1293\definemathfence [tuparrow] [\v!text][\c!middle="2191]
1294\definemathfence [tdownarrow] [\v!text][\c!middle="2193]
1295
1296\protect
1297 |