diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
commit | 57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch) | |
tree | 1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/tex/context/base/math-ali.mkiv | |
parent | 6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff) |
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/math-ali.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/math-ali.mkiv | 273 |
1 files changed, 255 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/context/base/math-ali.mkiv b/Master/texmf-dist/tex/context/base/math-ali.mkiv index f98eb11dfed..31f71219a44 100644 --- a/Master/texmf-dist/tex/context/base/math-ali.mkiv +++ b/Master/texmf-dist/tex/context/base/math-ali.mkiv @@ -19,7 +19,7 @@ %D \MKIV\ code is not gathered in files with the same name. %D \macros -%D {\definemathalignment, setupmathalignment, startmathalignment} +%D {definemathalignment, setupmathalignment, startmathalignment} %D %D Modules may provide additional alignment features. The following %D mechanisms are provided by the core. @@ -153,7 +153,7 @@ %D Here we implement the user interface part. -\def\setupmathalignment +\unexpanded\def\setupmathalignment {\dodoubleempty\dosetupmathalignment} \def\dosetupmathalignment[#1][#2]% @@ -240,7 +240,7 @@ {\finishalignno \popmacro\doalignNC} -\def\definemathalignment +\unexpanded\def\definemathalignment {\dodoubleempty\dodefinemathalignment} \def\dodefinemathalignment[#1]% [#2]% @@ -440,7 +440,7 @@ %D %D Another wish \unknown -\def\setupmathcases +\unexpanded\def\setupmathcases {\dodoubleempty\dosetupmathcases} \def\dosetupmathcases[#1][#2]% @@ -500,7 +500,7 @@ \mathcasesparameter\c!right \endgroup} -\def\definemathcases +\unexpanded\def\definemathcases {\dodoubleempty\dodefinemathcases} \def\dodefinemathcases[#1]% [#2]% @@ -556,7 +556,7 @@ %D %D Yet another one \unknown -\def\setupmathmatrix +\unexpanded\def\setupmathmatrix {\dodoubleempty\dosetupmathmatrix} \def\dosetupmathmatrix[#1][#2]% @@ -606,18 +606,18 @@ \buildmathmatrix \halign \@EA \bgroup\the\scratchtoks \crcr} -\def\definemathmatrix +\unexpanded\def\definemathmatrix {\dodoubleempty\dodefinemathmatrix} \def\dodefinemathmatrix[#1]% [#2]% - {\setvalue{\e!start#1}{\dodoubleempty\dostartmathmatrix[#1]}% - \setvalue{\e!stop #1}{\dostopmathmatrix}% + {\setuvalue{\e!start#1}{\dodoubleempty\dostartmathmatrix[#1]}% + \setuvalue{\e!stop #1}{\dostopmathmatrix}% \setupmathmatrix[#1]}% [#2] \definemathmatrix[matrix] \definemathmatrix[\v!mathmatrix] -\def\dodomatrixNC +\unexpanded\def\dodomatrixNC {\gdef\domatrixNC{\endmath&}} \def\installmathmatrixhandler#1#2% @@ -806,11 +806,11 @@ %D %D Just a handy keystroke safer: -\def\startmatrices +\unexpanded\def\startmatrices {\begingroup \setupmathmatrix} -\def\stopmatrices +\unexpanded\def\stopmatrices {\endgroup} %D \startbuffer @@ -849,7 +849,7 @@ %D \stopformula %D \stopbuffer %D -%D \typebuffer \getbuffer +%D \typebuffer % does not run well: \getbuffer %D \macros %D {startintertext} @@ -858,7 +858,7 @@ %D %D {\em example code} -\def\startintertext#1\stopintertext +\unexpanded\def\startintertext#1\stopintertext {\noalign{\dointertext{#1}}} \def\intertext#1% @@ -888,7 +888,7 @@ % %D \stopformula % %D \stoptyping -% \def\startsubstack +% \unexpanded\def\startsubstack % {\begingroup % \null % \vcenter\bgroup @@ -905,7 +905,7 @@ % \everycr\emptytoks % \halign\bgroup\hfil$\scriptstyle\mathstrut##$\hfil\crcr} -% \def\stopsubstack +% \unexpanded\def\stopsubstack % {\crcr % \egroup % \popmacro\domatrixNC @@ -940,9 +940,11 @@ %D \text{ and } %D \sum_{\scriptstyle a \atop \scriptstyle} %D \stopformula +%D \stopbuffer +%D %D \typebuffer which gives \getbuffer -\def\startsubstack +\unexpanded\def\startsubstack {\begingroup \vcenter\bgroup \baselineskip\mathstacktotal @@ -960,7 +962,7 @@ \everycr\emptytoks \halign\bgroup\hfil$\scriptstyle##$\hfil\crcr} -\def\stopsubstack +\unexpanded\def\stopsubstack {\crcr \egroup \egroup @@ -1042,6 +1044,241 @@ {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\zeropoint#2}\limits_{#1}}} +%D The following code comes from \type {math-str.mkiv}. + +%D Here we implement a basic math alignment mechanism. Numbers +%D are also handled. The macros \type {\startinnermath} and +%D \type {\stopinnermath} can be overloaded in specialized +%D modules. + +\unexpanded\def\startinnermath + {\getvalue{\e!start\??fm\formulaparameter\c!align}} + +\unexpanded\def\stopinnermath + {\getvalue{\e!stop \??fm\formulaparameter\c!align}} + +\def\mathinnerstrut + {\doif{\formulaparameter\c!strut}\v!yes\strut} + +\long\unexpanded\def\defineinnermathhandler#1#2#3% + {\setvalue{\e!start\??fm#1}{#2}% + \setvalue{\e!stop \??fm#1}{#3}} + +\newif\iftracemath + +\def\mathhbox + {\iftracemath\ruledhbox\else\hbox\fi} + +\chardef\mathraggedstatus=0 % normal left center right +\chardef\mathnumberstatus=0 % nothing normal shift_right +\let\mathnumbercorrection\!!zeropoint + +\unexpanded\def\startmathbox#1% + {\hsize\displaywidth + \global\chardef\mathnumberstatus\plusone + \chardef\mathraggedstatus#1\relax + \let\mathnumbercorrection\!!zeropoint + \global\let\@eqno \empty \def\eqno {\gdef\@eqno }% + \global\let\@leqno\empty \def\leqno{\gdef\@leqno}% + % added + \let\normalreqno\eqno + \let\normalleqno\leqno + % added + \doplaceformulanumber + \setbox\scratchbox\mathhbox to \displaywidth\bgroup + \mathinnerstrut + $% + \displaystyle + \ifcase\mathraggedstatus\or\hfill\or\hfill\fi} + +\def\llappedmathno + {\ifcase\mathraggedstatus\or + \@eqno + \or + \llap{\@eqno}% + \or + \llap{\@eqno}% + \fi} + +\def\rlappedmathno + {\ifcase\mathraggedstatus\or + \rlap{\@leqno}% + \or + \rlap{\@leqno}% + \or + \@leqno + \fi} + +\unexpanded\def\stopmathbox + {$% + \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi + \egroup + \setbox0\hbox{\unhcopy\scratchbox}% + \scratchdimen\wd0 + \ifdim\scratchdimen>\displaywidth + \donetrue + \else + \donefalse + \fi + \hbox to \displaywidth\bgroup + \ifcase\mathnumberstatus + \box\scratchbox + \or + \ifx\@leqno\empty + \ifx\@eqno\empty + \box\scratchbox + \else + \ifdone + \vbox{\box\scratchbox\hbox to \displaywidth{\hss\llappedmathno}}% + \else + \hss\box\scratchbox\llappedmathno % hss makes room for number + \fi + \fi + \else + \ifdone + \vbox{\hbox to \displaywidth{\rlappedmathno\hss}\box\scratchbox}% + \else + \rlappedmathno\box\scratchbox\hss % hss makes room for number + \fi + \fi + \or + \hskip\mathnumbercorrection + \box\scratchbox + \hss + \else + \box\scratchbox + \fi + \egroup} + +\defineinnermathhandler\v!left {\startmathbox\plusone }{\stopmathbox} +\defineinnermathhandler\v!middle {\startmathbox\plustwo }{\stopmathbox} +\defineinnermathhandler\v!right {\startmathbox\plusthree}{\stopmathbox} +\defineinnermathhandler\v!flushleft {\startmathbox\plusthree}{\stopmathbox} +\defineinnermathhandler\v!center {\startmathbox\plustwo }{\stopmathbox} +\defineinnermathhandler\v!flushright{\startmathbox\plusone }{\stopmathbox} + +%D [The examples below are in english and don't process in the +%D documentation style, which will be english some day.] +%D +%D Normally a formula is centered, but in case you want to +%D align it left or right, you can set up formulas to behave +%D that way. Normally a formula will adapt is left indentation +%D to the environment: +%D +%D \startbuffer +%D \fakewords{20}{40}\epar +%D \startitemize +%D \item \fakewords{20}{40}\epar +%D \placeformula \startformula \fakeformula \stopformula +%D \item \fakewords{20}{40}\epar +%D \stopitemize +%D \fakewords{20}{40}\epar +%D \stopbuffer +%D +%D % \getbuffer +%D +%D In the next examples we explicitly align formulas to the +%D left (\type {\raggedleft}), center and right (\type +%D {\raggedright}): +%D +%D \startbuffer +%D \setupformulas[align=left] +%D \startformula\fakeformula\stopformula +%D \setupformulas[align=middle] +%D \startformula\fakeformula\stopformula +%D \setupformulas[align=right] +%D \startformula\fakeformula\stopformula +%D \stopbuffer +%D +%D \typebuffer +%D +%D Or in print: +%D +%D % {\getbuffer} +%D +%D With formula numbers these formulas look as follows: +%D +%D \startbuffer +%D \setupformulas[align=left] +%D \placeformula \startformula\fakeformula\stopformula +%D \setupformulas[align=middle] +%D \placeformula \startformula\fakeformula\stopformula +%D \setupformulas[align=right] +%D \placeformula \startformula\fakeformula\stopformula +%D \stopbuffer +%D +%D % {\getbuffer} +%D +%D This was keyed in as: +%D +%D \typebuffer +%D +%D When tracing is turned on (\type {\tracemathtrue}) you can +%D visualize the bounding box of the formula, +%D +%D % {\tracemathtrue\getbuffer} +%D +%D As you can see, the dimensions are the natural ones, but if +%D needed you can force a normalized line: +%D +%D \startbuffer +%D \setupformulas[strut=yes] +%D \placeformula \startformula \fakeformula \stopformula +%D \stopbuffer +%D +%D \typebuffer +%D +%D This time we get a more spacy result. +%D +%D % {\tracemathtrue\getbuffer} +%D +%D We will now show a couple of more settings and combinations +%D of settings. In centered formulas, the number takes no space +%D +%D \startbuffer +%D \setupformulas[align=middle] +%D \startformula \fakeformula \stopformula +%D \placeformula \startformula \fakeformula \stopformula +%D \stopbuffer +%D +%D \typebuffer % {\tracemathtrue\getbuffer} +%D +%D You can influence the placement of the whole box with the +%D parameters \type {leftmargin} and \type {rightmargin}. +%D +%D \startbuffer +%D \setupformulas[align=right,leftmargin=3em] +%D \startformula \fakeformula \stopformula +%D \placeformula \startformula \fakeformula \stopformula +%D +%D \setupformulas[align=left,rightmargin=1em] +%D \startformula \fakeformula \stopformula +%D \placeformula \startformula \fakeformula \stopformula +%D \stopbuffer +%D +%D \typebuffer % {\tracemathtrue\getbuffer} +%D +%D You can also inherit the margin from the environment. +%D +%D \startbuffer +%D \setupformulas[align=right,margin=standard] +%D \startformula \fakeformula \stopformula +%D \placeformula \startformula \fakeformula \stopformula +%D \stopbuffer +%D +%D \typebuffer % {\tracemathtrue\getbuffer} +%D +%D The distance between the formula and the number is only +%D applied when the formula is left or right aligned. +%D +%D \startbuffer +%D \setupformulas[align=left,distance=2em] +%D \startformula \fakeformula \stopformula +%D \placeformula \startformula \fakeformula \stopformula +%D \stopbuffer +%D +%D \typebuffer % {\tracemathtrue\getbuffer} + \protect \endinput % \placeformula \startformula[-] \startmatrix |