# Equation numbering inside align*

Consider:

\begin{align*}
&\begin{bmatrix} P_1 J&0\\0&NP_2\end{bmatrix}=\\&\begin{bmatrix}I&0\\0&N\end{bmatrix}\begin{bmatrix}P_1&0\\0& P_2\end{bmatrix}
\begin{bmatrix}J&0\\0&I\end{bmatrix}
\stackrel{2.18}{=}\begin{bmatrix}I&0\\0&N\end{bmatrix}[V,W]^{-1}[EV,AW]\begin{bmatrix}
J&0\\0&I\end{bmatrix}\\
&\stackrel{(2.10)}{=}[EV,AW]^{-1}EA[V,W]=[EV,AW]^{-1}AE[V,W]\\
&\stackrel{(2.10)}{=}\begin{bmatrix}J&0\\0&I\end{bmatrix}[V,W]^{-1}[EV,AW]\begin{bmatrix}I&0\\0&N\end{bmatrix}\\
&\stackrel{(2.18)}{=}\begin{bmatrix}J&0\\0&I\end{bmatrix}
\begin{bmatrix}P_1&0\\0&P_2\end{bmatrix}\begin{bmatrix}I&0\\0&N\end{bmatrix}
\begin{bmatrix}JP_1&0\\0&P_2N\end{bmatrix}\\
\end{align*}

The last line should produce an automatic equation numbering, say 2.15. I am using \begin{equation}\end{equation}, but while I am writing

\begin{align*}
&\begin{bmatrix} P_1 J&0\\0&NP_2\end{bmatrix}=\\&\begin{bmatrix}I&0\\0&N\end{bmatrix}\begin{bmatrix}P_1&0\\0& P_2\end{bmatrix}
\begin{bmatrix}J&0\\0&I\end{bmatrix}
\stackrel{2.18}{=}\begin{bmatrix}I&0\\0&N\end{bmatrix}[V,W]^{-1}[EV,AW]\begin{bmatrix}
J&0\\0&I\end{bmatrix}\\
&\stackrel{(2.10)}{=}[EV,AW]^{-1}EA[V,W]=[EV,AW]^{-1}AE[V,W]\\
&\stackrel{(2.10)}{=}\begin{bmatrix}J&0\\0&I\end{bmatrix}[V,W]^{-1}[EV,AW]\begin{bmatrix}I&0\\0&N\end{bmatrix}\\
$$&\stackrel{(2.18)}{=}\begin{bmatrix}J&0\\0&I\end{bmatrix} \begin{bmatrix}P_1&0\\0&P_2\end{bmatrix}\begin{bmatrix}I&0\\0&N\end{bmatrix} \begin{bmatrix}JP_1&0\\0&P_2N\end{bmatrix}\\$$
\end{align*}

it is showing some error.

• You can't nest environments that start math mode like that, use one align, and \nonumber on the lines that shouldn't be numbered. Mar 11, 2017 at 9:03
• Mar 11, 2017 at 9:07
• I dont understand, could anyone give a code :( :( Mar 11, 2017 at 9:09
• Take your first code, replace align* with align (i.e. remove the *), and then before the \\ of the first few lines, write \nonumber. Mar 11, 2017 at 9:14
• If you want automatic numbering of equations, use align, not align*.
– Mico
Mar 11, 2017 at 9:21

You can use aligned inside equation, so you can choose what line the global equation number will be aligned with; in this case, with \begin{aligned}[b], we have the last line.

You shouldn't hardwire the numbers, but use \eqref together with suitable \label commands.

\documentclass{article}
\usepackage{amsmath}

\numberwithin{equation}{section}

\begin{document}

\setcounter{section}{2}\setcounter{equation}{9}
$$\label{a} 0=0$$
\setcounter{equation}{17}
$$\label{b} 1=1$$

This was just to set up numbers to be used in the main
display
\label{c} \begin{aligned}[b] &\begin{bmatrix} P_1 J&0\\0&NP_2\end{bmatrix}= \begin{bmatrix}I&0\\0&N\end{bmatrix}\begin{bmatrix}P_1&0\\0& P_2\end{bmatrix} \begin{bmatrix}J&0\\0&I\end{bmatrix} \\[1ex] &\qquad\overset{\eqref{b}}{=} \begin{bmatrix}I&0\\0&N\end{bmatrix}[V,W]^{-1}[EV,AW] \begin{bmatrix}J&0\\0&I\end{bmatrix} \\[1ex] &\qquad\overset{\eqref{a}}{=} [EV,AW]^{-1}EA[V,W]=[EV,AW]^{-1}AE[V,W] \\[1ex] &\qquad\overset{\eqref{a}}{=} \begin{bmatrix}J&0\\0&I\end{bmatrix}[V,W]^{-1}[EV,AW] \begin{bmatrix}I&0\\0&N\end{bmatrix} \\[1ex] &\qquad\overset{\eqref{b}}{=} \begin{bmatrix}J&0\\0&I\end{bmatrix} \begin{bmatrix}P_1&0\\0&P_2\end{bmatrix}\begin{bmatrix}I&0\\0&N\end{bmatrix} \begin{bmatrix}JP_1&0\\0&P_2N\end{bmatrix} \end{aligned}

\end{document}

Just for completeness, here's a solution that uses a single align environment, rather than an aligned environment nested inside an equation environment. The cost is that the first four rows -- the ones that aren't supposed to be numbered -- need to be terminated with a \nonumber (or \notag) directive.

\documentclass{article}
\usepackage{amsmath} % for 'align' environment
\begin{document}

\begin{align}
&\begin{bmatrix}P_1 J&0\\0&NP_2\end{bmatrix}=
\begin{bmatrix}I&0\\0&N\end{bmatrix}
\begin{bmatrix}P_1&0\\0&P_2\end{bmatrix}
\begin{bmatrix}J&0\\0&I\end{bmatrix}\nonumber\\