I would like to know how to make a nested comments (see figure) for a equation.

Kind Regards S.L.

Adapted from my answer at How to link two terms in math mode, though I had to make some changes. First, you helped me discover a bug there (which I fixed), when the label was wider than the underset material. But in addition, I had to introduce a new dimension.

EDITED to improve syntax, but the basic macro is \ubar{left term}{middle stuff}{right term}{label}. In order to nest them, I now provide \addlevel and \subtractlevel.

To change the nest level (bracket depth), pre-emptively invoke \addlevel prior to the invocation (can be done more than once). Then, within the middle stuff, you can invoke \subtractlevel to reduce the bracket depth. In these two macros, I merely play with the strut height.

However, if you wish to adapt \addlevel and \subtractlevel to alter any of the dimensions, those at your disposal are:

\rldp the vertical underset of the horizontal bar

\rlht the height of the vertical struts below the math

\rlwd the rule width, and

\rlstub the height of the bottom (central) rule leading to the undertext

\documentclass{article}
\usepackage{stackengine,graphicx,amsmath}
\stackMath
\newlength\rldp
\rldp1.3ex
\newlength\rlht
\rlht.8ex
\newlength\rlstub
\rlstub.8ex
\newlength\rlwd
\rlwd.8pt
\setstackgap{L}{\rldp}
\def\uvbarR#1{%
\def\stackalignment{r}\def\stacktype{S}\stackunder[-\rlwd]{%
\def\stackalignment{c}\def\stacktype{L}\stackunder{#1}{\rule{\rlwd}{\rlht}}%
}{\setbox0\hbox{$#1$}\rule{.5\wd0}{\rlwd}}%
}
\def\uvbarL#1{%
\def\stackalignment{l}\def\stacktype{S}\stackunder[-\rlwd]{%
\def\stackalignment{c}\def\stacktype{L}\stackunder{#1}{\rule{\rlwd}{\rlht}}%
}{\setbox0\hbox{$#1$}\rule{.5\wd0}{\rlwd}}%
}
\newlength\tmplen
\def\uvbar#1#2{%
\def\stacktype{S}\def\useanchorwidth{T}\def\stackalignment{c}\stackunder[0pt]{%
\def\stacktype{L}\setbox0\hbox{${}#1{}$}%
\stackunder[\rldp]{{}#1{}}{\rule{\wd0}{\rlwd}}%
}{\def\stacktype{S}\stackunder[1pt]{\rule{\rlwd}{\rlstub}}{\scriptscriptstyle#2}}%
}
\newcommand\ubar[4]{\uvbarR{#1}\uvbar{#2}{#4}\uvbarL{#3}}
}
\newcommand\subtractlevel[1][.9\baselineskip]{%
$\addlevel a\ubar{b} { \subtractlevel \ubar{}{c}{}{\scalebox{.3}{inner}} d } {e}{\text{outer}} f + ghick = lmn$
$\addlevel\addlevel\ubar {} {\subtractlevel\subtractlevel \ubar{a}{^2 + b}{^2} {\text{sides}} = \addlevel \ubar{}{c^2}{}{\text{\makebox[3ex][r]{hypotenuse}}}} {\,\,} {\text{The Pythagorean Theorem}}$