ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Math: Nested Cases?
@ 2021-03-18 18:01 Weber, Matthias
  2021-03-18 18:36 ` Aditya Mahajan
  0 siblings, 1 reply; 2+ messages in thread
From: Weber, Matthias @ 2021-03-18 18:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello,

Is it possible to nest cases in math, like so:

\starttext
\startformula
x=
       \startcases[align={right,left},distance=3pt]
               \NC  a \NC =
                       \startcases[align={right,left},distance=3pt]
                       \NC  1 \NC  \text{case  a1} \NR
                       \NC  2 \NC  \text{case  a2} \NR
                       \stopcases
               \NR
               \NC b \NC =
                       \startcases[align={right,left},distance=3pt]
                       \NC  3 \NC  \text{case  b3}\NR
                       \NC 4  \NC  \text{case  b4}\NR
                       \stopcases
               \NR
       \stopcases
\stopformula
\stoptext

I get an error about a missing $ when I try a nested start/stop-cases.

Thanks,

Matthias
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Math: Nested Cases?
  2021-03-18 18:01 Math: Nested Cases? Weber, Matthias
@ 2021-03-18 18:36 ` Aditya Mahajan
  0 siblings, 0 replies; 2+ messages in thread
From: Aditya Mahajan @ 2021-03-18 18:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, 18 Mar 2021, Weber, Matthias wrote:

> Hello,
> 
> Is it possible to nest cases in math, like so:

In principle, it should be. But we never tested this and I suspect that there is some macro which doesn't get initialized correctly in nested cases. 

> \starttext
> \startformula
> x=
>        \startcases[align={right,left},distance=3pt]
>                \NC  a \NC =
>                        \startcases[align={right,left},distance=3pt]
>                        \NC  1 \NC  \text{case  a1} \NR
>                        \NC  2 \NC  \text{case  a2} \NR
>                        \stopcases
>                \NR
>                \NC b \NC =
>                        \startcases[align={right,left},distance=3pt]
>                        \NC  3 \NC  \text{case  b3}\NR
>                        \NC 4  \NC  \text{case  b4}\NR
>                        \stopcases
>                \NR
>        \stopcases
> \stopformula
> \stoptext
> 
> I get an error about a missing $ when I try a nested start/stop-cases.

The missing $ error is because the cases environment uses two column separators (for the second column): \NC for "normal text column" and \MC for "math column". This is so that in the typical case, you can just use:

\startformula
  x = \startcases
      \NC 1 \NC case $a_1$ \NR
      \NC 2 \NC case $a_2$ \NR
      \stopcases
\stopformula

So, in your cases, you should have used:

\starttext
\startformula
x=
       \startcases[align={right,left},distance=3pt]
               \NC  a \MC =
                       \startcases[align={right,left},distance=3pt]
                       \NC  1 \NC  case  a1 \NR
                       \NC  2 \NC  case  a2 \NR
                       \stopcases
               \NR
               \NC b \MC =
                       \startcases[align={right,left},distance=3pt]
                       \NC  3 \NC  case  b3\NR
                       \NC 4  \NC  case  b4\NR
                       \stopcases
               \NR
       \stopcases
\stopformula
\stoptext


But, something goes wrong and that doesn't work either (with a different error message). I suspect that something is not getting initialized correctly at \startcases and will look into that. 

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2021-03-18 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 18:01 Math: Nested Cases? Weber, Matthias
2021-03-18 18:36 ` Aditya Mahajan

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