# Typesetting Math in Texts

## Basic math

Whenever you typeset mathematical notation, it needs to have “Math” style. For example: If $$a$$ is an integer, then $$2a+1$$ is odd.

Superscripts and subscripts are created using the characters ^ and _, respectively: $$x^2+y^2=1$$ and $$a_n=0$$. It is fine to have both on a single letter: $$x_0^2$$.

If the superscript [or subscript] is more than a single character, enclose the superscript in curly braces: $$e^{-x}$$.

Greek letters are typed using commands such as \gamma ($$\gamma)$$ and \Gamma ($$\Gamma$$).

Named mathematics operators are usually typeset in roman. Most of the standards are already available. Some examples: $$\det A$$, $$\cos\pi$$, and $$\log(1-x)$$.

## Displayed equations

When an equation becomes too large to run in-line, you display it in a “Math” paragraph by itself.

The \begin{aligned}...\end{aligned} environment is superb for lining up equations.

To insert ordinary text inside of mathematics mode, use \text:

This is the $$3^{\text{rd}}$$ time I’ve asked for my money back.

The \begin{cases}...\end{cases} environment is perfect for defining functions piecewise:

## Relations and operations

• Equality-like: $$x=2$$, $$x \not= 3$$, $$x \cong y$$, $$x \propto y$$, $$y\sim z$$, $$N \approx M$$, $$y \asymp z$$, $$P \equiv Q$$.

• Order: $$x < y$$, $$y \le z$$, $$z \ge 0$$, $$x \preceq y$$, $$y\succ z$$, $$A \subseteq B$$, $$B \supset Z$$.

• Arrows: $$x \to y$$, $$y\gets x$$, $$A \Rightarrow B$$, $$A \iff B$$, $$x \mapsto f(x)$$, $$A \Longleftarrow B$$.

• Set stuff: $$x \in A$$, $$b \notin C$$, $$A \ni x$$. Use \notin rather than \not\in. $$A \cup B$$, $$X \cap Y$$, $$A \setminus B = \emptyset$$.

• Arithmetic: $$3+4$$, $$5-6$$, $$7\cdot 8 = 7\times8$$, $$3\div6=\frac{1}{2}$$, $$f\circ g$$, $$A \oplus B$$, $$v \otimes w$$.

• Mod: As a binary operation, use \bmod: $$x \bmod N$$. As a relation use \mod, \pmod, or \pod:

• Calculus: $$\partial F/\partial x$$, $$\nabla g$$.

## Use the right dots

Do not type three periods; instead use \cdots between operations and \ldots in lists: $$x_1 + x_2 + \cdots + x_n$$ and $$(x_1,x_2,\ldots,x_n)$$.

## Built up structures

• Fractions: $$\frac{1}{2}$$, $$\frac{x-1}{x-2}$$.

• Binomial coefficients: $$\binom{n}{2}$$.

• Sums and products. Do not use \Sigma and \Pi.

• Integrals:

The extra bit of space before the $$dx$$ term is created with the \, command.

• Limits:

Also $$\limsup_{n\to\infty} a_n$$.

• Radicals: $$\sqrt{3}$$, $$\sqrt[3]{12}$$, $$\sqrt{1+\sqrt{2}}$$.

• Matrices:

A big matrix:

## Delimiters

• Parentheses and square brackets are easy: $$(x-y)(x+y)$$, $$[3-x]$$.

• For curly braces use \{ and \}: $$\{x : 3x-1 \in A\}$$.

• Absolute value: $$|x-y|$$, $$|\vec{x} - \vec{y}|$$.

• Floor and ceiling: $$\lfloor \pi \rfloor = \lceil e \rceil$$.

• To make delimiters grow so they are properly sized to contain their arguments, use \left and \right:

Occasionally, it is useful to coerce a larger sized delimiters than \left/\right produce. Look at the two sides of this equation:

I think the right is better. Use \bigl, \Bigl, \biggl, and the matching \bigr, etc.

• Underbraces:

## Styled and decorated letters

• Primes: $$a'$$, $$b''$$.

• Hats: $$\bar a$$, $$\hat a$$, $$\vec a$$, $$\widehat{a_j}$$.

• Vectors are often set in bold: $$\mathbf{x}$$.

• Calligraphic letters (for sets of sets): $$\mathcal{A}$$.

• Blackboard bold for number systems: $$\mathbb{C}$$.

The text above is based on a paper by Edward R. Scheinerman1.

A few more examples from mathTeX tutorial2.

Demonstrating \left\{…\right. and accents.