summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/math-frc.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/math-frc.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/math-frc.mkiv89
1 files changed, 58 insertions, 31 deletions
diff --git a/Master/texmf-dist/tex/context/base/math-frc.mkiv b/Master/texmf-dist/tex/context/base/math-frc.mkiv
index ea3a737aa81..e11e79e8230 100644
--- a/Master/texmf-dist/tex/context/base/math-frc.mkiv
+++ b/Master/texmf-dist/tex/context/base/math-frc.mkiv
@@ -19,6 +19,8 @@
%D This module is reimplemented in \MKIV\ style.
+\registerctxluafile{math-frc}{1.001}
+
%D \macros
%D {frac, xfrac, xxfrac}
%D
@@ -89,53 +91,68 @@
\installcorenamespace{mathfractions}
\installcorenamespace{mathfractionstyle}
-\installcorenamespace{mathfractionalign}
\installcorenamespace{mathfractionalternative}
\installcommandhandler \??mathfractions {mathfraction} \??mathfractions
\let\setupmathfractions\setupmathfraction
+% color only applies to rule, use regular color for rest
+
\setupmathfractions
- [\c!mathstyle=\v!auto,
- \c!align=\v!normal,
+ [\c!mathstyle=,
\c!alternative=\v!inner,
- \c!command=\normalover] % beware a <arg 1><command><arg 2> variant
+ \c!rulethickness=.25\exheight,
+ \c!left=0x2E,
+ \c!right=0x2E,
+ \c!rule=\v!auto]
\appendtoks
\setuevalue{\currentmathfraction}{\math_frac{\currentmathfraction}}%
\to \everydefinemathfraction
-\letvalue{\??mathfractionalign\v!normal}\mathstylehbox
-\letvalue{\??mathfractionalign\v!lohi }\mathstylevcenteredhbox
-
-\def\math_frac_align
- {\expandnamespaceparameter\??mathfractionalign\mathfractionparameter\c!align\v!normal}
-
\unexpanded\def\math_frac#1%
{\begingroup
\edef\currentmathfraction{#1}%
- \expandnamespaceparameter\??mathfractionstyle\mathfractionparameter\c!mathstyle\s!math}
+ \edef\p_math_fractions_color{\mathfractionparameter\c!color}%
+ \ifx\p_math_fractions_color\empty
+ \expandafter\math_frac_normal
+ \else
+ \expandafter\math_frac_colored
+ \fi}
+
+\unexpanded\def\math_frac_colored#1#2%
+ {\savecolor
+ \colo_helpers_activate\p_math_fractions_color
+ \math_frac_normal{\restorecolor#1}{\restorecolor#2}}
+
+\unexpanded\def\math_frac_normal
+ {\expandnamespaceparameter\??mathfractionalternative\mathfractionparameter\c!alternative\v!inner}
-\setvalue{\??mathfractionalternative\v!inner}#1#2#3%
- {\math_frac_align{\Ustack{{#1{#2}}\mathfractionparameter\c!command{#1{#3}}}}%
- \endgroup}
+% we use utfchar anyway so we can as well do all at the lua end
-\setvalue{\??mathfractionalternative\v!outer}#1#2#3%
- {\math_frac_align{\Ustack{{#1{{#2}\mathfractionparameter\c!command{#3}}}}}%
- \endgroup}
+\def\math_frac_command
+ {\ctxcommand{math_frac(%
+ "\mathfractionparameter\c!rule",%
+ \number\mathfractionparameter\c!left,%
+ \number\mathfractionparameter\c!right,%
+ \number\dimexpr\mathfractionparameter\c!rulethickness%
+ )}}
-\def\math_frac_alternative
- {\expandnamespaceparameter\??mathfractionalternative\mathfractionparameter\c!alternative\v!inner}
+\setvalue{\??mathfractionalternative\v!inner}#1#2%
+ {\Ustack{%
+ {\usemathstyleparameter\mathfractionparameter{#1}}% we should store this one
+ \math_frac_command
+ {\usemathstyleparameter\mathfractionparameter{#2}}% and reuse it here
+ }\endgroup}
-\setvalue{\??mathfractionstyle\v!auto }{\math_frac_alternative\firstofoneargument} % was: 0
-\setvalue{\??mathfractionstyle\s!display }{\math_frac_alternative\displaystyle} % was: 1
-\setvalue{\??mathfractionstyle\s!text }{\math_frac_alternative\textstyle} % was: 2
-\setvalue{\??mathfractionstyle\s!script }{\math_frac_alternative\scriptstyle} % was: 3
-\setvalue{\??mathfractionstyle\s!scriptscript}{\math_frac_alternative\scriptscriptstyle} % was: 4
-\setvalue{\??mathfractionstyle\s!math }{\math_frac_alternative\mathstyle} % was: else
+\setvalue{\??mathfractionalternative\v!outer}#1#2%
+ {\Ustack{%
+ \usemathstyleparameter\mathfractionparameter
+ {{#1}\math_frac_command{#2}}%
+ }\endgroup}
-\definemathfraction[frac][\c!mathstyle=\v!auto]
+\definemathfraction[frac][\c!mathstyle=]
\unexpanded\def\xfrac {\begingroup\let\xfrac\xxfrac\math_frac_alternative\scriptstyle}
\unexpanded\def\xxfrac{\begingroup \math_frac_alternative\scriptscriptstyle}
@@ -157,6 +174,18 @@
%D \typebuffer
%D \getbuffer
+% $$
+% {{a}\over{b}} +
+% {{a}\overwithdelims(){b}} +
+% {{a}\atopwithdelims(){b}} +
+% {{a}\abovewithdelims()\zeropoint{b}} +
+% \left({{a}\over{b}}\right)
+% $$
+
+% \dorecurse {10} { % weird
+% $$ {{a}\abovewithdelims()#1pt{b}} $$
+% }
+
% \unexpanded\def\dfrac #1#2{{\displaystyle {{#1}\normalover {#2}}}}
% \unexpanded\def\tfrac #1#2{{\textstyle {{#1}\normalover {#2}}}}
@@ -164,8 +193,6 @@
\definemathfraction[tfrac][\c!alternative=\v!outer,\c!mathstyle=\s!text]
\definemathfraction[sfrac][\c!alternative=\v!outer,\c!mathstyle=\s!script]
-\def\normaloverbinum{\normalabovewithdelims()\zeropoint}
-
% \definemathfraction[ddfrac][\c!mathstyle=\s!display]
% \definemathfraction[ttfrac][\c!mathstyle=\s!text]
% \definemathfraction[ssfrac][\c!mathstyle=\s!script]
@@ -174,9 +201,9 @@
% \unexpanded\def\dbinom#1#2{{\displaystyle{{#1}\normalabovewithdelims()\zeropoint{#2}}}}
% \unexpanded\def\tbinom#1#2{{\textstyle {{#1}\normalabovewithdelims()\zeropoint{#2}}}}
-\definemathfraction[binom] [\c!alternative=\v!outer,\c!command=\normaloverbinum,\c!mathstyle=\s!auto]
-\definemathfraction[dbinom][\c!alternative=\v!outer,\c!command=\normaloverbinum,\c!mathstyle=\s!display]
-\definemathfraction[tbinom][\c!alternative=\v!outer,\c!command=\normaloverbinum,\c!mathstyle=\s!text]
+\definemathfraction[binom] [\c!alternative=\v!outer,\c!rule=\v!no,\c!left=0x28,\c!right=0x29,\c!mathstyle=\s!auto]
+\definemathfraction[dbinom][\c!alternative=\v!outer,\c!rule=\v!no,\c!left=0x28,\c!right=0x29,\c!mathstyle=\s!display]
+\definemathfraction[tbinom][\c!alternative=\v!outer,\c!rule=\v!no,\c!left=0x28,\c!right=0x29,\c!mathstyle=\s!text]
%D \macros
%D {cfrac}