1

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}

which produces: enter image description here

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.

2

A simple and straightforward solution is available if one is willing to issue explicit sizing instructions, i.e., \big, \Big, \bigg, and \Bigg, rather than rely on \left and \right to size the parentheses and norm symbols.

enter image description here

A non-negligible advantage of the approach taken here is that low-level LaTeX equation placement parameters such as \abovedisplayskip and \abovedisplayshortskip needn't be tweaked.

\documentclass{article}
\usepackage{mathtools} % for \DeclarePairedDelimiter and \mathclap macros
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert_2}
\newcommand{\myunderbrace}[2]{\underbrace{#1}_{\mathclap{#2}}}

\begin{document}
\noindent
Some text some text some text some text some text \dots
\[
\norm[\bigg]{\Bigl( 2, \myunderbrace{\frac{5}{3}}{\approx 1.6667} \,\Bigr)}
\]
Some text some text some text some text some text \dots
\end{document}
|improve this answer|||||
1

Just I have, only, added after \begin{document},

        \abovedisplayskip=0.6cm
        \abovedisplayshortskip=-0.3cm
        \belowdisplayskip=0.6cm
        \belowdisplayshortskip=0.2cm

after to have modificated the parameters of the code that you can find into this link.


enter image description here

\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:
\abovedisplayskip=0.6cm
\abovedisplayshortskip=-0.3cm
\belowdisplayskip=0.6cm
\belowdisplayshortskip=0.2cm
\[
\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}
|improve this answer|||||
  • Based on what have you chosen the numbers? Is there a possibility to do this without using explicit numbers, as these numbers are probably different for different journals and styles. In this solution \myVtoken could be dropped as it would not be needed and does not have any effect here. – Jakob Feb 16 at 17:29
  • for very large stuff under the underbrace, this solution does not work :( – Jakob Feb 16 at 17:41
  • @Jakob I have chosen the numbers in function to the blank space between above and below formula; I have done several compilations to have an adapt space. – Sebastiano Feb 16 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.