Typevia
Mathematical Typesetting

Introduction to Mathematical Operators

One of the primary reasons researchers and students use LaTeX is its unparalleled ability to typeset complex mathematical formulas. Among the most common elements in scientific writing are integrals, sums, and limits.

In LaTeX, these are treated as "large operators." Unlike standard variables, these symbols change their appearance based on whether they are placed inside a line of text (inline) or centered on their own line (display mode). In this guide, we will explore how to typeset these operators accurately and professionally.

Note: To follow along with the examples in this guide, ensure you have the amsmath package included in your document preamble: \usepackage{amsmath}. While basic operators work without it, amsmath provides essential tools for complex layouts.


1. Summation and Products

The summation symbol ($\sum$) and the product symbol ($\prod$) are the foundations of discrete mathematics notation.

Basic Syntax

The commands for these symbols are \sum and \prod. To add the lower and upper bounds, we use the underscore (_) for the bottom and the caret (^) for the top.

\[
\sum_{i=1}^{n} i^2 = \frac{n(n+1)(2n+1)}{6}
\]

\[
\prod_{i=1}^{n} a_i = a_1 \cdot a_2 \cdot \dots \cdot a_n
\]

Key Rules for Indices

  • Braces are essential: If your index contains more than one character (e.g., $n=1$), you must wrap it in curly braces {}. For example, \sum_{i=1}.
  • Order doesn't matter: \sum_{i=1}^{n} produces the same result as \sum^{n}_{i=1}.
  • Multiple lines: For complex conditions under a sum, you can use the \substack command (requires amsmath).
\[
\sum_{\substack{0 < i < n \\ 0 < j < n}} P(i, j)
\]

2. Integrals

Integrals are typeset using the \int command. Like sums, they use _ and ^ for their limits of integration.

Basic Integrals

\[
\int_{a}^{b} x^2 \, dx
\]

Multiple Integrals and Paths

LaTeX provides specific commands for double and triple integrals, as well as contour integrals. Using these specific commands ensures the spacing between the integral signs is correct.

  • Double integral: \iint
  • Triple integral: \iiint
  • Contour integral: \oint
\[
\iint_{D} f(x,y) \, dA
\]

\[
\oint_{C} \vec{F} \cdot d\vec{r}
\]

Best Practice: The Differential "d"

In professional typesetting, the "d" in "dx" is often set in an upright (roman) font to distinguish it from a variable $d$. Additionally, a small space (\,) should be added between the integrand and the differential.

Tip: Instead of writing \, dx every time, many users define a shortcut in their preamble: \newcommand{\dd}{\,\mathrm{d}}. This allows you to simply type \int x \dd x.


3. Limits

The limit operator is typeset using the \lim command. The condition (e.g., $x \to \infty$) is placed using the subscript symbol (_).

Basic Syntax

To create the "arrow" symbol, we use the \to or \rightarrow command.

\[
\lim_{x \to \infty} \frac{1}{x} = 0
\]

Limit Variations

You can represent limits from the left or right by adding a superscript to the value the variable is approaching:

\[
\lim_{x \to 0^+} \ln(x) = -\infty
\]

4. Inline vs. Display Mode

One of the most confusing aspects for beginners is why their formulas look different when they are inside a paragraph versus on a new line.

Inline Mode ($...$)

When you place a sum or integral inside a sentence using single dollar signs, LaTeX compresses the symbol to prevent the line height from becoming uneven. The limits are placed to the side of the symbol rather than above and below.

Display Mode ([ ... ])

In display mode, the symbols are larger, and the limits are placed directly above and below the operator (for sums and limits) or in the standard position (for integrals).

Forcing Style

If you want a sum in a sentence to look like it does in display mode, you can use the \limits command. Conversely, you can use \nolimits to force the side-positioning.

The sum $\sum_{'{'}i=1{'}'}^{'{'}n{'}'} i$ is inline. 
The sum $\sum\limits_{'{'}i=1{'}'}^{'{'}n{'}'} i$ uses \limits.

5. Practical Example: A Complete Formula

Let's combine these concepts into a more complex mathematical expression to see how they interact.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\section*{The Fundamental Theorem of Calculus}
The relationship between the limit of a sum and an integral is defined as:
\[
\int_{a}^{b} f(x) \, dx = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i^*) \Delta x
\]

\section*{Product of a Sequence}
The capital Pi notation is used for products:
\[
\prod_{k=1}^{\infty} \left( 1 + a_k \right)
\]

\end{document}

6. Common Pitfalls and Best Practices

To ensure your documents look professional, avoid these common mistakes:

  1. Forgetting amsmath: Always include \usepackage{amsmath} for better spacing and access to commands like \substack.
  2. Using Text for Operators: Never type "lim" or "sum" in math mode (e.g., $\lim_{x \to 0}$). Always use the backslash command (\lim). The backslash ensures the font is upright and the spacing around the operator is mathematically correct.
  3. Missing Braces: \sum_i=1^n will only put the "i" under the sum and print "=1" next to it. Use \sum_{i=1}^n.
  4. Integral Spacing: Always add a small space before the differential.
    • Bad: \int x dx ($ \int x dx $)
    • Good: \int x \, dx ($ \int x , dx $)

Note on Performance: While it might seem tedious to type \, \mathrm{d}x for every integral, these small details are what separate amateur documents from professional, publication-quality typesetting. Using custom commands (macros) can significantly speed up this process.