4

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}\\
\begin{equation}
&\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{equation}
\end{align*}

it is showing some error.

Myshkin
  • 653
  • You can't nest environments that start math mode like that, use one align, and \nonumber on the lines that shouldn't be numbered. – Torbjørn T. Mar 11 '17 at 09:03
  • 1
    See e.g. http://tex.stackexchange.com/questions/42726 – Torbjørn T. Mar 11 '17 at 09:07
  • I dont understand, could anyone give a code :( :( – Myshkin Mar 11 '17 at 09:09
  • 2
    Take your first code, replace align* with align (i.e. remove the *), and then before the \\ of the first few lines, write \nonumber. – Torbjørn T. Mar 11 '17 at 09:14
  • If you want automatic numbering of equations, use align, not align*. – Mico Mar 11 '17 at 09:21
  • what do you mean by first few lines – Myshkin Mar 11 '17 at 09:31
  • @Urgent -- all lines that shouldn't be numbered – Mico Mar 11 '17 at 09:39
  • It seems strange to me to put equation numbers above the equals signs. Why not just put them at the end of the line, as normal? When you write \begin{align}A&=B\\ &=C\end{align} the first equation number already refers to A=B and the second to B=C. I can see the point if you're saving space by putting multiple equalities on one line but, with one per line, it just looks weird. – David Richerby Mar 11 '17 at 18:29

2 Answers2

8

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}
\begin{equation} \label{a}
0=0
\end{equation}
\setcounter{equation}{17}
\begin{equation} \label{b}
1=1
\end{equation}

This was just to set up numbers to be used in the main
display
\begin{equation} \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{equation}

\end{document}

enter image description here

egreg
  • 1,121,712
3

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.

enter image description here

\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\\
&\quad\stackrel{(2.18)}{=}\begin{bmatrix}I&0\\0&N\end{bmatrix} 
  [V,W]^{-1}[EV,AW]
  \begin{bmatrix}J&0\\0&I\end{bmatrix}\nonumber\\
&\quad\stackrel{(2.10)}{=}[EV,AW]^{-1}EA[V,W]
  =[EV,AW]^{-1}AE[V,W]\nonumber\\
&\quad\stackrel{(2.10)}{=}\begin{bmatrix}J&0\\0&I\end{bmatrix}
  [V,W]^{-1}[EV,AW]
  \begin{bmatrix}I&0\\0&N\end{bmatrix}\nonumber\\
&\quad\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}
\end{document}
Mico
  • 506,678