Firstly, sorry for my english level, I'm French.
Secondly, I've read eqnarray
environment becomes obsolete, and we have to replace this by align
. Ok, but it's not satisfying for me. I explain :
\documentclass[12pt]{article}
\usepackage{amsmath,amsfonts,amssymb} % Tableaux, maths
\usepackage[frenchb]{babel}
\usepackage[top=1.5cm,bottom=1.5cm,right=1.5cm,left=1.5cm]{geometry} % Marges
\begin{document}
\begin{eqnarray*}
Test~eqnarray* & = & \text{Good alignment} \\
& Because & \text{the text is aligned near to the equal sign}
\end{eqnarray*}
\end{document}
With the environment align
\documentclass[12pt]{article}
\usepackage{amsmath,amsfonts,amssymb} % Tableaux, maths
\usepackage[frenchb]{babel}
\usepackage[top=1.5cm,bottom=1.5cm,right=1.5cm,left=1.5cm]{geometry} % Marges
\begin{document}
\begin{align*}
Test~align* & = & \text{Bad alignment} \\
& Because & \text{the text is right-aligned, far to the equal sign}
\end{align*}
\end{document}
gives :
How can I obtain absolutly the same results as eqnarray
with align
?
Note : I don't care the spacing problem with eqnarray
Best Answer
You have to understand that in
align
and similar amsmath environments, if you want n alignment groups, each group except the first requires 2 ampersands: the first&
introduces a new alignment group, and the second&
specifies the alignment point inside this group. The first group doesn't require the first ampersand, of course, so n alignment groups in all require 2 n – 1&
s.You have used the
eqnarray
syntax, with two&
, so amsmath understands there are two groups. As there's no&
for the alignment point in the second group, it is aligned on the last characters of each line.Added:
An easy solution to your problem is obtained with the
eqparbox
package. Incidentally, I simplified your code for geometry (since all your margins are equal you can simply setmargin =
). Also, thefrenchb
option is ibsolete, and should be replaced withfrench
, preferable loaded with the\documentclass
, so that all language-dependent packages be informed. Lastn needless to loadamsfonts
, sinceamssymb
does it for you.