ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* math align
@ 2006-01-15 22:37 Hans Hagen
  2006-01-16  3:31 ` Aditya Mahajan
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Hans Hagen @ 2006-01-15 22:37 UTC (permalink / raw)


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

Hi,

Here a first attempts for a flexible alignment mechanism (i depend on 
taco for the fine points of math typesetting since he's typeset \infty 
more complex formulas than i have)

(n=n_of_columns, m=n_of_pairs, so both requested multiple column 
features are supported)

Hans

[-- Attachment #2: math-ext.tex --]
[-- Type: text/x-tex, Size: 6363 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,
%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.

% 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\@@eqm
     {\ifnum\recurselevel>\plusone\appendtoks\tabskip\@@eqdistance&\tabskip\zeropoint\to\scratchtoks\fi
      \expanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
      \dorecurse{\numexpr\@@eqn-\plusone\relax}
        {\expanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
   \expanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}

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

\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}%
   }\,}

\def\eqalignno#1%
  {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
   \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
   \!!toksc{\hfil\tabskip\centering&\llap{$\forgetalign##$}\tabskip\zeropoint}%
   \buildeqalign
   \presetdisplaymath
   \tabskip\centering
   \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1\crcr}}

\def\leqalignno#1%
  {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
   \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
   \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{$\forgetalign##$}\tabskip\displaywidth}%
   \buildeqalign
   \presetdisplaymath
   \tabskip\centering
   \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1\crcr}}

\definesystemvariable{eq}

\def\setupmathalign
  {\dodoubleargument\getparameters[\??eq]}

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

\def\numberedeqalign
  {\doifelse\@@fmlocation\v!left\leqalignno\eqalignno}

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

\def\startalign
  {\dosingleempty\dostartalign}

\long\def\dostartalign[#1]#2\stopalign
  {\doifassignmentelse{#1}{\setupmathalign[#1]}\donothing
   \def\NC{\crcr\def\NC####1{&####1}}%
   \def\EQ{&=}
   \def\NR{&\dodoubleempty\doalignNR}%
   % amstex compatibility mode: (ugly)
   \def\notag{\def\\{&\crcr}}%
   \doifelse{#1}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
   % end of compatibility mode
   \numberedeqalign{#2}}

%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:hans]
%D \NC    \EQ g \NR[for:whoelse][a]
%D \NC    \EQ h \NR[for:whomore][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 a &= b \NR[+]
%D c &= d \NR
%D   &= e \NR
%D   &= f \NR[+]
%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:hans]
%D \NC    \NC \geq g \NR[for:whoelse][a]
%D \NC    \NC \leq h \NR[for:whomore][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 \notag \\
%D   &= e \notag \\
%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

\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] 22+ messages in thread

* Re: math align
  2006-01-15 22:37 math align Hans Hagen
@ 2006-01-16  3:31 ` Aditya Mahajan
  2006-01-16  6:17 ` David Arnold
  2006-01-16  7:30 ` David Arnold
  2 siblings, 0 replies; 22+ messages in thread
From: Aditya Mahajan @ 2006-01-16  3:31 UTC (permalink / raw)


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

> Hi,
>
> Here a first attempts for a flexible alignment mechanism (i depend on taco 
> for the fine points of math typesetting since he's typeset \infty more 
> complex formulas than i have)
>
> (n=n_of_columns, m=n_of_pairs, so both requested multiple column features are 
> supported)

Thanks a lot. I tested it with the little context math documents that 
I have and it works as expected. There is a minor bug. I thought that 
& ... \\ and \NC .. \NC .. \NR were equivalent, with the latter giving 
more configurability with respect to equation numbering and all. 
However, with multiple columns, \NC ... \NC does not work as expected. 
Consider

\usemodule[math-ext]

\starttext

Three columns work correctly if I use \&
\startbuffer
\startformula \startalign[n=3]
   a &= b &= c \\
   d &= e &= f
\stopalign \stopformula
\stopbuffer

\typebuffer \getbuffer

But they do not work if I use \type{\NC}

\startbuffer
\startformula \startalign[n=3]
   \NC a \NC= b \NC= c \NR
   \NC d \NC= e \NC= f \NR
\stopalign \stopformula
\stopbuffer

\typebuffer \getbuffer

\stoptext


This takes care of most of the alignment and equation numbering in 
Context. With this, one should also be able to define \startstop split 
such that

\placeformula \startformula \startsplit
  a &= b \\
    &= c
\stopsplit \stopformula

comes out as

  a &= b
    &= c   (1)

But, my attempts to define such a startstop did not work. Can you 
suggest something?

Thanks,
Aditya

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

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

