Integrals in LaTeX
An integral sums a quantity over an interval or region; in LaTeX \int makes the sign, with the lower limit as a subscript and the upper limit as a superscript.
LaTeX command
\int_a^b f(x)\,dxNot the symbol you meant? Draw it to find the command →
The template is \int_a^b f(x)\,dx. The subscript _a sets the lower limit and the superscript ^b the upper; on the integral sign these limits sit to the right, which is the standard convention. The \, is a thin space that separates the integrand from the dx, a small touch that makes the expression read correctly.
Multiple integrals have their own commands: \iint for a double integral, \iiint for a triple, and \oint for a contour integral around a closed curve. These give proper spacing between the signs. In full LaTeX \iint and friends come from amsmath, and KaTeX supports them directly.
For an indefinite integral simply omit the limits: \int f(x)\,dx. Inline, a long integral is shrunk to fit the line; wrap it in \displaystyle or move it to a display to restore full height. Some authors prefer an upright differential, written \mathrm{d}x, for extra clarity.
Other forms
\iintdouble integral\ointcontour integralExamples
$\int_0^\infty e^{-x}\,dx = 1$an improper integral to infinity
$\iint_D f(x,y)\,dA$a double integral over a region D
$\int_a^b f(x)\,dx = F(b) - F(a)$the fundamental theorem of calculus
$\oint_C \mathbf{F} \cdot d\mathbf{r}$a contour integral around a closed curve
$$\displaystyle\int_0^1 x^2 \, dx = \tfrac{1}{3}$$a full-size displayed integral
Tips and common mistakes
- Always put
\,before dx. Without it the integrand and differential are set too close together. - Limits on
\intsit to the side by design; that is correct. To force them above and below, add\limitsafter\int. \iint,\iiintand\ointneed amsmath in a real document, though KaTeX renders them without extra setup.- An inline integral looks cramped; use
\displaystyleor a displayed block to give it full height. - For an upright differential, write
\mathrm{d}x rather than a plain italic d.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into clean, compilable LaTeX - graphs and all. Free to try, no sign-up.
Convert your maths to LaTeX →FAQ
How do I add limits to an integral?
Use a subscript for the lower limit and a superscript for the upper: \int_a^b f(x)\,dx. Braces are only needed if a limit has more than one token, e.g. \int_{a-1}^{b+1}.
Why is dx too close to the function?
Math mode ignores your spaces, so add a thin space with \,: write \int f(x)\,dx. This is the standard typesetting of a differential.
How do I write a double or triple integral?
Use \iint for a double integral and \iiint for a triple. For a closed contour use \oint. Add limits and the area or volume element as usual, e.g. \iint_D f\,dA.