Enumerating the align environment

Consider the following MWE:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\setcounter{equation}{42}

\begin{align}
a & = b + c              \label{label1} \\
\alpha_{i,j,k} & = \theta^2 + \phi^2  \label{label2} \\
M_\text{res} & = a + \alpha_{i,j,k} \label{label3}
\end{align}

\end{document}


How can I enumerate the three equations? Wrapping the align environment in an enumerate environment and starting each equation line with \item won't work.

The equations should be enumerated like normal, and will thus depend on what comes before the align environment in question. I've arbitrarily set the equation counter to 42 to represent the content before the align. I also need to reference the equation labels as normal.

-
Don't they have already a number? –  egreg Sep 4 '14 at 15:58
@egreg: They do have automatic numbering, which depends on what comes before the align environment. I need to enumerate the three equations as 1., 2. and 3. on the left hand side. –  eiterorm Sep 4 '14 at 16:01
What's the reason? I see none. –  egreg Sep 4 '14 at 16:01
@egreg: I'm outlining the mathematical steps of numerical algorithms. –  eiterorm Sep 4 '14 at 16:03
Do you need to refer to those numbers? –  egreg Sep 4 '14 at 16:03

Use alignat and a \step macro:

\documentclass{article}
\usepackage{amsmath}

\newcounter{step}

\begin{document}

\setcounter{equation}{42}

\setcounter{step}{0} % do this when you want to reset the numbering
\begin{alignat}{2}
\step&&              a & = b + c              \label{label1} \\
\step&& \alpha_{i,j,k} & = \theta^2 + \phi^2  \label{label2} \\
\step&&   M_\text{res} & = a + \alpha_{i,j,k} \label{label3}
\end{alignat}

\end{document}


-
Surely there is a way to push the left number to the margin. –  John Kormylo Sep 4 '14 at 16:33
@John Kormylo: See my answer. –  Bernard Sep 4 '14 at 16:35
@egreg: Don't forget to reset the counter on entering of leaving the environment. –  Bernard Sep 4 '14 at 16:37
@Bernard Isn't \setcounter{step}{0} before the environment? ;-) –  egreg Sep 4 '14 at 16:54
@JohnKormylo That would be an abomination. –  egreg Sep 4 '14 at 16:55

A solution that uses the flalign environment:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\newcounter{algostep}
\newcommand\step{\stepcounter{algostep}\hskip\parindent\thealgostep.}
\usepackage{etoolbox}
\BeforeBeginEnvironment{flalign}{\setcounter{algostep}{0}}

\begin{document}
\setcounter{equation}{42}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{flalign}
&\step & a & = b + c \label{label1} & \\
&\step & q & = e + f \label{label2} \\
&\step & z & = a + d \label{label3}
\end{flalign}
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
\begin{flalign}
&\step & z & = a + d \label{label3} & \\
&\step & q & = e + f \label{label2} \\
&\step & a & = b + c \label{label1}
\end{flalign}

\end{document}


-
Thanks for the nice solution. This compiles nicely on its own, but sadly, somewhere in my main document, something is causing an error with \gappto when using your solution. –  eiterorm Sep 4 '14 at 17:00
Could you produce a MWE so we can test? –  Bernard Sep 4 '14 at 18:04
I can't seem to pinpoint the error. It's none of the packages themselves, so there has to be something in my document causing the error. –  eiterorm Sep 5 '14 at 12:17