I would like to define a command to automatize https://tex.stackexchange.com/a/503610/128042, since many LaTeX-users don't like the spacing of \underbrace
(see using underbrace without having left( and right) scale, How to prevent an underbrace, with a subscript, from affecting the sizes of delimiters, Underbrace messing with horizontal spacing, ...)
I tried the following MWE
:
\documentclass{article}
%\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{hyperref}
\DeclarePairedDelimiter{\norm}{\|}{\|_{2}}
\newcommand{\myVtoken}{}
\newcommand{\myunderbrace}[2]{%
\renewcommand{\myVtoken}{\vphantom{\underbrace{{#1}}_{{#2}}}}%
\vphantom{#1}\smash[b]{\underbrace{{#1}}_{\mathclap{{#2}}}}%
}
\begin{document}
I would like this to work:
\[
\norm*{\left(2,\myunderbrace{\frac{5}{3}}{\approx 1.66666667\frac{1}{1}} \right)}
\myVtoken %\vphantom{\underbrace{\frac{5}{3}}_{\approx 1.66666667\frac{1}{1}}} %with this \vphantom it would work
\]
The above formula is too close to this line, but this works fine:
\[
\norm*{\left(2,\smash[b]{\underbrace{\frac{5}{3}}_{\mathclap{\approx 1.66666667}}} \right)}
\vphantom{\underbrace{\frac{5}{3}}_{\approx 1.66666667}}
\]
This text has the correct distance to the line above, because of the vphantom outside of the delimiters.
\end{document}
The \renewcommand
within the \newcommand
seems not to work, the way I expected. I tried a bit around with \let
and \def
, but I have very litttle knowledge about them.
Does someone know how to redefine a command within a command properly to get the desired effect?
Or are there better solutions to get the desired result, where have an easy to use command where I don't have to copy the content of the \underbrace
multiple times. I don't want to decide manually how large the delimiters should be using something like \big
.