Help with left align?
You're making several errors.
$$
should never be used in LaTeX (see Why is \[ ... \] preferable to $$ ... $$?)Just
equation
is sufficient to get an equation numberLines in
aligned
are never numbered by themselvesThe syntax is
<left hand side> &= <right hand side>
There is no
\nonnumber
command; it is\nonumber
, but in this case it's not necessaryThe label should be outside the inner
aligned
The
amsmath
package should be loaded only once.
In the example I used \lipsum
to provide some mock text and show the alignment.
More important is the correct usage of \left
and \right
around big fractions.
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[fleqn]{amsmath}
\numberwithin{equation}{section}
\usepackage{lipsum} % just for this example
\begin{document}
\section{A new section}
\lipsum*[3]
\begin{equation}\label{eq:21}
\begin{aligned}
E_\theta(L(\delta_1(X))
&= E_\theta\left((1-\frac{b}{a+X^2}) X-\theta\right)^2 \\
&=E_\theta\left(Y-\frac{b}{a+(Y+\theta)^2}(Y+\theta)\right)^2 \\
&= n-2bE\frac{Y(Y+\theta)}{a+(Y+\theta)^2}+b^2E\frac{(Y+\theta)^2}{[a+(Y+\theta)^2]^2}\\
&<n-2bE\frac{Y(Y+\theta)^2-b/2}{a+(Y+\theta)^2}
\end{aligned}
\end{equation}
\lipsum[3]
\end{document}
several problems here ...
if you use
\begin{equation} ... \end{equation}
you shouldn't use$$
. (besides,\[ ... \]
should be used instead of$$
if you do want an unnumbered equation.)\nonumber
(not\nonnumber
) isn't needed if you're usingaligned
. sincealigned
"groups" all the lines within it, any appearance there of\nonumber
will suppress the equation number.the extra
&
following the=
or<
is what is forcing everything on the right-hand side to the right. foraligned
you should use only one&
, before the sign of relation. the extra&
is the eqnarray convention; the single&
is the proper method for the structures provided byamsmath
(wherealigned
is defined).move the label outside the
aligned
; it belongs at theequation
level. this won't affect whether or not the equation number is printed, but it makes more sense to someone else reading the input code.
I'm not clear on what you mean when you say left aligned, but here's my attempt. Also, I wasn't clear if you wanted to explicitly number the equation, like I've done below, or if you want the equations to follow section numbers.
See the wiki book for some more explanation on alignment and equation numbering.
\documentclass[12pt,fleqn]{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
E_\theta(L(\delta_1(X)) &= E_\theta[(1-\frac{b}{a+X^2}) X-\theta]^2 \\
&=E_\theta[Y-\frac{b}{a+(Y+\theta)^2}(Y+\theta)]^2 \\
&= n-2bE\frac{Y(Y+\theta)}{a+(Y+\theta)^2}+b^2E\frac{(Y+\theta)^2}{[a+(Y+\theta)^2]^2} \\
&<n-2bE\frac{Y(Y+\theta)^2-b/2}{a+(Y+\theta)^2} \label{eq:21} \tag{2.1}
\end{align*}
\end{document}