1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Math Macros Initializations}
15
16
17
18
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\unprotect
61
62
63
64
65
66
67\registerctxluafile{mathini}{}
68\registerctxluafile{mathdim}{}
69\registerctxluafile{mathact}{}
70\registerctxluafile{mathext}{}
71\registerctxluafile{mathvfu}{}
72\registerctxluafile{mathttv}{}
73\registerctxluafile{mathmap}{optimize}
74\registerctxluafile{mathren}{}
75\registerctxluafile{mathnoa}{optimize}
76\registerctxluafile{mathtag}{}
77\registerctxluafile{mathfbk}{}
78\registerctxluafile{mathdir}{}
79\registerctxluafile{mathspa}{}
80
81
82
83
84
85
86
87
88
89
90
91
92
93\newcount\mathnestinglevel
94
95\appendtoks
96 \advance\mathnestinglevel\plusone
97\to \everymathematics
98
99
100
101\def\Umathbotaccent{\Umathaccent \s!bottom }
102\def\Umathtopaccent{\Umathaccent \s!top }
103\def\Umathaccents {\Umathaccent \s!both }
104
105\ifdefined\Umathcharclass \else
106 \def\Umathcharclass{\numexpr\cldcontext{tex.getmathcode(token.scan_int())[1]}\relax}
107 \def\Umathcharfam {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[2]}\relax}
108 \def\Umathcharslot {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[3]}\relax}
109\fi
110
111
112
113\definesystemattribute[mathalphabet] [public]
114\definesystemattribute[mathsize] [public]
115\definesystemattribute[mathpunctuation][public]
116\definesystemattribute[mathgreek] [public]
117\definesystemattribute[mathalternate] [public]
118\definesystemattribute[mathrendering] [public]
119\definesystemattribute[mathcategory] [public]
120\definesystemattribute[mathmode] [public]
121\definesystemattribute[mathitalics] [public]
122\definesystemattribute[mathkernpairs] [public]
123\definesystemattribute[mathbidi] [public]
124\definesystemattribute[mathdomain] [public]
125\definesystemattribute[mathcollapsing] [public]
126\definesystemattribute[mathunstack] [public]
127
128\definesystemattribute[displaymath] [public]
129
130\mathflattenmode 31
131
132\ifdefined\ordlimits\else
133 \let\ordlimits\limits
134\fi
135
136\appendtoks
137 \c_attr_mathmode\plusone
138\to \everydisplay
139
140\appendtoks
141 \c_attr_mathmode \plusone
142 \c_attr_displaymath\plusone
143\to \everybeforedisplayformula
144
145\setnewconstant\defaultmathfamily \zerocount
146
147\unexpanded\def\resetmathattributes{\clf_resetmathattributes}
148
149
150
151\newconditional\indisplaymath
152
153\appendtoks
154 \setfalse\indisplaymath
155\to \everymath
156
157\appendtoks
158 \settrue\indisplaymath
159\to \everydisplay
160
161\def\inlineordisplaymath{\ifconditional\indisplaymath\expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments\fi}
162
163\unexpanded\def\forcedisplaymath
164 {\ifmmode
165 \displaystyle
166 \settrue\indisplaymath
167 \fi}
168
169\unexpanded\def\startforceddisplaymath
170 {\startimath
171 \displaystyle
172 \begingroup
173 \settrue\indisplaymath}
174
175\unexpanded\def\stopforceddisplaymath
176 {\endgroup
177 \stopimath}
178
179\unexpanded\def\startpickupmath
180 {\ifconditional\indisplaymath
181 \startforceddisplaymath
182 \let\stoppickupmath\stopforceddisplaymath
183 \else
184 \startimath
185 \let\stoppickupmath\stopimath
186 \fi}
187
188\let\stoppickupmath\relax
189
190
191
192
193
194
195
196
197
198
199\unexpanded\def\rawmathematics#1
200 {\begingroup
201 \ifmmode
202 \clf_resetmathattributes#1
203 \else
204 \startimath\clf_resetmathattributes#1\stopimath
205 \fi
206 \endgroup}
207
208
209
210
211
212
213
214
215
216
217
218
219
220\installcorenamespace{mathematics}
221
222\installswitchcommandhandler \??mathematics {mathematics} \??mathematics
223
224\unexpanded\def\startmathematics
225 {\doifelsenextoptionalcs\math_mathematics_start_yes\math_mathematics_start_nop}
226
227\installmacrostack\currentmathematics
228
229\unexpanded\def\math_mathematics_start_yes[#1]
230 {\push_macro_currentmathematics
231 \edef\currentmathematics{#1}
232 \the\everyswitchmathematics}
233
234\unexpanded\def\math_mathematics_start_nop
235 {\push_macro_currentmathematics
236 \let\currentmathematics\empty
237 \the\everyswitchmathematics}
238
239\unexpanded\def\stopmathematics
240 {\pop_macro_currentmathematics
241 \the\everyswitchmathematics}
242
243\definemathematics[\v!default]
244
245
246
247\unexpanded\def\mathematics
248 {\doifelsenextoptionalcs\math_m_yes\math_m_nop}
249
250\def\math_m_yes
251 {\relax
252 \ifmmode
253 \expandafter\math_m_yes_math
254 \else
255 \expandafter\math_m_yes_text
256 \fi}
257
258\def\math_m_yes_math[#1]#2
259 {#2}
260
261
262
263
264
265
266
267
268
269
270
271
272
273\def\math_m_yes_text[#1]
274 {\begingroup
275 \ifcondition\validassignment{#1}
276 \setupcurrentmathematics[#1]
277 \else
278 \edef\currentmathematics{#1}
279 \fi
280 \edef\p_openup{\mathematicsparameter\c!openup}
281 \ifx\p_openup\v!yes
282 \expandafter\math_m_yes_text_openedup
283 \else
284 \expandafter\math_m_yes_text_normal
285 \fi}
286
287\def\math_m_yes_text_openedup#1
288 {\setbox\scratchbox\hbox\bgroup
289 \the\everyswitchmathematics\relax
290 \normalstartimath
291 #1
292 \normalstopimath
293 \egroup
294 \ifdim\ht\scratchbox>\strutht
295 \math_inline_openup_start_yes
296 \else\ifdim\dp\scratchbox>\strutdp
297 \math_inline_openup_start_yes
298 \else
299 \math_inline_openup_start_nop
300 \fi\fi
301 \unhbox\scratchbox
302 \math_inline_openup_stop
303 \endgroup}
304
305\def\math_m_yes_text_normal#1
306 {\the\everyswitchmathematics\relax
307 \normalstartimath
308 #1
309 \normalstopimath
310 \endgroup}
311
312\def\math_m_nop#1
313 {\relax
314 \ifmmode
315 #1
316 \else
317 \normalstartimath
318 #1
319 \normalstopimath
320 \fi}
321
322\let\m \mathematics
323\let\math\mathematics
324
325
326
327\newmuskip\defaultthickmuskip \defaultthickmuskip 5mu plus 5mu
328\newmuskip\defaultmedmuskip \defaultmedmuskip 4mu plus 2mu minus 4mu
329\newmuskip\defaultthinmuskip \defaultthinmuskip 3mu
330
331\newmuskip\halfthickmuskip \halfthickmuskip 2.5mu plus 2.5mu
332\newmuskip\halfmedmuskip \halfmedmuskip 2.0mu plus 1.0mu minus 2.0mu
333\newmuskip\halfthinmuskip \halfthinmuskip 1.5mu
334
335\newcount \defaultrelpenalty \defaultrelpenalty 500
336\newcount \defaultbinoppenalty \defaultbinoppenalty 700
337\newcount \defaultprerelpenalty \defaultprerelpenalty 100
338\newcount \defaultprebinoppenalty \defaultprebinoppenalty 100
339\newcount \defaultdisplayprepenalty \defaultdisplayprepenalty 10
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357\startsetups math:spacing:default
358 \thickmuskip \defaultthickmuskip
359 \medmuskip \defaultmedmuskip
360 \thinmuskip \defaultthinmuskip
361 \relpenalty \defaultrelpenalty
362 \binoppenalty \defaultbinoppenalty
363 \prebinoppenalty\maxdimen
364 \prerelpenalty \maxdimen
365\stopsetups
366
367\startsetups math:spacing:split
368 \thickmuskip \defaultthickmuskip
369 \medmuskip \defaultmedmuskip
370 \thinmuskip \defaultthinmuskip
371 \relpenalty \defaultrelpenalty
372 \binoppenalty \defaultbinoppenalty
373 \prebinoppenalty\defaultprebinoppenalty
374 \prerelpenalty \defaultprerelpenalty
375\stopsetups
376
377\startsetups math:spacing:half
378 \thickmuskip \halfthickmuskip
379 \medmuskip \halfmedmuskip
380 \thinmuskip \halfthinmuskip
381 \relpenalty \defaultrelpenalty
382 \binoppenalty \defaultbinoppenalty
383 \prebinoppenalty\maxdimen
384 \prerelpenalty \maxdimen
385\stopsetups
386
387\startsetups math:spacing:tight
388 \ifcase\raggedstatus
389 \thickmuskip \halfthickmuskip
390 \medmuskip \halfmedmuskip
391 \thinmuskip \halfthinmuskip
392 \else
393 \thickmuskip 1\halfthickmuskip
394 \medmuskip 1\halfmedmuskip
395 \thinmuskip 1\halfthinmuskip
396 \fi
397 \relpenalty \defaultrelpenalty
398 \binoppenalty \maxdimen
399 \prebinoppenalty\maxdimen
400 \prerelpenalty \maxdimen
401\stopsetups
402
403\startsetups math:spacing:fixed
404 \ifcase\raggedstatus
405 \thickmuskip \halfthickmuskip
406 \medmuskip \halfmedmuskip
407 \thinmuskip \halfthinmuskip
408 \else
409 \thickmuskip 1\halfthickmuskip
410 \medmuskip 1\halfmedmuskip
411 \thinmuskip 1\halfthinmuskip
412 \fi
413 \relpenalty \maxdimen
414 \binoppenalty \maxdimen
415 \prebinoppenalty\maxdimen
416 \prerelpenalty \maxdimen
417\stopsetups
418
419
420
421\definemathematics[i:default][\c!setups=math:spacing:equal]
422\definemathematics[i:half] [\c!setups=math:spacing:half]
423\definemathematics[i:tight] [\c!setups=math:spacing:tight]
424\definemathematics[i:fixed] [\c!setups=math:spacing:fixed]
425
426
427
428
429
430
431
432
433\unexpanded\def\math_set_attribute #1#2{\ifmmode\clf_setmathattribute{#1}{#2}\fi}
434\unexpanded\def\math_set_alphabet #1{\ifmmode\clf_setmathalphabet{#1}\fi}
435\unexpanded\def\math_set_font_style #1{\ifmmode\clf_setmathstyle{#1}\fi}
436\unexpanded\def\math_set_font_alternate#1{\ifmmode\clf_setmathalternate\defaultmathfamily{#1}\fi}
437
438\installcorenamespace{mathstylealternative}
439
440\unexpanded\def\math_set_font_style_alternate#1
441 {\ifcsname\??mathstylealternative\fontclass:#1\endcsname
442
443 \expandafter\math_set_font_alternate\lastnamedcs
444 \else\ifcsname\??mathstylealternative#1\endcsname
445
446 \expandafter\math_set_font_alternate\lastnamedcs
447 \fi\fi}
448
449\unexpanded\def\setupmathrendering
450 {\dodoubleargument\math_setup_rendering}
451
452\def\math_setup_rendering[#1][#2]
453 {\ifsecondargument
454 \getparameters[\??mathstylealternative#1:][#2]
455 \else
456 \getparameters[\??mathstylealternative][#1]
457 \fi}
458
459\appendtoks
460 \edef\p_stylealternative{\mathematicsparameter\c!stylealternative}
461 \ifx\p_stylealternative\empty\else
462 \clf_presetmathalternate\defaultmathfamily{\p_stylealternative}
463 \fi
464\to \everymathematics
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479\unexpanded\def\mathaltcalligraphic{\math_set_font_alternate{calligraphic}\cal}
480\unexpanded\def\mathaltitalic {\math_set_font_alternate{italic}}
481\unexpanded\def\mathslashedzero {\begingroup\math_set_font_alternate{zero}∅\endgroup}
482\unexpanded\def\mathdotless {\math_set_font_alternate{dotless}}
483\unexpanded\def\mathdotlessi {\begingroup\mathdotless i\endgroup}
484\unexpanded\def\mathdotlessj {\begingroup\mathdotless j\endgroup}
485
486\let\mathaltcal\mathaltcalligraphic
487\let\mathaltit \mathaltitalic
488
489
490\let\textdotlessi \dotlessi \unexpanded\def\autodotlessi {\mathortext\mathdotlessi \textdotlessi}
491\let\textdotlessj \dotlessj \unexpanded\def\autodotlessj {\mathortext\mathdotlessj \textdotlessj}
492
493\appendtoks
494
495 \let\dotlessi \autodotlessi
496 \let\dotlessj \autodotlessj
497\to \everymathematics
498
499\let\setmathattribute \math_set_attribute
500\let\setmathalphabet \math_set_alphabet
501\let\setmathfontstyle \math_set_font_style
502\let\setmathfontalternate \math_set_font_alternate
503\let\setmathfontalternative \math_set_font_alternate
504\let\setmathfontstylealternate \math_set_font_style_alternate
505\let\setmathfontstylealternative\math_set_font_style_alternate
506
507\let\mathalternate \math_set_font_alternate
508
509\unexpanded\def\mathupright {\math_set_attribute\s!regular\s!tf\math_set_font_style_alternate\s!tf}
510\unexpanded\def\mathitalic {\math_set_attribute\s!regular\s!it\math_set_font_style_alternate\s!it}
511\unexpanded\def\mathscript {\math_set_alphabet \s!script \math_set_font_style_alternate\s!script}
512\unexpanded\def\mathfraktur {\math_set_alphabet \s!fraktur \math_set_font_style_alternate\s!fraktur}
513\unexpanded\def\mathblackboard{\math_set_alphabet \s!blackboard \math_set_font_style_alternate\s!blackboard}
514
515\unexpanded\def\mathrm {\math_set_attribute\s!rm\s!tf \math_set_font_style_alternate\s!tf}
516\unexpanded\def\mathss {\math_set_attribute\s!ss\s!tf \math_set_font_style_alternate\s!tf}
517\unexpanded\def\mathtt {\math_set_attribute\s!tt\s!tf \math_set_font_style_alternate\s!tf}
518
519\unexpanded\def\mathtf {\math_set_font_style\s!tf \math_set_font_style_alternate\s!tf}
520\unexpanded\def\mathsl {\math_set_font_style\s!it \math_set_font_style_alternate\s!it}
521\unexpanded\def\mathit {\math_set_font_style\s!it \math_set_font_style_alternate\s!it}
522
523\unexpanded\def\mathbf {\math_set_font_style\s!bf \math_set_font_style_alternate\s!bf}
524\unexpanded\def\mathbs {\math_set_font_style\s!bi \math_set_font_style_alternate\s!bi}
525\unexpanded\def\mathbi {\math_set_font_style\s!bi \math_set_font_style_alternate\s!bi}
526
527\let\mathdefault\mathitalic
528
529\appendtoks
530 \edef\p_default{\mathematicsparameter\c!default}
531 \ifx\p_default\v!normal
532 \let\mathdefault\mathupright
533 \else
534 \let\mathdefault\mathitalic
535 \fi
536\to \everysetupmathematics
537
538\setupmathematics
539 [\c!default=\v!italic]
540
541\let\tfmath\mathtf
542\let\slmath\mathsl
543\let\itmath\mathit
544
545\let\bfmath\mathbf
546\let\bsmath\mathbs
547\let\bimath\mathbi
548
549\let\Bbb\mathblackboard
550
551\unexpanded\def\frak {\ifmmode\expandafter\mathfraktur \fi}
552\unexpanded\def\cal {\ifmmode\expandafter\mathscript \fi}
553\unexpanded\def\bbd {\ifmmode\expandafter\mathblackboard\fi}
554\unexpanded\def\blackboard{\ifmmode\expandafter\mathblackboard\fi}
555\unexpanded\def\fraktur {\ifmmode\expandafter\mathfraktur \fi}
556\unexpanded\def\gothic {\ifmmode\expandafter\mathfraktur \fi}
557
558\unexpanded\def\mathcal #1{{\mathscript #1}}
559\unexpanded\def\mathfrak#1{{\mathfraktur #1}}
560\unexpanded\def\mathbb #1{{\mathblackboard#1}}
561
562\ifdefined\normaltf\else\let\normaltf\tf\fi \unexpanded\def\tf{\ifmmode\mathtf\else\normaltf\fi}
563\ifdefined\normalbf\else\let\normalbf\bf\fi \unexpanded\def\bf{\ifmmode\mathbf\else\normalbf\fi}
564\ifdefined\normalit\else\let\normalit\it\fi \unexpanded\def\it{\ifmmode\mathit\else\normalit\fi}
565\ifdefined\normalsl\else\let\normalsl\sl\fi \unexpanded\def\sl{\ifmmode\mathsl\else\normalsl\fi}
566\ifdefined\normalbi\else\let\normalbi\bi\fi \unexpanded\def\bi{\ifmmode\mathbi\else\normalbi\fi}
567\ifdefined\normalbs\else\let\normalbs\bs\fi \unexpanded\def\bs{\ifmmode\mathbs\else\normalbs\fi}
568
569\unexpanded\def\rm{\ifmmode\mathrm\else\normalrm\fi}
570\unexpanded\def\ss{\ifmmode\mathss\else\normalss\fi}
571\unexpanded\def\tt{\ifmmode\mathtt\else\normaltt\fi}
572
573\ifdefined\mr \else \let\mr\relax \fi
574\ifdefined\mb \else \let\mb\relax \fi
575
576
577
578
579
580
581
582\prependtoks
583 \mathdefault
584\to \everymathematics
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603\newcount\c_math_renderings_attribute
604
605\appendtoks
606 \c_math_renderings_attribute\clf_mathrenderset{\mathematicsparameter\c!symbolset}\relax
607\to \everysetupmathematics
608
609\appendtoks
610 \ifcase\c_math_renderings_attribute\else
611 \c_attr_mathrendering\c_math_renderings_attribute
612 \fi
613\to \everymathematics
614
615\setupmathematics
616 [\c!symbolset=]
617
618
619
620
621
622
623\let\mathboldsymbol\relax
624
625\unexpanded\def\boldsymbol
626 {\mathortext\mathboldsymbol\bold}
627
628
629
630\def\utfmathclass #1{\clf_utfmathclass {#1}}
631\def\utfmathstretch#1{\clf_utfmathstretch{#1}}
632\def\utfmathcommand#1{\clf_utfmathcommand{#1}}
633\def\utfmathfiller #1{\clf_utfmathfiller {#1}}
634
635\def\utfmathcommandabove #1{\clf_utfmathcommandabove {#1}}
636\def\utfmathcommandbelow #1{\clf_utfmathcommandbelow {#1}}
637\def\utfmathcommandfiller#1{\clf_utfmathcommandfiller{#1}}
638
639\unexpanded\def\doifelseutfmathaccent#1{\clf_doifelseutfmathaccent{#1}}
640\unexpanded\def\doifelseutfmathabove #1{\clf_doifelseutfmathabove {#1}}
641\unexpanded\def\doifelseutfmathbelow #1{\clf_doifelseutfmathbelow {#1}}
642\unexpanded\def\doifelseutfmathfiller#1{\clf_doifelseutfmathfiller{#1}}
643\unexpanded\def\doifelseutfmathlimop #1{\clf_doifelseutfmathlimop {#1}}
644
645\let\doifutfmathaccentelse \doifelseutfmathaccent
646\let\doifutfmathaboveelse \doifelseutfmathabove
647\let\doifutfmathbelowelse \doifelseutfmathbelow
648\let\doifutfmathfillerelse \doifelseutfmathfiller
649\let\doifutfmathlimopelse \doifelseutfmathlimop
650
651
652
653\installcorenamespace{mathcodecommand}
654
655\unexpanded\def\mathlimop#1{\mathop{#1}}
656\unexpanded\def\mathbox #1{\dontleavehmode\hbox\Ustartmath\mathsurround\zeropoint#1\Ustopmath}
657\unexpanded\def\mathnolop#1{\mathop{#1}\nolimits}
658
659\let\mathnothing\firstofoneunexpanded
660\let\mathalpha \firstofoneunexpanded
661
662\setnewconstant\mathordcode \zerocount \letvalue{\??mathcodecommand ord}\mathord
663\setnewconstant\mathopcode \plusone \letvalue{\??mathcodecommand op}\mathop
664\setnewconstant\mathbincode \plustwo \letvalue{\??mathcodecommand bin}\mathbin
665\setnewconstant\mathrelcode \plusthree \letvalue{\??mathcodecommand rel}\mathrel
666\setnewconstant\mathopencode \plusfour \letvalue{\??mathcodecommand open}\mathopen
667\setnewconstant\mathclosecode \plusfive \letvalue{\??mathcodecommand close}\mathclose
668\setnewconstant\mathpunctcode \plussix \letvalue{\??mathcodecommand punct}\mathpunct
669\setnewconstant\mathalphacode \plusseven \letvalue{\??mathcodecommand alpha}\mathalpha
670\setnewconstant\mathinnercode \zerocount \letvalue{\??mathcodecommand inner}\mathinner
671\setnewconstant\mathnothingcode \zerocount \letvalue{\??mathcodecommand nothing}\mathnothing
672\setnewconstant\mathlimopcode \plusone \letvalue{\??mathcodecommand limop}\mathlimop
673\setnewconstant\mathnolopcode \plusone \letvalue{\??mathcodecommand nolop}\mathnolop
674\setnewconstant\mathboxcode \zerocount \letvalue{\??mathcodecommand box}\mathbox
675\setnewconstant\mathchoicecode \zerocount
676
677\setnewconstant\mathaccentcode \pluseight
678\setnewconstant\mathradicalcode \plusnine
679
680 \def\mathcodenumber #1{\the\csname math#1code\endcsname}
681\unexpanded\def\mathcodecommand#1{\csname\??mathcodecommand#1\endcsname}
682
683
684
685
686
687
688
689
690
691
692
693
694
695\installcorenamespace{mathcommand}
696
697\unexpanded\def\definemathcommand
698 {\dotripleempty\math_define_command}
699
700\def\math_define_command[#1][#2][#3]#4
701 {\ifthirdargument
702 \edef\nofmathcommandarguments{#3}
703 \ifx\nofmathcommandarguments\v!one
704 \setuvalue{\??mathcommand#1}##1{\mathcodecommand{#2}{#4{##1}}}
705 \else\ifx\nofmathcommandarguments\v!two
706 \setuvalue{\??mathcommand#1}##1##2{\mathcodecommand{#2}{#4{##1}{##2}}}
707 \else
708 \setuvalue{\??mathcommand#1}{\mathcodecommand{#2}{#4}}
709 \fi\fi
710 \else\ifsecondargument
711 \setuvalue{\??mathcommand#1}{\mathcodecommand{#2}{#4}}
712 \else
713 \setuvalue{\??mathcommand#1}{\mathcodecommand{nothing}{#4}}
714 \fi\fi
715 \letcsnamecsname\csname#1\endcsname\csname\??mathcommand#1\endcsname}
716
717\unexpanded\def\mathcommand#1
718 {\begincsname\??mathcommand#1\endcsname}
719
720
721
722
723
724\definemathcommand [joinrel] [rel] {\mkern3mu}
725
726\chardef\c_math_strut"28
727
728\unexpanded\def\math_strut_htdp#1
729 {\s!height\fontcharht#1\c_math_strut
730 \s!depth \fontchardp#1\c_math_strut}
731
732\unexpanded\def\math_strut_normal
733 {\vrule
734 \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}
735 \s!width \zeropoint
736 \relax}
737
738\unexpanded\def\math_strut_visual
739 {\hskip.01\emwidth
740 \vrule
741 \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}
742 \s!width .02\emwidth
743 \relax
744 \hskip.01\emwidth}
745
746\unexpanded\def\showmathstruts
747 {\let\math_strut\math_strut_visual}
748
749\let\math_strut\math_strut_normal
750
751
752
753\definemathcommand [mathstrut] {\math_strut}
754
755
756
757\unexpanded\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits}
758\unexpanded\def\stackrel #1#2{\mathrel{\mathop{#2}\limits{#1}}}
759
760
761
762
763
764
765
766
767\unexpanded\def\mf
768 {\begincsname\fontalternative\endcsname}
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784\unexpanded\def\normalmbox
785 {\normalhbox\bgroup
786 \usemathematicsstyleandcolor\c!textstyle\c!textcolor
787 \dowithnextboxcs\math_mbox_finish\normalhbox}
788
789\def\math_mbox_finish
790 {\flushnextbox
791 \egroup}
792
793\unexpanded\def\mbox
794 {\ifmmode\normalmbox\else\normalhbox\fi}
795
796\unexpanded\def\enablembox
797 {\toksapp\everymathematics{\math_enable_mbox}}
798
799\def\math_enable_mbox
800 {\let\hbox\mbox}
801
802\unexpanded\def\snappedmath#1
803 {\dontleavehmode
804 \begingroup
805 \setbox\scratchbox\normalhbox\bgroup
806 \startimath#1\stopimath
807 \egroup
808 \ht\scratchbox\strutht
809 \dp\scratchbox\strutdp
810 \box\scratchbox
811 \endgroup}
812
813\unexpanded\def\mtext#1
814 {\text{\usemathematicsstyleandcolor\c!textstyle\c!textcolor#1}}
815
816
817
818\let\mathfunction\firstofoneunexpanded
819
820\let\math_tags_function \firstofoneunexpanded
821\let\math_tags_functionlabeltext\mathlabeltext
822
823\let\math_tags_mo\firstofoneunexpanded
824\let\math_tags_mi\firstofoneunexpanded
825
826\unexpanded\def\math_tags_mn#1{\begingroup\mathupright\math_set_o_both#1\endgroup}
827\unexpanded\def\math_tags_ms#1{\begingroup\mathupright\math_set_p_both#1\endgroup}
828
829
830
831
832
833
834\setupmathematics
835 [\c!textstyle=,
836 \c!textcolor=,
837 \c!functionstyle=,
838 \c!functioncolor=]
839
840\unexpanded\def\math_mfunction_styled
841 {\begingroup
842 \usemathematicscolorparameter\c!functioncolor
843 \edef\p_functionstyle{\mathematicsparameter\c!functionstyle}
844 \ifx\p_functionstyle\empty
845 \expandafter\math_mfunction_styled_none
846 \else\ifcsname\??alternativestyle\p_functionstyle\endcsname
847 \doubleexpandafter\math_mfunction_styled_text
848 \else
849 \doubleexpandafter\math_mfunction_styled_math
850 \fi\fi}
851
852\unexpanded\def\math_mfunction_styled_text#1
853
854 {\expandafter\mathoptext\expandafter{\lastnamedcs#1}
855 \endgroup}
856
857\unexpanded\def\math_mfunction_styled_math#1
858 {\p_functionstyle
859 #1
860 \endgroup}
861
862\unexpanded\def\math_mfunction_styled_none#1
863 {\mathupright
864 #1
865 \endgroup}
866
867\unexpanded\def\mfunction#1
868 {\begingroup
869 \math_tags_mfunctiontxt{#1}\c_apply_function
870 \math_mfunction_styled{#1}
871 \endgroup}
872
873\unexpanded\def\mfunctionlabeltext#1
874 {\begingroup
875 \math_tags_mfunctionlab{#1}\c_apply_function
876 \math_mfunction_styled{\mathlabeltext{#1}}
877 \endgroup}
878
879\let\math_tags_mfunctiontxt\gobbletwoarguments
880\let\math_tags_mfunctionlab\gobbletwoarguments
881
882\unexpanded\def\math_tags_mo_indeed#1{\begingroup \c_attr_mathcategory\plusone #1\endgroup}
883\unexpanded\def\math_tags_mi_indeed#1{\begingroup \c_attr_mathcategory\plustwo #1\endgroup}
884\unexpanded\def\math_tags_mn_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusthree\math_set_o_both#1\endgroup}
885\unexpanded\def\math_tags_ms_indeed#1{\begingroup\mathupright\c_attr_mathcategory\plusfour \math_set_p_both#1\endgroup}
886
887\newconditional\c_apply_function
888
889\unexpanded\def\math_tags_apply#1#2
890 {\begingroup
891 \settrue\c_apply_function
892 #1
893 \endgroup
894 \begingroup
895
896 #2
897 \endgroup}
898
899\appendtoks
900 \let\math_tags_mfunctiontxt\clf_tagmfunctiontxt
901 \let\math_tags_mfunctionlab\clf_tagmfunctionlab
902 \let\math_tags_mo \math_tags_mo_indeed
903 \let\math_tags_mi \math_tags_mi_indeed
904 \let\math_tags_mn \math_tags_mn_indeed
905 \let\math_tags_ms \math_tags_ms_indeed
906\to \everyenableelements
907
908\appendtoks
909 \let\mo \math_tags_mo
910 \let\mi \math_tags_mi
911 \let\mn \math_tags_mn
912 \let\ms \math_tags_ms
913 \let\apply\math_tags_apply
914\to\everymathematics
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935\def\currentmscaledstyle{rm}
936
937\unexpanded\def\mscaledtext#1
938 {\mathchoice
939 {\hbox{\csname\currentmscaledstyle\endcsname\tf #1}}
940 {\hbox{\csname\currentmscaledstyle\endcsname\tf #1}}
941 {\hbox{\csname\currentmscaledstyle\endcsname\tfx #1}}
942 {\hbox{\csname\currentmscaledstyle\endcsname\tfxx#1}}}
943
944\unexpanded\def\setmathfunctionstyle#1
945 {\setupmathematics[\c!functionstyle=#1]}
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977\setnewconstant\activemathcharcode "8000
978
979\newtoks\activatedmathcharacters
980
981\unexpanded\def\activatemathcharacter#1
982 {\appendtoks
983 \global\mathcode#1=\activemathcharcode
984 \to \activatedmathcharacters}
985
986\def\activatemathcharacters
987 {\the\activatedmathcharacters}
988
989
990
991\activatemathcharacter\circumflexasciicode
992\activatemathcharacter\underscoreasciicode
993\activatemathcharacter\ampersandasciicode
994
995\appendtoks
996 \edef\p_ampersand{\mathematicsparameter\s!ampersand}
997 \ifx\p_ampersand\v!normal
998 \let\specialmathaligntab\normalmathaligntab
999 \else
1000 \let\specialmathaligntab\mathampersand
1001 \fi
1002\to \everysetupmathematics
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127{ \catcode\circumflexasciicode\othercatcode \glet\othercircumflextoken }
1128{ \catcode\circumflexasciicode\superscriptcatcode \glet\superscriptcircumflextoken }
1129
1130\ifdefined \prime \else
1131 \Umathchardef\prime "0 "0 "2032
1132\fi
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191\bgroup
1192
1193 \catcode\underscoreasciicode\activecatcode
1194 \catcode\circumflexasciicode\activecatcode
1195 \catcode\ampersandasciicode \activecatcode
1196
1197 \glet\specialmathaligntab\normalmathaligntab
1198
1199 \unexpanded\gdef\obeymathcatcodes
1200 {\let \normalsubscript
1201 \let \normalsuperscript
1202 \def \specialmathaligntab
1203 }
1204
1205 \doglobal \appendtoks
1206 \let \normalsubscript
1207 \let \normalsuperscript
1208 \let \specialmathaligntab
1209 \to \everymathematics
1210
1211
1212
1213
1214\egroup
1215
1216\newtoks\everydonknuthmode
1217\newtoks\everynonknuthmode
1218
1219\newconditional \knuthmode
1220
1221\let\nonknuthmode\relax
1222\let\donknuthmode\relax
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
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302\unexpanded\def\enableasciimode
1303 {\clf_enableasciimode}
1304
1305\unexpanded\def\asciimode
1306 {\catcodetable\txtcatcodes
1307 \clf_enableasciimode}
1308
1309\unexpanded\def\startasciimode
1310 {\pushcatcodetable
1311 \catcodetable\txtcatcodes
1312 \clf_enableasciimode}
1313
1314\unexpanded\def\stopasciimode
1315 {\popcatcodetable}
1316
1317
1318
1319\def\nulloperator{\mathortext{\mathop{\emptyhbox}}{\emptyhbox}}
1320
1321
1322
1323\def\math_basics_check_compact
1324 {\doifelse{\mathematicsparameter\c!compact}\v!yes
1325 \enabledirectives\disabledirectives[math.virtual.optional]}
1326
1327\appendtoks
1328 \ifx\currentmathematics\empty
1329 \math_basics_check_compact
1330 \fi
1331\to \everysetupmathematics
1332
1333\setupmathematics
1334 [\c!compact=\v!no]
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367\newconditional\c_math_right_to_left
1368
1369\installcorenamespace{mathaligndirection}
1370
1371\setvalue{\??mathaligndirection r2l}{\settrue\c_math_right_to_left}
1372\setvalue{\??mathaligndirection\v!righttoleft}{\settrue\c_math_right_to_left}
1373
1374\appendtoks
1375 \ifcsname\??mathaligndirection\mathematicsparameter\c!align\endcsname
1376 \lastnamedcs
1377 \else
1378 \setfalse\c_math_right_to_left
1379 \fi
1380\to \everyswitchmathematics
1381
1382\unexpanded\def\math_basics_synchronize_direction
1383 {\mathdirection\ifconditional\c_math_right_to_left\directionrighttoleft\else\directionlefttoright\fi}
1384
1385
1386
1387
1388\appendtoks
1389 \math_basics_synchronize_direction
1390\to \everyswitchmathematics
1391
1392
1393
1394\installcorenamespace {mathbidi}
1395
1396\newcount\c_math_bidi
1397
1398\def\math_bidi_enable {\clf_setmathdirection\plusone \relax\c_math_bidi\plusone}
1399\def\math_bidi_disable{\clf_setmathdirection\zerocount\relax\c_math_bidi\attributeunsetvalue}
1400
1401\letvalue{\??mathbidi\v!yes}\math_bidi_enable
1402\letvalue{\??mathbidi\v!no }\math_bidi_disable
1403
1404\appendtoks
1405 \edef\p_bidi{\mathematicsparameter\c!bidi}
1406 \ifcsname\??mathbidi\p_bidi\endcsname\lastnamedcs\else\math_bidi_disable\fi
1407\to \everysetupmathematics
1408
1409\appendtoks
1410 \c_attr_mathbidi\ifconditional\c_math_right_to_left\c_math_bidi\else\attributeunsetvalue\fi
1411\to \everyswitchmathematics
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427\installcorenamespace{mathgreek}
1428
1429\newconstant\c_math_greek_attribute
1430
1431\setvalue{\??mathgreek\v!none }{1}
1432\setvalue{\??mathgreek\v!normal}{2}
1433\setvalue{\??mathgreek\v!italic}{3}
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449\appendtoks
1450 \edef\p_sygreek{\mathematicsparameter\s!sygreek}
1451 \edef\p_lcgreek{\mathematicsparameter\s!lcgreek}
1452 \edef\p_ucgreek{\mathematicsparameter\s!ucgreek}
1453 \c_math_greek_attribute"
1454 \ifcsname\??mathgreek\p_sygreek\endcsname\lastnamedcs\else1\fi
1455 \ifcsname\??mathgreek\p_lcgreek\endcsname\lastnamedcs\else1\fi
1456 \ifcsname\??mathgreek\p_ucgreek\endcsname\lastnamedcs\else1\fi
1457 \relax
1458 \ifcase\c_math_greek_attribute
1459 \c_math_greek_attribute\attributeunsetvalue
1460 \fi
1461\to \everyswitchmathematics
1462
1463
1464
1465\unexpanded\def\mathgreekupright{\c_attr_mathgreek"222\relax}
1466\unexpanded\def\mathgreekitalic {\c_attr_mathgreek"333\relax}
1467\unexpanded\def\mathgreekdefault{\c_attr_mathgreek"000\relax}
1468
1469\let\mathgreeknormal\mathgreekupright
1470\let\mathgreeknone \mathgreekdefault
1471
1472\appendtoks
1473 \c_attr_mathgreek\c_math_greek_attribute
1474\to \everymathematics
1475
1476\setupmathematics
1477 [\s!sygreek=\v!normal,
1478 \s!lcgreek=\v!italic,
1479 \s!ucgreek=\v!normal]
1480
1481
1482
1483\installcorenamespace{mathcollapsing}
1484
1485\setnewconstant\c_math_collapsing_attribute\attributeunsetvalue
1486
1487\letvalue{\??mathcollapsing 1}\plusone
1488\letvalue{\??mathcollapsing 2}\plustwo
1489\letvalue{\??mathcollapsing 3}\plusthree
1490\letvalue{\??mathcollapsing\v!none }\attributeunsetvalue
1491\letvalue{\??mathcollapsing\v!reset}\attributeunsetvalue
1492
1493\def\math_collapsing_initialize
1494 {\ifnum\c_math_collapsing_attribute=\attributeunsetvalue \else
1495 \clf_initializemathcollapsing
1496 \glet\math_collapsing_initialize\relax
1497 \fi}
1498
1499\appendtoks
1500 \edef\p_collapsing{\mathematicsparameter\s!collapsing}
1501 \c_math_collapsing_attribute
1502 \ifcsname\??mathcollapsing\p_collapsing\endcsname\lastnamedcs\else\attributeunsetvalue\fi
1503 \relax
1504\to \everyswitchmathematics
1505
1506\appendtoks
1507 \math_collapsing_initialize
1508 \c_attr_mathcollapsing\c_math_collapsing_attribute
1509\to \everymathematics
1510
1511\setupmathematics
1512 [\s!collapsing=1]
1513
1514
1515
1516
1517
1518
1519\installcorenamespace{mathitalics}
1520
1521\setnewconstant\c_math_italics_attribute\attributeunsetvalue
1522
1523\letvalue{\??mathitalics 1}\plusone
1524\letvalue{\??mathitalics 2}\plustwo
1525\letvalue{\??mathitalics 3}\plusthree
1526\letvalue{\??mathitalics 4}\plusfour
1527\letvalue{\??mathitalics\v!none }\attributeunsetvalue
1528\letvalue{\??mathitalics\v!reset}\attributeunsetvalue
1529
1530\def\math_italics_initialize
1531 {\ifnum\c_math_italics_attribute=\attributeunsetvalue \else
1532 \clf_initializemathitalics
1533 \glet\math_italics_initialize\relax
1534 \fi}
1535
1536\appendtoks
1537 \edef\p_italics{\mathematicsparameter\s!italics}
1538 \c_math_italics_attribute
1539 \ifcsname\??mathitalics\p_italics\endcsname\lastnamedcs\else\attributeunsetvalue\fi
1540 \relax
1541
1542\to \everyswitchmathematics
1543
1544\appendtoks
1545 \math_italics_initialize
1546 \c_attr_mathitalics\c_math_italics_attribute
1547\to \everymathematics
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566\installcorenamespace{mathkernpairs}
1567
1568\setnewconstant\c_math_kernpairs_attribute\attributeunsetvalue
1569
1570\def\math_kernpairs_initialize
1571 {\ifnum\c_math_kernpairs_attribute=\attributeunsetvalue \else
1572 \clf_initializemathkernpairs
1573 \glet\math_kernpairs_initialize\relax
1574 \fi}
1575
1576\appendtoks
1577 \edef\p_kernpairs{\mathematicsparameter\s!kernpairs}
1578 \c_math_kernpairs_attribute\ifx\p_kernpairs\v!yes\plusone\else\attributeunsetvalue\fi\relax
1579\to \everyswitchmathematics
1580
1581\appendtoks
1582 \math_kernpairs_initialize
1583 \c_attr_mathkernpairs\c_math_kernpairs_attribute
1584\to \everymathematics
1585
1586\setupmathematics
1587 [\s!kernpairs=\v!no]
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668\setnewconstant\c_math_comma "002C
1669\setnewconstant\c_math_period "002E
1670
1671\setnewconstant\c_math_semicolon"003B
1672\setnewconstant\c_math_special "8000
1673
1674\def\math_set_o_comma {\Umathcode\c_math_comma \mathordcode \zerocount\c_math_comma}
1675\def\math_set_p_comma {\Umathcode\c_math_comma \mathpunctcode\zerocount\c_math_comma}
1676\def\math_set_o_period {\Umathcode\c_math_period \mathordcode \zerocount\c_math_period}
1677\def\math_set_p_period {\Umathcode\c_math_period \mathpunctcode\zerocount\c_math_period}
1678\def\math_set_o_semicolon{\Umathcode\c_math_semicolon\mathordcode \zerocount\c_math_semicolon}
1679\def\math_set_p_semicolon{\Umathcode\c_math_semicolon\mathpunctcode\zerocount\c_math_semicolon}
1680
1681\edef\math_set_o_both {\math_set_o_period\math_set_o_comma}
1682\edef\math_set_p_both {\math_set_p_period\math_set_p_comma}
1683
1684\unexpanded\def\math_punctuation_nop_comma {\begingroup\math_set_p_comma ,\endgroup}
1685\unexpanded\def\math_punctuation_nop_period {\begingroup\math_set_o_period .\endgroup}
1686\unexpanded\def\math_punctuation_nop_semicolon{\begingroup\math_set_p_semicolon;\endgroup}
1687
1688\unexpanded\def\math_punctuation_all_comma {\futurelet\nexttoken\math_punctuation_comma_next}
1689\unexpanded\def\math_punctuation_all_period {\futurelet\nexttoken\math_punctuation_period_next}
1690\unexpanded\def\math_punctuation_all_semicolon{\futurelet\nexttoken\math_punctuation_semicolon_next}
1691
1692 \let\math_punctuation_yes_comma \math_punctuation_all_comma
1693 \let\math_punctuation_yes_period \math_punctuation_nop_period
1694 \let\math_punctuation_yes_semicolon\math_punctuation_all_semicolon
1695
1696\def\math_punctuation_comma_next {\begingroup\Umathcode\c_math_comma \ifx\nexttoken\blankspace\mathpunctcode\else\mathordcode\fi\zerocount\c_math_comma ,\endgroup}
1697\def\math_punctuation_period_next {\begingroup\Umathcode\c_math_period \ifx\nexttoken\blankspace\mathpunctcode\else\mathordcode\fi\zerocount\c_math_period .\endgroup}
1698\def\math_punctuation_semicolon_next{\begingroup\Umathcode\c_math_semicolon\ifx\nexttoken\blankspace\mathpunctcode\else\mathordcode\fi\zerocount\c_math_semicolon;\endgroup}
1699
1700\installcorenamespace {mathautopunctuation}
1701
1702\bgroup
1703
1704 \catcode\c_math_comma \activecatcode
1705 \catcode\c_math_period \activecatcode
1706 \catcode\c_math_semicolon\activecatcode
1707
1708 \setgvalue{\??mathautopunctuation\v!no}
1709 {\let,\math_punctuation_nop_comma
1710 \let.\math_punctuation_nop_period
1711 \let;\math_punctuation_nop_semicolon}
1712
1713
1714
1715
1716
1717
1718
1719 \setgvalue{\??mathautopunctuation\v!yes}
1720 {\let,\math_punctuation_yes_comma
1721 \let.\math_punctuation_yes_period
1722 \let;\math_punctuation_nop_semicolon}
1723
1724 \setgvalue{\??mathautopunctuation\v!all}
1725 {\let,\math_punctuation_all_comma
1726 \let.\math_punctuation_all_period
1727 \let;\math_punctuation_nop_semicolon}
1728
1729 \setgvalue{\??mathautopunctuation comma}
1730 {\let,\math_punctuation_yes_comma
1731 \let.\math_punctuation_yes_period
1732 \let;\math_punctuation_nop_semicolon}
1733
1734 \setgvalue{\??mathautopunctuation\v!yes\string,semicolon}
1735 {\let,\math_punctuation_yes_comma
1736 \let.\math_punctuation_yes_period
1737 \let;\math_punctuation_yes_semicolon}
1738
1739 \setgvalue{\??mathautopunctuation comma\string,semicolon}
1740 {\let,\math_punctuation_yes_comma
1741 \let.\math_punctuation_yes_period
1742 \let;\math_punctuation_yes_semicolon}
1743
1744 \setgvalue{\??mathautopunctuation\v!all\string,semicolon}
1745 {\let,\math_punctuation_all_comma
1746 \let.\math_punctuation_all_period
1747 \let;\math_punctuation_all_semicolon}
1748
1749\egroup
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761\appendtoks
1762 \mathcode\c_math_comma \c_math_special
1763 \mathcode\c_math_period \c_math_special
1764 \mathcode\c_math_semicolon\c_math_special
1765 \begincsname\??mathautopunctuation\mathematicsparameter\c!autopunctuation\endcsname
1766\to \everymathematics
1767
1768\appendtoks
1769 \ifcsname\??mathautopunctuation\mathematicsparameter\c!autopunctuation\endcsname \else
1770 \letmathematicsparameter\c!autopunctuation\v!no
1771 \fi
1772\to \everysetupmathematics
1773
1774\def\enablemathpunctuation {\csname\??mathautopunctuation\v!no \endcsname}
1775\def\disablemathpunctuation{\csname\??mathautopunctuation\v!yes\endcsname}
1776
1777\setupmathematics
1778 [\c!autopunctuation=\v!no]
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832\def\uncramped#1
1833 {{\ifcase\normalmathstyle
1834 \or \displaystyle \or
1835 \or \textstyle \or
1836 \or \scriptstyle \or
1837 \or \scriptscriptstyle \fi
1838 #1}}
1839
1840\def\cramped#1
1841 {{\ifcase\normalmathstyle
1842 \crampeddisplaystyle \or \or
1843 \crampedtextstyle \or \or
1844 \crampedscriptstyle \or \or
1845 \crampedscriptscriptstyle \fi
1846 #1}}
1847
1848\def\triggermathstyle#1
1849 {\ifcase\numexpr#1\relax
1850 \displaystyle \or
1851 \crampeddisplaystyle \or
1852 \textstyle \or
1853 \crampedtextstyle \or
1854 \scriptstyle \or
1855 \crampedscriptstyle \or
1856 \scriptscriptstyle \or
1857 \crampedscriptscriptstyle \else
1858
1859 \fi}
1860
1861\let\mathstyletrigger\triggermathstyle
1862
1863\def\triggeredmathstyleparameter#1
1864 {\ifcase\numexpr\normalmathstyle\relax
1865 #1\displaystyle \or
1866 #1\crampeddisplaystyle \or
1867 #1\textstyle \or
1868 #1\crampedtextstyle \or
1869 #1\scriptstyle \or
1870 #1\crampedscriptstyle \or
1871 #1\scriptscriptstyle \or
1872 #1\crampedscriptscriptstyle \else
1873
1874 \fi}
1875
1876\def\mathstylefont#1
1877 {\ifcase\numexpr#1\relax
1878 \textfont \or
1879 \textfont \or
1880 \textfont \or
1881 \textfont \or
1882 \scriptfont \or
1883 \scriptfont \or
1884 \scriptscriptfont \or
1885 \scriptscriptfont \else
1886 \textfont
1887 \fi\fam}
1888
1889\def\somemathstylefont#1
1890 {\ifcase\numexpr#1\relax
1891 \textfont \or
1892 \textfont \or
1893 \textfont \or
1894 \textfont \or
1895 \scriptfont \or
1896 \scriptfont \or
1897 \scriptscriptfont \or
1898 \scriptscriptfont \else
1899 \textfont
1900 \fi}
1901
1902\def\mathsmallstylefont#1
1903 {\ifcase\numexpr#1\relax
1904 \scriptfont \or
1905 \scriptfont \or
1906 \scriptfont \or
1907 \scriptfont \or
1908 \scriptscriptfont \or
1909 \scriptscriptfont \or
1910 \scriptscriptfont \or
1911 \scriptscriptfont \else
1912 \scriptfont
1913 \fi\fam}
1914
1915\def\mathstyleface#1
1916 {\ifcase\numexpr#1\relax
1917 \textface \or
1918 \textface \or
1919 \textface \or
1920 \textface \or
1921 \scriptface \or
1922 \scriptface \or
1923 \scriptscriptface \or
1924 \scriptscriptface \else
1925 \textface
1926 \fi}
1927
1928\def\mathsmallstyleface#1
1929 {\ifcase\numexpr#1\relax
1930 \scriptface \or
1931 \scriptface \or
1932 \scriptface \or
1933 \scriptface \or
1934 \scriptscriptface \or
1935 \scriptscriptface \or
1936 \scriptscriptface \or
1937 \scriptscriptface \else
1938 \scriptface
1939 \fi}
1940
1941\def\mathstylecommand#1#2#3
1942 {\ifcase\numexpr\normalmathstyle\relax
1943 \expandafter#1\or
1944 \expandafter#1\or
1945 \expandafter#1\or
1946 \expandafter#1\or
1947 \expandafter#2\or
1948 \expandafter#2\or
1949 \expandafter#3\or
1950 \expandafter#3\else
1951 \expandafter#1\fi}
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966\unexpanded\def\verbosemathstyle#1
1967 {{\normalexpanded{\relax\darkgray\ttxx[\number#1:\ifcase\numexpr#1\relax
1968 display\or
1969 crampeddisplay\or
1970 text\or
1971 crampedtext\or
1972 script\or
1973 crampedscript\or
1974 scriptscript\or
1975 crampedscriptscript\else
1976 unknown\fi]}}}
1977
1978\unexpanded\def\showmathstyle{\verbosemathstyle\normalmathstyle}
1979
1980
1981
1982\def\mathcharwd{\fontcharwd\mathstylefont\normalmathstyle}
1983\def\mathcharht{\fontcharht\mathstylefont\normalmathstyle}
1984\def\mathchardp{\fontchardp\mathstylefont\normalmathstyle}
1985
1986
1987
1988\def\mathexheight
1989 {\fontdimen
1990 \plusfive
1991 \ifcase\numexpr\normalmathstyle\relax
1992 \textfont \or
1993 \textfont \or
1994 \textfont \or
1995 \textfont \or
1996 \scriptfont \or
1997 \scriptfont \or
1998 \scriptscriptfont \or
1999 \scriptscriptfont \else
2000 \textfont
2001 \fi
2002 \zerocount}
2003
2004\def\mathemwidth
2005 {\fontdimen
2006 \plussix
2007 \ifcase\numexpr\normalmathstyle\relax
2008 \textfont \or
2009 \textfont \or
2010 \textfont \or
2011 \textfont \or
2012 \scriptfont \or
2013 \scriptfont \or
2014 \scriptscriptfont \or
2015 \scriptscriptfont \else
2016 \textfont
2017 \fi
2018 \zerocount}
2019
2020
2021
2022\def\mathpalette#1#2
2023 {\mathchoice
2024 {#1\displaystyle {#2}}
2025 {#1\textstyle {#2}}
2026 {#1\scriptstyle {#2}}
2027 {#1\scriptscriptstyle{#2}}}
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043\unexpanded\def\mathstylehbox#1#
2044 {\math_style_hbox{#1}}
2045
2046\unexpanded\def\math_style_hbox#1#2
2047 {\normalexpanded{\hbox#1\bgroup
2048 \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#2\stopimath\egroup}
2049
2050\unexpanded\def\mathstylevbox#1
2051 {\normalexpanded{\vbox\bgroup
2052 \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup}
2053
2054\unexpanded\def\mathstylevcenter#1
2055 {\normalexpanded{\vcenter\bgroup
2056 \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup}
2057
2058\unexpanded\def\mathstylevcenteredhbox#1
2059 {\normalexpanded{\vcenter\bgroup\hbox\bgroup
2060 \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup\egroup}
2061
2062\unexpanded\def\mathstylevcenteredvbox#1
2063 {\normalexpanded{\vcenter\bgroup\vbox\bgroup
2064 \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup\egroup}
2065
2066\unexpanded\def\setmathsmalltextbox#1#2#
2067 {\normalizebodyfontsize\m_math_text_choice_face{\mathsmallstyleface\normalmathstyle}
2068 \setbox#1#2\bgroup
2069 \font_basics_switchtobodyfont\m_math_text_choice_face
2070 \let\next}
2071
2072\unexpanded\def\setmathtextbox#1#2#
2073 {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}
2074 \setbox#1#2\bgroup
2075 \font_basics_switchtobodyfont\m_math_text_choice_face
2076 \let\next}
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099\def\triggerdisplaystyle
2100 {\ifcase\normalmathstyle\relax
2101 \displaystyle \or
2102 \crampeddisplaystyle \or
2103 \displaystyle \or
2104 \crampeddisplaystyle \or
2105 \displaystyle \or
2106 \crampeddisplaystyle \or
2107 \displaystyle \or
2108 \crampeddisplaystyle \or
2109 \fi}
2110
2111\def\triggertextstyle
2112 {\ifcase\normalmathstyle\relax
2113 \textstyle \or
2114 \crampedtextstyle \or
2115 \textstyle \or
2116 \crampedtextstyle \or
2117 \textstyle \or
2118 \crampedtextstyle \or
2119 \textstyle \or
2120 \crampedtextstyle \else
2121 \fi}
2122
2123\def\triggerscriptstyle
2124 {\ifcase\normalmathstyle\relax
2125 \scriptstyle \or
2126 \crampedscriptstyle \or
2127 \scriptstyle \or
2128 \crampedscriptstyle \or
2129 \scriptstyle \or
2130 \crampedscriptstyle \or
2131 \scriptstyle \or
2132 \crampedscriptstyle \or
2133 \fi}
2134
2135\def\triggerscriptscriptstyle
2136 {\ifcase\normalmathstyle\relax
2137 \scriptscriptstyle \or
2138 \crampedscriptscriptstyle \or
2139 \scriptscriptstyle \or
2140 \crampedscriptscriptstyle \or
2141 \scriptscriptstyle \or
2142 \crampedscriptscriptstyle \or
2143 \scriptscriptstyle \or
2144 \crampedscriptscriptstyle \or
2145 \fi}
2146
2147\def\triggeruncrampedstyle
2148 {\ifcase\normalmathstyle\relax
2149 \or \displaystyle \or
2150 \or \textstyle \or
2151 \or \scriptstyle \or
2152 \or \scriptscriptstyle \fi}
2153
2154\def\triggercrampedstyle
2155 {\ifcase\normalmathstyle\relax
2156 \crampeddisplaystyle \or \or
2157 \crampedtextstyle \or \or
2158 \crampedscriptstyle \or \or
2159 \crampedscriptscriptstyle \fi}
2160
2161\def\triggersmallstyle
2162 {\ifcase\normalmathstyle\relax
2163 \scriptstyle \or
2164 \crampedscriptstyle \or
2165 \scriptstyle \or
2166 \crampedscriptstyle \or
2167 \scriptscriptstyle \or
2168 \crampedscriptscriptstyle \or
2169 \scriptscriptstyle \or
2170 \crampedscriptscriptstyle \or
2171 \fi}
2172
2173\def\triggeruncrampedsmallstyle
2174 {\ifcase\normalmathstyle\relax
2175 \scriptstyle \or
2176 \scriptstyle \or
2177 \scriptstyle \or
2178 \scriptstyle \or
2179 \scriptscriptstyle \or
2180 \scriptscriptstyle \or
2181 \scriptscriptstyle \or
2182 \scriptscriptstyle \or
2183 \fi}
2184
2185\def\triggercrampedsmallstyle
2186 {\ifcase\normalmathstyle\relax
2187 \crampedscriptstyle \or
2188 \crampedscriptstyle \or
2189 \crampedscriptstyle \or
2190 \crampedscriptstyle \or
2191 \crampedscriptscriptstyle \or
2192 \crampedscriptscriptstyle \or
2193 \crampedscriptscriptstyle \or
2194 \crampedscriptscriptstyle \or
2195 \fi}
2196
2197\def\triggerbigstyle
2198 {\ifcase\normalmathstyle\relax
2199 \displaystyle \or
2200 \crampeddisplaystyle \or
2201 \textstyle \or
2202 \crampedtextstyle \or
2203 \textstyle \or
2204 \crampedtextstyle \or
2205 \scriptstyle \or
2206 \crampedscriptstyle \or
2207 \fi}
2208
2209\def\triggeruncrampedbigstyle
2210 {\ifcase\normalmathstyle\relax
2211 \displaystyle \or
2212 \displaystyle \or
2213 \textstyle \or
2214 \textstyle \or
2215 \textstyle \or
2216 \textstyle \or
2217 \scriptstyle \or
2218 \scriptstyle \or
2219 \fi}
2220
2221\def\triggercrampedbigstyle
2222 {\ifcase\normalmathstyle\relax
2223 \crampeddisplaystyle \or
2224 \crampeddisplaystyle \or
2225 \crampedtextstyle \or
2226 \crampedtextstyle \or
2227 \crampedtextstyle \or
2228 \crampedtextstyle \or
2229 \crampedscriptstyle \or
2230 \crampedscriptstyle \or
2231 \fi}
2232
2233\newcount\c_math_saved_style
2234
2235\unexpanded\def\pushmathstyle
2236 {\c_math_saved_style\mathstyle}
2237
2238\unexpanded\def\popmathstyle
2239 {\ifnum\mathstyle=\c_math_saved_style\else
2240 \triggermathstyle\c_math_saved_style
2241 \fi}
2242
2243\installcorenamespace{mathstylecommand}
2244\installcorenamespace{mathstylecache}
2245
2246\newconstant\c_math_styles_state_style
2247\newconstant\c_math_styles_state_cramped
2248\newconstant\c_math_styles_state_size
2249
2250\def\math_style_add_to_cache_choice {
2251 \ifcase\c_math_styles_state_size
2252 \ifcase\c_math_styles_state_style
2253 \ifcase\c_math_styles_state_cramped
2254 \relax \or
2255 \noexpand\triggeruncrampedstyle \or
2256 \noexpand\triggercrampedstyle \fi
2257 \or\ifcase\c_math_styles_state_cramped
2258 \noexpand\triggerdisplaystyle \or
2259 \displaystyle \or
2260 \crampeddisplaystyle \fi
2261 \or\ifcase\c_math_styles_state_cramped
2262 \noexpand\triggertextstyle \or
2263 \textstyle \or
2264 \crampedtextstyle \fi
2265 \or\ifcase\c_math_styles_state_cramped
2266 \noexpand\triggerscriptstyle \or
2267 \scriptstyle \or
2268 \crampedscriptstyle \fi
2269 \or\ifcase\c_math_styles_state_cramped
2270 \noexpand\triggerscriptscriptstyle \or
2271 \scriptscriptstyle \or
2272 \crampedscriptscriptstyle \fi
2273 \fi
2274 \or
2275 \ifcase\c_math_styles_state_style
2276 \ifcase\c_math_styles_state_cramped
2277 \noexpand\triggersmallstyle \or
2278 \noexpand\triggeruncrampedsmallstyle \or
2279 \noexpand\triggercrampedsmallstyle \fi
2280 \or\ifcase\c_math_styles_state_cramped
2281 \noexpand\triggerscriptstyle \or
2282 \scriptstyle \or
2283 \crampedscriptstyle \fi
2284 \or\ifcase\c_math_styles_state_cramped
2285 \noexpand\triggerscriptstyle \or
2286 \scriptstyle \or
2287 \crampedscriptstyle \fi
2288 \or\ifcase\c_math_styles_state_cramped
2289 \noexpand\triggerscriptscriptstyle \or
2290 \scriptscriptstyle \or
2291 \crampedscriptscriptstyle \fi
2292 \or\ifcase\c_math_styles_state_cramped
2293 \noexpand\triggerscriptscriptstyle \or
2294 \scriptscriptstyle \or
2295 \crampedscriptscriptstyle \fi
2296 \fi
2297 \or
2298 \ifcase\c_math_styles_state_style
2299 \ifcase\c_math_styles_state_cramped
2300 \noexpand\triggerbigstyle \or
2301 \noexpand\triggeruncrampedbigstyle \or
2302 \noexpand\triggercrampedbigstyle \fi
2303 \or\ifcase\c_math_styles_state_cramped
2304 \noexpand\triggerdisplaystyle \or
2305 \displaystyle \or
2306 \crampeddisplaystyle \fi
2307 \or\ifcase\c_math_styles_state_cramped
2308 \noexpand\triggertextstyle \or
2309 \textstyle \or
2310 \crampedtextstyle \fi
2311 \or\ifcase\c_math_styles_state_cramped
2312 \noexpand\triggertextstyle \or
2313 \textstyle \or
2314 \crampedtextstyle \fi
2315 \or\ifcase\c_math_styles_state_cramped
2316 \noexpand\triggerscriptstyle \or
2317 \scriptstyle \or
2318 \crampedscriptstyle \fi
2319 \fi
2320 \fi
2321}
2322
2323\unexpanded\def\math_style_set#1
2324 {\edef\m_math_style_asked{#1}
2325 \ifx\m_math_style_asked\empty \else
2326 \math_style_set_indeed
2327 \fi}
2328
2329\let\setmathstyle\math_style_set
2330
2331\def\installmathstyle#1#2
2332 {\ifcsname\??mathstylecommand#1\endcsname \else
2333 \setvalue{\??mathstylecommand#1}{#2}
2334 \fi}
2335
2336\def\math_style_collect#1
2337 {\csname\??mathstylecommand#1\endcsname}
2338
2339\setvalue{\??mathstylecommand\s!display }{\c_math_styles_state_style \plusone}
2340\setvalue{\??mathstylecommand\s!text }{\c_math_styles_state_style \plustwo}
2341\setvalue{\??mathstylecommand\s!script }{\c_math_styles_state_style \plusthree}
2342\setvalue{\??mathstylecommand\s!scriptscript}{\c_math_styles_state_style \plusfour}
2343
2344\setvalue{\??mathstylecommand\s!uncramped }{\c_math_styles_state_cramped\plusone}
2345\setvalue{\??mathstylecommand\s!cramped }{\c_math_styles_state_cramped\plustwo}
2346\setvalue{\??mathstylecommand\v!normal }{\c_math_styles_state_cramped\plusone}
2347\setvalue{\??mathstylecommand\v!packed }{\c_math_styles_state_cramped\plustwo}
2348
2349\setvalue{\??mathstylecommand\v!small }{\c_math_styles_state_size \plusone}
2350\setvalue{\??mathstylecommand\v!big }{\c_math_styles_state_size \plustwo}
2351
2352\unexpanded\def\setupmathstyle[#1]
2353 {\edef\m_math_style_asked{#1}
2354 \ifx\m_math_style_asked\empty \else
2355 \math_style_set_indeed
2356 \fi}
2357
2358\unexpanded\def\usemathstyleparameter#1
2359 {\edef\m_math_style_asked{#1\c!mathstyle}
2360 \ifx\m_math_style_asked\empty \else
2361 \math_style_set_indeed
2362 \fi}
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372\installcorenamespace {mathstyle}
2373
2374\unexpanded\def\definemathstyle
2375 {\dodoubleargument\math_style_define}
2376
2377\def\math_style_define[#1][#2]
2378 {\c_math_styles_state_style \zerocount
2379 \c_math_styles_state_cramped\zerocount
2380 \c_math_styles_state_size \zerocount
2381 \rawprocesscommacommand[#2]\math_style_collect
2382 \expandafter\let\csname\??mathstyle#1\normalexpanded{\endcsname\math_style_add_to_cache_choice}}
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410\def\math_style_set_indeed
2411 {\ifcsname\??mathstyle\m_math_style_asked\endcsname
2412 \lastnamedcs
2413 \else
2414 \math_style_set_mathstyle_mathstyle
2415 \fi}
2416
2417\def\math_style_set_mathstyle_mathstyle
2418 {\ifcsname\??mathstylecache\m_math_style_asked\endcsname
2419 \lastnamedcs
2420 \else
2421 \math_style_set_mathstyle_mathstylecache
2422 \fi}
2423
2424\def\math_style_set_mathstyle_mathstylecache
2425 {\c_math_styles_state_style \zerocount
2426 \c_math_styles_state_cramped\zerocount
2427 \c_math_styles_state_size \zerocount
2428 \rawprocesscommacommand[\m_math_style_asked]\math_style_collect
2429 \expandafter\glet\csname\??mathstylecache\m_math_style_asked\normalexpanded{\endcsname\math_style_add_to_cache_choice}
2430 \csname\??mathstylecache\m_math_style_asked\endcsname}
2431
2432\letvalue{\??mathstyle \??mathstyle }\math_style_set_mathstyle_mathstyle
2433\letvalue{\??mathstylecache\??mathstylecache}\math_style_set_mathstyle_mathstylecache
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443\unexpanded\def\startmathstyle[#1]
2444 {\edef\m_math_style_asked{#1}
2445 \ifx\m_math_style_asked\empty
2446 \let\stopmathstyle\relax
2447 \else
2448 \bgroup
2449 \math_style_set_indeed
2450 \let\stopmathstyle\egroup
2451 \fi}
2452
2453\let\stopmathstyle\relax
2454
2455\unexpanded\def\startusemathstyleparameter#1
2456 {\edef\m_math_style_asked{#1\c!mathstyle}
2457 \ifx\m_math_style_asked\empty
2458 \let\stopusemathstyleparameter\relax
2459 \else
2460 \bgroup
2461 \math_style_set_indeed
2462 \let\stopusemathstyleparameter\egroup
2463 \fi}
2464
2465\let\stopusemathstyleparameter\relax
2466
2467
2468
2469
2470
2471\let\m_math_text_choice_face\relax
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504\def\math_text_choice_font#1#2#
2505 {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}
2506 \hbox#2\bgroup
2507 \bgroup
2508 \aftergroup\hss
2509 \aftergroup\egroup
2510 \hss
2511 \font_basics_switchtobodyfont\m_math_text_choice_face
2512 #1
2513 \let\next}
2514
2515\def\math_text_choice_word#1#2#
2516 {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}
2517 \hbox#2\bgroup
2518 \bgroup
2519 \aftergroup\hss
2520 \aftergroup\egroup
2521 \hss
2522 \font_basics_switchtobodyfont\m_math_text_choice_face
2523 #1
2524 \nospacing
2525 \let\next}
2526
2527
2528
2529
2530
2531
2532
2533
2534\mathscriptboxmode \plustwo
2535\mathscriptcharmode \plusone
2536
2537\mathrulethicknessmode\plusone
2538
2539\unexpanded\def\mathtext {\mathortext{\math_text_choice_font\relax}\hbox}
2540\unexpanded\def\mathword {\mathortext{\math_text_choice_word\relax}\hbox}
2541
2542\unexpanded\def\mathtexttf{\mathortext{\math_text_choice_font\tf}\hbox}
2543\unexpanded\def\mathtextit{\mathortext{\math_text_choice_font\it}\hbox}
2544\unexpanded\def\mathtextsl{\mathortext{\math_text_choice_font\sl}\hbox}
2545\unexpanded\def\mathtextbf{\mathortext{\math_text_choice_font\bf}\hbox}
2546\unexpanded\def\mathtextbi{\mathortext{\math_text_choice_font\bi}\hbox}
2547\unexpanded\def\mathtextbs{\mathortext{\math_text_choice_font\bs}\hbox}
2548
2549\unexpanded\def\mathwordtf{\mathortext{\math_text_choice_word\tf}\hbox}
2550\unexpanded\def\mathwordit{\mathortext{\math_text_choice_word\it}\hbox}
2551\unexpanded\def\mathwordsl{\mathortext{\math_text_choice_word\sl}\hbox}
2552\unexpanded\def\mathwordbf{\mathortext{\math_text_choice_word\bf}\hbox}
2553\unexpanded\def\mathwordbi{\mathortext{\math_text_choice_word\bi}\hbox}
2554\unexpanded\def\mathwordbs{\mathortext{\math_text_choice_word\bs}\hbox}
2555
2556
2557
2558\appendtoks
2559 \let\_\normalunderscore
2560\to \everymathematics
2561
2562
2563
2564\appendtoks \let\text\mathtext \to \everymathematics
2565
2566
2567
2568\newcount\interdisplaylinepenalty \interdisplaylinepenalty\plushundred
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590\newtoks\mathdisplayaligntweaks
2591
2592
2593
2594\unexpanded\def\math_display_align_hack
2595 {\glet\math_display_align_hack_indeed\math_display_align_hack_remove_skip
2596 \math_openup\displayopenupvalue
2597 \everycr{\noalign{\math_display_align_hack_indeed}}}
2598
2599\def\math_display_align_hack_remove_skip
2600 {\ifdim\prevdepth>\thousandpoint
2601 \vskip\dimexpr\lineskiplimit\normallineskiplimit\relax
2602 \fi
2603 \glet\math_display_align_hack_indeed\math_display_align_hack_insert_penalty}
2604
2605\def\math_display_align_hack_insert_penalty
2606 {\penalty\interdisplaylinepenalty}
2607
2608\appendtoks
2609 \math_display_align_hack
2610\to \mathdisplayaligntweaks
2611
2612
2613
2614\unexpanded\def\mathortext
2615 {\ifmmode
2616 \expandafter\firstoftwoarguments
2617 \else
2618 \expandafter\secondoftwoarguments
2619 \fi}
2620
2621
2622
2623
2624
2625\ifdefined\text\else \let\text\hbox \fi
2626
2627
2628
2629\unexpanded\def\mathoptext
2630 {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}
2631
2632 \dowithnextbox
2633 {\mathop{\box\nextbox}}
2634 \hbox\bgroup\font_basics_switchtobodyfont\m_math_text_choice_face\let\next}
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645\appendtoks
2646 \edef\p_setups{\mathematicsparameter\c!setups}
2647 \ifx\p_setups\empty\else
2648 \directsetup\p_setups
2649 \fi
2650\to \everyswitchmathematics
2651
2652
2653
2654\unexpanded\def\smallmathsymbol#1
2655 {\mathematics{\mathbin{\normalexpanded{\raise.15\exheight\hbox{\normalstartimath
2656 \triggermathstyle{\the\numexpr\normalmathstyle2\relax}#1
2657 \normalstopimath}}}}}
2658
2659
2660
2661\def\mathextensiblecode#1#2{\clf_extensiblecode\numexpr#1\relax\numexpr#2\relax}
2662\def\mathhorizontalcode#1#2{\clf_horizontalcode\numexpr#1\relax\numexpr#2\relax}
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708\def\m_math_inline_openup_ht{\dimexpr\ifinsidecolumns\strutdp\else\lineheight\fi\plusfour\relax}
2709\def\m_math_inline_openup_dp{\dimexpr\ifinsidecolumns\strutdp\else\lineheight\fi\plusfour\relax}
2710
2711
2712
2713
2714\installtextracker
2715 {math.openedup}
2716 {\let\math_inline_openup_start_yes\math_inline_openup_traced_start}
2717 {\let\math_inline_openup_start_yes\math_inline_openup_normal_start}
2718
2719\unexpanded\def\math_inline_openup_normal_start
2720 {\scratchheight\dimexpr\ht\scratchbox\m_math_inline_openup_ht\relax
2721 \scratchdepth \dimexpr\dp\scratchbox\m_math_inline_openup_dp\relax
2722 \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax
2723 \begingroup
2724 \let\math_inline_openup_stop\math_inline_openup_normal_stop}
2725
2726\unexpanded\def\math_inline_openup_normal_stop
2727 {\endgroup
2728 \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax}
2729
2730\unexpanded\def\math_inline_openup_traced_start
2731 {\scratchtopoffset \ht\scratchbox
2732 \scratchbottomoffset\dp\scratchbox
2733 \scratchheight \dimexpr\scratchtopoffset \m_math_inline_openup_ht\relax
2734 \scratchdepth \dimexpr\scratchbottomoffset\m_math_inline_openup_dp\relax
2735 \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax
2736 \begingroup
2737 \dofastcoloractivation{darkred}
2738 \vrule\s!width\emwidth\s!height\scratchheight\s!depth\scratchtopoffset\relax
2739 \endgroup
2740 \kern\emwidth
2741 \begingroup
2742 \let\math_inline_openup_stop\math_inline_openup_traced_stop}
2743
2744\unexpanded\def\math_inline_openup_traced_stop
2745 {\endgroup
2746 \kern\emwidth
2747 \begingroup
2748 \dofastcoloractivation{darkblue}
2749 \vrule\s!width\emwidth\s!height\scratchbottomoffset\s!depth\scratchdepth\relax
2750 \endgroup
2751 \vrule\s!width\zeropoint\s!height\scratchheight\s!depth\scratchdepth\relax}
2752
2753\let\math_inline_openup_start_yes\math_inline_openup_normal_start
2754\let\math_inline_openup_stop \relax
2755
2756\def\math_inline_openup_start_nop
2757 {\let\math_inline_openup_stop\relax}
2758
2759\unexpanded\def\openedupimath
2760 {\dontleavehmode
2761 \begingroup
2762 \ifmmode
2763 \expandafter\openedupimath_math
2764 \else
2765 \expandafter\openedupimath_text
2766 \fi}
2767
2768\unexpanded\def\openedupimath_math#1
2769 {\setbox\scratchbox\mathstylehbox{#1}
2770 \ifdim\ht\scratchbox>\strutht
2771 \math_inline_openup_start_yes
2772 \else\ifdim\dp\scratchbox>\strutdp
2773 \math_inline_openup_start_yes
2774 \else
2775 \math_inline_openup_start_nop
2776 \fi\fi
2777 #1
2778 \math_inline_openup_stop
2779 \endgroup}
2780
2781\unexpanded\def\openedupimath_text#1
2782 {\setbox\scratchbox\hbox{\startimath#1\stopimath}
2783 \ifdim\ht\scratchbox>\strutht
2784 \math_inline_openup_start_yes
2785 \else\ifdim\dp\scratchbox>\strutdp
2786 \math_inline_openup_start_yes
2787 \else
2788 \math_inline_openup_start_nop
2789 \fi\fi
2790 \startimath
2791 #1
2792 \stopimath
2793 \math_inline_openup_stop
2794 \endgroup}
2795
2796
2797
2798
2799
2800\unexpanded\def\mathplus {}
2801\unexpanded\def\mathminus {\ifmmode –\else\iffontchar\font−−\else –\fi\fi}
2802\unexpanded\def\mathplusminus{±}
2803
2804
2805
2806
2807\def\checkeddisplaywidth
2808 {\dimexpr
2809 \ifzeropt\displaywidth
2810 \hsize
2811 \else
2812 \displaywidth
2813 \fi
2814 \relax}
2815
2816\def\maximizeddisplaywidth
2817 {\dimexpr
2818 \ifzeropt\displaywidth
2819 \hsize
2820 \else\ifdim\displaywidth>\hsize
2821 \hsize
2822 \else
2823 \displaywidth
2824 \fi\fi
2825 \relax}
2826
2827
2828
2829\newcount\c_math_domain_attribute
2830
2831\def\math_domain_initialize
2832 {\ifnum\c_math_domain_attribute=\attributeunsetvalue \else
2833 \clf_initializemathdomain
2834 \glet\math_domain_initialize\relax
2835 \fi}
2836
2837\appendtoks
2838 \edef\p_domain{\mathematicsparameter\c!domain}
2839 \ifx\p_domain\empty
2840 \c_math_domain_attribute\attributeunsetvalue
2841 \else
2842 \c_math_domain_attribute\clf_getmathdomain\p_domain\relax
2843 \math_domain_initialize
2844 \fi
2845\to \everyswitchmathematics
2846
2847\appendtoks
2848 \c_attr_mathdomain\c_math_domain_attribute
2849\to \everymathematics
2850
2851\setupmathematics
2852 [\s!italics=3]
2853
2854
2855
2856\installcorenamespace{mathrules}
2857
2858\unexpanded\def\enablemathrules{\letgvalue{\??mathrules\fontclass}\plusone}
2859
2860\appendtoks
2861 \mathrulesmode\ifcsname\??mathrules\fontclass\endcsname
2862 \lastnamedcs
2863 \else
2864 \zerocount
2865 \fi
2866 \mathrulesfam\zerocount
2867\to \everymathematics
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921\unexpanded\def\math_scripts_stack
2922 {\c_attr_mathunstack\attributeunsetvalue}
2923
2924\unexpanded\def\math_scripts_unstack
2925 {\clf_enablescriptunstacking
2926 \c_attr_mathunstack\plusone}
2927
2928\appendtoks
2929 \let\stackscripts \math_scripts_stack
2930 \let\unstackscripts\math_scripts_unstack
2931\to \everymathematics
2932
2933
2934
2935
2936\def\math_openup_parameter#1#2
2937 {\ifzeropt#1\displaystyle \else\ifdim#1\displaystyle =\maxdimen\else\frozen#1\displaystyle #2#1\displaystyle \fi\fi
2938 \ifzeropt#1\crampeddisplaystyle \else\ifdim#1\crampeddisplaystyle =\maxdimen\else\frozen#1\crampeddisplaystyle #2#1\crampeddisplaystyle \fi\fi
2939 \ifzeropt#1\textstyle \else\ifdim#1\textstyle =\maxdimen\else\frozen#1\textstyle #2#1\textstyle \fi\fi
2940 \ifzeropt#1\crampedtextstyle \else\ifdim#1\crampedtextstyle =\maxdimen\else\frozen#1\crampedtextstyle #2#1\crampedtextstyle \fi\fi
2941 \ifzeropt#1\scriptstyle \else\ifdim#1\scriptstyle =\maxdimen\else\frozen#1\scriptstyle #2#1\scriptstyle \fi\fi
2942 \ifzeropt#1\crampedscriptstyle \else\ifdim#1\crampedscriptstyle =\maxdimen\else\frozen#1\crampedscriptstyle #2#1\crampedscriptstyle \fi\fi
2943 \ifzeropt#1\scriptscriptstyle \else\ifdim#1\scriptscriptstyle =\maxdimen\else\frozen#1\scriptscriptstyle #2#1\scriptscriptstyle \fi\fi
2944 \ifzeropt#1\crampedscriptscriptstyle\else\ifdim#1\crampedscriptscriptstyle=\maxdimen\else\frozen#1\crampedscriptscriptstyle#2#1\crampedscriptscriptstyle\fi\fi}
2945
2946\unexpanded\def\mathopenupparameter#1#2
2947 {\ifdim#2\points=\zeropoint\else
2948 \math_openup_parameter#1{#2}
2949 \fi}
2950
2951
2952
2953\def\math_relax_limits{\let\limits\relax}
2954
2955\protect \endinput
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973 |