summaryrefslogtreecommitdiff
path: root/tex/context/base/math-ali.mkiv
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-07-04 10:42:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-07-04 10:42:00 +0200
commit6fab0bf5d80191fb0748006da3cbdf4561541484 (patch)
tree85ef2d4c3b8dd63bf3a1b27ec7eb621761efee73 /tex/context/base/math-ali.mkiv
parent16a05ab43b53feac7c21bceccc2886857e9822a8 (diff)
downloadcontext-6fab0bf5d80191fb0748006da3cbdf4561541484.tar.gz
beta 2012.07.04 10:42
Diffstat (limited to 'tex/context/base/math-ali.mkiv')
-rw-r--r--tex/context/base/math-ali.mkiv87
1 files changed, 41 insertions, 46 deletions
diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv
index 94800b3ba..57727b03a 100644
--- a/tex/context/base/math-ali.mkiv
+++ b/tex/context/base/math-ali.mkiv
@@ -15,17 +15,6 @@
\unprotect
-% helpers .. will move
-
-\def\doxxdoubleempty#1#2%
- {\ifx#2[\expandafter\dodoxxdoubleempty\else\expandafter\noxxdoubleempty\fi#1#2}
-
-\def\dodoxxdoubleempty#1[#2]#3%
- {\ifx#3[\else\expandafter\nonoxxdoubleempty\fi#1[#2]#3}
-
-\def\noxxdoubleempty #1{#1[][]}
-\def\nonoxxdoubleempty#1[#2]{#1[#2][]}
-
%D The code here has been moved from other files. Beware: the \MKII\ and
%D \MKIV\ code is not gathered in files with the same name. In the
%D meantime this code has been adapted to \MKIV\ but mnore is possible.
@@ -38,19 +27,25 @@
% n>1 #### needed, strange # interaction in recurse
+\newtoks\c_math_align_a
+\newtoks\c_math_align_b
+\newtoks\c_math_align_c
+
\def\math_build_eqalign
{\scratchtoks\emptytoks
- \dorecurse{\mathalignmentparameter\c!m}
- {\ifnum\recurselevel>\plusone
- %\appendtoks
- % \tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint
- %\to\scratchtoks
- \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint}%
- \fi
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
- \dorecurse{\numexpr\mathalignmentparameter\c!n-\plusone\relax}
- {\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}
+ \dorecurse{\mathalignmentparameter\c!m}\def\math_build_eqalign
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_c}}}
+
+\def\math_build_eqalign_step
+ {\ifnum\recurselevel>\plusone
+ %\appendtoks
+ % \tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint
+ %\to\scratchtoks
+ \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint}%
+ \fi
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_a}}%
+ \dorecurse{\numexpr\mathalignmentparameter\c!n-\plusone\relax}
+ {\normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_b}}}}
\def\math_math_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks\displaystyle{{}#1{}}$}
\def\math_text_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks#1$}
@@ -73,14 +68,14 @@
% use zeroskipplusfill
\def\math_prepare_r_eqalign_no
- {\!!toksa{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
- \!!toksb{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \c_math_align_b{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
\ifnum\mathraggedstatus=\plusone
- \!!toksc{\hfil&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else\ifnum\mathraggedstatus=\plusthree
- \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else
- \!!toksc{\hfil\tabskip\centering&\llap{\span\math_text_in_eqalign{##}}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil\tabskip\centering&\llap{\span\math_text_in_eqalign{##}}\tabskip\zeropoint}%
\fi\fi
\global\mathnumberstatus\zerocount
\math_build_eqalign
@@ -88,15 +83,15 @@
\tabskip\centering}
\def\math_prepare_l_eqalign_no
- {\!!toksa{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
- \!!toksb{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \c_math_align_b{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
% problem: number is handled after rest and so ends up in the margin
\ifnum\mathraggedstatus=\plusone
- \!!toksc{\hfil&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else\ifnum\mathraggedstatus=\plusthree
- \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\kern-\displaywidth\span\math_rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\kern-\displaywidth\span\math_rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else
- \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\fi\fi
\global\mathnumberstatus\zerocount
\math_build_eqalign
@@ -112,7 +107,7 @@
\let\math_finish_eqalign_no\relax
\fi
#1%
- \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#2\crcr}%
+ \halign \ifcase\eqalignmode \or to \displaywidth \fi \expandafter {\the\scratchtoks\crcr#2\crcr}%
\math_finish_eqalign_no}
\def\math_both_eqalign_no_aligned#1%
@@ -128,7 +123,7 @@
\fi
\fi
#1%
- \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}
+ \halign \ifcase\eqalignmode \or to \displaywidth \fi \expandafter \bgroup\the\scratchtoks\crcr}
\def\math_rlap#1%
{\setbox\scratchbox\hbox{#1}%
@@ -221,7 +216,7 @@
\setupmathalignment
[\c!n=2,
\c!m=1,
- \c!distance=1em]
+ \c!distance=\emwidth]
\definemathalignment[align] % default case (this is what amstex users expect)
\definemathalignment[\v!mathalignment] % prefered case (this is cleaner, less clashing)
@@ -408,8 +403,8 @@
\installcommandhandler \??mathcases {mathcases} \??mathcases
\setupmathcases
- [\c!distance=1em,
- \c!numberdistance=2.5em,
+ [\c!distance=\emwidth,
+ \c!numberdistance=2.5\emwidth,
\c!left={\left\{\mskip\thinmuskip},
\c!right={\right.}]
@@ -434,7 +429,7 @@
\def\NC{\math_cases_NC}%
\def\MC{\math_cases_NC\ifmmode\else$\def\endmath{$}\fi}%
\global\let\math_cases_NC\math_cases_NC_indeed
- \def\NR{\unskip\endmath&\global\let\math_cases_NC\math_cases_NC_indeed\doxxdoubleempty\math_cases_NR}%
+ \def\NR{\unskip\endmath&\global\let\math_cases_NC\math_cases_NC_indeed\dodirectdoubleempty\math_cases_NR}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
@@ -515,7 +510,7 @@
\installcommandhandler \??mathmatrix {mathmatrix} \??mathmatrix
\setupmathmatrix
- [\c!distance=1em,
+ [\c!distance=\emwidth,
\c!left=,
\c!right=,
\c!align=\v!middle]
@@ -570,20 +565,20 @@
\definemathmatrix[\v!mathmatrix]
\def\math_matrix_prepare
- {\!!toksa{\strut\math_first_in_eqalign\math_left_of_equalign\span
+ {\c_math_align_a{\strut\math_first_in_eqalign\math_left_of_equalign\span
\math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
- \!!toksb{&\hskip\mathmatrixparameter\c!distance
+ \c_math_align_b{&\hskip\mathmatrixparameter\c!distance
\math_next_in_eqalign\math_left_of_equalign\span
\math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
- \!!toksc{&&\hskip\mathmatrixparameter\c!distance
+ \c_math_align_c{&&\hskip\mathmatrixparameter\c!distance
\math_left_of_equalign\span
\math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
\scratchtoks\emptytoks
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_a}}%
\dorecurse{\numexpr\scratchcounter-\plusone\relax}
- {\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}%
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}%
- \halign \@EA \bgroup\the\scratchtoks \crcr}
+ {\normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_b}}}%
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_c}}%
+ \halign \expandafter \bgroup\the\scratchtoks \crcr}
\unexpanded\def\dodomatrixNC
{\gdef\domatrixNC{\endmath&}}