ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* math
@ 2006-01-17 13:50 Hans Hagen
  2006-01-18  6:56 ` math sjoerd siebinga
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Hans Hagen @ 2006-01-17 13:50 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

Hi,

Attached is a new version of math-ext

- multiple columns
- alignment per column

See examples in source (mixed &|cr and NC|NR is no longer supported).

That's all the math for this week.

Hans

[-- Attachment #2: math-ext.tex --]
[-- Type: text/x-tex, Size: 12542 bytes --]

%D \module
%D   [       file=math-ext,
%D        version=2006.01.14,
%D          title=\CONTEXT\ Math Macros,
%D       subtitle=Extra Macros,
%D         author={Hans Hagen \& Taco Hoekwater},
%D           date=\currentdate,
%D      copyright=\PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This will go into core-mat

%M \ifx\startalign\undefined \input math-ext.tex \fi

% some simple math constructs (based on user requests)
%
% preliminary

\unprotect

% adapted stuff

% we need to make this plain code a bit more 'readable'

\def\openup
  {\afterassignment\dopenup\scratchdimen=}

\def\dopenup
  {\advance\lineskip     \scratchdimen
   \advance\baselineskip \scratchdimen
   \advance\lineskiplimit\scratchdimen}

\def\jot{.25\bodyfontsize} % plain tex: 3 pt (todo: better name)

\newif\ifdt@p

\def\displ@y % \presetdisplayspacing or so
  {\global\dt@ptrue
   \openup\jot
   \mathsurround\zeropoint
   \everycr{\noalign{%
      \ifdt@p
        \global\dt@pfalse
        \ifdim\prevdepth>-\thousandpoint
          \vskip-\lineskiplimit
          \vskip\normallineskiplimit
        \fi
      \else
        \penalty\interdisplaylinepenalty
      \fi}}}

% context (hooks)

\let\normaldispl@y\displ@y

\def\displ@y{\resetdisplaymatheq\normaldispl@y}

\let\presetdisplaymath\displ@y

% plain tex value: \centering = 0pt plus 1000pt minus 1000pt
% plain tex valye: \jot = 3pt

% n>1 #### needed, strange # interaction (maybe we need a toks in recurse ane no macro)

\def\buildeqalign
  {\scratchtoks\emptytoks
   \dorecurse{\mathalignparameter\c!m}
     {\ifnum\recurselevel>\plusone
        \appendtoks
          \tabskip\mathalignparameter\c!distance&\tabskip\zeropoint
        \to\scratchtoks
      \fi
      \expanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
      \dorecurse{\numexpr\mathalignparameter\c!n-\plusone\relax}
        {\expanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
   \expanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}

\def\forgetalign
  {\tabskip\zeropoint\everycr\emptytoks}

\let\firstineqalign\empty
\let\nextineqalign \empty
\let\leftofeqalign \empty
\let\rightofeqalign\empty

\def\mathineqalign#1{$\forgetalign\displaystyle{{}#1{}}$}
\def\textineqalign#1{$\forgetalign#1$}

\def\eqalign#1% why no halign here, probably because of displaywidth
  {\!!toksa{\strut\hfil$\displaystyle{##}$}%
   \!!toksb{&$\displaystyle{{}##{}}$\hfil}%
   \!!toksc\emptytoks
   \buildeqalign
   \null\,\vcenter
     {\openup\jot
      \mathsurround\zeropoint
      \expandafter \ialign \expandafter {\the\scratchtoks\crcr#1\crcr}%
   }\,}

% preamble is scanned for tabskips so we need the span to prevent an error message

\def\prepareeqalignno
  {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
   \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
   \!!toksc{\hfil\tabskip\centering&\llap{\span\textineqalign{##}}\tabskip\zeropoint}%
   \buildeqalign
   \presetdisplaymath
   \tabskip\centering}

\def\prepareleqalignno
  {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
   \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
   \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\textineqalign{##}}\tabskip\displaywidth}%
   \buildeqalign
   \presetdisplaymath
   \tabskip\centering}

\chardef\eqalignmode=1

\def\eqalignno#1%
  {\prepareeqalignno
   \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#1\crcr}}

\def\leqalignno#1%
  {\prepareleqaligno
   \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#1\crcr}}

\def\aligneqalignno
  {\prepareeqalignno
   \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}

\def\alignleqalignno
  {\prepareleqalignno
   \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}

\def\finishalignno
  {\crcr\egroup}

\definesystemvariable{eq}

\def\setupmathalign
  {\dodoubleempty\dosetupmathalign}

\def\dosetupmathalign[#1][#2]%
  {\ifsecondargument
     \getparameters[\??eq#1][#2]%
   \else
     \getparameters[\??eq][#1]%
   \fi}

\let\currentmathalign\empty

\def\mathalignparameter#1%
  {\executeifdefined{\??eq\currentmathalign#1}{\executeifdefined{\??eq#1}\empty}}

\setupmathalign
  [\c!n=2,
   \c!m=1,
   \c!distance=1em]

\def\numberedeqalign
  {\doifelse\@@fmlocation\v!left\alignleqalignno\aligneqalignno}

\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][]}

\newcount\eqaligncolumn

\def\firstineqalign{\global\eqaligncolumn\plusone}
\def\nextineqalign {\global\advance\eqaligncolumn\plusone}
\def\leftofeqalign {\getvalue{\??eq:\v!left :\number\eqaligncolumn}}
\def\rightofeqalign{\getvalue{\??eq:\v!right:\number\eqaligncolumn}}

\def\doseteqaligncolumn#1%
  {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\empty
   \letvalue{\??eq:\v!right:\number\eqaligncolumn}\empty
   \doif{#1}\v!left  {\letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfill}%
   \doif{#1}\v!right {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfill}%
   \doif{#1}\v!middle{\letvalue{\??eq:\v!right:\number\eqaligncolumn}\hfill
                      \letvalue{\??eq:\v!left :\number\eqaligncolumn}\hfill}}

\def\dodoalignNC
  {\gdef\doalignNC##1{&##1}}

\def\doalignNR[#1][#2]%
  {\doifsomething{#1}
     {\doifelse{#1}{+}
        {\doformulanumber[][#2][]{}}
        {\doformulanumber[#1][#2][]{}}}%
   \crcr}

\def\dostartmathalign[#1][#2]%
  {\pushmacro\doalignNC
   \edef\currentmathalign{#1}%
   \doifassignmentelse{#2}{\setupmathalign[#1][#2]}\donothing
   \def\NC{\doalignNC}%
   \global\let\doalignNC\dodoalignNC
   \def\EQ{&=}%
   \def\NR{&\global\let\doalignNC\dodoalignNC\doxxdoubleempty\doalignNR}%
   % amstex compatibility mode: (ugly)
   \def\notag{\def\\{&\crcr}}%
   \doifelse{#2}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
   % end of compatibility mode
   \eqaligncolumn\zerocount
   \processcommacommand[\mathalignparameter\c!align]{\advance\eqaligncolumn\plusone\doseteqaligncolumn}%
   % the real action
   \global\eqaligncolumn\plusone
   \numberedeqalign}

\def\dostopmathalign
  {\finishalignno
   \popmacro\doalignNC}

\def\definemathalign
  {\dodoubleempty\dodefinemathalign}

\def\dodefinemathalign[#1]% [#2]%
  {\setvalue{\e!start#1}{\dodoubleempty\dostartmathalign[#1]}%
   \setvalue{\e!stop #1}{\dostopmathalign}%
   \setupmathalign[#1]}% [#2]

\definemathalign[align]     % default case

% \def\startsplit
%   {\startalign[*]} % no number by default
%
% \def\stopsplit
%   {&\doalignNR[+][]\crcr % for a number on last line
%    \stopalign}

%D \startbuffer
%D \placeformula \startformula \eqalignno {
%D  a &= b & \formulanumber \cr
%D  c &= d \cr
%D    &= e \cr
%D    &= f & \formulanumber
%D } \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign
%D \NC  a \EQ b \NR[+]
%D \NC  c \EQ d \NR
%D \NC    \EQ f \NR[for:demo-a-1]
%D \NC    \EQ g \NR[for:demo-a-2][a]
%D \NC    \EQ h \NR[for:demo-a-3][b]
%D \NC    \EQ i \NR
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign
%D \NC a \EQ b \NR[+]
%D \NC c \EQ d \NR
%D \NC   \EQ f \NR
%D \NC   \EQ g \NR
%D \NC   \EQ h \NR
%D \NC   \EQ i \NR[+]
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign
%D a &= b \\
%D c &= d \notag \\
%D   &= e \notag \\
%D   &= f \\
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign
%D \NC  a \NC \eq  b \NR[+]
%D \NC  c \NC \neq d \NR
%D \NC    \NC \neq f \NR[for:demo-b-1]
%D \NC    \NC \geq g \NR[for:demo-b-2][a]
%D \NC    \NC \leq h \NR[for:demo-b-3][b]
%D \NC    \NC \neq i \NR
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign[*]
%D a &= b \\
%D c &= d \\
%D   &= e \\
%D   &= f \\
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign
%D     x &= y \\
%D     a &= b \\
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign[m=3]
%D     x &= y & x &= y & z &= t \\
%D     a &= b & p &= q & w &= s \\
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign[m=3,distance=0pt]
%D     x &= y &= x &= y &= z &= t \\
%D     a &= b &= p &= q &= w &= s \\
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign[n=5,distance=0pt]
%D     x &= yy &= xx &= yy &= zz \\
%D     a &= b  &= p  &= q  &= w  \\
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign[n=3,align={left,middle,right}]
%D \NC       l \NC = \NC r     \NR
%D \NC    left \NC = \NC right \NR
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign[n=3,align={right,middle,left}]
%D \NC       l \NC = \NC r     \NR
%D \NC    left \NC = \NC right \NR
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula \startformula \startalign[n=3,align={middle,middle,middle}]
%D \NC       l \NC = \NC r     \NR
%D \NC    left \NC = \NC right \NR
%D \stopalign \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer

% BEGIN OF PATCH (CORE-MAT.TEX)

\def\doplaceformula[#1][#2]% #2 = dummy, gobbles spaces
  {\def\redoplaceformula
     {\bgroup
      \ifx\next\bgroup
        \egroup \@EA\moreplaceformula % [ref]{}
      \else
        \def\nextnext{$}%
        \ifx\next\nextnext
          \egroup \@EAEAEA\dispplaceformula % [ref]$$
        \else
          \egroup \@EAEAEA\dodoplaceformula % [ref]\start
        \fi
      \fi[#1]{}}%
   \futurelet\next\redoplaceformula}

\long\def\moreplaceformula[#1]#2#3#4% #2 dummy #4 gobbles spaces
  {\def\redoplaceformula
     {\bgroup
      \def\nextnext{$}%
      \ifx\next\nextnext
        \egroup \@EA\dispplaceformula % [ref]$$
      \else
        \egroup \@EA\dodoplaceformula % [ref]\start
      \fi
      [#1]{#3}}%
   \futurelet\next\redoplaceformula#4}

% END OF PATCH

\def\startformulas#1\stopformulas
  {\bgroup
   \forgetdisplayskips
   \startdisplaymath
   \setlocalhsize
   \long\def\startformula##1\stopformula{\advance\scratchcounter\plusone}%
   \scratchcounter\zerocount #1% preroll
   \divide \hsize \scratchcounter
   \hbox to \localhsize \bgroup
     \hss
     \def\normalstartformula{\vskip-\strutdepth$$}% i hate this
     \def\normalstopformula {$$}%
   % \def\jot{0pt}%
     \def\startformula{$\vcenter\bgroup\normalstartformula}%
     \def\stopformula {\normalstopformula\egroup$\hss}%
     #1%
     \egroup
     \stopdisplaymath
   \egroup}

%D \startbuffer
%D \placeformula
%D \startformula
%D     \startalign[n=3,align={middle,middle,middle}]
%D         \NC a  \NC = \NC b  \NR[+]
%D         \NC 2a \NC = \NC 2b \NR
%D     \stopalign
%D \stopformula
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula
%D \startformulas
%D     \setupmathalign[n=3,align={middle,middle,middle}]%
%D     \startformula
%D         \startalign
%D             \NC a  \NC = \NC b  \NR[+]
%D             \NC 2a \NC = \NC 2b \NR
%D         \stopalign
%D     \stopformula
%D     \startformula
%D         \startalign
%D             \NC a  \NC = \NC b  \NR[+]
%D             \NC 2a \NC = \NC 2b \NR
%D         \stopalign
%D     \stopformula
%D \stopformulas
%D \stopbuffer
%D
%D \typebuffer \getbuffer
%D
%D \startbuffer
%D \placeformula
%D \startformulas
%D     \dorecurse{5}{\startformula
%D         \startalign[n=3,align={middle,middle,middle}]
%D             \NC a  \NC = \NC b  \NR[+]
%D             \NC 2a \NC = \NC 2b \NR
%D         \stopalign
%D     \stopformula}
%D \stopformulas
%D \stopbuffer
%D
%D \typebuffer \getbuffer

\protect \endinput

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-17 13:50 math Hans Hagen
@ 2006-01-18  6:56 ` sjoerd siebinga
  2006-01-18  7:48   ` math Taco Hoekwater
  2006-01-18  8:17 ` math sjoerd siebinga
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: sjoerd siebinga @ 2006-01-18  6:56 UTC (permalink / raw)



