The following code:
f(\textcolor{red}{-3})= 4 {\times} ~ \underbrace{\textcolor{red}{(-3)}}_{parenth\`{e}ses !!}-1
results in too much space after \times:
How to get (-3)
close to the multiplication?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityUse \mathclap
from mathtools
:
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}
\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
Feb 27, 2018 at 15:55
-
("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.
\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.
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}
{}
removes the normal space and~
adds the space that you would normally get between words.