16

This question is related to, but distinct from Oversized \underbrace's label causes unwanted spacing.

My issue isn't with the spacing of the label, but with the size of the underbrace itself. Using the accepted answer at that page as a reference, I do not like the space around (?) caused by the brace underneath it. I would like the left and right vertical limits of the brace to lie under the parentheses, not around them.

That is, the brace in that answer could crudely be sketched as

 (?)
\---/

but I instead would like

(?)
\-/

(In the case I am actually frustrated with right now, the object is du rather than (?), but I think the same reasoning should apply.)

Thanks!

4 Answers 4

12

Even after smashing the label width (the usual culprit as addressed in the linked question), the brace cannot shrink any more because it is the smallest size provided in Computer Modern.

Some font/symbol packages define smaller curly braces. The only one I can think of off the top of my head is MnSymbol, which is unfortunate because it has several incompatibilities.

An alternative that should work with any font packages is to define a new \smallunderbrace command that uses the smallest font \tiny to create the brace:

\def\smallunderbrace#1{\mathop{\vtop{\m@th\ialign{##\crcr
   $\hfil\displaystyle{#1}\hfil$\crcr
   \noalign{\kern3\p@\nointerlineskip}%
   \tiny\upbracefill\crcr\noalign{\kern3\p@}}}}\limits}

This command is identical to \underbrace from base LaTeX with the exception of \tiny inserted in the last line. Here's the result:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\def\smallunderbrace#1{\mathop{\vtop{\m@th\ialign{##\crcr
   $\hfil\displaystyle{#1}\hfil$\crcr
   \noalign{\kern3\p@\nointerlineskip}%
   \tiny\upbracefill\crcr\noalign{\kern3\p@}}}}\limits}
\makeatother

\begin{document}
\begin{gather}
  (du) \\
  (\smallunderbrace{du}_{\text{\clap{label}}}) \\
  (\smallunderbrace{\text{test}}_{\text{\clap{label}}})
\end{gather}
\end{document}

The last test line is just to show that this new command is still extensible, but the \smallunderbrace command should only be used when the standard \underbrace is too big.

5
  • So this package just redefines braces? There is some other reason I have MnSymbol in my preamble already, but I've commented it out temporarily because calling as many packages as I am using makes compilation take a ridiculously long time.
    – jdc
    Commented Jan 25, 2015 at 4:16
  • No, it does a lot more, which is part of the reason there are many incompatibilities. It changes nearly all the symbols, which may or may not be desirable for your document. Commented Jan 25, 2015 at 4:18
  • Whoa. I really like Minion, actually, but I didn't know how to put my document in it, so it's currently in Palatino.
    – jdc
    Commented Jan 25, 2015 at 4:26
  • @jdc see the update. This version should work with whichever math/text fonts you've selected. Commented Jan 25, 2015 at 4:46
  • I had some issues with Misplaced \noalign, I solved those by wrapping the \tiny\upbracefill in curly braces: {\tiny\upbracefill} in my definition of \smallunderbrace.
    – josh
    Commented Jun 5, 2020 at 6:54
7

There is a minimum size of the underbrace and there's nothing to do with it, unless a different strategy is used:

  1. TikZ bracket decorations, that are just awful, in my opinion
  2. underbrackets instead of underbraces

The best strategy, however, is to use underbraces in very rare occasions.

If you want that the underbrace is slimmer and shorter, you can exploit the fact that amsmath defines the math extension font also at a reduced size (I've never understood why Knuth didn't provide cmex5 and cmex7).

\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\upbracefill}{\m@th}{\scriptstyle\m@th}{}{}
\patchcmd{\upbracefill}{$\braceld$}{$\scriptstyle\braceld$}{}{}
\patchcmd{\upbracefill}{\bracelu}{\bracelu\mkern-1mu}{}{}
\patchcmd{\upbracefill}{\hfill\braceru}{\hfill\mkern-1mu\braceru}{}{}
\makeatother

\begin{document}
\begin{gather*}
\underbrace{du}_{\text{label}}\\
\underbrace{} \\ % minimum size
\underbrace{loooooooooooong}
\end{gather*}
\end{document}

As you'll see in the picture, the minimum size is quite smaller than the standard one and the underbrace is smaller.

enter image description here

4

You want it like this?

enter image description here

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\[
    \left( x-1 \right) (\underbrace{\text{du}}_{ \mathclap{\text{what is this?}} })
\]

\end{document}
1
  • Close! I want du in math mode (d is a linear map in this context), but more importantly, and I want the brace itself to fit under du, so that, for example, the parentheses would not have any inclination to be as far away from du as they are in your output.
    – jdc
    Commented Jan 25, 2015 at 3:36
1

This is similar to a way I got the brackets to be a little tighter. It is not perfect, but I hope it helps.

\documentclass[12pt]{book}
\usepackage{subfiles}
\newcounter{figno} %sets figure counter
\setcounter{figno}{0}
\usepackage{graphicx} %for scalebox
\usepackage{tikz}

\begin{document}
    \obeylines
    
    Original $\underbrace{(?)}$
    
    Smaller $(?) \hspace{-0.47cm} \scalebox{0.7}[1]{$\underbrace{\phantom{(?)}}$}$
    
    \vspace*{0.5cm}
    
    Or a little easier is in tikz
    
    \begin{tikzpicture}
        \node[] at (0,0) {$(?)$};
        \node[] at (0,-0.08) {\scalebox{0.7}[1]{$\underbrace{\phantom{(?)}}$}};
    \end{tikzpicture}
    
    \vspace*{0.5cm}
    
    or here is a commands use:
    
    \newcommand{\minibrace}[2][0.5]{\raisebox{-.5cm}{\begin{tikzpicture}
            \node[] at (0,0.5){\phantom{.}};
            \node[] at (0,0) {\normalsize{$#2$}};
            \node[] at (0,-0.08) {\scalebox{#1}[1]{$\underbrace{\phantom{(#2)}}$}};
    \end{tikzpicture}}}

    hello \minibrace{(?)} hello  \\[-0.4cm]
    have I ever shown you \minibrace[0.42]{x}$x$ it \\[-0.4cm]
    2 time the value of \minibrace[0.42]{y}$y$ which\\[-0.4cm]
    is equal to 2.
    
    \vspace*{0.5cm}
    
    It is not 100\% perfect, but hope it helps : )
\end{document}

And then this is the output on TexStudio enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .