[Tex/LaTex] Underbrace changing spacing of operators

math-modespacing

I have found that using an \underbrace on a term in an equation causes the spacing of the following terms to be changed, in particular, the + is moved closer to the \dot{m}. This seems to be distinct from the problem in Oversized \underbrace's label causes unwanted spacing because

  1. the amount of space is getting smaller
  2. the label under the brace is not larger than the brace
  3. trying \mathclap as suggested in that question doesn't help

I noticed this problem when putting together a presentation in beamer, but I'm able to reproduce it in the standard article class as well. Changing the font doesn't help either (I noticed the problem with TeX Gyre Pagella Math). How can I avoid changing the spacing surrounding an underbrace?

\documentclass{article}
\begin{document}
\[ \dot{W}_{cv} + \dot{m} \]
\[ \underbrace{\dot{W}_{cv}}_{=0} + \dot{m} \]
\[ \underbrace{\dot{W}}_{=0} + \dot{m} \]
\end{document}

enter image description here

Best Answer

The definition of \underbrace in latex.ltx is essentially borrowed from Plain TeX:

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

This allows the syntax

\underbrace{...}_{...}

but has the consequence you can see in your example.

The spacing would be the same as with

\sin+x

enter image description here

Solution: add braces, which make the object into an ordinary atom.

\documentclass{article}
\begin{document}
\[ \dot{W}_{cv} + \dot{m} \]
\[ {\underbrace{\dot{W}_{cv}}_{=0}} + \dot{m} \]
\[ {\underbrace{\dot{W}}_{=0}} + \dot{m} \]
\end{document}

enter image description here

The proper syntax for LaTeX would be

\Underbrace{label}{formula}

and you can obtain it by saying

\newcommand{\Underbrace}[2]{{\underbrace{#2}_{#1}}}
Related Question