diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/math-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/math-ini.mkiv | 276 |
1 files changed, 211 insertions, 65 deletions
diff --git a/Master/texmf-dist/tex/context/base/math-ini.mkiv b/Master/texmf-dist/tex/context/base/math-ini.mkiv index 81ec339d658..dcd2a5c3343 100644 --- a/Master/texmf-dist/tex/context/base/math-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/math-ini.mkiv @@ -44,6 +44,14 @@ \registerctxluafile{math-noa}{1.001} \registerctxluafile{math-tag}{1.001} \registerctxluafile{math-fbk}{1.001} +\registerctxluafile{math-dir}{1.001} + +%D A few compatibility helpers: + +\def\Umathbotaccent{\Umathaccent \s!bottom } +\def\Umathaccents {\Umathaccent \s!both } + +%D The attributes that we will use: \definesystemattribute[mathalphabet] [public] \definesystemattribute[mathsize] [public] @@ -54,6 +62,7 @@ \definesystemattribute[mathcategory] [public] \definesystemattribute[mathmode] [public] \definesystemattribute[mathitalics] [public] +\definesystemattribute[mathbidi] [public] \definesystemattribute[displaymath] [public] @@ -108,7 +117,7 @@ \installswitchcommandhandler \??mathematics {mathematics} \??mathematics \unexpanded\def\startmathematics % no grouping, if ever then also an optional second - {\doifnextoptionalelse\math_mathematics_start_yes\math_mathematics_start_nop} + {\doifnextoptionalcselse\math_mathematics_start_yes\math_mathematics_start_nop} \unexpanded\def\math_mathematics_start_yes[#1]% {\pushmacro\currentmathematics @@ -277,9 +286,15 @@ \def\utfmathclassfiltered #1#2{\ctxcommand{utfmathclass (\!!bs#1\!!es,nil,"#2")}} \def\utfmathcommandfiltered#1#2{\ctxcommand{utfmathcommand(\!!bs#1\!!es,nil,"#2")}} +\def\utfmathcommandabove#1{\ctxcommand{utfmathcommandabove(\!!bs#1\!!es)}} +\def\utfmathcommandbelow#1{\ctxcommand{utfmathcommandbelow(\!!bs#1\!!es)}} + \unexpanded\def\doifelseutfmathaccent #1{\ctxcommand{doifelseutfmathaccent(\!!bs#1\!!es)}} \unexpanded\def\doifelseutfmathaccentfiltered#1#2{\ctxcommand{doifelseutfmathaccent(\!!bs#1\!!es,"#2")}} +\unexpanded\def\doifelseutfmathabove #1{\ctxcommand{doifelseutfmathabove(\!!bs#1\!!es)}} +\unexpanded\def\doifelseutfmathbelow #1{\ctxcommand{doifelseutfmathbelow(\!!bs#1\!!es)}} + %D Not used that much: \installcorenamespace{mathcodecommand} @@ -349,6 +364,46 @@ \unexpanded\def\mathcommand#1% {\csname\??mathcommand#1\endcsname} +%D Let's define a few comands here: + +%definemathcommand [mathstrut] {\vphantom{(}} +%definemathcommand [joinrel] {\mathrel{\mkern-3mu}} +\definemathcommand [joinrel] [rel] {\mkern-3mu} + +\chardef\c_math_strut"28 + +\unexpanded\def\math_strut_htdp#1% + {\s!height\fontcharht#1\c_math_strut + \s!depth \fontchardp#1\c_math_strut} + +\unexpanded\def\math_strut_normal + {\vrule + \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}% + \s!width \zeropoint + \relax} + +\unexpanded\def\math_strut_visual + {\hskip-.01\emwidth + \vrule + \normalexpanded{\math_strut_htdp{\mathstylefont\normalmathstyle}}% + \s!width .02\emwidth + \relax + \hskip-.01\emwidth} + +\unexpanded\def\showmathstruts % let's not overload \nath_strut_normal + {\let\math_strut\math_strut_visual} + +\let\math_strut\math_strut_normal + +% \unexpanded\def\mathstrut{\mathcodecommand{nothing}{\math_strut}} + +\definemathcommand [mathstrut] {\math_strut} + +%D We could have a arg variant \unknown\ but not now. + +\unexpanded\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits} +\unexpanded\def\stackrel #1#2{\mathrel{\mathop{#2}\limits^{#1}}} + %D Moved from font-ini.mkiv: %D %D \macros @@ -388,6 +443,17 @@ {\ifdefined\normalhbox\else\let\normalhbox\hbox\fi % ? \let\hbox\mbox} +\unexpanded\def\snappedmath#1% sort of \struttedbox + {\dontleavehmode + \begingroup + \setbox\scratchbox\hbox\bgroup + \startimath#1\stopimath + \egroup + \ht\scratchbox\strutht + \dp\scratchbox\strutht + \box\scratchbox + \endgroup} + %D The next hack is needed needed for sine, cosine etc. \let\mathfunction\firstofoneunexpanded @@ -494,10 +560,6 @@ %D \tt test $\sin{(x^{\sin(x^{\sin(x)})})}$ test %D \stoptyping -%D Some goodies: - -\unexpanded\def\Angstrom{\nomathematics{\Aring}} - %D \macros %D {nonknuthmode, donknuthmode} %D @@ -531,12 +593,13 @@ \def\activatemathcharacters {\the\activatedmathcharacters} -% \setnewconstant\primeasciicode 39 % ' +% beware, not runtime, so has to happen at format generation \activatemathcharacter\circumflexasciicode \activatemathcharacter\underscoreasciicode \activatemathcharacter\ampersandasciicode -\activatemathcharacter\primeasciicode + +% \activatemathcharacter\primeasciicode % not used: % @@ -601,57 +664,57 @@ \Umathchardef\prime "0 "0 "2032 \fi -\let\math_prime_indeed_normal\prime - -\appendtoks - \let\math_prime_indeed_normal\prime % gets defined later - \let\mathfontprime\prime % for tracing - \let\prime\math_prime_indeed % so this is needed -\to \everydump - -\unexpanded\def\math_prime_indeed - {\iffontchar\textfont\zerocount"FE325\relax - ^\bgroup - \expandafter\math_prime_indeed_virtual % virtual mess (using funny signal) - \else - % \expandafter\math_prime_indeed_normal % gets collapsed - \expandafter\math_prime_indeed_crapped % gets collapsed - \fi} - -\def\math_prime_indeed_crapped - {{^{\math_prime_indeed_normal}}} - -\let\prime\math_prime_indeed - -\def\math_prime_indeed_virtual - {\math_prime_indeed_normal - \futurelet\nexttoken\math_prime_indeed_choice} - -\installcorenamespace{mathprime} - -\def\math_prime_indeed_choice - {\csname\??mathprime - \ifx '\nexttoken a\else - \ifx \math_prime_indeed_normal\nexttoken a\else - \ifx \prime\nexttoken a\else - \ifx\superscriptcircumflextoken\nexttoken b\else - \ifx\othercircumflextoken \nexttoken b\else - c\fi\fi\fi\fi\fi - \endcsname} - -\setvalue{\??mathprime a}#1{\math_prime_indeed_virtual} -\setvalue{\??mathprime b}#1#2{#2\egroup} -\setvalue{\??mathprime c}{\egroup} - -\let\activemathprime\math_prime_indeed - -\bgroup - - \catcode\primeasciicode\activecatcode - - \global\everymathematics\expandafter{\the\everymathematics\let'\math_prime_indeed} % todo: do this at the lua end - -\egroup +% \let\math_prime_indeed_normal\prime +% +% \appendtoks +% \let\math_prime_indeed_normal\prime % gets defined later +% \let\mathfontprime\prime % for tracing +% \let\prime\math_prime_indeed % so this is needed +% \to \everydump +% +% \unexpanded\def\math_prime_indeed +% {\iffontchar\textfont\zerocount"FE325\relax +% ^\bgroup +% \expandafter\math_prime_indeed_virtual % virtual mess (using funny signal) +% \else +% % \expandafter\math_prime_indeed_normal % gets collapsed +% \expandafter\math_prime_indeed_crapped % gets collapsed +% \fi} +% +% \def\math_prime_indeed_crapped +% {{^{\math_prime_indeed_normal}}} +% +% % \let\prime\math_prime_indeed +% +% \def\math_prime_indeed_virtual +% {\math_prime_indeed_normal +% \futurelet\nexttoken\math_prime_indeed_choice} +% +% \installcorenamespace{mathprime} +% +% \def\math_prime_indeed_choice +% {\csname\??mathprime +% \ifx '\nexttoken a\else +% \ifx \math_prime_indeed_normal\nexttoken a\else +% \ifx \prime\nexttoken a\else +% \ifx\superscriptcircumflextoken\nexttoken b\else +% \ifx\othercircumflextoken \nexttoken b\else +% c\fi\fi\fi\fi\fi +% \endcsname} +% +% \setvalue{\??mathprime a}#1{\math_prime_indeed_virtual} +% \setvalue{\??mathprime b}#1#2{#2\egroup} +% \setvalue{\??mathprime c}{\egroup} +% +% \let\activemathprime\math_prime_indeed +% +% \bgroup +% +% \catcode\primeasciicode\activecatcode +% +% \global\everymathematics\expandafter{\the\everymathematics\let'\math_prime_indeed} % todo: do this at the lua end +% +% \egroup \bgroup @@ -672,8 +735,8 @@ \newconditional \knuthmode -\let\nonknuthmode\relax -\let\donknuthmode\relax +\let\nonknuthmode\relax % no longer needed in MkIV +\let\donknuthmode\relax % no longer needed in MkIV % \def\nonknuthmode % {\pushcatcodetable @@ -784,7 +847,34 @@ \setupmathematics [\c!compact=no] -%D Arabic: +% \enabletrackers[typesetters.directions.math] + +%D Right||to||left typesetting in math is supported by the \type {align} parameter +%D with as option the \type {bidi} parameter. Of course support for special symbols +%D like square roots depends on the font as well. We probably need to mirror a few +%D more characters. +%D +%D \startbuffer +%D \removeunwantedspaces +%D \m{ ( 1 = 1) }\quad +%D \m{ (123 = 123) }\quad +%D \m{ a ( 1 = 1) b }\quad +%D \m{ a (123 = 123) b }\quad +%D \m{ x = 123 y + (1 / \sqrt {x}) } +%D \stopbuffer +%D +%D \typebuffer +%D +%D \starttabulate[|T|T||] +%D \HL +%D \NC align \NC bidi \NC \NC \NR +%D \HL +%D \NC l2r \NC no \NC \setupmathematics[bidi=no] \getbuffer \NC \NR +%D \NC l2r \NC yes \NC \setupmathematics[bidi=yes] \getbuffer \NC \NR +%D \NC r2l \NC no \NC \setupmathematics[align=r2l,bidi=no] \getbuffer \NC \NR +%D \NC r2l \NC yes \NC \setupmathematics[align=r2l,bidi=yes] \getbuffer \NC \NR +%D \HL +%D \stoptabulate \newconditional\c_math_right_to_left @@ -797,9 +887,28 @@ \appendtoks \math_basics_synchronize_direction -%to \everymathematics % comes too late and I'm not in the mood for a mixed mode kludge now +%to \everymathematics % comes too late and I'm not in the mood for a mixed mode kludge now (should be a property of beginmath nodes and passed to callbacks) +\to \everyswitchmathematics + +% experimental (needed for an article) + +\installcorenamespace {mathbidi} + +\newcount\c_math_bidi + +\setvalue{\??mathbidi\v!no }{\ctxcommand{setmathdirection(0)}\c_math_bidi\attributeunsetvalue} +\setvalue{\??mathbidi\v!yes}{\ctxcommand{setmathdirection(1)}\c_math_bidi\plusone} + +\appendtoks + \edef\p_bidi{\mathematicsparameter\c!bidi}% + \csname\??mathbidi\ifcsname\??mathbidi\p_bidi\endcsname\p_bidi\else\v!no\fi\endcsname +\to \everysetupmathematics + +\appendtoks + \attribute\mathbidiattribute\ifconditional\c_math_right_to_left\c_math_bidi\else\attributeunsetvalue\fi \to \everyswitchmathematics + %D Delayed: greek. %D %D \starttyping @@ -1008,6 +1117,9 @@ % \global\mathcode\c_math_period\c_math_special % \to \everyjob +% \activatemathcharacter\c_math_comma +% \activatemathcharacter\c_math_period + \appendtoks \mathcode\c_math_comma \c_math_special \mathcode\c_math_period\c_math_special @@ -1153,6 +1265,20 @@ \expandafter#3\else \expandafter#1\fi} +\unexpanded\def\verbosemathstyle#1% #1 is number (\normalmathstyle) + {{\normalexpanded{\relax\darkgray\ttxx[\number#1:\ifcase\numexpr#1\relax + display\or % 0 + crampeddisplay\or % 1 + text\or % 2 + crampedtext\or % 3 + script\or % 4 + crampedscript\or % 5 + scriptscript\or % 6 + crampedscriptscript\else % 7 + unknown\fi]}}} + +\unexpanded\def\showmathstyle{\verbosemathstyle\normalmathstyle} + %D A plain inheritance: \def\mathpalette#1#2% @@ -1170,7 +1296,9 @@ %D %D \typebuffer \getbuffer -\unexpanded\def\mathstylehbox#1% +% to be tested: {#1} but it could have side effects + +\unexpanded\def\mathstylehbox#1% sensitive for: a \over b => {a\over b} or \frac{a}{b} {\normalexpanded{\hbox\bgroup \startimath\triggermathstyle\normalmathstyle}\mathsurround\zeropoint#1\stopimath\egroup} @@ -1616,6 +1744,7 @@ \def\math_text_choice% if needed we can get rid of the normalize (predo in font code) {\normalizebodyfontsize\m_math_text_choice_face{\mathstyleface\normalmathstyle}% + %\showmathstyle \hbox\bgroup\font_basics_switchtobodyfont\m_math_text_choice_face\let\next} %D Safeguard against redefinitions: @@ -1639,7 +1768,7 @@ % % \def\displ@y % {\global\dt@ptrue -% \openup\displayopenupvalue % was \openup\jot +% \math_openup\displayopenupvalue % was \openup\jot % \everycr % {\noalign % {\ifdt@p @@ -1660,7 +1789,7 @@ \unexpanded\def\math_display_align_hack % I don't like the global, maybe we should push and pop {\global\let\math_display_align_hack_indeed\math_display_align_hack_remove_skip - \openup\displayopenupvalue % was \openup\jot + \math_openup\displayopenupvalue % was \math_openup\jot \everycr{\noalign{\math_display_align_hack_indeed}}} \def\math_display_align_hack_remove_skip @@ -1723,3 +1852,20 @@ \def\mathhorizontalcode#1#2{\ctxcommand{horizontalcode(\number#1,\number#2)}} \protect \endinput + +% % not used (yet) +% +% \newtoks \everystartimath +% \newtoks \everystopimath +% +% \unexpanded\def\startimath{\Ustartmath\the\everystartimath} +% \unexpanded\def\stopimath {\the\everystopimath\Ustopmath} +% +% \unexpanded\def\m% +% {\relax +% \ifmmode\expandafter\math_m_stay\else\expandafter\math_m_math\fi} +% +% \unexpanded\def\math_m_math#1% +% {\startimath#1\stopimath} +% +% \let\math_m_stay\firstofoneargument |