I've been struggling with matrix underbrace, and I can't find any way through all LaTeX questions about how to use an underbrace in a matrix without the array package.
So far I got here, with these new commands, but the underbrace/overbrace is not correctly placed in the second matrix.
MWE
\documentclass[12pt]{report}
\usepackage{amsmath, amssymb, etoolbox}
\newcommand\aug{\fboxsep=-\fboxrule!!!\fbox{\strut}!!!}
\newcommand\undermat[2]
{\makebox[0pt][l]{$\smash{\underbrace{\phantom{\begin{matrix}#2\end{matrix}}}_{\text{$#1$}}}$}#2}
\newcommand\overmat[2]{
\makebox[0pt][l]{$\smash{\overbrace{\phantom{\begin{matrix}#2\end{matrix}}}^{\text{$#1$}}}$}#2}
\begin{document}
$$\begin{pmatrix}
2 & 3 & 1 & \aug & 1 & 0 & 0 \
1 & 0 & 1 & \aug & 0 & 1 & 0 \
\undermat{A}{ 5 & 4 & 6 } & \aug & \undermat{I}{ 0 & 0 & 0 }\
\end{pmatrix}
\xrightarrow[\rm{Jordan}]{\rm{Gauss}}
\begin{pmatrix}
\overmat{I}{ 1 & 0 & 0 }& \aug & \overmat{A^{-1}}{ 4/7 & 2 & -3/7 }\
0 & 1 & 0 & \aug & 1/7 & -1 & 1/7 \
0 & 0 & 1 & \aug & -4/7 & -1 & 3/7 \
\end{pmatrix}$$
\end{document}
In the second matrix, if I use \undermat{}{} it gives the same result.



\rmis not defined by default in latex, but where it is defined for compatibility with pre-1993 documents, the syntax is{\rm Jordan}]not\rm{Jordan}it did not take an argument. – David Carlisle Nov 04 '23 at 12:30\textrmto\rmto make it faster. I don't like the array package because I got a lot of trouble with incompatibilites with the xltabular package and a bunch others. – Agente 156 Nov 04 '23 at 12:32\rmhas been known to tex syntax checkers editor highlighting etc for nearly 40 years defining a new command of the same name but different syntax will confuse everything, not just me. – David Carlisle Nov 04 '23 at 12:35xltabularusestabularxwhich is based onarrayby the same author, me:-) so you are loadingarray. – David Carlisle Nov 04 '23 at 12:37xltabular, can I ask you how to move the title of a section to a new page if anxltabularenvironment inmediatly breaks page. I mean that there is some cases were the title of the section is in the last line of the page and thexltabularstarts in a new page and it looks weird. Thank you for you LaTeX colaborations – Agente 156 Nov 04 '23 at 12:52\clearpagebefore the\section– David Carlisle Nov 04 '23 at 13:21