Substitute for eqnarray?
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}
in align
you have one ampersand to much:
\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*}
or
\begin{align*}
Test~align* & = \text{Bad alignment} \\
& \text{Because the text is right-aligned, far to the equal sign}
\end{align*}
or
\begin{align*}
Test~align* & = \parbox[t]{0.4\linewidth}{
Bad alignment \\
Because the text is right-aligned, far to the equal sign}
\end{align*}
\end{document}
adedndum: apparently you looking for the following:
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\[\setlength\arraycolsep{2pt}
\begin{array}{rcl}
Test~array & = & \text{Fine alignment}\\
& Because & \text{the text is left-aligned \dots}
\end{array}
\]
\end{document}
addendum (2):
with help of very old (and almost forgotten) package mathenv
from mfwtools
:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{mathenv}
\usepackage[frenchb]{babel}
\usepackage[top=1.5cm,bottom=1.5cm,right=1.5cm,left=1.5cm]{geometry} % Marges
\begin{document}
\begin{eqnarray}[rc@{\;}l]
Test~eqnarray & = & \text{Good alignment} \\
& Because & \text{the text is aligned near to the equal sign}
\end{eqnarray}
\end{document}