A couple people have asked me recently how to properly format integrals in $\LaTeX$, be it controlling where the limits are displayed or adding half spaces before the differentials (a formatting standard that too many don’t even know about). This isn’t the first time those questions have been raised, so I’m going to address some of them here.

This is also my first post using MathJax. I may write a short article soon about MathJax, as I’ve found that integrating it into this site is ridiculously easy. MathJax allows for vector-based and $\LaTeX$/MathML-based math rendering on webpages, instead of the raster graphics you find on many sites having math content. Basically, I’m a big fan.

### Proper Spacing inside Integrals

First, I’ll give an example of an improperly written improper integral. (That’s a pun.) The code in $\LaTeX$ that most would write looks like this:

$\lim_{t\to\infty}\int_a^tf(x)dx$

When rendered by $\LaTeX$ that code snippet produces the following:

$$\lim_{t\to\infty}\int_a^tf(x)dx$$

What’s wrong with this? The answer is that there should be a half space between the integrand and the $dx$. That is, we should have something more like

$\lim_{t\to\infty}\int_a^tf(x)\,dx$

which will appear as

$$\lim_{t\to\infty}\int_a^tf(x)\,dx.$$

This is a very tiny difference. (There is a half space added between the $f(x)$ and the $dx$.) But, it is a matter of anal professionalism that many mathematicians follow. Look in any modern calculus text and you’ll notice that the half spaces are included. Look on a graduate TA’s calc II final, and the half spaces will probably not be included.

### Display Styles

Most of those writing $\LaTeX$ know the difference between inline and display modes. The same integral written inline will appear differently than when written in display mode. As an example, consider the inline integral $\int_0^2x^2\,dx$, which in display mode appears as

$$\int_0^2x^2\,dx.$$

Sometimes, for various reasons, we may want to force $\LaTeX$ to use display mode in inline text. We may force the display mode version $\displaystyle\int_0^2x^2\,dx$ in place of the inline version $\int_0^2x^2\,dx.$ We do this using the displaystyle command, as in:

We may force the display mode version $\displaystyle\int_0^2x^2\,dx$ in place...

If you tinker around with this a bit, you discover that $\LaTeX$ will descend to inline mode inside a nested sequence of commands in display mode. For instance, if we write

$f(x) = \frac{\int_0^1g(x)\,dx}{\int_0^1h(x)\,dx}$

then we would get

$$f(x) = \frac{\int_0^1g(x)\,dx}{\int_0^1h(x)\,dx}.$$

I don’t particularly like the way this looks, so I’ll use

$f(x) = \frac{\displaystyle\int_0^1g(x)\,dx}{\displaystyle\int_0^1h(x)\,dx}$

instead, which gives me

$$f(x) = \frac{\displaystyle\int_0^1g(x)\,dx}{\displaystyle\int_0^1h(x)\,dx}.$$

### Moving Limits

One thing you’ll notice is that the integration limits are placed differently between inline and display modes in $\LaTeX$. In display mode, the default is to place the limits of integration at a southeast and northeast location relative to the integral sign. Sometimes we wish to place the limits directly under (or directly over) the integral instead. Notice how the limits command is used in the following:

$\int\limits_{x^2 + y^2 \leq R^2} f(x,y)\,dx\,dy = \int\limits_{\theta=0}^{2\pi}\ \int\limits_{r=0}^R f(r\cos\theta,r\sin\theta) r\,dr\,d\theta$

This produces the output:

$$\int\limits_{x^2 + y^2 \leq R^2} f(x,y)\,dx\,dy = \int\limits_{\theta=0}^{2\pi}\ \int\limits_{r=0}^R f(r\cos\theta,r\sin\theta) r\,dr\,d\theta.$$

OK. I cheated a bit by putting the extra space between the two integral signs, but any experienced $\LaTeX$ user knows that sometimes the typesetting has to be coerced a bit.

Posted in LaTeX
Share this post, let the world know

### 3 Trackbacks

1. [...] are one of the most used equation forms out there. Look how much you can do.  Here are example integrals. They are the opposite of derivatives in a way. The typesetting here in this quick latex tutorial [...]

2. [...] are one of the most used equation forms out there. Look how much you can do.  Here are example integrals. They are the opposite of derivatives in a way. The typesetting here in this beginning latex [...]

3. [...] are one of the most used equation forms out there. Look how much you can do.  Here are example integrals. They are the opposite of derivatives in a way. The typesetting here in this beginning latex [...]