Why does aligning equations not work here?
You need to use a double &&
:
The reason is that the align
and alignat
environment both provide pairs of rl
aligned equations. So if you want a l
eft aligned point you need to skip over the r
ight aligned point.
If you want to control the spacing in between the columns, then use the alignat
in which case you need to manually add the space. Here I have added a \quad
for the spacing spacing:
As requested in the comments, here is an alternate use of align
which ensures that the start of the last two lines is aligned with the first =
of the first line.
Notes:
- A
\phantom{{}={}}
was used to ensure that the last two lines are aligned to the text to the right of the=
. The additional{}
in the\phantom
is used to ensure proper spacing is applied around the=
. We could also have use\hphantom{}
instead, but both will yield identical result in this case. rlap
was used so that the right hand sides is not going to have an effect on the alignment of the subsequent rows.
Code:
\documentclass{article}
\usepackage{amsmath}
\newcommand*{\op}[1]{\operatorname{#1}}
\begin{document}
\noindent
Using \verb|align|:
\begin{align*}
\noalign{$\quad \op{f} * \op{r} = \op{c}_{\op{f}*\op{r}} (x_1,...,x_k) = (\op{f}(a_1,...,a_k), \op{r}(b_1,...,b_k))$}
&\text{if } x_i=(x^{\op{f}}_i,x^{\op{r}}_i), &&\text{then } a_i=x^{\op{f}}_i \in \mathcal{S}, b_i=x^{\op{r}}_i \in (\mathcal{A}^*)^*, &&1 \leq i \leq k\\
&\text{if } x_i \in \mathcal{A}^*, &&\text{then } a_i=b_i=x_i, &&1 \leq i \leq k
\end{align*}
Using \verb|alignat|:
\begin{alignat*}{3}
\noalign{$\quad \op{f} * \op{r} = \op{c}_{\op{f}*\op{r}} (x_1,...,x_k) = (\op{f}(a_1,...,a_k), \op{r}(b_1,...,b_k))$}
&\text{if } x_i=(x^{\op{f}}_i,x^{\op{r}}_i), &&\quad\text{then } a_i=x^{\op{f}}_i \in \mathcal{S}, b_i=x^{\op{r}}_i \in (\mathcal{A}^*)^*, &&\quad 1 \leq i \leq k\\
&\text{if } x_i \in \mathcal{A}^*, &&\quad\text{then } a_i=b_i=x_i, &&\quad 1 \leq i \leq k
\end{alignat*}
\hrule\medskip\noindent
Alternate alignment with \verb|align|:
\begin{align*}
\op{f} * \op{r} &= \op{c}_{\op{f}*\op{r}} (x_1,...,x_k) \rlap{${}= (\op{f}(a_1,...,a_k), \op{r}(b_1,...,b_k))$}\\
&\phantom{{}={}}\text{if } x_i=(x^{\op{f}}_i,x^{\op{r}}_i), &&\text{then } a_i=x^{\op{f}}_i \in \mathcal{S}, b_i=x^{\op{r}}_i \in (\mathcal{A}^*)^*, &&1 \leq i \leq k\\
&\phantom{{}={}}\text{if } x_i \in \mathcal{A}^*, &&\text{then } a_i=b_i=x_i, &&1 \leq i \leq k
\end{align*}
\end{document}
Peter Grill has already answered your basic problem with the number of ampersands. However, I would suggest a different approach of introducing an aligned
environment to contain the second and third lines. This left hand side of this can then be lined up with the first line using an enclosing align
environment. Do this to the right of the equals sign is accomplished by a = {}&
to correct correct spacing around that sign.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Alignment to left of equals:
\begin{align*}
f * r &= c_{f*r} (x_1,...,x_k) = (f(a_1,...,a_k), r(b_1,...,b_k))\\
&
\begin{aligned}
&\text{if } x_i=(x^f_i,x^r_i), &&\text{then } a_i=x^f_i
\in \mathcal{S}, b_i=x^r_i \in (\mathcal{A}^*)^*,
&1 \leq i \leq k,\\
&\text{if } x_i \in \mathcal{A}^*, &&\text{then } a_i=b_i=x_i,
&1 \leq i \leq k.
\end{aligned}
\end{align*}
Alignment to right of equals:
\begin{align*}
f * r = {}& c_{f*r} (x_1,...,x_k) = (f(a_1,...,a_k), r(b_1,...,b_k))\\
&
\begin{aligned}
&\text{if } x_i=(x^f_i,x^r_i), &&\text{then } a_i=x^f_i
\in \mathcal{S}, b_i=x^r_i \in (\mathcal{A}^*)^*,
&1 \leq i \leq k,\\
&\text{if } x_i \in \mathcal{A}^*, &&\text{then } a_i=b_i=x_i,
&1 \leq i \leq k.
\end{aligned}
\end{align*}
\end{document}
I have taken advantage of the comments to the question to remove the \op
commands.