On 17 Jan 2006, at 23:54, Hans Hagen wrote:
>
> does {\it blabla} give italic?

Yes it does. But when I place the \uchar{1}{01} inbetween the bla  
bla's the glyph remains regular.

Sjoerd

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-18  6:56 ` math sjoerd siebinga
@ 2006-01-18  7:48   ` Taco Hoekwater
  0 siblings, 0 replies; 10+ messages in thread
From: Taco Hoekwater @ 2006-01-18  7:48 UTC (permalink / raw)


sjoerd siebinga wrote:
> 
> On 17 Jan 2006, at 23:54, Hans Hagen wrote:
> 
>>
>> does {\it blabla} give italic?
> 
> 
> Yes it does. But when I place the \uchar{1}{01} inbetween the bla  bla's 
> the glyph remains regular.

Are you in math mode, by any chance?
An very small example with wrong versus right would be very helpful.

Cheers, Taco

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-17 13:50 math Hans Hagen
  2006-01-18  6:56 ` math sjoerd siebinga
@ 2006-01-18  8:17 ` sjoerd siebinga
  2006-01-19  5:42 ` math Aditya Mahajan
  2006-01-21  4:01 ` math David Arnold
  3 siblings, 0 replies; 10+ messages in thread
From: sjoerd siebinga @ 2006-01-18  8:17 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 667 bytes --]

