10

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!

8

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
\newcommand{\clap}[1]{\makebox[0pt]{#1}}

\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.

  • 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 Jan 25 '15 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. – Paul Gessler Jan 25 '15 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 Jan 25 '15 at 4:26
  • @jdc see the update. This version should work with whichever math/text fonts you've selected. – Paul Gessler Jan 25 '15 at 4:46
5

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}
  • 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 Jan 25 '15 at 3:36

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.