LaTeX puts too much space next to integrals
-
08-07-2019 - |
Question
Integrals with limits take up width horizontally that includes their limits. In other words, if you have an integral with large limits below (or above) the integral
\int\limits_{-\infty < x < c} (c - x) \ dP(x)
you are left with a large amount of space to the left and right of the integral before the integrand (c - x) starts. This is sometimes desirable, but in my case it isn't, since I have a whole bunch of integrals like this all in the same expression. Is there a way to make whatever is inside the integral snuggle up next to the integral sign, ignoring the width of the limit?
Solution
Something like this will do the trick.
\usepackage{amsmath}
\def\mathclap#1{\text{\hbox to 0pt{\hss$\mathsurround=0pt#1$\hss}}}
\begin{document}
\[
\int\limits_{\mathclap{-\infty < x < c}} (c - x) \ dP(x)
\]
\end{document}
More about such tricks is given in this article.
OTHER TIPS
It is possible with less effort:
\int\!\!\!{olution}
\!
is a negative space. However, when a lot of formulas have to be altered, the previously posted answers may be more appropriate.
The mathtools
package contains a definition for \mathclap
, and also a command \smashoperator
that is a bit more convenient:
\smashoperator{\int_{\infty < x < c}} (c - x) \, dP(x)