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
<--- 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
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[][]}[][]%[]
. . . . . . .
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
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
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
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
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
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
<--- 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
<--- 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
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
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
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?
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
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
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?
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
participants (5)
-
Aditya Mahajan
-
David Arnold
-
Hans Hagen
-
Mojca Miklavec
-
Taco Hoekwater