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 writing a manuscript with long equations. In order to break the equations I prefer the align environment, provided by the amsmath package, over the eqnarray one.

In the below example I show the kind of align I need. The eqnarray gives the correct behaviour, will the align one drops a space after the & symbol.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{eqnarray}
  \vec{F} &=& m\vec{a}\\
          && + \frac{dm}{dt} \vec{v}
\end{eqnarray}  

\begin{align}
  \vec{F} =& m\vec{a}\\
          & + \frac{dm}{dt} \vec{v}
\end{align}  

\end{document}

Question

Is it possible to replicate the first example using align?

share|improve this question
3  
please note -- the answer, to put = *after the &, is stated clearly in the documentation: texdoc amsmath, near the top of p.3. (but, of course, nobody ever reads documentation ...) –  barbara beeton Aug 20 '12 at 18:23
1  
Why eqnarray shouldn't be used: Avoid eqnarray (PDF). –  Torbjørn T. Aug 20 '12 at 18:47
1  
@Barbara: has it ever been explained why one need the {} pair then one use ={}& ? –  daleif Aug 20 '12 at 20:22
    
@barbarabeeton I've read it, however the = after the & gives a result I'm not looking for. –  Dox Aug 20 '12 at 20:35
    
@TorbjørnT. Wonderful link, Thx. –  Dox Aug 20 '12 at 20:36
show 1 more comment

3 Answers

You should put = after &. I have added \phantom{=:} to push the+to right. (IMO it would be nice if we put this+` at the end of first line.)

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{eqnarray}
  \vec{F} &=& m\vec{a}\\
          && + \frac{dm}{dt} \vec{v}
\end{eqnarray}

\begin{align}
  \vec{F} &= m\vec{a} \\
          & \phantom{=:} + \frac{dm}{dt} \vec{v}
\end{align}

\end{document}

enter image description here

Update As per the suggestion of @egreg (who is a mathematician hence I don't say no to what he says :) ) instead of \phantom{=:} one can use \qquad to push things to right.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{eqnarray}
  \vec{F} &=& m\vec{a}\\
          && + \frac{dm}{dt} \vec{v}
\end{eqnarray}

\begin{align}
  \vec{F} &= m\vec{a} \\
          & \qquad + \frac{dm}{dt} \vec{v}
\end{align}

\end{document}

enter image description here

Note: It is advisable NOT to use eqnarray.

share|improve this answer
1  
I'd use \qquad instead of \phantom –  egreg Aug 20 '12 at 17:05
    
@egreg: As you wish. I added it in the answer. Thank you. –  Harish Kumar Aug 20 '12 at 17:11
1  
I usually use = {} & and just &+ instead. You might also find the \MoveEqLeft macro from mathtools useful. Instead of starting a line with &... and indenting the other lines, starting a line with \MoveEqLeft ... move this line backwards (2ems). This makes it easy to to the equation setup recommended in Mathematics into Type (or see the drawings in my (danish) LaTeX book, chapter 4) –  daleif Aug 20 '12 at 18:27
    
@daleif Thank you! That's what I was looking for! –  Dox Aug 20 '12 at 20:49
add comment
up vote 1 down vote accepted

In order for align to generate a similar result to eqnarray as in the example,

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{eqnarray}
  \vec{F} &=& m\vec{a}\\
          && + \frac{dm}{dt} \vec{v}
\end{eqnarray}

\end{document}

a pair of curly brackets should be used between the = sign and the &, as below,

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
  \vec{F} ={}& m\vec{a}\\
          & + \frac{dm}{dt} \vec{v}
\end{align}

\end{document}

Acknowledgements

I'd like to thank to daleif and TorbjørnT for pointing out the answer, and for recommending the manuscript by Lars Madsen,

Avoid eqnarray!

The Practex Journal, 2006, No. 4

share|improve this answer
add comment

okay, this "answer" stretches the bounds of what is proper here, but continued recommendations to place the & in an amsmath alignment after the sign of relation are simply wrong.

the proper placement of the & is before the sign of relation. this is basic to tex itself.

as an exercise, here is the code for the first multi-line display on p.192 of the texbook as (plain) \eqalign with &= and then again with =& as the only differences in the two examples.

$$\eqalign{%
  (x+y)(x-y) &= x^2 -xy +yx -y^2\cr
             &= x^2 -y^2\cr
  (x+y)^2    &= x^2 +2xy +y^2\cr
}$$
%
now, with ampersands and equal signs interchanged:
%
$$\eqalign{%
  (x+y)(x-y) =& x^2 -xy +yx -y^2\cr
             =& x^2 -y^2\cr
  (x+y)^2    =& x^2 +2xy +y^2\cr
}$$

\bye

here is the output:

enter image description here

the spacing is governed by the values in the spacing table on p.170. the "null" condition represented by the = sign followed by & isn't in that table. however, the result is clear. amsmath simply followed this model, and depends on the default outcome.

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.