5

Might be a dumb question, but I am firing it:

enter image description here

How can I align a text, A, in this case, right under a bmatrix/pmatrix?

I currently have this code:

        \begin{equation*}
        \begin{pmatrix}
            3 & -1 & 1 \\
            3 & 3  & 7 \\
            3 & 6  & 2
        \end{pmatrix}\begin{pmatrix}
            x_1 \\
            x_2 \\
            x_3
        \end{pmatrix} = \begin{pmatrix}
            1 \\
            4 \\
            0
        \end{pmatrix}
    \end{equation*}

and this equation:

enter image description here

Where matrixes make equation of Ax = b. I want to write corresponding variable, like x, b, A right under the matrixes.

help?

1
  • Welcome to TeX.SE.
    – Mico
    Commented Oct 24, 2023 at 10:26

3 Answers 3

3

The \underbrace macro may be your friend.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for '\underbrace' macro and 'pmatrix' environment
\begin{document}
    
\[
{\underbrace{\begin{pmatrix}
    3 & -1 & 1 \\
    3 & 3  & 7 \\
    3 & 6  & 2
\end{pmatrix}}_{A}} \,
{\underbrace{\begin{pmatrix}
    x_1 \\
    x_2 \\
    x_3
\end{pmatrix}}_{x\vphantom{A}}} = 
{\underbrace{\begin{pmatrix}
    1 \\
    4 \\
    0
\end{pmatrix}}_{b}}
\]
    
\end{document}
2
  • 1
    I love you mate <3 Commented Oct 24, 2023 at 10:33
  • @CanerÇetin - You're most welcome. :-)
    – Mico
    Commented Oct 24, 2023 at 10:38
4

Using \underbrace seems the best approach, but the spacing would be awful. Not to mention the input syntax.

\documentclass{article}
\usepackage{amsmath}

\NewDocumentEnvironment{ubpmatrix}{m+b}
 {% some space to compensate
  \mspace{9mu}%
  % a group to avoid \underbrace being a mathop
  {\underbrace{%
    \mspace{-9mu}%
    \begin{pmatrix}#2\end{pmatrix}%
    \mspace{-9mu}%
  }_{\mathstrut#1}}
  \mspace{9mu}%
 }{}

\begin{document}
    
\[
\begin{ubpmatrix}{A}
    3 & -1 & 1 \\
    3 & 3  & 7 \\
    3 & 6  & 2
\end{ubpmatrix}
\begin{ubpmatrix}{x}
    x_1 \\
    x_2 \\
    x_3
\end{ubpmatrix}
=
\begin{ubpmatrix}{b}
    1 \\
    4 \\
    0
\end{ubpmatrix}
\]
    
\end{document}

enter image description here

The underbrace is below a shrinked object, the same space is added around the construction to cover our tracks.

4

Here is what you can do with {pNiceMatrix} of nicematrix and its built-in command \SubMatrix.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{lipsum} % for dummy text

\begin{document}

\lipsum[1]
\[
A = \begin{pNiceMatrix}[last-row=4]
4  & -1 & 1 \\
4  & -8 & 1 \\
-2 & 1 & 5 \\
\\
\CodeAfter \UnderBrace[yshift=1mm]{3-1}{3-3}{A}
\end{pNiceMatrix}
\hspace{2cm}
B = \begin{pNiceMatrix}[last-row=4]
4  & -1 & 1 \\
4  & -8 & 1 \\
-2 & 1 & 5 \\
\\
\CodeAfter \UnderBrace[yshift=1mm,shorten]{3-1}{3-3}{B}
\end{pNiceMatrix}
\]
\lipsum[2]

\end{document}

The second matrix uses the key shorten of SubMatrix.

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .