Equation number for each row of a matrix equation

Is it possible to give an equation number to each row of a matrix equation?

How could I have equation labels in the vein of subequation numbers, one for each row of the matrix equation? Here, I'd like equation numbers such as, e.g., (3.1a), (3.1b), (3.1c) (I don't mean row/column labels as in a bordered matrix).

Thanks!

• Use an image we don't use mathjax on this site as it would confuse the issue as people need to show the tex rendering amd mathjax does not use tex May 9, 2014 at 23:36
• Related, but not automatic numbering: Label rows of a matrix by characters May 9, 2014 at 23:39
• I can't understand what the line number would refer to. May 10, 2014 at 7:44
• @egreg each line number would refer to a block equation of the system. May 10, 2014 at 19:44
• But matrix multiplication is rows by columns! Labeling rows doesn't make sense if there is a matrix product in your equation. May 12, 2014 at 21:49

Hmm! not really supported LaTeX syntax but

\documentclass{article}

\usepackage{amsmath}

\newsavebox\labelbox

\begin{document}

\savebox\labelbox{$\begin{matrix} \refstepcounter{equation}(\theequation)\label{aa}\\ \refstepcounter{equation}(\theequation)\label{bb}\\ \refstepcounter{equation}(\theequation)\label{cc} \end{matrix}$}

$\begin{bmatrix} H & J^T & -Z^{\frac12} \\ J & -\delta I & \\ -Z^{\frac12} & & -X \end{bmatrix} \begin{bmatrix} r \\ s \\ t \end{bmatrix} = \lambda \begin{bmatrix} H & & \\ & U & \\ & & W \end{bmatrix} \begin{bmatrix} r \\ s \\ t \end{bmatrix} \eqno \usebox{\labelbox}$

[\ref{aa}]
[\ref{bb}]
[\ref{cc}]
\end{document}

• Very interesting (and potentially useful) technique. Is there anything that can go wrong with it? May 10, 2014 at 2:01
• I didn't think of that. I like it! Why do you say it's not supported?It's not inelegant. May 10, 2014 at 4:30
• \eqno is a TeX primitive and wouldn't generally work in conjunction with amsmath constructs, but you get away with it here. Probably you could (and should) use \tag in other contexts. May 10, 2014 at 10:04
• @StevenB.Segletes something can go wrong with anything:-) \eqno shouldn't be used in latex (and wouldn't work in most ams math constructs) but it works here and I was getting tired:-) May 10, 2014 at 10:06
• But you know me. I'm not contemplating using in with ams math constructs, but rather with TABstacks ;^) May 10, 2014 at 11:10

By accident I discovered a simple and straight-forward way. If one has some large column in the actual matrix one should set a corresponding phantom in the numeration matrix. One could also add a \displaystyle in the equation number matrix if that is really needed.

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\ltxlabel}{\ltx@label}
\makeatother
\begin{document}
\begin{align}\refstepcounter{equation}
\begin{bmatrix}
H            & J^T       & -Z^{\frac12} \\
J            & -\delta I &              \\
-Z^{\frac12} &           & -X
\end{bmatrix}
\begin{bmatrix}
r \\ s \\ t
\end{bmatrix}
=
\lambda
\begin{bmatrix}
H &   &  \\
& U &  \\
&   & W
\end{bmatrix}
\begin{bmatrix}
r \\ s \\ t
\end{bmatrix}
\tag*{$\begin{matrix} \text{(\theequation a)}\\ \text{(\theequation b)}\\ \text{(\theequation c)} \end{matrix}$}
\ltxlabel{eq:matrix}
\end{align}
The first row (\ref{eq:matrix}a) is the most important row of the matrix.
\end{document}


Here's a way to manually avoid the need to manipulate the counter. I create two \vboxes. The first is an array of blank subequations, and the second is the desired matrix in a simple $...$ construct. Then I stack the two \vboxes atop each other. Voila!

I've even set it up so that adjusting the vertical baselineskip of the matrix (since I used TABstacks) is automatically reflected in the vertical separation of the equation numbering (through the use of the \aligngap macro).

One could, if desired, replace my TABstacks with {bmatrix}es and it would still work, though the definition of \aligngap would in that case, need some tweaking.

\documentclass{article}
\usepackage{amsmath,tabstackengine,lipsum}
\newsavebox\boxA
\def\aligngap{\dimexpr\Lstackgap-15pt\relax}
\begin{document}
\lipsum[1]

{\setstackgap{L}{14pt}% SELECTABLE MATRIX ROW BASELINESKIP
\setbox0=\vbox{\begin{subequations}%
\begin{align}\label{eq:A}\\aligngap]\label{eq:B} \\[\aligngap]\label{eq:C}\end{align}% \end{subequations}} \savebox\boxA{\vbox{\[ \setstacktabbedgap{5pt} \bracketMatrixstack{ H & J^T & -Z^{\frac12} \\ J & -\delta I & \\ -Z^{\frac12} & & -X} \bracketVectorstack{r \\ s \\ t} = \lambda \bracketMatrixstack{ H & & \\ & U & \\ & & W} \bracketVectorstack{r \\ s \\ t}}}
\noindent\stackengine{3.5pt}{\box0}{\usebox{\boxA}}{O}{c}{F}{F}{L}}

In equations \ref{eq:A}, \ref{eq:B}, and \ref{eq:C},
\lipsum[2]
\end{document}


Below there is a possible quick and dirty alternative if one needs AMS-\tags. The drawback is that it requires some manual height adjustment in the first matrix. This solution would not exist without the solution of David. Thanks, David! I needed this too.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\par\noindent\begin{minipage}[c][][c]{0.9\textwidth}
\begin{align*}
\begin{matrix}
1\cdot x_1&+&2\cdot x_2&+&3\cdot x_3&=&4\\[3pt]
5\cdot x_1&+&6\cdot x_2&+&7\cdot x_3&=&8\\[3pt]
9\cdot x_1&+&10\cdot x_2&+&11\cdot x_4&=&12
\end{matrix}
\end{align*}
\end{minipage}\begin{minipage}[c][][c]{0.1\textwidth}
\begin{align}\refstepcounter{equation}
\tag{\theequation a}\label{eq:1a}\\[0pt]
\tag{\theequation b}\label{eq:1b}\\[0pt]
\tag{\theequation c}\label{eq:1c}
\end{align}
\end{minipage}
\end{document}


• Where are the matrices? Feb 25, 2017 at 9:29