[NTG-context] Math: Nested Cases?

Aditya Mahajan adityam at umich.edu
Thu Mar 18 19:36:37 CET 2021


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


More information about the ntg-context mailing list