# 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}
$$X= \begin{cases} 0, & \text{if}\ a=1 \\ 1, & \text{otherwise} \end{cases}$$
\end{document}
• And how should looks the curly brace? Commented Aug 26, 2016 at 19:54
• @Zarko: It wouldn´t be symmetric. The pointy part would be towards the upper side in front of the equal sign. Commented Aug 26, 2016 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. Commented Aug 26, 2016 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. Commented Aug 26, 2016 at 20:10

You can, but the result is very dubious.*

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

\begin{document}

$$\renewcommand{\arraystretch}{1.2} X=\begin{array}[t]\{{@{}l@{\quad}l@{}}. 0, & \text{if a=1} \\ 1, & \text{otherwise} \end{array}$$

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

\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 :) Commented Aug 26, 2016 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{matrix} X = \\ \\ \end{matrix} \begin{cases} 0, & \text{if}\ a=1 \\ 1, & \text{otherwise} \end{cases}$$

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

\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? Commented Aug 26, 2016 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
Commented Aug 26, 2016 at 20:05
• I guess the brace would need to be different, it would not have the "pointy part" in the center. Commented Aug 26, 2016 at 20:08
• @RamirodelaVega: That's what I said -- it's asymmetric. No, that's not nice
– user31729
Commented Aug 26, 2016 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}