Labelling Ax = b under an actual Matrix

Here's a perhaps better version, with a new environment which accepts the subscript as argument:

\documentclass{article}
\usepackage{amsmath}

\newenvironment{spmatrix}[1]
 {\def\mysubscript{#1}\mathop\bgroup\begin{pmatrix}}
 {\end{pmatrix}\egroup_{\textstyle\mathstrut\mysubscript}}

\begin{document}
\begin{equation}
\begin{spmatrix}{A}
    a & b \\
    c & d
\end{spmatrix}
\begin{spmatrix}{x}
    x_1 \\
    x_2
\end{spmatrix}
=
\begin{spmatrix}{b}
    b_1  \\
    b_2
\end{spmatrix}
\end{equation}
\end{document}

enter image description here

Note: too big subscripts may cause misalignment.

I wouldn't use \times for matrix multiplication: no symbol is generally used.

Also align for a single equation is wrong.


If someone is asking why the \def\mysubscript{#1} bit in the definition, the answer is that LaTeX doesn't allow using #1 in the "end" part of \newenvironment. This limitation does not hold with xparse:

\usepackage{xparse}
\NewDocumentEnvironment{spmatrix}{ m }
  {\mathop\bgroup\begin{pmatrix}}
  {\end{pmatrix}\egroup_{\textstyle\mathstrut #1}}

It can be achieved by putting the matrix and the vectors inside \mathop. The example also uses \textstyle for a larger size and \vphantom for adjusting the baselines.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\mathop{\begin{pmatrix}
    a & b \\
    c & d
\end{pmatrix}}_{\textstyle A} 
\times
\mathop{\begin{pmatrix}
    x1 \\
    x2
\end{pmatrix}}_{\textstyle x\vphantom{A}}
=
\mathop{\begin{pmatrix}
    b1  \\
    b2
\end{pmatrix}}_{\textstyle b\vphantom{A}}
\end{align}
\end{document}

Addition: Macro form.

\documentclass{article}
\usepackage{amsmath}
\newcommand*{\putunder}[2]{%
  {\mathop{#1}_{\textstyle #2}}%
}
\begin{document}
\begin{gather}
\putunder{
  \begin{pmatrix}
    a & b \\
    c & d
  \end{pmatrix}
}{A}
\times
\putunder{
  \begin{pmatrix}
    x1 \\
    x2
  \end{pmatrix}
}{x\vphantom{A}}
=
\putunder{
  \begin{pmatrix}
    b1  \\
    b2
  \end{pmatrix}
}{b\vphantom{A}}
\end{gather}
\end{document}

Result


Here is one that abuses a feature of mathtools (a supplement and some correction to amsmath features. Check the documentation) which I use often. It's actually drawing a bracket but zeroing it's linewidth makes it invisible. It's not elegant but still I didn't have any problems yet (doesn't mean I won't).

The command is \underbracket[<rule thickness>] [<bracket height>]{<arg>}

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
\underbracket[0pt][0pt]{%
\begin{pmatrix}
    a & b \\
    c & d
\end{pmatrix}}_{\mathstrut A}
\times
\underbracket[0pt][0pt]{%
\begin{pmatrix}
    x_1 \\
    x_2
\end{pmatrix}}_{\mathstrut x}
=
\underbracket[0pt][0pt]{%
\begin{pmatrix}
    b_1  \\
    b_2 
\end{pmatrix}}_{\mathstrut b}
\]
\end{document}

The contents of the labels are top aligned so I've pushed the x label a bit down. Thanks to egreg, now the contents are fixed to the baseline regardless of their height.

enter image description here

Tags:

Matrices