LaTeX math formatting guidelines 2006

From DPWiki
Jump to navigation Jump to search

These are guidelines for formatting the mathematics of DP projects using LaTeX. See also

The proofing and formatting guidelines are also available as typeset manuals, suitable for online viewing and printing.

We use many of the features found in the LaTeX packages developed by the American Mathematical Society: hence we almost always include \usepackage{amsmath} in the preamble.

In-line mathematics

Any maths that appears in the text, i.e. not set off on a line of its own should be surrounded with $ and $; e.g. x = y is formatted as $x = y$. This applies to equations, fractions, variables (x) and points ((x, y)). LaTeX ignores whitespace within the math environment, so longer expressions can be broken across several lines to improve readability of the code.

Also, \( and \) can be used in place of $..$, but involves more typing.

Out-of-line (displayed) mathematics

Surround any maths that is separated from the main body of the text with \[ and \]:
\[
  x = y.
\]

Unless the displayed math really does start a paragraph there should be no blank line above the \[, and unless it really ends a paragraph there should be no blank line following the \].

Equation numbers

Although LaTeX can generate equation numbers automatically, to ensure consistency with the text we hard-code equation numbers using \tag. Don't worry if the equation number appears on the wrong side when you check-compile your pages: this will be fixed at the post-processing stage. Also, don't worry about capturing the typography of the equation numbers (indentation, bold, etc): this is also a job for the post-processor when they write the final document preamble.

Aligned equations

We use the (starred forms of) AMSmath environments for displays consisting of multiple lines of equations. Those most often used are align* and gather*; refer to the AMSmath documentation on the LaTeX resources page for details and examples. Please do not use array or eqnarray to align equations (some reasons for avoiding eqnarray appear in this paper).

Mathematical notation

Elementary arithmetic operations:

The plus (+), minus (-), division (/) symbols have the usual meaning. When multiplication is denoted explicitly, use \cdot (producing a centered dot, "·"), \centerdot (producing a dot on the baseline spaced differently from an ordinary period, "."). For "×" there is no need to use any markup (\times) because the inputenc package handles this automatically. The "equal", "less than", and "greater than" symbols on the keyboard work as expected; to get "less than or equal", use \le; similarly, \ge gives "greater than or equal".

Square roots:

Square roots are generated with the command \sqrt{...}. For example,

$z = \sqrt{x^2+y^2}$

Other roots can be obtained by supplying the radix as an optional argument: for example \sqrt[3]{x-y} gives a cube root.

Subscripts and superscripts:

These are indicated by carets (^) and underscores (_), as in $2^n$ or $a_1$. If the sub/superscript contains more than one character, it must be enclosed in curly braces, as in $2^{x+y}$. The degree symbol ° supplied by the proofing rounds does not need to be formatted as a superscript: just leave it as is and let the inputenc package take care of interfacing with TeX. (See the LaTeX text formatting guidelines if you find the LaTeX warnings about "\textdegree not being valid in math mode" too annoying.)

Fractions and binomial coefficients:

Fractions are typeset with $\frac{x}{y}$, where x is the numerator and y is the denominator. There is a similar construct $\binom{x}{y}$ for binomial coefficients.

Normally \frac will get the sizing of the fraction right for the context. Only use \tfrac or \dfrac to explicitly size a fraction if the output from \frac doesn't match the scan.

Sums and integrals:

The symbols for sums and integrals are \sum and \int, respectively. These are examples of "large" operators, and their sizes are adjusted by TeX automatically, depending on the context (e.g., inline vs. display math). Note that the symbol generated by \sum is very different from the uppercase Sigma symbol, \Sigma (Σ); the latter should never be used to denote sums. LaTeX uses a simple but effective scheme to typeset summation and integration limits: lower and upper limits are specified as sub- and superscripts to \sum and \int. For example, $\sum_{k=1}^n k = \frac{n(n+1)}{2}$. (Note that the lower limit "k=1" here must be enclosed in braces.)

Limits

The "subscript" trick works also for limits; \lim produces the "lim" symbol, and the expression underneath this symbol (for example, "x tends to infinity") is typeset as a subscript: $\lim_{x\to\infty}f(x)=0$. Here \to produces the arrow, →, and \infty (note the abbreviation — "\infinity" does not work!) produces the "infinity" symbol, ∞. \limsup and \liminf work similarly, as do \sup and \inf (for supremum and infimum), and \max and \min (for maximum and minimum). For example, $\max_{0\le x\le 1}x(1-x)=1/4$.

Operators

LaTeX has commands for common mathematical operators or functions, such as \sin, \cos, \log, \ln, \exp, \arctan, etc. You should always use these commands instead of simply typing "sin", "cos", etc., without the backslash. Using the LaTeX commands ensures that the operators get typeset in the proper font and takes care of the spacing surrounding these operators.

Some books use older or variant functions that are not predefined in LaTeX, such as "cosec", "arccot" or "arccosec". For isolated instances, these can be rendered in the same way as the other functions using \operatorname{cosec} or \operatorname{arccosec}. (If a space is required, use a tilde: \operatorname{arc~vers}.) If the project includes several instances of the same function then it will improve the consistency of the code if the project's preamble is expanded to include (for example)

\DeclareMathOperator{\arccot}{arccot}

and then each occurence in the text can be simply coded as \arccot. The Project Forum is the best place to decide on the appropriate name for the new "operator", and to let other formatters know of its availability.

Arrays and Matrices

Link to arrays.

Arrays are never used to arrange multiple lines of equations so that they line up nicely. See link for example of what not to do :-).

Link to matrices.

A matrix is a "table" of values that line up in a grid-like format. See link for example.

Theorems, Lemmas, Corollaries, Conjectures, Propositions, Definitions, etc

Each of these should be marked with the appropriate \begin{environment} \end{environment} markup, e.g.

\begin{definition}
An equilateral triangle is one which has all sides of equal length.
\end{definition}

\begin{theorem}
The angles of an equilateral triangle are all equal.
\end{theorem}

If theorems etc are numbered or otherwise embellished, preserve the number in a comment or as an optional argument to the environment: for example

\begin{theorem} % XII
\begin{corollary}[to Theorem XII]

You may need some extra preamble code to test-compile pages containing theorem etc markup: check the Project Comments.