Integral in LaTeX

Type \int in math mode and add the limits as a subscript and superscript: \int_{a}^{b} f(x) \, dx. _ sets the lower limit, ^ the upper one, and \, puts the small space that belongs before dx. Double and triple integrals are \iint and \iiint from amsmath.

Integral commands

  • \int f(x) \, dx
    ∫ f ( x ) d x

    Indefinite integral.

  • \int_{a}^{b} f(x) \, dx
    ∫ a b f ( x ) d x

    Definite integral with lower limit a and upper limit b.

  • \iint_{D} f \, dA
    ∬ D f d A

    Double integral (amsmath), region written as a subscript.

  • \iiint_{V} f \, dV
    ∭ V f d V

    Triple integral (amsmath).

  • \idotsint
    ∫ ⋯ ∫

    Multiple integral with dots between the signs (amsmath).

  • \oint_{C} \mathbf{F} \cdot d\mathbf{r}
    ∮ C F ⋅ d r

    Contour (closed path) integral.

  • \oiint_{S}
    Text mode, no math preview

    Closed surface integral; needs the esint package in LaTeX and is not available in MathJax.

  • \int\limits_{a}^{b}
    ∫ a b

    Puts the limits above and below the sign instead of beside it.

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

Integral examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

  • Definite integral

    ∫ 0 1 x 2 d x = 1 3
    LaTeX
    \int_{0}^{1} x^2 \, dx = \frac{1}{3}
  • Indefinite integral

    ∫ cos ⁡ x d x = sin ⁡ x + C
    LaTeX
    \int \cos x \, dx = \sin x + C
  • Evaluation bar

    ∫ 1 e 1 x d x = [ ln ⁡ x ] 1 e = 1
    LaTeX
    \int_{1}^{e} \frac{1}{x} \, dx = \Big[ \ln x \Big]_{1}^{e} = 1

    \Big[ … \Big] or \left. … \right|_{a}^{b} draws the bracket or bar with the limits on it.

  • Double integral over a region

    ∬ D ( x + y ) d x d y
    LaTeX
    \iint_{D} (x + y) \, dx \, dy
  • Triple integral

    ∭ V ρ ( x , y , z ) d V
    LaTeX
    \iiint_{V} \rho(x, y, z) \, dV
  • Line integral

    ∮ C F ⋅ d r = ∬ S ( ∇ × F ) ⋅ d S
    LaTeX
    \oint_{C} \mathbf{F} \cdot d\mathbf{r} = \iint_{S} (\nabla \times \mathbf{F}) \cdot d\mathbf{S}
  • Upright differential

    ∫ − ∞ ∞ e − x 2 d x = π
    LaTeX
    \int_{-\infty}^{\infty} e^{-x^2} \, \mathrm{d}x = \sqrt{\pi}

    Some journals want the d upright (ISO style); \mathrm{d}x does that.

  • Limits above and below

    ∫ 0 2 π sin 2 ⁡ θ d θ = π
    LaTeX
    \int\limits_{0}^{2\pi} \sin^2 \theta \, d\theta = \pi

How to write an integral step by step

Start with \int inside math mode ($ … $ inline or \[ … \] displayed). Add _{…} for the lower limit and ^{…} for the upper limit. Braces are only optional for a single character, so \int_0^1 works but \int_0^{10} needs them.

Write the integrand, then a thin space \, and the differential: f(x) \, dx. Without the space LaTeX sets f(x)dx tightly, which reads like a product.

In displayed equations the integral sign is taller, but the limits stay to its right. That is the normal LaTeX style for integrals; add \limits only if your style guide wants them above and below.

LaTeX
\documentclass{article}
\usepackage{amsmath}
\begin{document}
The area is $\int_0^1 x^2 \, dx = \tfrac{1}{3}$, or displayed:
\[
  \int_{0}^{1} x^2 \, dx = \frac{1}{3}
\]
\end{document}

Multiple and closed integrals

\iint, \iiint, \iiiint and \idotsint come from amsmath and space the signs correctly. Typing \int\int instead leaves a gap that looks wrong.

\oint (a single closed path) is built into LaTeX. Closed surface and volume integrals such as \oiint need the esint package in LaTeX; MathJax and KaTeX do not provide them, so on the web you usually write \oint with a subscript such as S.

Common mistakes

  • Without braces only the first character is the limit, so the upper limit becomes 1 and the 0 lands in the integrand.

    Instead of
    \int_0^10 x \, dx
    Write
    \int_0^{10} x \, dx
  • The thin space \, separates the differential from the integrand, as in printed books.

    Instead of
    \int f(x)dx
    Write
    \int f(x) \, dx
  • Two \int in a row are spaced too far apart; \iint joins them properly and takes one subscript.

    Instead of
    \int \int_D f \, dA
    Write
    \iint_D f \, dA
  • \oiint exists only with the esint package in LaTeX. Web renderers show it as an unknown command.

    Instead of
    \oiint_S \mathbf{F} \cdot d\mathbf{S}  (in MathJax)
    Write
    \oint_S \mathbf{F} \cdot d\mathbf{S}

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    \int and \oint work in any document; \iint, \iiint and \idotsint need \usepackage{amsmath}, and \oiint needs \usepackage{esint}.

  • MathJax and KaTeX

    MathJax and KaTeX render \int, \iint, \iiint, \oint and \limits without setup. \oiint from esint is not available, so write it another way on web pages and in Markdown notes.

  • Microsoft Word

    Word has its own integral templates, but pasted LaTeX is not converted reliably. Write the integral in the editor here and press Copy for Word to paste an editable Word equation with the limits in place.

Integral in LaTeX: questions

How do I write an integral with limits in LaTeX?
Put the lower limit after _ and the upper after ^: \int_{a}^{b} f(x) \, dx. Use braces whenever a limit has more than one character.
How do I write a double integral?
Use \iint from amsmath, for example \iint_{D} f(x, y) \, dx \, dy. Triple integrals use \iiint.
Why are the integral limits beside the sign and not above it?
That is the default for integrals in LaTeX, even in displayed equations. Write \int\limits_{a}^{b} to put them above and below, or load amsmath with the intlimits option to change it for the whole document.
Should the d in dx be upright?
Both styles are used. ISO and many physics journals use an upright d, written \mathrm{d}x; most math texts use the italic dx. Pick one and keep it consistent.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX