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