The second alignat
below illustrates my problem.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{2}
a &= & b \\
& & + c
\end{alignat*}
\begin{alignat*}{2}
a &= & b \\
& & + c \\
&= \text{long expression}
\end{alignat*}
\end{document}
I want the third line of the equation not to alter spacing on previous lines. In other words, I want a math environment that behaves similarly to the tabbing
environment. Could somebody help?
Edit: The example I show above is a simplified one. In my real problem, the part corresponding to = b
is quite complicated. If we use Werner's solution below, we would be repeating the whole complicated expression in \phantom{}
. So, I guess there is no ready-made tabbing-like environment?
My current workaround is to use \hspace*{}
in place of \phantom{}
, manually adjusting the position. (I'm not claiming it is better. Manual adjustment is annoying.)
Edit 2: Werner has made me realize that I simplified my code so much that a simple \phantom{{}={}}
is a good solution to the simplified code. So, the example below is a more accurate illustration of my original problem:
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{align*}
a &= b [ c + d \\
&\phantom{{}=b [ c} + e] \\
&= \text{long expression}
\end{align*}
\end{document}
In this case, (I think) we have to repeat part of the previous line in \phantom
, which is annoying when b
and c
are complicated. As I said in my "Edit" above, I'm currently using \hspace*
to avoid repeating the complicated expression in a phantom
.
alignat
is really the wrong environment to use here, and the use of&
after the=
is defensible only in very special circumstances. thealign
example in @Werner's answer is a much better approach. i recommend referring to theamsmath
manual (texdoc amsmath
) -- it isn't really very long.