diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-mat.tex')
-rw-r--r-- | Master/texmf-dist/tex/context/base/core-mat.tex | 300 |
1 files changed, 252 insertions, 48 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-mat.tex b/Master/texmf-dist/tex/context/base/core-mat.tex index e9319068c47..a74d5f90eda 100644 --- a/Master/texmf-dist/tex/context/base/core-mat.tex +++ b/Master/texmf-dist/tex/context/base/core-mat.tex @@ -3,7 +3,7 @@ %D version=2006.03.27, % 1998.12.07 %D title=\CONTEXT\ Core Macros, %D subtitle=Math Fundamentals, -%D author={Hans Hagen \& Taco Hoekwater}, +%D author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan}, %D date=\currentdate, %D copyright=PRAGMA] %C @@ -17,6 +17,18 @@ \unprotect +% \startlines +% $\mathopnolimits{\rm d}x$ +% $\mathopnolimits{\kern\zeropoint \rm d}x$ +% $\puremathcomm{nolop}{\rm d}x$ +% $\puremathcomm{nolop}{\kern\zeropoint\rm d}x$ +% \blank +% $\puremathcomm{nolop}{\mr d}x$ +% $\puremathcomm{nolop}{\kern\zeropoint\mr d}x$ +% $\mathop{\kern\zeropoint\mr d}x$ +% $\mathopnolimits{\kern\zeropoint d}x$ +% \stoplines + % \definemessageconstant{math} % \startmessages all library: math @@ -50,6 +62,8 @@ \expandafter\secondoftwoarguments \fi} +% \defineactivecharacter _ {\mathortext{_}{\_}} text_text $a^2$ + % force text mode, will be overloaded later \ifx\text\undefined \let\text\hbox \fi @@ -153,6 +167,9 @@ \def\formuladistance{\formulaparameter\c!distance} +\def\doformulareference#1#2% + {\doifsomething{#1}{\doifnotinset{#1}{+,-}{\rawreference\s!for{#1}{#2}}}} + \def\dododoformulanumber#1#2#3#4% (#1,#2)=outer(ref,sub) (#3,#4)=inner(ref,sub) {\hbox\bgroup \ifconditional\handleformulanumber @@ -162,16 +179,16 @@ \makesectionnumber[\v!formula]% \setbox0\hbox{\ignorespaces#2\unskip}% \ifdim\wd0>\zeropoint - \edef\hetsubnummer{#2}% + \edef\hetsubnummer{\@@fnseparator#2}%AM: was \edef\hetsubnummer{#2}% \else \let\hetsubnummer\empty \fi - \doifsomething{#1}{\rawreference{\s!for}{#1}{\composedsectionnumber\hetsubnummer}}% + \doformulareference{#1}{\composedsectionnumber\hetsubnummer}% \setbox0\hbox{\ignorespaces#4\unskip}% \ifdim\wd0>\zeropoint - \edef\hetsubnummer{#4}% + \edef\hetsubnummer{\@@fnseparator#4}%AM: was \edef\hetsubnummer{#4}% \fi - \doifsomething{#3}{\rawreference\s!for{#3}{\composedsectionnumber\hetsubnummer}}% + \doformulareference{#3}{\composedsectionnumber\hetsubnummer}% \doflushformulalistentry{\composedsectionnumber\hetsubnummer}% \rm % nodig ? \doif{\formulaparameter\c!location}\v!right{\hskip\formuladistance}% @@ -281,6 +298,8 @@ {\displayindent\leftdisplayskip \advance\displayindent\leftdisplaymargin \displaywidth\hsize +% \setlocalhsize +% \displaywidth\localhsize \ifdim\hangindent>\zeropoint \advance\displayindent\hangindent \else @@ -315,7 +334,8 @@ % \ifdim\lastskip>\zeropoint % \resetlastlinewidth % else problems with in between stuff without \epar % \fi - \bgroup + \bgroup % HERE + \the\everybeforedisplayformula \formulaparskip\parskip \formulastrutdp\strutdepth \formulastrutht\strutheight @@ -518,9 +538,6 @@ % \placeformula {f} \startspformule \fakespacingformula \stopspformule % \fakewords{20}{40} -% \convertcommand\next\to\ascii \getfirstcharacter\ascii -% \ifx\firstcharacter\letterbackslash % a \cs - \def\placeformula {\settrue\incrementformulanumber \dodoubleempty\doplaceformula} @@ -569,7 +586,7 @@ {\incrementnumber[\v!formula]% \makesectionnumber[\v!formula]% \doflushformulalistentry{\composedsectionnumber}% - \doifsomething{#1}{\rawreference\s!for{#1}\composedsectionnumber}% + \doformulareference{#1}\composedsectionnumber \expanded{\setupnumber [\v!formula*] [\c!start={\rawnumber[\v!formula]}, @@ -605,7 +622,8 @@ \setupsubformulas [\c!conversion=\v!character, - \c!separator=\@@fmseparator, +% \c!separator=\@@fmseparator, + \c!separator=,%AM: for compatibility with \placesubformula \c!indentnext=\@@fmindentnext] %D Experimental goodie: @@ -671,6 +689,9 @@ [#1]{#3}}% \futurelet\next\redoplaceformula#4} +\let\startplaceformula\placeformula +\let\stopplaceformula \relax + \def\startformulas#1\stopformulas % new / to be internationalized {\bgroup \forgetdisplayskips @@ -1696,6 +1717,21 @@ \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#2\crcr}% \finishalignno} +\def\dobothaligneqalignno#1% + {\ifmmode + \displ@y + \global\chardef\mathnumberstatus\plusone + \ifcase\mathraggedstatus + \def\finishalignno{\crcr\egroup}% + \else + % we're in a mathbox + \vcenter\bgroup + \def\finishalignno{\crcr\egroup\egroup}% + \fi + \fi + #1% + \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr} + \def\mrlap#1% {\setbox\scratchbox\hbox{#1}% \ifdim\wd\scratchbox>\mathnumbercorrection @@ -1704,18 +1740,18 @@ \box\scratchbox \global\chardef\mathnumberstatus\plustwo} -\def\dobothaligneqalignno#1% - {\ifmmode - \displ@y - \global\chardef\mathnumberstatus\plusone - % we're in a mathbox - \vcenter\bgroup - \def\finishalignno{\crcr\egroup\egroup}% - \else - \def\finishalignno{\crcr\egroup}% - \fi - #1% - \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr} +% \def\dobothaligneqalignno#1% +% {\ifmmode +% \displ@y +% \global\chardef\mathnumberstatus\plusone +% we're in a mathbox +% \vcenter\bgroup +% \def\finishalignno{\crcr\egroup\egroup}% +% \else +% \def\finishalignno{\crcr\egroup}% +% \fi +% #1% +% \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr} \def\reqalignno {\dobotheqalignno \preparereqalignno} \def\leqalignno {\dobotheqalignno \prepareleqalignno} @@ -2287,7 +2323,7 @@ \tabskip\zeropoint \eqaligncolumn\zerocount % could be \scratchcounter \processcommacommand[\mathmatrixparameter\c!align]{\advance\eqaligncolumn\plusone\dosetmatrixcolumn}% - \scratchcounter=\ifnum\eqaligncolumn>\scratchcounter \eqaligncolumn \else \plusone \fi + \scratchcounter=\ifnum\eqaligncolumn>\zerocount \eqaligncolumn \else \plusone \fi \global\eqaligncolumn\plusone \preparemathmatrix } % uses scratchcounter @@ -2363,7 +2399,6 @@ %D %D \startbuffer %D \startformula -%D \startformula %D \text{Let }{\cal R} = \bigcup_{P_{X_1},P_{X_2}} %D \left\{ (R_1, R_2) : %D \startmatrix[distance=1em,align={left,left,right}] @@ -2447,12 +2482,53 @@ \penalty\predisplaypenalty \beforedisplayspace} +% %D \macros +% %D {substack} +% %D +% %D Preliminary code: +% %D +% %D \starttyping +% %D \startformula +% %D \sum_{% +% %D \startsubstack +% %D i = 1 \NR +% %D i \neq n \NR +% %D i \neq m +% %D \stopsubstack +% %D }a_i +% %D \stopformula +% %D \stoptyping + +% \def\startsubstack +% {\begingroup +% \null +% \vcenter\bgroup +% \pushmacro\domatrixNC +% \let\stopmathmode\relax +% \def\NC{\domatrixNC}% +% \def\MC{\domatrixNC\startmathmode}% +% \global\let\domatrixNC\dodomatrixNC +% \def\NR +% {\stopmathmode +% \global\let\domatrixNC\dodomatrixNC +% \crcr\noalign{\nointerlineskip}}% +% \mathsurround\zeropoint +% \everycr\emptytoks +% \halign\bgroup\hfil$\scriptstyle\mathstrut##$\hfil\crcr} + +% \def\stopsubstack +% {\crcr +% \egroup +% \popmacro\domatrixNC +% \egroup +% \endgroup} + %D \macros %D {substack} %D %D Preliminary code: %D -%D \starttyping +%D \startbuffer %D \startformula %D \sum_{% %D \startsubstack @@ -2462,31 +2538,44 @@ %D \stopsubstack %D }a_i %D \stopformula -%D \stoptyping +%D \stopbuffer +%D +%D \getbuffer which was typed as \typebuffer +%D +%D Notice that these macros give the correct spacing for +%D subscripts. Compare for example +%D +%D \startbuffer +%D \startformula +%D \sum_{\startsubstack a \NR b \NR \stopsubstack} +%D \text{ and } +%D \sum_{\scriptstyle a \atop \scriptstyle} +%D \stopformula +%D \typebuffer which gives \getbuffer \def\startsubstack - {\begingroup - \null - \vcenter\bgroup - \pushmacro\domatrixNC - \let\stopmathmode\relax - \def\NC{\domatrixNC}% - \def\MC{\domatrixNC\startmathmode}% - \global\let\domatrixNC\dodomatrixNC - \def\NR - {\stopmathmode - \global\let\domatrixNC\dodomatrixNC - \crcr\noalign{\nointerlineskip}}% - \mathsurround\zeropoint - \everycr\emptytoks - \halign\bgroup\hfil$\scriptstyle\mathstrut##$\hfil\crcr} + {\begingroup + \vcenter\bgroup + \baselineskip\dimexpr\fontdimen10 \scriptfont\plustwo + \fontdimen12 \scriptfont\plustwo\relax + \lineskip\plusthree\fontdimen8 \scriptfont\plusthree + \lineskiplimit\lineskip + \let\stopmathmode\relax + \def\NC{\domatrixNC}% + \def\MC{\domatrixNC\startmathmode}% + \global\let\domatrixNC\dodomatrixNC + \def\NR + {\stopmathmode + \global\let\domatrixNC\dodomatrixNC + \crcr}% + \mathsurround\zeropoint + \everycr\emptytoks + \halign\bgroup\hfil$\scriptstyle##$\hfil\crcr} \def\stopsubstack - {\crcr - \egroup - \popmacro\domatrixNC - \egroup - \endgroup} + {\crcr + \egroup + \egroup + \endgroup} %D \macros %D {frac, xfrac, xxfrac} @@ -2681,7 +2770,122 @@ \def\enablefiller {\let\normalorfiller\secondoftwoarguments} \def\disablefiller {\let\normalorfiller\firstoftwoarguments} -\def\mathopnolimits#1{\mathop{\rm#1}\nolimits} +\def\mathopnolimits#1{\mathop{\mr#1}\nolimits} % was \rm, which follows text fonts (used in mml parser) +\def\mathopdolimits#1{\mathop{\mr#1}} % was \rm, which follows text fonts (used in mml parser) + +%D \macros{overset, underset} +%D +%D The macros \type{\overset} and \type{\underset} are provided by +%D \AMS\ packages in \LATEX. These macro allows you to place a symbol +%D above or below another symbol, irrespective of whether the other +%D symbol is a relation or something else, and without influencing the +%D spacing. For most cases there is a better way to do such things +%D (declaring a math command with limop option, or using accents), but +%D occasionally these macros can be useful, for example: +%D +%D \startbuffer +%D \startformula +%D \overset{*}{X} \underset{*}{X} +%D \stopformula +%D \stopbuffer +%D \typebuffer \getbuffer +%D +%D Use these macros sparingly. Remember, \TEX\ was designed for +%D mathematics, so there is usually a proper method for typesetting +%D common math notation. + +%D These macros are a clearer version of \type{\binrel@} and +%D \type{\binrel@@} macros in \AMSTEX\ packages. + +\def\preparebinrel#1% + {\begingroup + \setbox\scratchbox\hbox + {\thinmuskip 0mu + \medmuskip -1mu + \thickmuskip -1mu + \setbox\scratchbox\hbox{$#1\mathsurround\zeropoint$}% + \kern-\wd\scratchbox + ${}#1{}\mathsurround\zeropoint$}% + \expanded + {\endgroup + \let\noexpand\currentbinrel + \ifdim\wd\scratchbox<\zeropoint + \mathbin + \else\ifdim\wd\scratchbox>\zeropoint + \mathrel + \else + \relax + \fi\fi}} + +\unexpanded\def\overset#1#2% + {\preparebinrel{#2}% + \currentbinrel{\mathop{\kern\zeropoint#2}\limits^{#1}}} + +\unexpanded\def\underset#1#2% + {\preparebinrel{#2}% + \currentbinrel{\mathop{\kern\zeropoint#2}\limits_{#1}}} + +%D \macros +%D {boldsymbol} +%D +%D The math definition is inspired by amsmath. +%D +%D \startbuffer +%D \definetypeface [boldmath] [mm] [boldmath] [latin-modern] [modern] [encoding=texnansi] +%D +%D $a \times b$ $a \boldsymbol{\times} b$ +%D \stopbuffer +%D +%D \typebuffer \start \getbuffer \stop + +\def\mathboldsymbol#1% + {\preparebinrel{#1}% + \currentbinrel{\mathchoice + {\hbox{\switchtoformulabodyfont [boldmath]$\m@th#1$}} + {\hbox{\switchtoformulabodyfont [boldmath]$\m@th#1$}} + {\hbox{\switchtoformulabodyfont [boldmath,script]$\m@th#1$}} + {\hbox{\switchtoformulabodyfont[boldmath,scriptscript]$\m@th#1$}}}} + +\def\boldsymbol + {\mathortext\mathboldsymbol\bold} + +%D Some encoding hackery (for Mojca. who else): +%D +%D \starttyping +%D \startmathcollection[eul:texnansi] +%D \definemathsymbol [breve] [accent] [tf] ["15] +%D \stopmathcollection +%D \startmathcollection[eul:ec] +%D \definemathsymbol [breve] [accent] [tf] ["08] +%D \stopmathcollection +%D +%D $\breve e$ +%D \stoptyping + +\let\outerencoding\empty + +\def\checkoutermathencoding + {\ifx\outerencoding\empty + \ifx\outerencoding\s!default\else + \edef\outerencoding{\currentencoding}% + \fi + \fi} + +\prependtoks + \checkoutermathencoding +\to \everymathematics + +%D More. (A temp hack, else no proper default fall back (like \type +%D {\textmultiply}); todo: sync encoding. + +\def\dealwithmathtextencoding + {\expanded{\everyhbox{\the\everyhbox\noexpand\fastenableencoding{\currentencoding}}}% + \def\dealwithmathtextencoding{\let\characterencoding\nocharacterencoding}% + \dealwithmathtextencoding} + +\appendtoks + \dealwithmathtextencoding +\to \everymathematics %D How negative such a symbol looks is demonstrated in: %D $\negative 10^{\negative 10^{\negative 10}}$. |