# Underbraces using tikzmark

I'm trying to get some sort of nesting braces for some math notes that I'm typing, this is the code that I'm using:

\documentclass[11pt, oneside, french]{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,intersections, decorations.pathreplacing,shapes,snakes}
\begin{document}
\tikzmark{a}
$\tikzmark{c}U^{T}\tikzmark{d}\;\quad\quad\tikzmark{e}A\tikzmark{f}\;\quad.\quad\tikzmark{g}U\tikzmark{h}$
\tikzmark{b}
\begin{tikzpicture}[remember picture, overlay, decoration={brace, amplitude=5pt}]
\foreach \i / \j in {a/0, b/10pt, c/0, d/0, e/0, f/0, g/0, h/0} \coordinate (\i) at ([yshift=\j]{pic cs:\i});
\draw [decorate] (b -| d) -- (c |- b) node[midway,below,yshift=-5pt] {$1 \times n$} coordinate(k);
\draw [decorate] (b -| f) -- (e |- b) node[midway,below,yshift=-5pt] {$n \times n$} coordinate(l);
\draw [decorate] (b -| h) -- (g |- b) node[midway,below,yshift=-5pt] {$1 \times 1$} coordinate(m);
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay, decoration={brace, amplitude=5pt}, yshift=-15pt]
\draw [decorate] (b -| l) -- (k |- b) node[midway,below] {$n \times n$};
\end{tikzpicture}
\end{document}


This is the output that I'm getting:

I would like to instead have the second brace under the 1 x n and n x n is there any way I can do that? I do have to go even lower to have another brace encompassing the next line which would be 1 x n to be braced with 1 x 1.

If you have any other ideas on how I could accomplish it, maybe without TikZ, I am more than open to suggestions.

• please extend your code snippet to complete small documnet beginning with \documentclass{...} folowoed by needed packages and your equation, and ending with \end{document} Feb 4, 2018 at 11:39

However, tikzmark is useless here, there is \underbrace from \amsmath package which could be also nested.

Maybe this is what you want to achieve (you could also add some \quad where you like or any other kerning, if you want):

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\underbrace{% \underbrace{% \underbrace{U^{T}}_{1\times n}\cdot\underbrace{A}_{n\times n} }_{1\times n}\cdot\underbrace{U}_{n\times 1} }_{1\times 1}$
\end{document}


• This is exactly what I was looking for, thanks you so much, didn't realize you could nest with \underbrace Feb 4, 2018 at 20:13
• I love the waterfall of underbrace's <3. Oct 9, 2018 at 19:01