Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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: alt text

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?

share|improve this question
2  
Wouldn't it be nicer to define a short(er) notation such that the separate cases would fit on a single line? –  Taco Hoekwater Nov 10 '10 at 13:12
    
@Taco Hoekwater, Yes. –  ptomato Nov 10 '10 at 15:17
add comment

2 Answers 2

up vote 15 down vote accepted

Well, I'd follow amsmath's suggestion to use aligned instead of split:

\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.

share|improve this answer
    
Ah, I didn't realize that aligned could take arguments for vertical alignment with things around it! Semantically speaking, that makes your answer better. –  Niel de Beaudrap Nov 10 '10 at 14:32
1  
@Niel: I didn't know that either, I just put it there and it worked :-) –  Hendrik Vogt Nov 10 '10 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 +. –  ptomato Nov 10 '10 at 15:16
    
@Niel: It seems that I did already know that and forgot it again ... –  Hendrik Vogt Nov 20 '10 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. –  neo Nov 14 '12 at 9:52
show 2 more comments

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.

share|improve this answer
    
+1 for improving alignment and spacing –  Hendrik Vogt Nov 11 '10 at 9:35
    
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 –  neo Nov 14 '12 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. –  Niel de Beaudrap Nov 14 '12 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. –  neo Nov 14 '12 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. –  Niel de Beaudrap Nov 14 '12 at 19:01
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.