Stage 3 · Mathematics 21 / 48 ≈ 13 min read

LaTeX Integrals: Double, Triple, Limits and Contour

Everything an integral needs as a typeset object: which glyph, where its bounds go, how the differentials line up, how to hang an evaluation bar on it, and what changes between inline and display.

    The integral sign never stacks on its own

    The behaviour that confuses everyone for the first time: \int_a^b f(x)\,\mathrm{d}x puts a and b at the side of the sign, in a display as well as inline, and that is correct. TeX splits operators into two declarations. The large operators — \sum, \prod, \bigcup — are declared to take their limits above and below, which happens only in display style; the integral family is declared the other way, so its bounds stay at the side in both styles. That is literally how the format files define them, and the reason is the glyph: an integral sign already runs well above and below the math axis, so stacking bounds on top of it buys nothing and costs a line.

    You can override it per occurrence with \int\limits_a^b (stacked) or \int\nolimits_a^b (side-set, which is already the default). \limits is a postfix switch that binds to the operator it follows, so it changes position only — never size, and never for the next operator on the line. Stacking is a house-style decision rather than a right answer: most maths publishers keep integral bounds at the side and reserve the stacked form for sums, so the places where \int\limits is clearly right are a multi-line condition that has to be read as a block, and matching a series or journal that stacks everything.

    One consequence people hit in aligned blocks: because a display-sized stacked bound makes the whole row taller, one \int\limits in a four-line derivation moves every other row with it. Check whether the row is actually more readable, or whether you have just paid leading for a habit.

    \int_a^b f(x)\,\mathrm{d}x
    \int_a^b f(x)\,\mathrm{d}x
    \int\limits_a^b f(x)\,\mathrm{d}x \qquad \int\nolimits_a^b f(x)\,\mathrm{d}x
    \int\limits_a^b f(x)\,\mathrm{d}x \qquad \int\nolimits_a^b f(x)\,\mathrm{d}x
    Where the limits of an integral land: side-set in text style, still side-set in display style, stacked only with \limits Row 1 and 2 are the same source. Only the style changed. inline — $ … $ inside a sentence ∫ a b f(x) dx the band is the line height the paragraph allows; limits sit at the side, hugging the glyph \int_a^b f(x)\,dx display — \[ … \] gets its own line ∫ a b f(x) dx taller glyph, still side-set: \int is a variable-symbol operator, so TeX never stacks it on its own — unlike \sum \[ \int_a^b f(x)\,dx \] \int\limits_a^b — stacked, and usually a mistake in a display ∫ a b f(x)\,dx pushes the whole line taller and puts a gap between the operator and its integrand. Legitimate use: a two-line condition under \iint. Decide by content, not by taste Leave them at the side when the bounds are short: a, b, 0, 1, ∞ \int_0^{\infty} e^{-x}dx the formula is inline and must not open the paragraph it is an ordinary integral, not a sum Stack them only when the lower bound is a condition that readers must parse as a block \idotsint\limits_{\substack{0<t<T \\ x\in\Omega}} you are imitating a paper that does it — journal style guides differ, and both are accepted, so stay consistent inside a document \limits binds to the operator, not to the line
    The same source in text style, in display style, and with \limits added — the only difference is where the bounds land.

    Bounds: the one-token rule and the infinity case

    A bound is an ordinary subscript or superscript, so the one-token rule applies: \int_a^b, \int_0^1, \int_{-\infty}^{\infty} all work because the bound is one token or is braced. The failure mode is the compound bound. \int_{n+1}^{2n} is right; \int_n+1^{2n} compiles without complaint and prints a subscript n, a +1 at full height and a superscript on the wrong object. It survives proof-reading precisely because nothing is missing — the material is simply at the wrong height.

    Infinity bounds need no special handling: \int_{0}^{\infty}, \int_{-\infty}^{\infty}, \int_{a}^{+\infty} are all just symbols. What does need care is honesty about what the notation claims. \int_{0}^{\infty} is an improper integral — a limit of \int_{0}^{R} as R grows — and where that limit process is the point of the argument, write the limit explicitly rather than hiding it in a bound. Same for a singular lower bound: \int_{\varepsilon}^{1} with a following \lim_{\varepsilon \to 0^{+}} says something an \int_{0}^{1} does not.

    The upper bound sits at the top of the tail of the sign and the lower bound at the bottom, so neither is vertically centred; that asymmetry is the glyph, not a bug, and it is why \int\limits with a long lower bound looks lopsided to a reader used to \sum.

    \int_{-\infty}^{\infty} e^{-x^{2}}\,\mathrm{d}x = \sqrt{\pi} \qquad \int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^{2}} = \frac{\pi}{2}
    \int_{-\infty}^{\infty} e^{-x^{2}}\,\mathrm{d}x = \sqrt{\pi} \qquad \int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^{2}} = \frac{\pi}{2}
    \int_{0}^{\infty} \frac{x^{s-1}}{e^{x}-1}\,\mathrm{d}x = \Gamma(s)\,\zeta(s)
    \int_{0}^{\infty} \frac{x^{s-1}}{e^{x}-1}\,\mathrm{d}x = \Gamma(s)\,\zeta(s)

    Multiple and iterated integrals

    Use the dedicated glyphs: \iint, \iiint and \iiiint are the amsmath integrals of multiplicity two, three and four, while the closed-surface forms \oiint and \oiiint come from additional packages (esint, wasysym). Do not build them by hand with \int\!\!\int: the kerning is approximate, the two signs have no shared relationship to the axis, and any bound you attach lands on whichever integral is nearest, not on the pair.

    A multiple integral and an iterated integral are different objects and should look different. \iint_{D} f\,\mathrm{d}x\,\mathrm{d}y says: integrate over the region D. \int_{0}^{1}\int_{0}^{x} f(y)\,\mathrm{d}y\,\mathrm{d}x says: the order matters, here are the two one-dimensional integrations. When you change the order of integration the bounds and the differentials swap, which is the most common algebraic slip in a chapter of multivariable calculus — write the differentials last-to-first in the same order you rewrite the bounds, and readers can check you.

    For an area element, \mathrm{d}A (or \mathrm{d}\sigma, \mathrm{d}S for surfaces) keeps the integrand short when the coordinate order is not the point. And when the bound of an inner integral is itself a formula — \int_{g_1(x)}^{g_2(x)} — braces are mandatory, and the subscripts on g are scriptstyle inside an already-scriptstyle bound, so keep those names one letter.

    \iint_{D} f\,\mathrm{d}x\,\mathrm{d}y \qquad \iiint_{V} \rho\,\mathrm{d}V
    \iint_{D} f\,\mathrm{d}x\,\mathrm{d}y \qquad \iiint_{V} \rho\,\mathrm{d}V
    \int_{0}^{1} \int_{0}^{x} f(y)\,\mathrm{d}y\,\mathrm{d}x = \int_{0}^{1} (1-y) f(y)\,\mathrm{d}y
    \int_{0}^{1} \int_{0}^{x} f(y)\,\mathrm{d}y\,\mathrm{d}x = \int_{0}^{1} (1-y) f(y)\,\mathrm{d}y

    Contour, surface and closed-path integrals

    The circle on the sign carries meaning: \oint is integration over a closed curve, \oiint over a closed surface, \oiiint over a closed volume. If the path is not closed, write \int_{\gamma} — using the loop glyph for an open arc is a notation error, not a font preference. Conversely, once the loop is the point, \oint beats \int_{C} at a glance, which is why complex analysis is full of it.

    Orientation is normally encoded in the text or in the path name, not in the glyph (\oint_{\partial \Omega} with \partial\Omega positively oriented, stated once). If you need the direction in the symbol, packages give you \ointctrclockwise and \ointclockwise (esint) or the arrows of \vec-annotated paths; most authors are better off writing it in a \text{…} note.

    For averages over a domain — flux averages, mean values in PDE estimates — \fint or \dashint from the esint package is the one-character-percentage-of-your-life improvement; hand-built \frac{1}{\lvert B_r \rvert}\int is correct but shifts attention to the prefactor.

    One practical warning: \iiiint, \oiint and \dashint are not universally supported outside LaTeX itself. The double and triple forms and \oint render in KaTeX, MathJax and pdfLaTeX alike; four-fold integrals and dashed signs are LaTeX-and-package specific, so on web renderers they degrade to text.

    \oint_{\partial \Omega} P\,\mathrm{d}x + Q\,\mathrm{d}y = \iint_{\Omega} \left( \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} \right) \mathrm{d}x\,\mathrm{d}y
    \oint_{\partial \Omega} P\,\mathrm{d}x + Q\,\mathrm{d}y = \iint_{\Omega} \left( \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} \right) \mathrm{d}x\,\mathrm{d}y
    \operatorname{p.v.} \int_{-\infty}^{\infty} \frac{e^{ix}}{x}\,\mathrm{d}x = i\pi
    \operatorname{p.v.} \int_{-\infty}^{\infty} \frac{e^{ix}}{x}\,\mathrm{d}x = i\pi

    The evaluation bar, and the invisible mate it needs

    The fundamental-theorem shorthand — a vertical bar with the bounds at its foot and head — has no dedicated glyph, so it is built out of an auto-sized delimiter pair with one side silenced: \left. F(x) \right\rvert_{a}^{b}. The \left. is a real command, not an abbreviation: \left and \right must come in matched pairs inside the same maths list, and the period is the name of the zero-width delimiter. Leave it out and TeX does not guess — it reports a missing \right. or silently sizes the wrong thing.

    Two manual alternatives, both better in a tight display: \Bigl[ F(x) \Bigr]_{a}^{b} when the brackets are part of the notation, and \bigl. \dots \bigr\rvert when you want a size you have chosen rather than one measured from the box. In an aligned derivation the manual ladder is the only option that can be kept constant across rows, because \left measures each row separately and the bars will not line up.

    If this notation appears more than a few times, make it a command in the preamble: \newcommand{\eval}[2]{\left.#1\right\vert_{#2}}. Two arguments instead of one is usually right, since an evaluation point of x = 0 needs to be typeset as a subscript, and doing that by hand at every use is how the = goes missing from half of them.

    \left. \frac{x^{2}}{2} \right|_{0}^{1} = \frac{1}{2} \qquad \Bigl[ F(x) \Bigr]_{a}^{b}
    \left. \frac{x^{2}}{2} \right|_{0}^{1} = \frac{1}{2} \qquad \Bigl[ F(x) \Bigr]_{a}^{b}
    The same trick gives you a one-sided delimiter anywhere: \left. or \right. as the mate, never a missing pair.
    Anatomy of a typeset integral: sign, side slots for bounds, integrand, thin space and the roman differential, plus the evaluation bar built with \left. Every slot of one integral, and the space that separates the integrand from d ∬ f(x, y)   d x dy 2π 0 upper slot: superscript position, scriptstyle, no braces needed for one token lower slot: subscript position — this is where the domain D goes the thin space before d is \,, not a typed blank \iint_{D} f(x,y)\,\mathrm{d}x\,\mathrm{d}y The evaluation bar, which is one trick, not one glyph [ F(x) ] 0 1 | x=0 both forms need a real delimiter on the quiet side: \left. F(x) \right|_{x=0}^{x=1} \left. is an invisible mate — you cannot open a \left group with nothing on the other side Differentials: three ways, only two are right Roman d, spaced \int f(x)\,\mathrm{d}x ISO 80000-2 asks for an upright d, and the \, keeps the d from gluing to the integrand. Define it once for the whole document: \newcommand{\dd}{\mathop{}\!\mathrm{d}} Italic dx reads as a product \int f(x) dx d times x — and it is the spacing TeX gives a binary minus in 2-x that makes it look wrong. × avoid in published maths Repeated integrals: pick the glyph \iint \iiint \oint \oiint \int\!\!\int is a hand-made fake: the signs collide and the bounds land on the wrong one.
    The slots of one integral — sign, side bounds, thin space, roman differential — and the invisible \left. that makes an evaluation bar possible.

    The differential: roman or italic, and the space before it

    \int f(x) dx is wrong twice over. The d is italic, so a reader parses it as a variable multiplied by x; and the space you typed does not exist, so d and x are glued. The standard fix is a thin space and an upright letter: \int f(x)\,\mathrm{d}x. ISO 80000-2 asks for the upright d, most analysis books keep the italic one, and both are defensible — what is not defensible is mixing them in one document, which reads as uncorrected copy-paste.

    For the roman form, a bare \mathrm{d} has a small spacing flaw: it is an ordinary atom, so a preceding relation or minus does not get its usual operator spacing, and \mathrm{d} hugs whatever precedes it. The robust definition, used in a preamble, is \newcommand{\dd}{\mathop{}\!\mathrm{d}}: it makes the d behave like a prefix operator and then removes the space that classification adds. Then \int_{0}^{1} x^{2} \dd x is correct everywhere, including after a -.

    The thin space is not decoration: it is what tells the reader that \mathrm{d}x is the operator being applied and not part of the integrand, and it is also what stops f(x)\,\mathrm{d}x\,\mathrm{d}y from setting as one long word. Put a \, before every differential and between stacked differentials, and keep the measure symbol attached where it belongs: \mathrm{d}\mu(x), \mathrm{d}^{2}x, \mathrm{d}\mathbf{A}.

    \int \frac{\mathrm{d}x}{1+x^{2}} = \arctan x + C
    \int \frac{\mathrm{d}x}{1+x^{2}} = \arctan x + C
    \documentclass[11pt,a4paper]{article}
    \usepackage[T1]{fontenc}
    \usepackage{amsmath,amssymb}
    \usepackage{esint}          % \fint, \dashint, \ointctrclockwise …
    
    \title{Integrals: glyphs, bounds and differentials}
    \author{A. Student}
    \date{\today}
    
    % A roman d that behaves like an operator: correct spacing after a relation
    \newcommand{\dd}{\mathop{}\!\mathrm{d}}
    % Evaluation bar: \eval{F(x)}{0}{1}
    \newcommand{\eval}[3]{\left.#1\right|_{#2}^{#3}}
    
    \begin{document}
    \maketitle
    
    \section{Definite integrals}
    The bounds belong to the operator, so braces matter: for a bound longer
    than one token write \verb|\int_{n+1}^{2n}|, never \verb|\int_n+1^{2n}|.
    \[
      \int_{0}^{1} x^{2} \dd x = \frac{1}{3},
      \qquad
      \eval{\frac{x^{2}}{2}}{0}{1} = \frac{1}{2}.
    \]
    
    \section{Several integrals}
    \[
      \iint_{D} f \dd A = \int_{a}^{b}\!\!\int_{g_1(x)}^{g_2(x)} f(x,y) \dd y \dd x,
      \qquad
      \iiint_{V} \rho \dd V = \int_{0}^{2\pi}\!\int_{0}^{1}\!\int_{0}^{r} F \dd z \dd r \dd\theta
    \]
    Average values use \verb|\fint| from the \texttt{esint} package:
    \( \fint_{B_r} u \dd x \).
    
    \section{Contour integrals}
    \[
      \oint_{\gamma} \frac{f(z)}{z-a}\,\dd z = 2\pi i\,f(a),
      \qquad
      \oiint_{\partial K} \mathbf{E}\cdot \dd\mathbf{A} = \iiint_{K} \frac{\rho}{\varepsilon_0} \dd V
    \]
    
    \section{Improper integrals}
    Write the limit that is actually being taken; \verb|\int_0^\infty| is
    shorthand, and where the shorthand hides a real argument it belongs in
    the text:
    \[
      \int_{0}^{\infty} \frac{\dd x}{\sqrt{x}(1+x)}
      = \lim_{R \to \infty} \int_{1/R}^{R} \frac{\dd x}{\sqrt{x}(1+x)}
      = \pi.
    \]
    
    \end{document}

    Long bounds, stacked conditions and layout

    When a bound is genuinely a compound statement — a band of indices, a domain with two conditions — the honest shape is a stacked block under the operator: \iint\limits_{\substack{0 \le t \le T \\ x \in \Omega}}. \substack comes from amsmath, sets its lines in scriptstyle, centres them, and is the only construct that keeps the alignment of a two-line bound sane. The alternative \begin{subarray}{l} gives you left-aligned lines inside the same slot when the conditions share a prefix.

    Everything on that line has now got taller, so check the neighbours: inside aligned a single stacked bound moves the whole row, and a bound that is wider than the operator makes the display look drunken. In prose, the better answer is usually to shorten the bound and name the set: \int_{\Omega_T} with \Omega_T = (0,T) \times \Omega defined once earlier, which is also what referees will ask you for.

    Finally, remember that an integral is an operator in a sentence, and sentences drive spacing. \int_{0}^{1} f = 1 inside a clause needs no extra space around it; a \text{for} or \text{if} clause after a differential wants \quad; and a displayed formula ending in \,\mathrm{d}x followed by a comma should have that comma outside the maths — … \,\mathrm{d}x, — because the comma is prose, not part of the integrand.

    \iiint\limits_{\substack{0 \le \theta \le 2\pi \\ r \le R}} f(r, \theta)\,\mathrm{d}V
    \iiint\limits_{\substack{0 \le \theta \le 2\pi \\ r \le R}} f(r, \theta)\,\mathrm{d}V
    \int_{a}^{b} f\,\mathrm{d}x = \int_{a}^{c} f\,\mathrm{d}x + \int_{c}^{b} f\,\mathrm{d}x
    \int_{a}^{b} f\,\mathrm{d}x = \int_{a}^{c} f\,\mathrm{d}x + \int_{c}^{b} f\,\mathrm{d}x
    \documentclass[11pt,a4paper]{article}
    \usepackage[T1]{fontenc}
    \usepackage{amsmath,amssymb,booktabs}
    
    % There is no reliable global switch: \limits is a per-occurrence postfix.
    % To stack every integral in a file, define a macro and use it instead of \int.
    \newcommand{\sdint}{\int\limits}       % stacked definite integral
    \newcommand{\ddint}{\iint\limits}
    
    \title{Four ways to bound an integral}
    \author{A. Student}
    \date{\today}
    
    \begin{document}
    \maketitle
    
    \begin{table}[htbp]
    \centering
    \begin{tabular}{@{}lll@{}}
    \toprule
    source & in a sentence & on its own line \\
    \midrule
    \verb|\int_a^b f\,\mathrm{d}x|
      & $\int_a^b f\,\mathrm{d}x$
      & $\displaystyle \int_a^b f(x)\,\mathrm{d}x$ \\[12pt]
    \verb|\int\limits_a^b f\,\mathrm{d}x|
      & $\int\limits_a^b f\,\mathrm{d}x$
      & $\displaystyle \int\limits_a^b f(x)\,\mathrm{d}x$ \\[12pt]
    \verb|\sum_{k=1}^{n} k|
      & $\sum_{k=1}^{n} k$
      & $\displaystyle \sum_{k=1}^{n} k$ \\[12pt]
    \verb|\sdint| (own macro)
      & $\sdint_0^1 f\,\mathrm{d}x$
      & $\displaystyle \sdint_0^1 f(x)\,\mathrm{d}x$ \\
    \bottomrule
    \end{tabular}
    \caption{An integral keeps its bounds at the side in both styles; a large
    operator such as \(\sum\) stacks only on its own line. \texttt{\textbackslash
    limits} moves the bounds and pays the leading, and there is no global way to
    ask for it that does not also affect sums, unions and limits.}
    \end{table}
    
    \[
      \ddint_{D} f \,\mathrm{d}A = \int_{a}^{b}\!\int_{g_1(x)}^{g_2(x)}
      f(x,y)\,\mathrm{d}y\,\mathrm{d}x
    \]
    
    \end{document}

    Lesson cheat sheet

    One key line of code from each section — jump to it or copy it straight from here.

    Section Key code
    \int_a^b f(x)\,\mathrm{d}x
    \int_{-\infty}^{\infty} e^{-x^{2}}\,\mathrm{d}x = \sqrt{\pi} \qquad \int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^{2}} = \frac{\pi}{2}
    \iint_{D} f\,\mathrm{d}x\,\mathrm{d}y \qquad \iiint_{V} \rho\,\mathrm{d}V
    \oint_{\partial \Omega} P\,\mathrm{d}x + Q\,\mathrm{d}y = \iint_{\Omega} \left( \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} \right) \mathrm{d}x\,\mathrm{d}y
    \left. \frac{x^{2}}{2} \right|_{0}^{1} = \frac{1}{2} \qquad \Bigl[ F(x) \Bigr]_{a}^{b}
    \documentclass[11pt,a4paper]{article}

    Common mistakes

    • An unbraced compound bound: \int_n+1^{2n} compiles and prints +1 at full height. Brace every bound longer than one token.
    • \int\!\!\int instead of \iint: the signs are hand-kerned, and bounds attach to one sign rather than to the pair.
    • Using \oint for an open path, or \int_C for a closed one when the closure is the point. The circle encodes topology, not taste.
    • dx italic with no thin space: TeX ignores your blank, so the d and the x set as a product of two variables. Write \,\mathrm{d}x, or define \dd once in the preamble.
    • Forgetting the invisible mate in \left. F \right|_{a}^{b}. There is no such thing as a lone \left or a lone \right; the missing half is the error you get.
    • Stacking bounds with \int\limits in one row of an aligned block and then chasing the resulting ragged leading row by row with \\[6pt].
    • Iterating an integral and rewriting the bounds while leaving \mathrm{d}x\,\mathrm{d}y in the old order — the differentials must be read inside-out against the bounds.

    Questions about this lesson

    How do I put the limits of an integral above and below the sign?
    Write \int\limits_a^b f(x)\,\mathrm{d}x. By default TeX keeps integral bounds at the side in both text and display style, because an integral is a variable-symbol operator rather than a large operator like \sum. Use the stacked form when the lower bound is a multi-line condition or when your house style stacks everything; otherwise leave it side-set.
    What is the difference between \int, \iint, \iiint and \oint?
    They are one, two, three and four integral signs merged into single glyphs with one shared set of bound positions, except that \oint (and \oiint, \oiiint) adds a circle meaning "over a closed curve" — or closed surface, closed volume. Use the multiple glyphs rather than hand-kerned \int\!\!\int.
    Should the d in dx be roman or italic?
    An upright \mathrm{d} is the ISO 80000-2 recommendation and the convention in applied maths and physics; italic d remains standard in much pure analysis. Both are correct, one document must pick one, and either way you need the thin space before it.
    How do I typeset the vertical bar with bounds used after integration?
    Built from an auto-sized pair with one side silenced: \left. F(x) \right|_{a}^{b}. Manually sized alternatives are \Bigl[ F(x) \Bigr]_{a}^{b} and \bigl. \dots \bigr|, which are the versions that stay consistent across the rows of an aligned derivation.
    Why do my integral bounds disappear in a subscript?
    They do not disappear, they shrink: anything inside a sub- or superscript is set in scriptstyle, so a two-token bound becomes very small. If the bound needs to be readable, restructure the expression so the integral is not inside an index.
    Is \iiiint safe to use?
    In LaTeX with amsmath, yes. On web renderers, no — KaTeX and some MathJax configurations do not define a four-fold integral, and the command degrades to literal text. Same caution for dashed average-integral signs from the esint package.

    Live playground: edit the LaTeX, see it render

    The preview updates as you type — break it on purpose to see how errors look.

    KaTeX error
    Try an example

    Keep reading

    Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.