LaTeX puts too much space next to integrals

Dan picture Dan · Sep 17, 2009 · Viewed 7.3k times · Source

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?

Answer

Rob Hyndman picture Rob Hyndman · Sep 17, 2009

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.