# Correct spacing when using aligned in cases

I have problems getting the spacing right when using aligned in a cases environment. The following illustrates my problem:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{cases} 1 & \operatorname{\mathbf{if}} a=1 \\ 2 & \operatorname{\mathbf{if}} a=2 \\ 3 & \operatorname{\mathbf{if}} a=3 \\ 4 & \!\begin{aligned} \operatorname{\mathbf{if}}\, & a=4 \; \wedge \\ & a \end{aligned} \end{cases}

\end{document}


My questions are

1. Why is there more space between a=1 and a=2 than between a=3 and a=4. How do I fix this?

2. Can it be that lines in the alignment environment are further apart? How do I fix this?

3. Is using \! and \, the proper way of achieving correct alignment of \operatorname{\mathbf{if}}?

-
Why \operatorname{\mathbf{…}}? I mean \operatorname is intended for one thing, I would change that, or define a new command which makes more sense in this context. By the way, $$…$$ should be $…$ in LaTeX. PS: I know, this is not an answer to your questions ;) –  Manuel Jul 11 '14 at 18:28
Welcome to TeX.SX! –  Andrew Swann Jul 11 '14 at 18:46

You should be using \text for the case descriptions: \text{\mathbf{if} $$a=1$$} etc. (normal use would not have bold though). The mathtools package (which loads and extends amsmath) provides a convenient environment dcases* which does two useful things:

• the first column is display style mathematics
• the second is automatically enclosed in \text{...}

In you case you then have to switch to math mode for the last case, but it is not really clear what your notation is meant to mean here.

With LaTeX you should use $...$ instead of $$...$$; I prefer to write \begin{equation*}...\end{equation*} which is quicker to changed to the numbered version and is equivalent to $...$ in amsmath.

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{equation*}
\begin{dcases*}
1 & \textbf{if} $$a=1$$ \\
2 & \textbf{if} $$a=2$$ \\
3 & \textbf{if} $$a=3$$ \\
4 & \!\begin{aligned} \text{\textbf{if} }& a=4 \ \wedge \\ & a \end{aligned}
\end{dcases*}
\end{equation*}

\end{document}

-
Didn't know about dcases...will have to look at mathtools. Thanks! –  Andrew Jul 11 '14 at 19:13

Don't use operatorname! Use \text or more accurately \text{if } with the trailing space. I'm not sure what you are trying to do with your fourth case but the embedded aligned environment strikes me as wrong...but as I don't know what you intended I can't recommend a fix.

Btw, in this situation I would use \text but if you really want boldface then use \textbf.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{cases} 1 & \textbf{if } a=1 \\ 2 & \textbf{if } a=2 \\ 3 & \textbf{if } a=3 \\ 4 & \!\begin{aligned}[t] \textbf{if } & a=4 \; \wedge \\ & a \end{aligned} \end{cases}

\end{document}


-
Just add [t] here: \begin{aligned}[t]; and the spacing would be similar. Using \textbf{… } you don't need \, inside the aligned. –  Manuel Jul 11 '14 at 18:36
The problem is that the conditions of some cases do not fit into one line. I tried to use the align environment to properly align these conditions in multiple lines. –  Florian Jul 11 '14 at 18:38
@Manuel I didn't touch the aligned block as to me it looks wrong. I agree with your edits, of course. The \! can also go. Will edit. –  Andrew Jul 11 '14 at 18:39
@Florian What is the last condition supposed to be? I guess this is a cut-down example... –  Andrew Jul 11 '14 at 18:39
@Andrew \! cannot go. The one that can is \; with a proper \wedge {}. –  Manuel Jul 11 '14 at 18:41