# Vertical alignment using cases

Using the following code, one gets the $X$ vertically aligned with the "center" of the cases. Is there a way to vertically align the $X$ with the $0$ in this output?

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation}
X=
\begin{cases}
0, & \text{if}\ a=1 \\
1, & \text{otherwise}
\end{cases}
\end{equation}
\end{document}

• And how should looks the curly brace? – Zarko Aug 26 '16 at 19:54
• @Zarko: It wouldn´t be symmetric. The pointy part would be towards the upper side in front of the equal sign. – Ramiro de la Vega Aug 26 '16 at 19:58
• This is can be only drawn with tikz or pstrick packages ... and as all answer says: don't doing this, result is ugly. – Zarko Aug 26 '16 at 20:07
• @Zarko: When one has many cases and this is at the beginning of a question (in an exam say), having the equal sign centered is uglier, because it looks like the brace invades the previous question. – Ramiro de la Vega Aug 26 '16 at 20:10

You can, but the result is very dubious.*

\documentclass{article}
\usepackage{amsmath}
\usepackage{delarray}

\begin{document}

\begin{equation}
\renewcommand{\arraystretch}{1.2}
0, & \text{if $a=1$} \\
1, & \text{otherwise}
\end{array}
\end{equation}

\begin{equation}
X=\begin{cases}
0, & \text{if $a=1$} \\
1, & \text{otherwise}
\end{cases}
\end{equation}

\end{document} * Big understatement; actually I believe it is completely wrong. Making the brace asymmetric would be even worse. See A curly brace with an asymmetric cusp for this, I refuse to even think about it. ;-)

• Thanks for the link @egreg, that´s closer to what I want, whether it´s popular or not :) – Ramiro de la Vega Aug 26 '16 at 20:13

Since cases is basically a matrix environment, a \begin{matrix} X\\ \end{matrix} should align this entry.

But it does not look nice! Don't do this!

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation}
\begin{matrix} X = \\
\\
\end{matrix}
\begin{cases}
0, & \text{if}\ a=1 \\
1, & \text{otherwise}
\end{cases}
\end{equation}

\begin{equation}
\begin{matrix} X  \\
\\
\end{matrix}  =
\begin{cases}
0, & \text{if}\ a=1 \\
1, & \text{otherwise}
\end{cases}
\end{equation}

\end{document} • Thanks Christian, the first alternative would look good if the pointy part of the brace was also aligned with the equal sign. Is this possible? – Ramiro de la Vega Aug 26 '16 at 20:03
• @RamirodelaVega: Huh??? The pointy part of the brace is centered -- it can't be centered any longer if you want to force that to be aligned with the = as well and the 0 as well. – user31729 Aug 26 '16 at 20:05
• I guess the brace would need to be different, it would not have the "pointy part" in the center. – Ramiro de la Vega Aug 26 '16 at 20:08
• @RamirodelaVega: That's what I said -- it's asymmetric. No, that's not nice – user31729 Aug 26 '16 at 20:09

It looks nicer with a bracket. Here is a simple way to do it with the empheq package:

\documentclass{article}
\usepackage{empheq}

\begin{document}

\begin{empheq}[left ={\begin{gathered}X=\\ ~\end{gathered}\empheqlbrack}]{gather}
\begin{alignedat}[t]{2}
& 0, &\quad & \text{if}\ a=1 \\
& 1, & & \text{otherwise}
\end{alignedat}
\end{empheq}

\end{document} 