[NTG-context] LaTeX array equivalence with multiline \lbrace

Hans Hagen pragma at wxs.nl
Thu Jan 26 22:50:45 CET 2006


Renaud AUBIN wrote:

>I've read the post [NTG-context] Math Cases and I'm interested to have 
>the possibility to do this kind of numbering:
>
> { b , if whatever     (1a)
>  a ={
>     { c,  otherwise       (1b)
>
>  
>
>>If I understand you correctly, then something like this
>>
>>\definealign[cases][left={\left\{}, right={\right.}, n=2, 
>>align={left,left}]
>>
>>will give us \startcases, \stopcases which works like \cases. Such a 
>>feature will be very useful.
>>
>>
>>Is it possible to define left|right in such a way that
>>\definealign[important][left={\framed\bgroup},right={\egroup}]
>>results in a frame around the equations (and does not include the equation 
>>numbers), that is the frame is as broad as the width of the largest 
>>equation that follows. This mechanism can be used to highlight equations.
>>
>>Also, in another post, I had asked if it is possible to have cases that 
>>are numbered, that is, can I get
>>
>>    { b , if whatever     (1a)
>> a ={
>>    { c,  otherwise       (1b)
>>
>>This is not important, but will be nice to have.
>>    
>>
something like this? 

\unprotect 

\definesystemvariable{ce}
\def\v!mathcases     {mathcases}
\def\c!numberdistance{numberdistance}

\def\setupmathcases
  {\dodoubleempty\dosetupmathcases}

\def\dosetupmathcases[#1][#2]%
  {\ifsecondargument
     \getparameters[\??ce#1][#2]%
   \else
     \getparameters[\??ce][#1]%
   \fi}

\let\currentmathcases\empty

\def\mathcasesparameter#1%
  {\executeifdefined{\??ce\currentmathcases#1}{\executeifdefined{\??ce#1}\empty}}

\setupmathcases
  [\c!distance=1em,
   \c!numberdistance=2.5em]

\def\definemathcases
  {\dodoubleempty\dodefinemathcases}

\def\dodefinemathcases[#1]% [#2]%
  {\setvalue{\e!start#1}{\dodoubleempty\dostartmathcases[#1]}%
   \setvalue{\e!stop #1}{\dostopmathcases}%
   \setupmathcases[#1]}% [#2]

\definemathcases[cases]
\definemathcases[\v!mathcases]

\def\dodocasesNC
  {\gdef\docasesNC{\endmath&}}

\let\docasesNR\doalignNR

\def\dostartmathcases[#1][#2]%
  {\begingroup
   \edef\currentmathcases{#1}%
   \doifassignmentelse{#2}{\setupmathcases[#1][#2]}\donothing
   \left\{%
   \,%
   \vcenter\bgroup
   \pushmacro\docasesNC
   \let\endmath\relax
   \def\NC{\docasesNC}%
   \def\MC{\docasesNC\ifmmode\else$\def\endmath{$}\fi}%
   \global\let\docasesNC\dodocasesNC
   \def\NR{\endmath&\global\let\docasesNC\dodocasesNC\doxxdoubleempty\docasesNR}%
   \normalbaselines
   \mathsurround\zeropoint
   \everycr\emptytoks
   \tabskip\zeropoint
   \global\eqaligncolumn\plusone
   \halign\bgroup
        \span$##$\hfil
       &\hskip\mathcasesparameter\c!distance\relax\popmacro\docasesNC##\hfil
       &\hskip\mathcasesparameter\c!numberdistance\relax\span\textineqalign{##}%
     \crcr} % todo: number

\def\dostopmathcases
  {\crcr
   \egroup
   \popmacro\docasesNC
   \egroup
   \right.
   \endgroup}

\protect

\showframe

\placeformula \startformula \startcases
\NC 2 \NC $ y > 0 $ \NR
\NC 7 \NC $ x = 7 $ \NR[+]
\NC 4 \NC otherwise \NR
\stopcases \stopformula

\placeformula \startformula x
\startcases
\NC 2 \NC $ y > 0 $ \NR[+]
\NC 7 \NC $ x = 7 $ \NR
\NC 4 \NC otherwise \NR
\stopcases
\stopformula

\placeformula \startformula \startcases
\NC 2 \NC $ y > 0 $ \NR
\NC 7 \NC $ x = 7 $ \NR
\NC 4 \NC otherwise \NR
\stopcases \stopformula

\placeformula \startformula x
\startcases
\NC 2 \NC $ y > 0 $ \NR
\NC 7 \NC $ x = 7 $ \NR
\NC 4 \NC otherwise \NR
\stopcases
\stopformula


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the ntg-context mailing list