* Re: math align
  2006-01-15 22:37 math align Hans Hagen
  2006-01-16  3:31 ` Aditya Mahajan
@ 2006-01-16  6:17 ` David Arnold
  2006-01-16  7:30 ` David Arnold
  2 siblings, 0 replies; 22+ messages in thread
From: David Arnold @ 2006-01-16  6:17 UTC (permalink / raw)


Hans et al,

I tried saving this file as ~/tmp/math-ext.tex and compiling with:

texexec --module math-ext.tex

But I got:

[MP texexec-mpgraph.4000] [1.1] [2.1] .
(/usr/local/teTeX/share/texmf.local/tex/context/base/verb-tex.tex
loading         : Context Support Macros / Pretty TEX Verbatim
) . . . . . . . . .
Overfull \hbox (98.21335pt too wide) in paragraph at lines 72--72
[][][] [][] [][] [][] [][] [][]\*10pttttf* {[][]\ifnum\recurselevel[] 
[]>[][]\pl
usone\appendtoks\tabskip\@@eqdistance[][]&[][]\tabskip\zeropoint\to 
\scratchtoks
\fi[]
. . . [3.1] .
Overfull \hbox (87.71338pt too wide) in paragraph at lines 112--112
[][][] [][] [][] [][]\*10pttttf* \!!toksc[][]{[][]\hfil\tabskip 
\centering[][]&[
][]\kern[][]-[][]\displaywidth\rlap[][]{[][]$[][]\forgetalign[][]##[] 
[]$[][]}[]
[]\tabskip\displaywidth[][]}[][]%[]
. . . . . . . <texexec-texexec.tmp> (./texexec-texexec.tmp [4.2])
<texexec-texexec.tmp> (./texexec-texexec.tmp
! Undefined control sequence.
<recently read> \startalign

l.1 \placeformula \startformula \startalign

?

Am I doing something wrong?


On Jan 15, 2006, at 2:37 PM, Hans Hagen wrote:

> Hi,
>
> Here a first attempts for a flexible alignment mechanism (i depend  
> on taco for the fine points of math typesetting since he's typeset  
> \infty more complex formulas than i have)
>
> (n=n_of_columns, m=n_of_pairs, so both requested multiple column  
> features are supported)
>
> 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,
> %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.
>
> % 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\@@eqm
>      {\ifnum\recurselevel>\plusone\appendtoks\tabskip\@@eqdistance& 
> \tabskip\zeropoint\to\scratchtoks\fi
>       \expanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
>       \dorecurse{\numexpr\@@eqn-\plusone\relax}
>         {\expanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
>    \expanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}
>
> \def\forgetalign
>   {\tabskip\zeropoint\everycr\emptytoks}
>
> \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}%
>    }\,}
>
> \def\eqalignno#1%
>   {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
>    \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
>    \!!toksc{\hfil\tabskip\centering&\llap{$\forgetalign##$}\tabskip 
> \zeropoint}%
>    \buildeqalign
>    \presetdisplaymath
>    \tabskip\centering
>    \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1 
> \crcr}}
>
> \def\leqalignno#1%
>   {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
>    \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
>    \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{$ 
> \forgetalign##$}\tabskip\displaywidth}%
>    \buildeqalign
>    \presetdisplaymath
>    \tabskip\centering
>    \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1 
> \crcr}}
>
> \definesystemvariable{eq}
>
> \def\setupmathalign
>   {\dodoubleargument\getparameters[\??eq]}
>
> \setupmathalign
>   [\c!n=2,
>    \c!m=1,
>    \c!distance=1em]
>
> \def\numberedeqalign
>   {\doifelse\@@fmlocation\v!left\leqalignno\eqalignno}
>
> \def\doalignNR[#1][#2]%
>   {\doifsomething{#1}
>      {\doifelse{#1}{+}
>         {\doformulanumber[][#2][]{}}
>         {\doformulanumber[#1][#2][]{}}}}
>
> \def\startalign
>   {\dosingleempty\dostartalign}
>
> \long\def\dostartalign[#1]#2\stopalign
>   {\doifassignmentelse{#1}{\setupmathalign[#1]}\donothing
>    \def\NC{\crcr\def\NC####1{&####1}}%
>    \def\EQ{&=}
>    \def\NR{&\dodoubleempty\doalignNR}%
>    % amstex compatibility mode: (ugly)
>    \def\notag{\def\\{&\crcr}}%
>    \doifelse{#1}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
>    % end of compatibility mode
>    \numberedeqalign{#2}}
>
> %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:hans]
> %D \NC    \EQ g \NR[for:whoelse][a]
> %D \NC    \EQ h \NR[for:whomore][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 a &= b \NR[+]
> %D c &= d \NR
> %D   &= e \NR
> %D   &= f \NR[+]
> %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:hans]
> %D \NC    \NC \geq g \NR[for:whoelse][a]
> %D \NC    \NC \leq h \NR[for:whomore][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 \notag \\
> %D   &= e \notag \\
> %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
>
> \protect \endinput
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

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

* Re: math align
  2006-01-15 22:37 math align Hans Hagen
  2006-01-16  3:31 ` Aditya Mahajan
  2006-01-16  6:17 ` David Arnold
@ 2006-01-16  7:30 ` David Arnold
  2006-01-16  9:02   ` Taco Hoekwater
  2 siblings, 1 reply; 22+ messages in thread
From: David Arnold @ 2006-01-16  7:30 UTC (permalink / raw)


And where should we put this module temporarily?


On Jan 15, 2006, at 2:37 PM, Hans Hagen wrote:

> Hi,
>
> Here a first attempts for a flexible alignment mechanism (i depend  
> on taco for the fine points of math typesetting since he's typeset  
> \infty more complex formulas than i have)
>
> (n=n_of_columns, m=n_of_pairs, so both requested multiple column  
> features are supported)
>
> 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,
> %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.
>
> % 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\@@eqm
>      {\ifnum\recurselevel>\plusone\appendtoks\tabskip\@@eqdistance& 
> \tabskip\zeropoint\to\scratchtoks\fi
>       \expanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
>       \dorecurse{\numexpr\@@eqn-\plusone\relax}
>         {\expanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
>    \expanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}
>
> \def\forgetalign
>   {\tabskip\zeropoint\everycr\emptytoks}
>
> \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}%
>    }\,}
>
> \def\eqalignno#1%
>   {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
>    \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
>    \!!toksc{\hfil\tabskip\centering&\llap{$\forgetalign##$}\tabskip 
> \zeropoint}%
>    \buildeqalign
>    \presetdisplaymath
>    \tabskip\centering
>    \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1 
> \crcr}}
>
> \def\leqalignno#1%
>   {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
>    \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
>    \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{$ 
> \forgetalign##$}\tabskip\displaywidth}%
>    \buildeqalign
>    \presetdisplaymath
>    \tabskip\centering
>    \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1 
> \crcr}}
>
> \definesystemvariable{eq}
>
> \def\setupmathalign
>   {\dodoubleargument\getparameters[\??eq]}
>
> \setupmathalign
>   [\c!n=2,
>    \c!m=1,
>    \c!distance=1em]
>
> \def\numberedeqalign
>   {\doifelse\@@fmlocation\v!left\leqalignno\eqalignno}
>
> \def\doalignNR[#1][#2]%
>   {\doifsomething{#1}
>      {\doifelse{#1}{+}
>         {\doformulanumber[][#2][]{}}
>         {\doformulanumber[#1][#2][]{}}}}
>
> \def\startalign
>   {\dosingleempty\dostartalign}
>
> \long\def\dostartalign[#1]#2\stopalign
>   {\doifassignmentelse{#1}{\setupmathalign[#1]}\donothing
>    \def\NC{\crcr\def\NC####1{&####1}}%
>    \def\EQ{&=}
>    \def\NR{&\dodoubleempty\doalignNR}%
>    % amstex compatibility mode: (ugly)
>    \def\notag{\def\\{&\crcr}}%
>    \doifelse{#1}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
>    % end of compatibility mode
>    \numberedeqalign{#2}}
>
> %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:hans]
> %D \NC    \EQ g \NR[for:whoelse][a]
> %D \NC    \EQ h \NR[for:whomore][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 a &= b \NR[+]
> %D c &= d \NR
> %D   &= e \NR
> %D   &= f \NR[+]
> %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:hans]
> %D \NC    \NC \geq g \NR[for:whoelse][a]
> %D \NC    \NC \leq h \NR[for:whomore][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 \notag \\
> %D   &= e \notag \\
> %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
>
> \protect \endinput
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

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

* Re: math align
  2006-01-16  7:30 ` David Arnold
