[Tex/LaTex] Substitute for eqnarray

aligneqnarray

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}

gives this :

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 :

enter image description here

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 set margin =). Also, the frenchb option is ibsolete, and should be replaced with french, preferable loaded with the \documentclass, so that all language-dependent packages be informed. Lastn needless to load amsfonts, since amssymb does it for you.

\documentclass[12pt, french]{article}
\usepackage{amsmath,amssymb} % Tableaux, maths
\usepackage{babel}
\usepackage[margin=1.5cm]{geometry} % Marges
\usepackage{eqparbox}
\newcommand{\eqrel}[2][B]{\mathrel{\eqmakebox[#1]{#2}}} %% eqparbox uses a system of tags, which is the optional argument here – defaults to B.

\begin{document}

\begin{align*}
  \emph{Test~align*} &\eqrel{$=$} \text{Bad alignment} \\
  &\eqrel{\em Because} \text{the text is left-aligned, near the equal sign}
\end{align*}

\end{document} 

enter image description here

Related Question