Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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) \\
& \quad \quad \quad \quad \cdot c(x) dx\\
%
\end{align*}
share|improve this question
add comment

5 Answers

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

enter image description here

\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}
share|improve this answer
    
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
add comment

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) \\
& \mathrel{\phantom{=\int}}\quad {}\cdot c(x)\,dx
\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*}

enter image description here

share|improve this answer
    
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
add comment

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.

share|improve this answer
    
the distance between c(x) and the equal sign is far. –  Pig Cry Oct 24 '11 at 16:00
add comment

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}

enter image description here

share|improve this answer
    
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
1  
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
show 2 more comments

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}

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.