# Specify alignment per column in align equation

Using the following mwe i have not yet found a way to align the formulas correctly.

\documentclass{article}
\usepackage{mathtools}  % extends amsmath and fixes some of its quirks
\usepackage{amssymb}
\begin{document}

\begin{align}\label{eq:mergefunction_with_weighting}
\curlyvee(v, \omega) :=
l_1 \triangleright l_2 =
\left\{
\begin{aligned}
&l_1(v)               &                          &\text{wenn $v \in G_1 \setminus G_2$}\\
\omega(&l_1(v)) + (1-\omega)(&\hat{R}l_2(v) +\hat{t})   &\text{wenn $v \in G_1 \cap G_2$}\\
&                     &\hat{R}l_2(v) +\hat{t}    &\text{wenn $v \in G_2 \setminus G_1$}.
\end{aligned}
\right.
\end{align}

\end{document}


My output is currently like this:

Everything is fine except the vertical and horizontal alignment/spacing within the aligned environment. But in that you can notice the following: - First & works fine. - The second & should be aligned to \hat{R} and without spacing between the ( and the \hat{R} in the middle row - At the last &, the spacing in the middle row between \hat(t)) and wenn should be larger. (I think this one would disappear as soon as the second & is fixed.

So the requests i have sum up to the question: Whats the best and consistent way to approach placement issues like these?

-

Your output is what you'd expect from aligned: you have four columns, the 1st and 3rd right aligned, the 2nd and 4th left aligned, and some space between the first and the second "lr pair". What you actually want is best achieved with a cases environment; @{} is used where you don't want space between the columns.

Note that the vertical space between the lines is smaller than with your aligned code. If you want the same vertical spacing as with aligned, use \\jot] instead of \\ in the code below. \documentclass{article} \usepackage{mathtools} % extends amsmath and fixes some of its quirks \usepackage{amssymb} \begin{document} \begin{align}\label{eq:mergefunction_with_weighting} \curlyvee(v, \omega) := l_1 \triangleright l_2 = \left\{ \begin{array}{@{}r@{}l@{}ll} &l_1(v) & &\text{wenn v \in G_1 \setminus G_2}\\ \omega(&l_1(v)) + (1-\omega)(&\hat{R}l_2(v) +\hat{t}) &\text{wenn v \in G_1 \cap G_2}\\ & &\hat{R}l_2(v) +\hat{t} &\text{wenn v \in G_2 \setminus G_1}. \end{array} \right. \end{align} \end{document}  You can also use \begin{cases}...\end{cases} instead of \left\{...\right., but then in this particular example the equation number doesn't fit anymore. Moreover, note that there's no need to use align as the outer environment since that one has no tab stops; I'd use equation instead. - if id use a cases construct, it would only change the source code of the "outer" part. the inner part would need to stay as an array like you posted, correct? – helt Oct 8 '12 at 15:09 See my edit: is that what you meant? – Hendrik Vogt Oct 8 '12 at 17:00 yeah! thanks. I havent found equation that works with an equation but not with align environment. Thats why i stick to align per default... – helt Oct 11 '12 at 7:20 @helt: See also align vs equation. – Hendrik Vogt Oct 11 '12 at 8:51 add comment You can use the cases environment and \phantom to achieve the desired alignments \[ \curlyvee(v, \omega) := l_1 \triangleright l_2 = \begin{cases} \phantom{\omega(}l_1(v) & \text{wenn v \in G_1 \setminus G_2}\\ \omega(l_1(v)) + (1-\omega)(\hat{R}l_2(v) +\hat{t}) &\text{wenn v \in G_1 \cap G_2}\\ \phantom{\omega(l_1(v)) + (1-\omega)(}\hat{R}l_2(v) +\hat{t} &\text{wenn v \in G_2 \setminus G_1}. \end{cases}


A second option is to use a tabbing environment inside a minipage

$\curlyvee(v, \omega) := l_1 \triangleright l_2 = \begin{cases} \begin{minipage}{0cm} \begin{tabbing} \omega(\=l_1(v)) + (1-\omega)(\=\hat{R}l_2(v)+\hat{t}) \quad\= \kill \> l_1(v) \>\> wenn v \in G_1 \setminus G_2\\ \omega(l_1(v)) + (1-\omega)(\hat{R}l_2(v) +\hat{t}) \>\>\> wenn v \in G_1 \cap G_2\\ \>\> \hat{R}l_2(v) +\hat{t} \> wenn v \in G_2 \setminus G_1. \end{tabbing} \end{minipage} \end{cases}$

-
thanks. Would you mind telling me which package is providing \phantom and its documentation? –  helt Oct 8 '12 at 10:32
and isnt there another way of doing this? Setting invisible text seems to be a source for typing errors –  helt Oct 8 '12 at 11:10
@helt \phantom is provided by TeX. –  Guido Oct 8 '12 at 11:41
could split both answers as they look like completely different approaches to me? –  helt Oct 8 '12 at 15:18

I think you want to use the alignedat environment instead of aligned. This is similar to the aligned environment in that it provides pairs of r/l equations, but without the inter equation space that the aligned environment adds. So the only changes required to your code as posted above are:

1. Replace the \begin{aligned} with \begin{alignedat}{4}, and the corresponding end{}.

2. Change the second and third alignment point from & to &&. This doubling changes the alignment from right aligned to left aligned which is what you want.

3. Change text{wenn...} to text{ wenn...}, or use \quad\text{wenn...} instead so that you have some space there.

## Notes:

• But as the other solutions mention, the outed environment really is a cases (or dcases) environment and should not be an align as you do not have multiple equations that are aligned. You have one equation.

## Code:

\documentclass{article}
\usepackage{mathtools}  % extends amsmath and fixes some of its quirks
\usepackage{amssymb}
\begin{document}

\begin{align}\label{eq:mergefunction_with_weighting}
\curlyvee(v, \omega) :=
l_1 \triangleright l_2 =
\left\{
\begin{alignedat}{4}
&l_1(v)               &&                          &&\quad\text{wenn $v \in G_1 \setminus G_2$}\\
\omega(&l_1(v)) + (1-\omega)(&&\hat{R}l_2(v) +\hat{t})   &&\quad\text{wenn $v \in G_1 \cap G_2$}\\
&                     &&\hat{R}l_2(v) +\hat{t}    &&\quad\text{wenn $v \in G_2 \setminus G_1$}.
\end{alignedat}
\right.
\end{align}

\end{document}

-