I was trying to left align this equation by using code
$$\begin{equation}
\begin{aligned}
E_\theta(L(\delta_1(X)) &=& E_\theta[(1-\frac{b}{a+X^2}) X-\theta]^2\nonnumber\\
&=&E_\theta[Y-\frac{b}{a+(Y+\theta)^2}(Y+\theta)]^2\nonnumber\\
&=& n-2bE\frac{Y(Y+\theta)}{a+(Y+\theta)^2}+b^2E\frac{(Y+\theta)^2}{[a+(Y+\theta)^2]^2}\nonnumber\\
&<&n-2bE\frac{Y(Y+\theta)^2-b/2}{a+(Y+\theta)^2} \label{eq:21}\end{aligned}\end{equation}$$
However, it turns out it's still right aligned and it is labelled (1) instead of (2.1)
My preamble is
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[fleqn]{amsmath}
Best Answer
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.