tags:

views:

416

answers:

3

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}$$
+11  A: 
\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
thanks! xD it worked!
mr.flow3r
+1  A: 

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
+3  A: 

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.)

ndim
Not really smart: eqnarray is *really* outdated (since 15 years or so). The AMS environment are a much safer choice.
Arthur Reutenauer
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
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
@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
@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