ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: LaTeX array equivalence with multiline \lbrace
Date: Thu, 26 Jan 2006 22:50:45 +0100	[thread overview]
Message-ID: <43D94435.7090006@wxs.nl> (raw)
In-Reply-To: <43D7AA52.4090402@nibua-r.org>

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

  reply	other threads:[~2006-01-26 21:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-24 19:23 Renaud AUBIN
2006-01-24 23:37 ` Aditya Mahajan
2006-01-25 12:22   ` Hans Hagen
2006-01-25 13:10     ` Renaud AUBIN
2006-01-25 16:32     ` Aditya Mahajan
2006-01-25 16:41       ` Renaud AUBIN
2006-01-26 21:50         ` Hans Hagen [this message]
2006-01-26 22:28           ` Renaud AUBIN
2006-01-27  2:08           ` Aditya Mahajan
2006-01-27  8:33             ` Hans Hagen
2006-01-27  9:34               ` Taco Hoekwater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43D94435.7090006@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).