<<

Some Suggestions for Mathematical Formulae in LATEX

Risi Kondor September 22, 2003

Some people hack LATEX like they hack computer code: as long as the syntax and the semantics are correct, they assume the document will be acceptable. Whilst LATEX generally does an excellent job of typesetting mathematics, we cannot expect a rule-based system to fully replace a professional typesetter. In various circumstances, manual adjustments are called for to improve the readability and aesthetic appeal of the final result.

Delimiters

In most cases, pairing with \left and \right producers delimiters of the ap- propriate size. Ocasionally, manual intervention is called for.

1. Limits above and below large operators such as \sum, \prod and \int often force the delimiters to be too large: 2 1/2 N \left(\sum_{i=1}^{N^2} x_i \right)^{1/2} x2 .  i  i=1 X This might not look so egregious by itself, but enclosing severalsuch terms in an even larger set of delimiters or putting them under a square root sign can eventually produce absurd looking displays. The only way I know to avoid this problem is to control the size of the delimiters manually:

2 N 1/2 \Biggl(\sum_{i=1}^{N^2} x_i \Biggr)^{1/2} 2 xi . Ãi=1 ! X

2. The opposite problem occurs when the semantics or readability would require delimiters to grow, but they don’t:

0 0 1/2 (κ (σ (x x0) + σ (y y0)) + κ (z z0)) x − y − −

1 Setting the size of the outer pairs of parentheses to \big and \Big, re- spectively, brings out the natural rhythm of this formula:

1 2 0 0 / κ σ (x x0) + σ (y y0) + κ (z z0) . x − y − − ³ ¡ ¢ ´ Spacing

Mathematical formulae are spaced in units determined by the surrounding . An is usually about the width of a the letter “M”. LATEX uses the following spaces in formulae:

\, thin (normally 3/18 of an em) \: medium space (normally 4/18 of an em) \; thick space (normally 5/18 of an em).

The elementary constituents of formulae, called atoms, are grouped into eight categories, such as: ordinary, large operator, binary operator, relation, etc.. The default spacing is determined solely by the categories of the atoms on either side. To fine tune spacing I define my own smaller spaces:

2 \ts tiny space, 18 em \newcommand{\ts}{\hspace{.11111em}} 1 \ts teeny-weeny space, 18 em \newcommand{\tts}{\hspace{.05555em}}. It also helps to define

\newcommand{\<}[1]{\hspace{-0.11111em}#1\hspace{-0.11111em}}.

1 Typing \< before an operator will then reduce the space on both sides by 18 of an em.

1. Most books on TEX and LATEX mention that infinitesimals need to be separated by thin spaces (or less) as in

b \int_a^b f(x)\,dx f(x) dx Za and

dx\tts dy=r\tts dr\tts d\theta dxdy = rdrdθ.

Otherwise, the function of d and what it refers to often become ambiguous, reducing the whole expression to a blur.

2. Binary operators such as +, , , etc. are usually surrounded by medium space on either side. This is great− ∈ for clearly separating complicated terms in an equation, but is far too big for “micro-formulae” such as x , especially when embedded in dense text. ∈ X

2 1 The soultion is to shave off space on both sides. In most cases 9 em of negative space is sufficient, but for really short expressions I tend to take off a full thinspace, as in x instead of x . ∈X ∈ X The same problem appears in displays, typically with + and operators connecting very simple terms. − 3. The spacing of simple quantified formulae, such as n N, is illogical. Usually, it is best to take off space on the two sides of∀ , ∈occasionally also ∈ adding space after the quantifier, giving the more pleasing n N. ∀ ∈ 4. It is almost always necessary to add space between displayed fractions and a proceeding ordinary atom: ∞ 1 t ib g(x) = f(x) F = − eiat dt. 2 a t2 + b2 Z0 Inserting a thin space and medium space, respectively, makes these dis- plays look much better: ∞ 1 t ib g(x) = f(x) F = − eiat dt. 2 a t2 + b2 Z0 5. It is sometimes desirable to offset the exponent by a thin space, as in

∗ − ∗> −1 ∗ ∗ − ∗> −1 ∗ p(y ) e y K y instead of p(y ) e y K y , ∝ ∝ 1 where 2 18em space was added before the sign, but this might be a matter of personal taste. − 6. Spacing is woefully inadequate in the intricate probability expressions that are the hallmark of Bayesian Statistics:

p(x1, x2, . . . , x θ), p(Y1 = y1, . . . , Y = y θ1, θ2, . . . , θ ) n| n n| m The judicious use of thin spaces and medium spaces around the paren- theses and the vertical separator combined with shrinking space around relation symbols in the argument makes these expressions much more read- able:

p ( x1, x2, . . . , x θ ), p ( Y1 = y1, . . . , Y = y θ1, θ2, . . . , θ ) n | n n | m 7. Sometimes when formulae start getting crowded it is even necessary to add space between factors. Writing Bayes’ law as p(y x) p(x) p(x y) = | | p(y x) p(x) x | looks much better than P p(y x)p(x) p(x y) = | . (1) | p(y x)p(x) x | P 3 8. When a sentence ends with a displayed equation, a right after the last mathematical symbol is easy to overlook, especially, when the formula ends with a busy fraction. Without a separating thin space, (1) would look like p(y x)p(x) p(x y) = | . | p(y x)p(x) | 9. In math mode there is no kearning,P so sometimes spacing needs to be adjusted simply to accomodate the varying shapes of different symbols. The following are examples from [1] of cases when adding a thin space improves appearance:

√2x √2 x √log x √ log x → [0, 1) [ 0, 1)

Here are some formulae, also from [1] that benefit from removing a thin space: x2/2 x2/2 n/ log n n/log n → Γ2 Γ2

References

[1] Donald E. Knuth. The TEXbook. Addison-Wesley, 1984.

4