# Breaking up an equation in the align* environment

I'm trying to produce the following formatting without use of all the \quad commands to get the last equation to align nicely across the break up (a(x), b(x), and c(x) are actually really long expressions). I searched the internet for quite bit to no avail. Any ideas?

\begin{align*}
f & = \int a(x) ) dx\\
%
& = \int b(x) \\
%
\end{align*}

-

Use \hphantom to obtain the correct horizontal spacing without typesetting anything:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}

\begin{align*}
f & = \int a(x) dx \\
& = \int b(x) \\
& \hphantom{{}=\int b(x)}\cdot c(x) dx
\end{align*}
\end{document}

-
Nice touch to use the \hphantom command -- it combines the \phantom and \smash commands I use in my answer! – Mico Oct 24 '11 at 15:53
Yes - I originally commented on that in your solution, but removed it. – Werner Oct 24 '11 at 15:57
Thank you so much. It worked like a charm. – mark Oct 24 '11 at 16:23

Your method is almost correct; if b(x) and c(x) represent here long expressions, it would be nonsense trying to align the \cdot with the end of b(x).

I would use a simple \quad, but with a slight improvement:

\begin{align*}
f & = \int a(x)\,dx\\
& = \int b(x) \\
\end{align*}


In this way the \quad will start just after the integral sign on the line above and the vertical spacing of the three lines will be uniform. The {} inserts a dummy object that makes the + into a binary operation symbol.

"Realistic" example:

\begin{align*}
f & = \int \cos(x-a)\,dx\\
& = \int (\cos a\cos x \\
& \mathrel{\phantom{=\int}}\quad{} + \sin a\sin x)\,dx
\end{align*}


-
Would it improve intelligibility to add a left parenthesis after the integral sign on the middle line and a right parenthesis between the end of the integrand and the "dx" term on the final line? – Mico Oct 24 '11 at 19:18
@Mico Yes, of course. – egreg Oct 25 '11 at 7:53

You can have more than one & per line, which allows you to align items along different 'anchors':

\begin{align*} f & = \int a(x) dx &\\%
& = \int b(x) \\
& & \cdot c(x) dx%
\end{align*}


or you can stretch them a bit farther apart by using flalign instead of align:

\begin{flalign*} f & = \int a(x) dx &\\%
& = \int b(x) \\
& & \cdot c(x) dx%
\end{flalign*}


See which suits you better.

-
the distance between c(x) and the equal sign is far. – Pig Cry Oct 24 '11 at 16:00

I think the code below meets your requirements. The \phantom{\phantom{=\int b(x)} command inserts an invisible block of the same width as its contents (i.e., of the line above), and the \smash{...} command prevents the invisible block from taking up too much vertical space. (Try the code without the \smash command to see the effect on the spacing between lines 2 and 3 of the align* environment.) Finally, the extra {} snippet inside the \phantom command is there to tell TeX to treat the (otherwise invisible) equal sign as a "normal" math-relational operator.

Separately, I've eliminated a stray right parenthesis from the first line and added a couple of "thin space" commands, \,, to provide a bit of separation between the integrands and the "dx" terms; doing so tends to improve legibility (and it's a practice followed by many mathematicians, including Don Knuth -- the creator of TeX). :-)

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
f &= \int a(x) \,dx\\
& = \int b(x) \\
&\smash{\phantom{{}=\int b(x)}}\cdot c(x)\,dx\\
\end{align*}
\end{document}


-
Your alignment is not 100% correct if due to the incorrect setting of = as the first item of \phantom. Typeset two lines (one with and one without the \hphantom to see the marginal difference. – Werner Oct 24 '11 at 15:55
Thanks, @Werner. I've changed this piece in the meantime, and added an explanation of what the {} snippet does for the alignment of the "invisible" equal sign. :-) – Mico Oct 24 '11 at 15:58
nice touch on the use of the thin space command. Thanks! – mark Oct 24 '11 at 16:25
Not \smash{\phantom{...}}, but \hphantom. On the other hand, \phantom would give uniform spacing for the lines. – egreg Oct 24 '11 at 22:04
Yes, but TeX has to do the same work twice, so the formula in the inner braces has to be typeset eight times: both \smash and \phantom use \mathchoice. – egreg Oct 24 '11 at 23:54

If both b(x) and c(x) are long enough, you can use this:

\begin{multline*}
\begin{aligned}
f &= \int a(x) \,dx\\
&= \int b(x)
\end{aligned}
\\
{}\cdot c(x)\,dx
\end{multline*}


Or just replace multiple \quads with \hspace{10em}

-