# How to write a multiline case in latex?

I am trying to get the output similar to this:

I have written this code:

$$\text{RHS} \rightarrow \begin{cases} \vert 1 \rangle \left[\frac{2\beta}{\sqrt{\alpha^2 + 4\beta^2}}\vert B\rangle - \frac{\alpha}{\sqrt{\alpha^2 + 4\beta^2}}\vert A \rangle\right] , &D_1\textrm{ clicks, probability \frac{\alpha^2}{4}}\\ \vert 2 \rangle\vert A \rangle, &D_2\textrm{ clicks, probability \frac{\alpha^2}{4}}\\ \vert \text{scattered} \rangle\vert A \rangle, &\textrm{ no clicks with probability \frac{\alpha^2}{2}} \end{cases}$$


And the following is the output:

How then, should I modify the code to get the output similar to first image? If I just add a line break in the first case it gives an error.

Thank you.

• What image are you referring to? – daleif Jul 3 '14 at 10:59
• Image of the output. First image, at the beginning is of the output I want. – Cain Jul 3 '14 at 11:04
• There was no images 6min ago ;-) – daleif Jul 3 '14 at 11:06
• Oh! They have been visible to me all along! :P – Cain Jul 3 '14 at 11:10
• You could take a look to physiscs package; it offers useful \bra and \ket commands. – Manuel Jul 3 '14 at 13:19

Would this hack be sufficient?

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$$\text{RHS} \rightarrow \begin{cases} \vert 1 \rangle \bigg[\frac{2\beta}{\sqrt{\alpha^2 + 4\beta^2}}\vert B\rangle &D_1\textrm{ clicks, probability \frac{\alpha^2}{4}}\\ \quad - \frac{\alpha}{\sqrt{\alpha^2 + 4\beta^2}}\vert A \rangle\bigg], & \\ \vert 2 \rangle\vert A \rangle, &D_2\text{ clicks, probability \frac{\alpha^2}{4}}\\ \vert \text{scattered} \rangle\vert A \rangle, &\text{no clicks with probability \frac{\alpha^2}{2}} \end{cases}$$
\end{document}


• This works perfectly, but can this not be done using some command similar to when we are writing multiline equations? – Cain Jul 3 '14 at 11:18

The amsmath "subsidiary" environments are built for just this purpose. Here, I use aligned, using the \verts inside the multi-line case expression as the alignment point. You could just as well change the alignment point to some other position, or use gathered if no special alignment of the expression is required.

The vertical alignment of the case conditions can be adjusted using t (top), b (bottom), or c (center, default) as the optional argument to the aligned or gathered environment.

Here's the result:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\text{RHS} \rightarrow \begin{cases}\!% alignment adjustment \begin{aligned}[b]% adjust case condition placement here, use [t]op, [b]ottom, or [c]enter (default) \vert 1 \rangle \bigg[\frac{2\beta}{\sqrt{\alpha^2 + 4\beta^2}} &\vert B \rangle \\ - \frac{\alpha}{\sqrt{\alpha^2 + 4\beta^2}} &\vert A \rangle \bigg], \end{aligned} &\textrm{D_1 clicks, probability \frac{\alpha^2}{4}}\\ \vert 2 \rangle \vert A \rangle, &\text{D_2 clicks, probability \frac{\alpha^2}{4}}\\ \vert \text{scattered} \rangle \vert A \rangle, &\text{no clicks with probability \frac{\alpha^2}{2}} \end{cases}
\end{document}


• Another option, which I tend to use when there is no clear alignment point is multlined environment. – Manuel Jul 3 '14 at 13:17
• @Manuel, good point! I stuck with amsmath environments here, but multlined is an equally valid choice using the mathtools package. – Paul Gessler Jul 3 '14 at 13:22