# Setting the right distance to “=”

Consider this expression:

How can I code this in LaTeX such that everything is aligned at the "=" sign such that the distance to the left and the right of the "=" sign at each line is the same as the distance to the other "=" which aren't in some separate column to which everything has to align to.

(Using for example eqnarray doesn't help, since in this case I can align everything at "=", but the distance to the left and the right is way off.)

-

You are perfectly correct in saying that eqnarray is not the right tool here. The amsmath package provides several environments for displayed equations with correct spacing. (Extra features are available from the mathtools package.) In your example align* is the relevant construct to use (remove the * if you want equation numbers):

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
x_1+x_2 &= (-p + i \sqrt{q-p^2}) + (-p - i \sqrt{q-p^2}) = - 2p,\\
x_1\cdot x_2 &= (-p + i \sqrt{q-p^2}) \cdot (-p - i \sqrt{q-p^2})
= (-p)^2 - (i \sqrt{q-p^2})^2 \\
&= q.
\end{align*}

\end{document}


Alignment points are specified by &, newlines by \\.

-
perfect! thanks. – user10324 Jun 21 '14 at 10:12
"eqnarray is no the right tool here" ... It's never the right tool. :) – Svend Tveskæg Jun 22 '14 at 11:50