More than two columns amsmath cases

I probably would find a different way to express my ideas. Anyway, here's a possibility:

\documentclass{article}
\usepackage{amsmath,amssymb}

\makeatletter
\newenvironment{mcases}[1][l]
 {\let\@ifnextchar\new@ifnextchar
  \left\lbrace
  \def\arraystretch{1.2}%
  \array{@{}l@{\quad}#1@{}}}
 {\endarray\right.}
\makeatother

\begin{document}

\begin{equation*}
M_1 \Cup M_2=
\begin{mcases}[ll@{\ }l]
  M_2          & \text{when $M_1 = \emptyset$} & \text{where} & x = f \\
               &                               &              & y = b \\
  M_1          & \text{when $M_2 = \emptyset$} & \text{where} & z = n \\
  M_1 \cup M_2 & \multicolumn{3}{@{}l}{\text{otherwise}}
\end{mcases}
\end{equation*}

\end{document}

Without an optional argument, mcases is the same as cases. The optional argument should specify the column types after the first, which is fixed.

enter image description here


Using only amsmath package, the environement aligned allows you to use as many columns as you want :

\documentclass{article}
\usepackage{amsmath}

\begin{document}
    \begin{equation*}
        M_1 \cup M_2 =
            \begin{cases}
            \begin{aligned}
                M_2 & \text{ when } M_1 = 0 &\text{where } & x = f\\
                    &                       &              & y = b\\
                M_1 & \text{ when } M_2 = 0 &\text{where } & z = n\\
                M_1 \cup M_2 & \text{ otherwise }&         &      \\
            \end{aligned}
        \end{cases}
    \end{equation*}
\end{document}

result using amsmath aligned environment


I would just use a \phantom to yield a similar alignment. Alternatively, make up your own array with the alignment you require:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
  M_1 \cup M_2 =
  \begin{cases}
        M_2            & \text{when $M_1 = foo$} \\
                       & \text{\phantom{when }$M_2 = bar$} \\
        M_1            & \text{when $M_2 = baz$} \\
        M_1 \cup M_2   & \text{otherwise}
  \end{cases}
\end{equation*}

\begin{equation*}
  M_1 \cup M_2 =
  \setlength{\arraycolsep}{0pt}
  \renewcommand{\arraystretch}{1.2}
  \left\{\begin{array}{l @{\quad} l r l}
        M_2            & \text{when } & M_1 &{}= foo \\
                       &              & M_2 &{}= bar \\
        M_1            & \text{when } & M_2 &{}= baz \\
        M_1 \cup M_2   & \text{otherwise}
  \end{array}\right.
\end{equation*}

\end{document}

The former may not work or be easy in general, but it works in your case. The latter should work in a more general setting.