7

I am trying to align the following equations around the equal sign. What can I do? Thanks! I am using the AMSMath package

    $$m\ddot{x}_{1}-K(x_{2}+x_{12})+C(\dot{x}_{12}+\dot{x}_{2})+2C\dot{x}_{1} = fx_{1}$$
$$m\ddot{x}_{2}-K(x_{3}+x_{1})+C(\dot{x}_{1}+\dot{x}_{3})+2C\dot{x}_{2} = fx_{2}$$ 
$$m\ddot{x}_{3}-K(x_{4}+x_{2})+C(\dot{x}_{2}+\dot{x}_{4})+2C\dot{x}_{3} = fx_{3}$$ 
ndim
  • 35,870
  • 12
  • 47
  • 57
Adam Lee
  • 2,983
  • 7
  • 35
  • 47
  • 1
    Please read [this](http://meta.stackexchange.com/q/138840/164376) before voting to migrate this to tex.stackexchange.com. – joran Jun 23 '13 at 02:14

3 Answers3

21
\begin{align}
    m\ddot{x}_{1}-K(x_{2}+x_{12})+C(\dot{x}_{12}+\dot{x}_{2})+2C\dot{x}_{1} &= fx_{1} \\
    m\ddot{x}_{2}-K(x_{3}+x_{1})+C(\dot{x}_{1}+\dot{x}_{3})+2C\dot{x}_{2} &= fx_{2} \\
    m\ddot{x}_{3}-K(x_{4}+x_{2})+C(\dot{x}_{2}+\dot{x}_{4})+2C\dot{x}_{3} &= fx_{3}
\end{align}

See the user's guide.

Jed
  • 1,651
  • 17
  • 26
5

To make a long story short... the following idea of using eqnarray is kind of obvious, but turns out to be a really bad idea. eqnarray brings lots of issues which are solved in amsmath and related packages. Read Lars Madsen: Avoid eqnarray for the details.

\begin{eqnarray*} %% Do avoid eqnarray if possible.
    x_1 & = & 1 \\
    x_2 & = & 2 \\
    x_3 & = & 3
\end{eqnarray*}

(Answer revised with information from Arthur Reutenauer, Thomas and the Madsen paper linked to by Thomas.)

Community
  • 1
  • 1
ndim
  • 35,870
  • 12
  • 47
  • 57
  • 1
    Not really smart: eqnarray is *really* outdated (since 15 years or so). The AMS environment are a much safer choice. – Arthur Reutenauer Nov 13 '09 at 21:37
  • 5
    I won't downvote you for this, but know for once and for all that eqnarray is evil: http://www.tug.org/pracjourn/2006-4/madsen/madsen.pdf – Thomas Nov 13 '09 at 21:45
  • I don't think eqnarray is that bad, but I appreciate the link to the article explaining why people prefer the amsmath alternative. – John D. Cook Nov 13 '09 at 23:47
  • @ndim: Thanks for taking our comments into account! I, too, started with eqnarray ten years ago, and then I read the LaTeX companion... – Arthur Reutenauer Nov 14 '09 at 00:49
  • @Arthur: I was not aware that so much had changed since that time in the 1990s when I read my first book on LaTeX, so eqnarray seemed obvious. Apparently though, I am not the only one who is prone to falling into that trap, so I guess it is a good idea to leave this answer here. Thanks for enlightening me. – ndim Nov 14 '09 at 01:33
4

There are several packages to do what you want, one of the most widely used is the AMS' align environment from the amsmath package.

Simplified extract from amsldoc.pdf:

\begin{align} 
x&=y \\ 
x’&=y’ \\ 
x+x’&=y+y’ 
\end{align}

The equations are aligned around the symbols that follow & (the equals signs, in this case).

Arthur Reutenauer
  • 2,622
  • 1
  • 17
  • 15