5

The following code:

 f(\textcolor{red}{-3})= 4 {\times} ~ \underbrace{\textcolor{red}{(-3)}}_{parenth\`{e}ses !!}-1

results in too much space after \times:

enter image description here

How to get (-3) close to the multiplication?

  • you can hide the width of underbrace text but why ` {\times} ~ ` which removes the normal space around times and adds a word-space (which isn't normally used in mathematics) – David Carlisle Feb 27 '18 at 15:35
  • I just think of the 'removes the normal space' and not the 'adds a word-space' ... – Jean-Pat Feb 27 '18 at 15:47
  • {} removes the normal space and ~ adds the space that you would normally get between words. – David Carlisle Feb 27 '18 at 15:52
10

Use \mathclap from mathtools:

enter image description here

A few more things:

  • Consider using \mathrm \text for text in math mode. \text is context-aware, so if you are in an italic context, it will output italicized text. \mathrm, on the other hand, will discard any spaces, because it is still math-mode!

  • As David Carlisle noted, don't use the space ~ after \times. There is no need for it there.

  • Also, as @egreg and @Mico said in the comments, enclosing the \times in braces makes the spacing incorrect around it. You should, instead, enclose the whole \underbrace{...}_{...} in braces.

Code below:

\documentclass{article}

\usepackage{xcolor}
\usepackage{mathtools}

\begin{document}
 \[f(\textcolor{red}{-3})= 4 \times {\underbrace{\textcolor{red}{(-3)}}_{\mathclap{\mathrm{parenth\grave{e}ses !!}}}}-1\]
\end{document}
  • 1
    I would too, until @DavidCarlisle showed this earlier today :) – Phelype Oleinik Feb 27 '18 at 15:46
  • 3
    Don’t brace \times, but rather the whole \underbrace – egreg Feb 27 '18 at 15:50
  • 2
    Although I would use \text here, as this is a textual annotation (and could have needed multiple words) not an identifier like max that is just conventionally set in roman, for which I'd use \mathrm – David Carlisle Feb 27 '18 at 15:55
  • 3
    In your current screenshot, TeX is treating the - ("minus") symbol in front of "1" as a unary operator. As @egreg has already pointed out, you should encase the entire \underbrace{...}_{...} construct in curly braces. That way, TeX will also treat the - symbol as a binary operator. And, do remove the curly braces around \times. Oh, and since mathtools loads amsmath automatically, there's no need to load amsmath separately. – Mico Feb 27 '18 at 15:57
  • 3
    Explanation: \underbrace{...}_{...} makes an Op atom (like \sin, for instance) and this causes incorrect spacing (in this and other cases) in front or behind it: bracing the whole part makes it into an Ord atom, which is what's needed here. – egreg Feb 27 '18 at 16:12
4

You can also hide the width of parentheses!! by \makebox[0pt]{parentheses!!}. You only need to adjust the size to match a subscript using \scriptsize.

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\begin{document}

\[
f(\textcolor{red}{-3})= 4\times{\underbrace{\textcolor{red}{(-3)}}_{\makebox[0pt]{\scriptsize parenth\`eses!!}}}-1
\]

\end{document}

enter image description here

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.