@ 2006-01-16  9:02   ` Taco Hoekwater
  2006-01-16 12:30     ` Hans Hagen
  2006-01-16 18:01     ` David Arnold
  0 siblings, 2 replies; 22+ messages in thread
From: Taco Hoekwater @ 2006-01-16  9:02 UTC (permalink / raw)




David Arnold wrote:
> And where should we put this module temporarily?

Put it in the local directory and do

   \input math-ext

at the top of your test files.

Cheers, Taco

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

* Re: math align
  2006-01-16  9:02   ` Taco Hoekwater
@ 2006-01-16 12:30     ` Hans Hagen
  2006-01-16 15:40       ` Mojca Miklavec
  2006-01-17  3:02       ` Aditya Mahajan
  2006-01-16 18:01     ` David Arnold
  1 sibling, 2 replies; 22+ messages in thread
From: Hans Hagen @ 2006-01-16 12:30 UTC (permalink / raw)


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

Taco Hoekwater wrote:

>
>
> David Arnold wrote:
>
>> And where should we put this module temporarily?
>
>
> Put it in the local directory and do
>
>   \input math-ext
>
> at the top of your test files.
>
attached is a next version with 'definable' aligns

\definemathalign[myalign][...]

\startmyalign ...


Hans

[-- Attachment #2: math-ext.tex --]
[-- Type: text/x-tex, Size: 7897 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.

%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}

\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}%
   }\,}