Hi Taco,

I am not in math mode. I am not sure what happened, but somehow I  
must have send my reply to the wrong thread. I have since send it to  
the correct thread, see \uchar and italics question.

Sorry for the inconvenience,

Sjoerd


On 18 Jan 2006, at 08:47, Taco Hoekwater wrote:

> sjoerd siebinga wrote:
> >
> > On 17 Jan 2006, at 23:54, Hans Hagen wrote:
> >
> >>
> >> does {\it blabla} give italic?
> >
> >
> > Yes it does. But when I place the \uchar{1}{01} inbetween the bla  
> bla's
> > the glyph remains regular.
>
> Are you in math mode, by any chance?
> An very small example with wrong versus right would be very helpful.
>
> Cheers, Taco
>





[-- Attachment #1.2: Type: text/html, Size: 2983 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-17 13:50 math Hans Hagen
  2006-01-18  6:56 ` math sjoerd siebinga
  2006-01-18  8:17 ` math sjoerd siebinga
@ 2006-01-19  5:42 ` Aditya Mahajan
  2006-01-19  7:57   ` math Hans Hagen
  2006-01-21  4:01 ` math David Arnold
  3 siblings, 1 reply; 10+ messages in thread
From: Aditya Mahajan @ 2006-01-19  5:42 UTC (permalink / raw)


<--- On Jan 17, Hans Hagen wrote --->

> Hi,
>
> Attached is a new version of math-ext
>
> - multiple columns
> - alignment per column
>
> See examples in source (mixed &|cr and NC|NR is no longer supported).

Thanks a lot. This takes care of 95% of my math needs, and I have 
finally started using context for a project. I did a bit of testing of 
the code and things work as expected. Once it is included in the main 
distribution, I will write an entry on the wiki.

I am not sure of what is distance supposed to do when we specify the 
columns as n=something. Consider the following example for the source. 
I changed distance=0pt to distance=5cm and see no change.

\startbuffer
\placeformula \startformula \startalign[n=5,distance=5cm]
     x &= yy &= xx &= yy &= zz \\
     a &= b  &= p  &= q  &= w  \\
\stopalign \stopformula
\stopbuffer

\typebuffer \getbuffer


Thanks
Aditya

-- 
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-19  5:42 ` math Aditya Mahajan
@ 2006-01-19  7:57   ` Hans Hagen
  0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2006-01-19  7:57 UTC (permalink / raw)


Aditya Mahajan wrote:

> <--- On Jan 17, Hans Hagen wrote --->
>
>> Hi,
>>
>> Attached is a new version of math-ext
>>
>> - multiple columns
>> - alignment per column
>>
>> See examples in source (mixed &|cr and NC|NR is no longer supported).
>
>
> Thanks a lot. This takes care of 95% of my math needs, and I have 
> finally started using context for a project. I did a bit of testing of 
> the code and things work as expected. Once it is included in the main 
> distribution, I will write an entry on the wiki.
>
> I am not sure of what is distance supposed to do when we specify the 
> columns as n=something. Consider the following example for the source. 
> I changed distance=0pt to distance=5cm and see no change.
>
> \startbuffer
> \placeformula \startformula \startalign[n=5,distance=5cm]
>     x &= yy &= xx &= yy &= zz \\
>     a &= b  &= p  &= q  &= w  \\
> \stopalign \stopformula
> \stopbuffer
>
> \typebuffer \getbuffer
>
it's only used when m is set

Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-17 13:50 math Hans Hagen
                   ` (2 preceding siblings ...)
  2006-01-19  5:42 ` math Aditya Mahajan
@ 2006-01-21  4:01 ` David Arnold
  2006-01-23 21:51   ` math Hans Hagen
  3 siblings, 1 reply; 10+ messages in thread
From: David Arnold @ 2006-01-21  4:01 UTC (permalink / raw)


Hans et al,

I am going to assume that all of this is saved as math-ext.tex. None  
of it goes anywhere else at the moment. Correct?

Also, I assume that:

   \ifx\startalign\undefined \input math-ext.tex \fi

still needs to go into cont-new.tex.

Correct?

On Jan 17, 2006, at 5:50 AM, Hans Hagen wrote:

> Hi,
>
> Attached is a new version of math-ext
>
> - multiple columns
> - alignment per column
>
> See examples in source (mixed &|cr and NC|NR is no longer supported).
>
> That's all the math for this week.
>
> Hans
> %D \module
> %D   [       file=math-ext,
> %D        version=2006.01.14,
> %D          title=\CONTEXT\ Math Macros,
> %D       subtitle=Extra Macros,
> %D         author={Hans Hagen \& Taco Hoekwater},
> %D           date=\currentdate,
> %D      copyright=\PRAGMA]
> %C
> %C This module is part of the \CONTEXT\ macro||package and is
> %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
> %C details.
>
> %D This will go into core-mat
>
> %M \ifx\startalign\undefined \input math-ext.tex \fi
>
> % some simple math constructs (based on user requests)
> %
> % preliminary
>
> \unprotect
>
> % adapted stuff
>
> % we need to make this plain code a bit more 'readable'
>
> \def\openup
>   {\afterassignment\dopenup\scratchdimen=}
>
> \def\dopenup
>   {\advance\lineskip     \scratchdimen
>    \advance\baselineskip \scratchdimen
>    \advance\lineskiplimit\scratchdimen}
>
> \def\jot{.25\bodyfontsize} % plain tex: 3 pt (todo: better name)
>
> \newif\ifdt@p
>
> \def\displ@y % \presetdisplayspacing or so
>   {\global\dt@ptrue
>    \openup\jot
>    \mathsurround\zeropoint
>    \everycr{\noalign{%
>       \ifdt@p
>         \global\dt@pfalse
>         \ifdim\prevdepth>-\thousandpoint
>           \vskip-\lineskiplimit
>           \vskip\normallineskiplimit
>         \fi
>       \else
>         \penalty\interdisplaylinepenalty
>       \fi}}}
>
> % context (hooks)
>
> \let\normaldispl@y\displ@y
>
> \def\displ@y{\resetdisplaymatheq\normaldispl@y}
>
> \let\presetdisplaymath\displ@y
>
> % plain tex value: \centering = 0pt plus 1000pt minus 1000pt
> % plain tex valye: \jot = 3pt
>
> % n>1 #### needed, strange # interaction (maybe we need a toks in  
> recurse ane no macro)
>
> \def\buildeqalign
>   {\scratchtoks\emptytoks
>    \dorecurse{\mathalignparameter\c!m}
>      {\ifnum\recurselevel>\plusone
>         \appendtoks
>           \tabskip\mathalignparameter\c!distance&\tabskip\zeropoint
>         \to\scratchtoks
>       \fi
>       \expanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
>       \dorecurse{\numexpr\mathalignparameter\c!n-\plusone\relax}
>         {\expanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
>    \expanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}
>
> \def\forgetalign
>   {\tabskip\zeropoint\everycr\emptytoks}
>
> \let\firstineqalign\empty
> \let\nextineqalign \empty
> \let\leftofeqalign \empty
> \let\rightofeqalign\empty
>
> \def\mathineqalign#1{$\forgetalign\displaystyle{{}#1{}}$}
> \def\textineqalign#1{$\forgetalign#1$}
>
> \def\eqalign#1% why no halign here, probably because of displaywidth
>   {\!!toksa{\strut\hfil$\displaystyle{##}$}%
>    \!!toksb{&$\displaystyle{{}##{}}$\hfil}%
>    \!!toksc\emptytoks
>    \buildeqalign
>    \null\,\vcenter
>      {\openup\jot
>       \mathsurround\zeropoint
>       \expandafter \ialign \expandafter {\the\scratchtoks\crcr#1 
> \crcr}%
>    }\,}
>
> % preamble is scanned for tabskips so we need the span to prevent  
> an error message
>
> \def\prepareeqalignno
>   {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span 
> \mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
>    \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##} 
> \rightofeqalign\tabskip\zeropoint}%
>    \!!toksc{\hfil\tabskip\centering&\llap{\span\textineqalign{##}} 
> \tabskip\zeropoint}%
>    \buildeqalign
>    \presetdisplaymath
>    \tabskip\centering}
>
> \def\prepareleqalignno
>   {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span 
> \mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
>    \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##} 
> \rightofeqalign\tabskip\zeropoint}%
>    \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span 
> \textineqalign{##}}\tabskip\displaywidth}%
>    \buildeqalign
>    \presetdisplaymath
>    \tabskip\centering}
>
> \chardef\eqalignmode=1
>
> \def\eqalignno#1%
>   {\prepareeqalignno
>    \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the 
> \scratchtoks\crcr#1\crcr}}
>
> \def\leqalignno#1%
>   {\prepareleqaligno
>    \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the 
> \scratchtoks\crcr#1\crcr}}
>
> \def\aligneqalignno
>   {\prepareeqalignno
>    \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup 
> \the\scratchtoks\crcr}
>
> \def\alignleqalignno
>   {\prepareleqalignno
>    \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup 
> \the\scratchtoks\crcr}
>
> \def\finishalignno
>   {\crcr\egroup}
>
> \definesystemvariable{eq}
>
> \def\setupmathalign
>   {\dodoubleempty\dosetupmathalign}
>
> \def\dosetupmathalign[#1][#2]%
>   {\ifsecondargument
>      \getparameters[\??eq#1][#2]%
>    \else
>      \getparameters[\??eq][#1]%
>    \fi}
>
> \let\currentmathalign\empty
>
> \def\mathalignparameter#1%
>   {\executeifdefined{\??eq\currentmathalign#1}{\executeifdefined{\?? 
> eq#1}\empty}}
>
> \setupmathalign
>   [\c!n=2,
>    \c!m=1,
>    \c!distance=1em]
>
> \def\numberedeqalign
>   {\doifelse\@@fmlocation\v!left\alignleqalignno\aligneqalignno}
>
> \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][]}
>
> \newcount\eqaligncolumn
>
> \def\firstineqalign{\global\eqaligncolumn\plusone}
> \def\nextineqalign {\global\advance\eqaligncolumn\plusone}
> \def\leftofeqalign {\getvalue{\??eq:\v!left :\number\eqaligncolumn}}
> \def\rightofeqalign{\getvalue{\??eq:\v!right:\number\eqaligncolumn}}
>
> \def\doseteqaligncolumn#1%
>   {\letvalue{\??eq:\v!left :\number\eqaligncolumn}\empty
>    \letvalue{\??eq:\v!right:\number\eqaligncolumn}\empty
>    \doif{#1}\v!left  {\letvalue{\??eq:\v!right:\number 
> \eqaligncolumn}\hfill}%
>    \doif{#1}\v!right {\letvalue{\??eq:\v!left :\number 
> \eqaligncolumn}\hfill}%
>    \doif{#1}\v!middle{\letvalue{\??eq:\v!right:\number 
> \eqaligncolumn}\hfill
>                       \letvalue{\??eq:\v!left :\number 
> \eqaligncolumn}\hfill}}
>
> \def\dodoalignNC
>   {\gdef\doalignNC##1{&##1}}
>
> \def\doalignNR[#1][#2]%
>   {\doifsomething{#1}
>      {\doifelse{#1}{+}
>         {\doformulanumber[][#2][]{}}
>         {\doformulanumber[#1][#2][]{}}}%
>    \crcr}
>
> \def\dostartmathalign[#1][#2]%
>   {\pushmacro\doalignNC
>    \edef\currentmathalign{#1}%
>    \doifassignmentelse{#2}{\setupmathalign[#1][#2]}\donothing
>    \def\NC{\doalignNC}%
>    \global\let\doalignNC\dodoalignNC
>    \def\EQ{&=}%
>    \def\NR{&\global\let\doalignNC\dodoalignNC\doxxdoubleempty 
> \doalignNR}%
>    % amstex compatibility mode: (ugly)
>    \def\notag{\def\\{&\crcr}}%
>    \doifelse{#2}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
>    % end of compatibility mode
>    \eqaligncolumn\zerocount
>    \processcommacommand[\mathalignparameter\c!align]{\advance 
> \eqaligncolumn\plusone\doseteqaligncolumn}%
>    % the real action
>    \global\eqaligncolumn\plusone
>    \numberedeqalign}
>
> \def\dostopmathalign
>   {\finishalignno
>    \popmacro\doalignNC}
>
> \def\definemathalign
>   {\dodoubleempty\dodefinemathalign}
>
> \def\dodefinemathalign[#1]% [#2]%
>   {\setvalue{\e!start#1}{\dodoubleempty\dostartmathalign[#1]}%
>    \setvalue{\e!stop #1}{\dostopmathalign}%
>    \setupmathalign[#1]}% [#2]
>
> \definemathalign[align]     % default case
>
> % \def\startsplit
> %   {\startalign[*]} % no number by default
> %
> % \def\stopsplit
> %   {&\doalignNR[+][]\crcr % for a number on last line
> %    \stopalign}
>
> %D \startbuffer
> %D \placeformula \startformula \eqalignno {
> %D  a &= b & \formulanumber \cr
> %D  c &= d \cr
> %D    &= e \cr
> %D    &= f & \formulanumber
> %D } \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign
> %D \NC  a \EQ b \NR[+]
> %D \NC  c \EQ d \NR
> %D \NC    \EQ f \NR[for:demo-a-1]
> %D \NC    \EQ g \NR[for:demo-a-2][a]
> %D \NC    \EQ h \NR[for:demo-a-3][b]
> %D \NC    \EQ i \NR
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign
> %D \NC a \EQ b \NR[+]
> %D \NC c \EQ d \NR
> %D \NC   \EQ f \NR
> %D \NC   \EQ g \NR
> %D \NC   \EQ h \NR
> %D \NC   \EQ i \NR[+]
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign
> %D a &= b \\
> %D c &= d \notag \\
> %D   &= e \notag \\
> %D   &= f \\
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign
> %D \NC  a \NC \eq  b \NR[+]
> %D \NC  c \NC \neq d \NR
> %D \NC    \NC \neq f \NR[for:demo-b-1]
> %D \NC    \NC \geq g \NR[for:demo-b-2][a]
> %D \NC    \NC \leq h \NR[for:demo-b-3][b]
> %D \NC    \NC \neq i \NR
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign[*]
> %D a &= b \\
> %D c &= d \\
> %D   &= e \\
> %D   &= f \\
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign
> %D     x &= y \\
> %D     a &= b \\
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign[m=3]
> %D     x &= y & x &= y & z &= t \\
> %D     a &= b & p &= q & w &= s \\
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign[m=3,distance=0pt]
> %D     x &= y &= x &= y &= z &= t \\
> %D     a &= b &= p &= q &= w &= s \\
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign[n=5,distance=0pt]
> %D     x &= yy &= xx &= yy &= zz \\
> %D     a &= b  &= p  &= q  &= w  \\
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign[n=3,align= 
> {left,middle,right}]
> %D \NC       l \NC = \NC r     \NR
> %D \NC    left \NC = \NC right \NR
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign[n=3,align= 
> {right,middle,left}]
> %D \NC       l \NC = \NC r     \NR
> %D \NC    left \NC = \NC right \NR
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula \startformula \startalign[n=3,align= 
> {middle,middle,middle}]
> %D \NC       l \NC = \NC r     \NR
> %D \NC    left \NC = \NC right \NR
> %D \stopalign \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
>
> % BEGIN OF PATCH (CORE-MAT.TEX)
>
> \def\doplaceformula[#1][#2]% #2 = dummy, gobbles spaces
>   {\def\redoplaceformula
>      {\bgroup
>       \ifx\next\bgroup
>         \egroup \@EA\moreplaceformula % [ref]{}
>       \else
>         \def\nextnext{$}%
>         \ifx\next\nextnext
>           \egroup \@EAEAEA\dispplaceformula % [ref]$$
>         \else
>           \egroup \@EAEAEA\dodoplaceformula % [ref]\start
>         \fi
>       \fi[#1]{}}%
>    \futurelet\next\redoplaceformula}
>
> \long\def\moreplaceformula[#1]#2#3#4% #2 dummy #4 gobbles spaces
>   {\def\redoplaceformula
>      {\bgroup
>       \def\nextnext{$}%
>       \ifx\next\nextnext
>         \egroup \@EA\dispplaceformula % [ref]$$
>       \else
>         \egroup \@EA\dodoplaceformula % [ref]\start
>       \fi
>       [#1]{#3}}%
>    \futurelet\next\redoplaceformula#4}
>
> % END OF PATCH
>
> \def\startformulas#1\stopformulas
>   {\bgroup
>    \forgetdisplayskips
>    \startdisplaymath
>    \setlocalhsize
>    \long\def\startformula##1\stopformula{\advance\scratchcounter 
> \plusone}%
>    \scratchcounter\zerocount #1% preroll
>    \divide \hsize \scratchcounter
>    \hbox to \localhsize \bgroup
>      \hss
>      \def\normalstartformula{\vskip-\strutdepth$$}% i hate this
>      \def\normalstopformula {$$}%
>    % \def\jot{0pt}%
>      \def\startformula{$\vcenter\bgroup\normalstartformula}%
>      \def\stopformula {\normalstopformula\egroup$\hss}%
>      #1%
>      \egroup
>      \stopdisplaymath
>    \egroup}
>
> %D \startbuffer
> %D \placeformula
> %D \startformula
> %D     \startalign[n=3,align={middle,middle,middle}]
> %D         \NC a  \NC = \NC b  \NR[+]
> %D         \NC 2a \NC = \NC 2b \NR
> %D     \stopalign
> %D \stopformula
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula
> %D \startformulas
> %D     \setupmathalign[n=3,align={middle,middle,middle}]%
> %D     \startformula
> %D         \startalign
> %D             \NC a  \NC = \NC b  \NR[+]
> %D             \NC 2a \NC = \NC 2b \NR
> %D         \stopalign
> %D     \stopformula
> %D     \startformula
> %D         \startalign
> %D             \NC a  \NC = \NC b  \NR[+]
> %D             \NC 2a \NC = \NC 2b \NR
> %D         \stopalign
> %D     \stopformula
> %D \stopformulas
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
> %D
> %D \startbuffer
> %D \placeformula
> %D \startformulas
> %D     \dorecurse{5}{\startformula
> %D         \startalign[n=3,align={middle,middle,middle}]
> %D             \NC a  \NC = \NC b  \NR[+]
> %D             \NC 2a \NC = \NC 2b \NR
> %D         \stopalign
> %D     \stopformula}
> %D \stopformulas
> %D \stopbuffer
> %D
> %D \typebuffer \getbuffer
>
> \protect \endinput
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-21  4:01 ` math David Arnold
@ 2006-01-23 21:51   ` Hans Hagen
  2006-01-24  4:56     ` math David Arnold
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Hagen @ 2006-01-23 21:51 UTC (permalink / raw)


David Arnold wrote:

> Hans et al,
>
> I am going to assume that all of this is saved as math-ext.tex. None  
> of it goes anywhere else at the moment. Correct?
>
> Also, I assume that:
>
>   \ifx\startalign\undefined \input math-ext.tex \fi
>
> still needs to go into cont-new.tex.
>
> Correct?

till you update, because on my machine the code is now in core-mat so 
it's part of the core

Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-23 21:51   ` math Hans Hagen
@ 2006-01-24  4:56     ` David Arnold
  2006-01-24  8:21       ` math Hans Hagen
  0 siblings, 1 reply; 10+ messages in thread
From: David Arnold @ 2006-01-24  4:56 UTC (permalink / raw)


Does this mean if I update I will have it in the core and I can get  
rid of the line in cont-new.tex?

On Jan 23, 2006, at 1:51 PM, Hans Hagen wrote:

> David Arnold wrote:
>
>> Hans et al,
>>
>> I am going to assume that all of this is saved as math-ext.tex. None
>> of it goes anywhere else at the moment. Correct?
>>
>> Also, I assume that:
>>
>>   \ifx\startalign\undefined \input math-ext.tex \fi
>>
>> still needs to go into cont-new.tex.
>>
>> Correct?
>
> till you update, because on my machine the code is now in core-mat so
> it's part of the core
>
> Hans
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: math
  2006-01-24  4:56     ` math David Arnold
@ 2006-01-24  8:21       ` Hans Hagen
  0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2006-01-24  8:21 UTC (permalink / raw)


David Arnold wrote:

>Does this mean if I update I will have it in the core and I can get  
>rid of the line in cont-new.tex?
>  
>
cont-new will be renewed automatically

Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-01-24  8:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-17 13:50 math Hans Hagen
2006-01-18  6:56 ` math sjoerd siebinga
2006-01-18  7:48   ` math Taco Hoekwater
2006-01-18  8:17 ` math sjoerd siebinga
2006-01-19  5:42 ` math Aditya Mahajan
2006-01-19  7:57   ` math Hans Hagen
2006-01-21  4:01 ` math David Arnold
2006-01-23 21:51   ` math Hans Hagen
2006-01-24  4:56     ` math David Arnold
2006-01-24  8:21       ` math Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).