# Split-like environment inside cases environment

I'd like to have a cases environment with some cases that are too long to fit on one line. I tried this:

\begin{cases}
\begin{split}
long expression \\ second line of long expression
\end{split} & condition \\
...


but I get the warning

Package amsmath Warning: Cannot use 'split' here; trying to recover with 'aligned' on input line 201.

It automatically replaces the split with an aligned environment, which looks like this:

Is there any way to get these long expressions to behave like they were in split or multline environments, with the top line flush left and the next line indented a little?

• Wouldn't it be nicer to define a short(er) notation such that the separate cases would fit on a single line? Nov 10, 2010 at 13:12
• @Taco Hoekwater, Yes. Nov 10, 2010 at 15:17
• The solutions below work fine, but they change the size of the math. It seems that cases changes to textstyle, but aligned changes back to displaystyle (so you get bigger fractions and sums, etc.). As explained in this answer, you can get back to textstyle by defining a new environment talign that redefines displaystyle as textstyle. (You could also do that manually in a group, if you prefer.)
– Mike
May 4, 2016 at 15:29

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\text{left hand side} = \begin{cases} \!\begin{aligned}%[b] & \text{a very long expression} \\ & + \text{that continues on the next line} \end{aligned} & \text{1st condition} \\%[1ex] \text{short expression} & \text{2nd condition} \end{cases}
\end{document}


Does this yield the output you want? (Note that the \! in front of aligned is needed since that environment adds a \, we have to cancel out.)

EDIT: If you want to achieve alignment and spacing as Niel suggests (@Niel: I would want that; good catch), then just remove the two % in the code.

• Ah, I didn't realize that aligned could take arguments for vertical alignment with things around it! Semantically speaking, that makes your answer better. Nov 10, 2010 at 14:32
• @Niel: I didn't know that either, I just put it there and it worked :-) Nov 10, 2010 at 14:34
• Thanks, it was the &'s at the beginning of each line that did what I wanted! To get multline-like indenting, I put \quad in between the second & and the +. Nov 10, 2010 at 15:16
• @Niel: It seems that I did already know that and forgot it again ... Nov 20, 2010 at 10:01
• The spacing/alignment at the beginning of the line is wrong though (compared to Niel's answer). The a is preceded by a bigger space than the s of short on the third line. Nov 14, 2012 at 9:52

Here is an alternative construction to Hendrik's, which aligns the 1st condition with the bottom-most line of the long expression (which I would suggest as good practise generally for readability). I also add vertical space between the two formulae to make it easier to separate the two visually.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\text{left hand side} = \left\{ \begin{aligned} & \text{a very long expression} \\ & + \text{that continues on the next line} && \text{1st condition} \\[1ex] & \text{short expression} && \text{2nd condition} \end{aligned} \right.
\end{document}


I omit the cases environment here, as all of the alignment work that it does is now better performed by aligned. The alignment tabs are chosen to get uniform alignment of the conditions, and left-alignment for everything involved; they can be changed to obtain right-alignment where desired.

• Using aligned still results in inconsistent alignment at the beginning of each line. The beginning is not fully left-aligned unlike with the cases env. See my example: pastie.org/5376249 Nov 14, 2012 at 10:09
• @neo: do you mean just that there is a little extra space in between the brace and the formulae? I've often deliberately added space in cases environments in order to obtain a comparable amount of space. Nov 14, 2012 at 13:32
• No, have a close look at the "r" in my example, it's a bit too far right compared to "z". Using only cases, the left corner of both letters align correctly. Nov 14, 2012 at 17:22
• @neo: I see, it would seem to be precisely because \operatorname{r} is gives r the spacing appropriate to operators (which the tab-stops of the align environments try to accomodate specially). If we use {\operatorname{r}} (which is ugly), the problem goes away. Nov 14, 2012 at 19:01
• Oh boy... how do you know all that?? :D Thanks very much. Nov 14, 2012 at 20:08

# ShareLatex

Just to give concrete example rather than only putting text assume that you have written the following cases equation

\begin{equation*}
L_{t}=
\begin{cases}
A_{t} & \text{if }A_{t}\leq L_{t-1}e^{g} \\
L_{t-1}e^{g} & \text{if }L_{t-1}e^{g}<A_{t}\leq
L_{t-1}e^{g}+E_{t-1}e^{g}+B_{t-1} \\
\begin{split}
L_{t-1}e^{g} \\
+\alpha \delta(1-b)(A_{t}-L_{t-1}e^{g}-E_{t-1}e^{g}-B_{t-1})
\end{split} & \text{if } A_{t}>L_{t-1}e^{g}+E_{t-1}e^{g}+B_{t-1}
\end{cases}
\end{equation*}


As you may see it is not fitted well then you may write the following

\begin{equation*}
L_{t}=
\left\{
\begin{aligned}
& A_{t} && \text{if }A_{t}\leq L_{t-1}e^{g} \\
& L_{t-1}e^{g} && \text{if }L_{t-1}e^{g}<A_{t}\leq L_{t-1}e^{g}+E_{t-1}e^{g}+B_{t-1} \\
& L_{t-1}e^{g} \\
& \quad + \alpha \delta(1-b)(A_{t}-L_{t-1}e^{g}-E_{t-1}e^{g}-B_{t-1})   && \text{if } A_{t}>L_{t-1}e^{g}+E_{t-1}e^{g}+B_{t-1} \\
\end{aligned}
\right.
\end{equation*}


Which will be printed as