[Tex/LaTex] How to write cases with grouping braces on both left and right side, and split the condition into two lines in LaTeX

casesmath-mode

The code I used to write

this

is this one

$$
X(m,n)=
\begin{cases}
x(n),\\
x(n-1)\\
x(n-1)
\end{cases}
$$

But I don't know how to write this one


Also, what if I want to write this

Best Answer

\documentclass{article}
\usepackage{amsmath}

\begin{document}
  \[
    X(m,n) = \left\{\begin{array}{lr}
        x(n), & \text{for } 0\leq n\leq 1\\
        x(n-1), & \text{for } 0\leq n\leq 1\\
        x(n-1), & \text{for } 0\leq n\leq 1
        \end{array}\right\} = xy
  \]
\end{document}

enter image description here

If you want two conditions on different lines, can use a \multirow for the first column:

\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow}

\begin{document}
  \[
    X(m,n) = \left\{\begin{array}{@{}lr@{}}
        \multirow{2}{*}{x(n),} & \text{for }0\leq n\leq 1\\
                               & \text{or }0\leq n\leq 1\\
        x(n-1), & \text{for }0\leq n\leq 1\\
        x(n-1), & \text{for }0\leq n\leq 1
        \end{array}\right\} = xy
  \]
\end{document}

enter image description here

Related Question