\def\prepareeqalignno
  {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
   \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
   \!!toksc{\hfil\tabskip\centering
            &\llap{$\forgetalign##$}\tabskip\zeropoint}%
   \buildeqalign
   \presetdisplaymath
   \tabskip\centering}

\def\prepareleqalignno
  {\!!toksa{\hfil$\forgetalign\displaystyle{##}$\tabskip\zeropoint}%
   \!!toksb{&$\forgetalign\displaystyle{{}##}$\tabskip\zeropoint}%
   \!!toksc{\hfil\tabskip\centering
            &\kern-\displaywidth\rlap{$\forgetalign##$}\tabskip\displaywidth}%
   \buildeqalign
   \presetdisplaymath
   \tabskip\centering}

\def\eqalignno#1%
  {\prepareeqalignno
   \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1\crcr}}

\def\leqalignno#1%
  {\prepareleqaligno
   \halign to \displaywidth \expandafter {\the\scratchtoks\crcr#1\crcr}}

\def\aligneqalignno
  {\prepareeqalignno
   \halign to \displaywidth \expandafter \bgroup\the\scratchtoks\crcr}

\def\alignleqalignno
  {\prepareleqalignno
   \halign to \displaywidth \expandafter \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][]}

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

\def\dostartmathalign[#1][#2]%
  {\edef\currentmathalign{#1}%
   \doifassignmentelse{#2}{\setupmathalign[#1][#2]}\donothing
   \def\NC{\def\NC####1{&####1}}%
   \def\EQ{&=}%
   \def\NR{&\doxxdoubleempty\doalignNR}%
   % amstex compatibility mode: (ugly)
   \def\notag{\def\\{&\crcr}}%
   \doifelse{#2}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
   % end of compatibility mode
   \numberedeqalign}

\let\dostopmathalign\finishalignno

\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 a &= b \NR[+]
%D c &= d \NR
%D   &= e \NR
%D   &= f \NR[+]
%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

\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] 22+ messages in thread

* Re: math align
  2006-01-16 12:30     ` Hans Hagen
@ 2006-01-16 15:40       ` Mojca Miklavec
  2006-01-16 16:38         ` Hans Hagen
  2006-01-17  3:02       ` Aditya Mahajan
  1 sibling, 1 reply; 22+ messages in thread
From: Mojca Miklavec @ 2006-01-16 15:40 UTC (permalink / raw)


I might have missed it by not reading careful enough: is it possible
to left/right/middle align certain columns inside \startalign?

Thanks a lot for these definitions, Hans!

Mojca

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

* Re: math align
  2006-01-16 15:40       ` Mojca Miklavec
@ 2006-01-16 16:38         ` Hans Hagen
  2006-01-16 19:47           ` Aditya Mahajan
  0 siblings, 1 reply; 22+ messages in thread
From: Hans Hagen @ 2006-01-16 16:38 UTC (permalink / raw)


Mojca Miklavec wrote:

>I might have missed it by not reading careful enough: is it possible
>to left/right/middle align certain columns inside \startalign?
>  
>
some day (try to convince me/taco, bribe us, write detailed specs, send 
us so many mails that we give in, etc)

Hans

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

* Re: math align
  2006-01-16  9:02   ` Taco Hoekwater
  2006-01-16 12:30     ` Hans Hagen
@ 2006-01-16 18:01     ` David Arnold
  2006-01-16 18:16       ` Hans Hagen
  2006-01-16 18:20       ` Taco Hoekwater
  1 sibling, 2 replies; 22+ messages in thread
From: David Arnold @ 2006-01-16 18:01 UTC (permalink / raw)


Taco, Hans, et al,

That worked by putting it in the same directory as my little test file.

However, with this directory structure:

../book.tex
../bookenv.tex
../math-ext.tex
../chapter6/chapter6.tex
../chapter6/section5.tex

Bookenv.tex is our environment file. I tried:

\input math-ext

and

\usemoduel[math-ext]

in bookenv.tex, but when compiling section5.tex, both resulted in  
math-ext not found.

In this situation, will I have to put it into the "base" context tree?

On Jan 16, 2006, at 1:02 AM, Taco Hoekwater wrote:

>
>
> David Arnold wrote:
>> And where should we put this module temporarily?
>
> Put it in the local directory and do
>
>   \input math-ext
>
> at the top of your test files.
>
> Cheers, Taco
>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

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

* Re: math align
  2006-01-16 18:01     ` David Arnold
@ 2006-01-16 18:16       ` Hans Hagen
  2006-01-16 18:22         ` David Arnold
  2006-01-16 18:42         ` David Arnold
  2006-01-16 18:20       ` Taco Hoekwater
  1 sibling, 2 replies; 22+ messages in thread
From: Hans Hagen @ 2006-01-16 18:16 UTC (permalink / raw)


David Arnold wrote:

> Taco, Hans, et al,
>
> That worked by putting it in the same directory as my little test file.
>
> However, with this directory structure:
>
> ../book.tex
> ../bookenv.tex
> ../math-ext.tex
> ../chapter6/chapter6.tex
> ../chapter6/section5.tex
>
> Bookenv.tex is our environment file. I tried:
>
> \input math-ext
>
> and
>
> \usemoduel[math-ext]

it's not a module, it will end up in the core

so, for the moment:

= put the file in context/base
= run mktexls
= add to cont-new.tex:

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

That should work ok

Hans

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

* Re: math align
  2006-01-16 18:01     ` David Arnold
  2006-01-16 18:16       ` Hans Hagen
@ 2006-01-16 18:20       ` Taco Hoekwater
  2006-01-16 19:09         ` David Arnold
  1 sibling, 1 reply; 22+ messages in thread
From: Taco Hoekwater @ 2006-01-16 18:20 UTC (permalink / raw)


David Arnold wrote:
> 
> In this situation, will I have to put it into the "base" context tree?

Yes, you would, but we are only testing now. I assume (based on the
name) that Hans has a new core file in mind instead of a module.

Taco

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

* Re: math align
  2006-01-16 18:16       ` Hans Hagen
@ 2006-01-16 18:22         ` David Arnold
  2006-01-16 19:45           ` Hans Hagen
  2006-01-16 18:42         ` David Arnold
  1 sibling, 1 reply; 22+ messages in thread
From: David Arnold @ 2006-01-16 18:22 UTC (permalink / raw)



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

Yikes,

Cont-new.tex is huge. Where do I put this line? Between  
\unprotect ... \protect? Or at the very end?

On Jan 16, 2006, at 10:16 AM, Hans Hagen wrote:

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


[-- Attachment #1.2: Type: text/html, Size: 668 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] 22+ messages in thread

* Re: math align
  2006-01-16 18:16       ` Hans Hagen
  2006-01-16 18:22         ` David Arnold
@ 2006-01-16 18:42         ` David Arnold
  2006-01-16 20:41           ` Hans Hagen
  1 sibling, 1 reply; 22+ messages in thread
From: David Arnold @ 2006-01-16 18:42 UTC (permalink / raw)


Hans, Willi, et al,

I was thinking there are pros and cons to each solution, Hans' and  
Willi's. So I tried:

Here are some simple examples of adding fractions already having  
common denominators.

%output=pdf

\input math-ext

\starttext

\placeformula[-]
\startformula
   \startalign[m=2,distance=5em]
     \frac5{21}-\frac3{21}&=\frac{5-3}{21} &
     \frac{2}{x+2}-\frac{x-3}{x+2}&=\frac{2-(x-3)}{x+2}\\
     &=\frac2{21} & &=\frac{2-x+3}{x+2}\\
     &&&=\frac{5-x}{x+2}
   \stopalign
\stopformula

\startbuffer[1]
\framed[frame=on,width=fit]
    {\startformula
      \eqalign{
        \frac{5}{21}-\frac{3}{21}
        &=\frac{5-3}{21}\cr
        &=\frac{2}{21}}
    \stopformula}
\stopbuffer

\startbuffer[2]
   \framed[frame=on,width=fit]
   {\startformula
     \eqalign{
       \frac2{x+2}-\frac{x-3}{x+2}
       &=\frac{2-(x-3)}{x+2}\cr
       &=\frac{2-x+3}{x+2}\cr
       &=\frac{5-x}{x+2}}
   \stopformula}
\stopbuffer

\startbuffer
   \startcombination[2*1]
     {\externalfigure[1][width=0.45\textwidth,type=buffer]}{}
     {\externalfigure[2][width=0.45\textwidth,type=buffer]}{}
   \stopcombination
\stopbuffer

\placefigure
[][-]
{none}
{\getbuffer}

\stoptext

As you can see, Hans' solution works perfectly, but note the very  
ugly source code for that section. Willi's source is cleaner, much  
easier to read (especially at a later date when I will have to  
revisit for revisions), but it doesn't work (the output is scaled of  
course).

Any suggestions as to how I can fix Willi's approach so it doesn't  
scale?

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

* Re: math align
  2006-01-16 18:20       ` Taco Hoekwater
@ 2006-01-16 19:09         ` David Arnold
  2006-01-16 20:18           ` Hans Hagen
  0 siblings, 1 reply; 22+ messages in thread
From: David Arnold @ 2006-01-16 19:09 UTC (permalink / raw)


Hans, Taco, et al,

If I do something like this:

\placeformula[-]
\startformula
   \startalign[m=2,distance=7em]
     \frac5{21}-\frac3{21}&=\frac{5-3}{21} &
     \frac{2}{x+2}-\frac{x-3}{x+2}&=\frac{2-(x-3)}{x+2}\\
     &=\frac2{21} & &=\frac{2-x+3}{x+2}\\
     &&&=\frac{5-x}{x+2}
   \stopalign
\stopformula

Note that distance=7em separates the equations nicely, at least for  
the layout within which this code is contained. It might not look as  
good if the layout changes.

I'm wondering if the current math-ext allows these to be evenly  
distributed across the page without adjusting the distance?

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

* Re: math align
  2006-01-16 18:22         ` David Arnold
@ 2006-01-16 19:45           ` Hans Hagen
  0 siblings, 0 replies; 22+ messages in thread
From: Hans Hagen @ 2006-01-16 19:45 UTC (permalink / raw)


David Arnold wrote:

> Yikes,
>
> Cont-new.tex is huge. Where do I put this line? Between \unprotect ... 
> \protect? Or at the very end?
>
> On Jan 16, 2006, at 10:16 AM, Hans Hagen wrote:

at the top, before \unprotect

(not that critical btw)

Hans

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

* Re: math align
  2006-01-16 16:38         ` Hans Hagen
@ 2006-01-16 19:47           ` Aditya Mahajan
  2006-01-16 21:43             ` Hans Hagen
  0 siblings, 1 reply; 22+ messages in thread
From: Aditya Mahajan @ 2006-01-16 19:47 UTC (permalink / raw)


On Mon, 16 Jan 2006, Hans Hagen wrote:

> Mojca Miklavec wrote:
>
>> I might have missed it by not reading careful enough: is it possible
>> to left/right/middle align certain columns inside \startalign?
>> 
> some day (try to convince me/taco,

Please, please, please :-)

> bribe us,

Not possible, I am a poor student :-)

> write detailed specs,

For certain applications, one needs to left/right align the columns. It 
will be nice if

\startformula \startalign
\NC a \NC[align=right]= -1 \NR
\NC b \NC[align=right]= 1  \NR
\stopalign \stopformula

comes out as

   a = -1
   b =  1

Maybe some way of doing this for all columns in a align, say
\startformula \startalign[align={2,right}] %This is ugly syntax, can't
                           % think of something good right away
\NC a \NC= -1 \NR
\NC b \NC=  1 \NR
\stopalign \stopformula

> send us so 
> many mails that we give in, etc)

This will be the next step :-) Hans, thanks a ton for all this 
functionality.

Aditya

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

* Re: math align
  2006-01-16 19:09         ` David Arnold
@ 2006-01-16 20:18           ` Hans Hagen
  0 siblings, 0 replies; 22+ messages in thread
From: Hans Hagen @ 2006-01-16 20:18 UTC (permalink / raw)


David Arnold wrote:

> Hans, Taco, et al,
>
> If I do something like this:
>
> \placeformula[-]
> \startformula
>   \startalign[m=2,distance=7em]
>     \frac5{21}-\frac3{21}&=\frac{5-3}{21} &
>     \frac{2}{x+2}-\frac{x-3}{x+2}&=\frac{2-(x-3)}{x+2}\\
>     &=\frac2{21} & &=\frac{2-x+3}{x+2}\\
>     &&&=\frac{5-x}{x+2}
>   \stopalign
> \stopformula
>
> Note that distance=7em separates the equations nicely, at least for  
> the layout within which this code is contained. It might not look as  
> good if the layout changes.
>
> I'm wondering if the current math-ext allows these to be evenly  
> distributed across the page without adjusting the distance?

  \startalign[m=2,distance=7em plus 1 fil]

is a start but i assume that you want it more centered

Hans

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

* Re: math align
  2006-01-16 18:42         ` David Arnold
@ 2006-01-16 20:41           ` Hans Hagen
  2006-01-16 23:19             ` David Arnold
  0 siblings, 1 reply; 22+ messages in thread
From: Hans Hagen @ 2006-01-16 20:41 UTC (permalink / raw)


David Arnold wrote:

> Hans, Willi, et al,
>
> I was thinking there are pros and cons to each solution, Hans' and  
> Willi's. So I tried:
>
> Here are some simple examples of adding fractions already having  
> common denominators.
>
> %output=pdf
>
> \input math-ext
>
> \starttext
>
> \placeformula[-]
> \startformula
>   \startalign[m=2,distance=5em]
>     \frac5{21}-\frac3{21}&=\frac{5-3}{21} &
>     \frac{2}{x+2}-\frac{x-3}{x+2}&=\frac{2-(x-3)}{x+2}\\
>     &=\frac2{21} & &=\frac{2-x+3}{x+2}\\
>     &&&=\frac{5-x}{x+2}
>   \stopalign
> \stopformula
>
> \startbuffer[1]
> \framed[frame=on,width=fit]
>    {\startformula
>      \eqalign{
>        \frac{5}{21}-\frac{3}{21}
>        &=\frac{5-3}{21}\cr
>        &=\frac{2}{21}}
>    \stopformula}
> \stopbuffer
>
> \startbuffer[2]
>   \framed[frame=on,width=fit]
>   {\startformula
>     \eqalign{
>       \frac2{x+2}-\frac{x-3}{x+2}
>       &=\frac{2-(x-3)}{x+2}\cr
>       &=\frac{2-x+3}{x+2}\cr
>       &=\frac{5-x}{x+2}}
>   \stopformula}
> \stopbuffer
>
> \startbuffer
>   \startcombination[2*1]
>     {\externalfigure[1][width=0.45\textwidth,type=buffer]}{}
>     {\externalfigure[2][width=0.45\textwidth,type=buffer]}{}
>   \stopcombination
> \stopbuffer
>
> \placefigure
> [][-]
> {none}
> {\getbuffer}
>
> \stoptext
>
> As you can see, Hans' solution works perfectly, but note the very  
> ugly source code for that section. Willi's source is cleaner, much  
> easier to read (especially at a later date when I will have to  
> revisit for revisions), but it doesn't work (the output is scaled of  
> course).
>
> Any suggestions as to how I can fix Willi's approach so it doesn't  
> scale?


wikiable:

\definecombination[twoformulas][location=top,align=middle]

\startalignment[middle] \dontleavehmode \startcombination[twoformulas][2*1]
    {\getbuffer[1]} {}
    {\getbuffer[2]} {}
\stopcombination \stopalignment

\def\StartTwo{\startalignment[middle] \dontleavehmode 
\startcombination[twoformulas][2*1]}
\def\StopTwo {\stopcombination \stopalignment}]

\StartTwo
  {\getbuffer[1]} {}
  {\getbuffer[2]} {}
\StopTwo

\StartTwo
  {\getbuffer[1]} {correct}
  {\getbuffer[2]} {wrong}
\StopTwo

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

* Re: math align
  2006-01-16 19:47           ` Aditya Mahajan
@ 2006-01-16 21:43             ` Hans Hagen
  2006-01-16 23:03               ` Aditya Mahajan
  0 siblings, 1 reply; 22+ messages in thread
From: Hans Hagen @ 2006-01-16 21:43 UTC (permalink / raw)


Aditya Mahajan wrote:

> Maybe some way of doing this for all columns in a align, say
> \startformula \startalign[align={2,right}] %This is ugly syntax, can't
>                           % think of something good right away
> \NC a \NC= -1 \NR
> \NC b \NC=  1 \NR
> \stopalign \stopformula

since we hav esimple alignments here, we could make something:

\startformula \startalign[n=4,align={left,right,middle,right}]
\NC a \NC= -1 \NR
\NC b \NC=  1 \NR
\stopalign \stopformula

Does that make sense? I think that it's enough to do this for al columns 
(not per cell)

Hans

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

* Re: math align
  2006-01-16 21:43             ` Hans Hagen
@ 2006-01-16 23:03               ` Aditya Mahajan
  0 siblings, 0 replies; 22+ messages in thread
From: Aditya Mahajan @ 2006-01-16 23:03 UTC (permalink / raw)


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

> Aditya Mahajan wrote:
>
>> Maybe some way of doing this for all columns in a align, say
>> \startformula \startalign[align={2,right}] %This is ugly syntax, can't
>>                           % think of something good right away
>> \NC a \NC= -1 \NR
>> \NC b \NC=  1 \NR
>> \stopalign \stopformula
>
> since we hav esimple alignments here, we could make something:
>
> \startformula \startalign[n=4,align={left,right,middle,right}]
> \NC a \NC= -1 \NR
> \NC b \NC=  1 \NR
> \stopalign \stopformula
>
> Does that make sense? I think that it's enough to do this for al columns (not 
> per cell)

Something like this will be perfect. Per column is enough, I can not 
even think of a case when per cell could be useful.

Aditya



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

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

* Re: math align
  2006-01-16 20:41           ` Hans Hagen
@ 2006-01-16 23:19             ` David Arnold
  0 siblings, 0 replies; 22+ messages in thread
From: David Arnold @ 2006-01-16 23:19 UTC (permalink / raw)


Hans,

This is pretty good!

But yes, I know that I can get some separation with:

\definecombination[twoformulas][location=top,align=middle,distance=1cm]

But, as you noted in another post, is there a way to use the full  
spread of the page where each of these maths are centered in their  
respective half of the page?


>
> wikiable:
>
> \definecombination[twoformulas][location=top,align=middle]
>
> \startalignment[middle] \dontleavehmode \startcombination 
> [twoformulas][2*1]
>    {\getbuffer[1]} {}
>    {\getbuffer[2]} {}
> \stopcombination \stopalignment
>
> \def\StartTwo{\startalignment[middle] \dontleavehmode  
> \startcombination[twoformulas][2*1]}
> \def\StopTwo {\stopcombination \stopalignment}]
>
> \StartTwo
>  {\getbuffer[1]} {}
>  {\getbuffer[2]} {}
> \StopTwo
>
> \StartTwo
>  {\getbuffer[1]} {correct}
>  {\getbuffer[2]} {wrong}
> \StopTwo
>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context

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

* Re: math align
  2006-01-16 12:30     ` Hans Hagen
  2006-01-16 15:40       ` Mojca Miklavec
@ 2006-01-17  3:02       ` Aditya Mahajan
  1 sibling, 0 replies; 22+ messages in thread
From: Aditya Mahajan @ 2006-01-17  3:02 UTC (permalink / raw)


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

> Taco Hoekwater wrote:
>
>> 
>> 
>> David Arnold wrote:
>> 
>>> And where should we put this module temporarily?
>> 
>> 
>> Put it in the local directory and do
>>
>>   \input math-ext
>> 
>> at the top of your test files.
>> 
> attached is a next version with 'definable' aligns
>
> \definemathalign[myalign][...]
>
> \startmyalign ...

The following works as expected.

\def\startsplit
   {\startalign[*]} % no number by default

\def\stopsplit
   {&\doalignNR[+][]\crcr % for a number on last line
    \stopalign}

\placeformula \startformula \startsplit
  a &= b \\
    &= c
\stopsplit \stopformula

It seems that you are still thinking about [#2] in the definition of 
\definealign. Can it be such that,

\definealign[gather][n=1,align={middle}]
\definealign[lgather][n=1,align={left}]

\startformula \startgather
  a = b + c \\
  e = f
\stopgather \stopformula

results in center aligned equations
   a = b + c
     e = f

and

\startformula \startlgather
  a = b + c \\
  e = f
\stoplgather \stopformula

results in left aligned equations

  a = b + c
  e = f

Thanks,

Aditya

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

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

end of thread, other threads:[~2006-01-17  3:02 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-15 22:37 math align Hans Hagen
2006-01-16  3:31 ` Aditya Mahajan
2006-01-16  6:17 ` David Arnold
2006-01-16  7:30 ` David Arnold
2006-01-16  9:02   ` Taco Hoekwater
2006-01-16 12:30     ` Hans Hagen
2006-01-16 15:40       ` Mojca Miklavec
2006-01-16 16:38         ` Hans Hagen
2006-01-16 19:47           ` Aditya Mahajan
2006-01-16 21:43             ` Hans Hagen
2006-01-16 23:03               ` Aditya Mahajan
2006-01-17  3:02       ` Aditya Mahajan
2006-01-16 18:01     ` David Arnold
2006-01-16 18:16       ` Hans Hagen
2006-01-16 18:22         ` David Arnold
2006-01-16 19:45           ` Hans Hagen
2006-01-16 18:42         ` David Arnold
2006-01-16 20:41           ` Hans Hagen
2006-01-16 23:19             ` David Arnold
2006-01-16 18:20       ` Taco Hoekwater
2006-01-16 19:09         ` David Arnold
2006-01-16 20:18           ` 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).