TeX Mathematics

From PeformIQ Upgrade
Jump to navigation Jump to search

The classic Mathematics into Type, by Ellen Swanson (the AMS has made a PDF copy available here), gives a good explanation (Section 3.1 SPACING BETWEEN SYMBOLS IN MATHEMATICS) of when to use no space, thin space, thick space, em quad and two-em quad in math mode. A brief summary:

No space

  • Between two symbols and between a number and the symbol it multiplies.
  • Before and after subscripts, superscripts, parentheses, braces, brackets, and vertical rules.
  • In expressions in the subscript or superscript.

Thin space

  • Before and after symbols used as verbs.
  • Before and after symbols used as conjunctions.
  • After, but not before +, -, \pm, \mp used as an adjective.
  • After the commas in sets of symbols, sequences of fractions, and coordinates of points.
  • Before and after the symbols of integration, summation, product, and union.
  • Before and after functions set in roman type. Exceptions: If any of these functions are preceded or followed by parentheses, braces, brackets, or bars, then the space is eliminated.
  • Before and after vertical rules appearing singly rather than in pairs; the same rule holds for a colon that is used as a mathematical symbol rather than as punctuation.
  • Before back subscripts.
  • Before and after ds, dx, and similar combinations of d and another symbol following.

Thick space

  • Before the parenthesis in congruences in text.
  • Before a mathematical condition in text.

Em quad

  • Between a symbolic statement and a verbal expression in displayed expressions.
  • Around conjunctions.

Two-em quad

  • Between two separate equations or inequalities in the same line.
  • Between a symbolic statement and a condition on the statement.

TeX has built-in spacing, and most of the times it does an excellent job, so (most of the times) you don't need to add space manually.

The following document contains the summary of the rules given by Swanson and some examples; these examples also contain some cases which are not built-in and which require manual attention.

\documentclass{article}
\usepackage{amsmath}

\setlength\parindent{0pt}
\begin{document}

\textbf{No space}\    Between two symbols and between a number and the symbol it multiplies:
\[
  ab\qquad xy\qquad 2a\qquad 2xz\qquad 4aC
\]

Before and after subscripts, superscripts, parentheses, braces, brackets,
and vertical rules:
\[
  2x^2y_3z (x)y\qquad a\{b\}\qquad y[a]\qquad a\lvert x\rvert\qquad b\lVert y\rVert
\]

In expressions in the subscript or superscript:
\[
  \lim_{0\to a}\qquad a^{n-1}
\]

\textbf{Thin space}\    Before and after symbols used as verbs:
\[
  a \subseteq 2
\]

Before and after symbols used as conjunctions:
\[
  a +2
\]

After, but not before $+$, $-$, $\pm$, $\mp$ used as an adjective
\[
  a= -2
\]

After the commas in sets of symbols, sequences of fractions, and coordi-
coordinates of points:
  \[ (a,b,c) \]

Before and after the symbols of integration, summation, product, and
union:
\[
  a\int x\,\mathrm{d}y
\]
The thin space between $x$ and $\mathrm{d}y$ in the expression above is \emph{not} built
into \TeX.

Before and after functions set in roman type:
\[
a \sin x \qquad \log 2.
\]
Exceptions: If any of these functions are preceded or followed by parentheses, braces, brackets, or bars, then the space is eliminated:
\[
a \sin \lvert x \rvert.
\]

Before and after vertical rules appearing singly rather than in pairs; the
same rule holds for a colon that is used as a mathematical symbol rather
than as punctuation:
\[
  a \mid b
\]

Before back subscripts:
\[
a\,_2T_3
\]
The thin space between $a$ and the following back subscript on $T$ in this example is not built into \TeX.


Before and after $\mathrm{d}s$, $\mathrm{d}x$, and similar combinations of $d$ and another
symbol following:
\[
  \int f(x)\,\mathrm{d}x\qquad \iiint f(x)\,\mathrm{d}r\,\mathrm{d}\theta\,\mathrm{d}\phi
\]

\textbf{Thick space}\    Before the parenthesis in congruences in text: $z= a\pmod x$

Before a mathematical condition in text: $t_n\ (n=1,2,\ldots, p)$

\textbf{Em quad}\    Between a symbolic statement and a verbal expression in displayed expressions 
\[
  E_n(t) \to e^{-t}\quad\text{as }t\to\infty.
\]

Around conjunctions:
\[
x(a+b)\quad\text{or}\quad y(a-b).
\]

\textbf{Two-em quad}\    Between two separate equations or inequalities in the same line
\[
x^2 + y^2 = a^2,\qquad x-y=b.
\]

Between a symbolic statement and a condition on the statement
\[
x^n + y^n = a^n\qquad (n = 1,2,\ldots p).
\]

\end{document}