3 - Mathematics in TeX
3 - Mathematics in TeX
William Matcham
September 2013
Chapter 1
Mathematics in LaTeX
Inputting mathematics
Symbols
Fractions
Brackets
Large operators
1.1 Introduction
In the third tutorial of the series, we explore how to insert mathematics into LaTeX
documents. Apart from the degree of control and aesthetic impact, the main advantage of
using LaTeX is the ease at which mathematics can be typeset. Although the introduction
of the equation mode on Microsoft Word 2007 facilitated the typesetting of mathematics
for Microsoft users, LaTeX still preferred for two reasons: first, mathematics looks better
on LaTeX, and second, certain techniques are much easier to produce on LaTeX than
Microsoft Word.
Entering mathematics inline on LaTeX is very straightforward. Simply place your desired
mathematical text inside dollar signs:
Rectangle B has side lengths x + 3 and x + 5 1 Rectangle B has side lengths $x+3$ and $x+5$
1
Oftentimes, it looks messy to have detailed mathematical expressions inside of prose. In
such cases, one can force mathematics onto a new line. To do this, place mathematical
text inside four dollar signs - two at the start of the mathematical content and two at the
end:
dy/dx = 2x (1.1)
1 \begin{eqnarray}
2 (x+3)(x+5) + (x+3)(
(x + 3)(x + 5) + (x + 3)(x + 4) = x2 + 8x + 15 + x2 + 7x + 12 (1.2)
3 &=& 2x^{2} + 15x +
= 2x2 + 15x + 27 (1.3) 4 &=& (2x + 9)(x + 3)
Note that equation numbers follow from the previous example. To remove numbers, use
the eqnarray* environment instead.
2
learn by wrote the codewords of every mathematical symbol. It is an investment of time
to learn the basic symbols to memory. We advise the reader to learn the symbols that
they will use regularly by wrote, but to avoid learning the code for symbols that they will
use rarely. We provide a reference list of the most commonly used LaTeX mathematical
symbols:
, , , , , , , , , , , , , 1 $\alpha,\beta,\gamma,\delta,\epsilon,\varepsilon,\zeta,\eta,\the
, , $, , , %, , , , , , , , , 2 $\nu,\pi, \varpi,\xi,\rho,\varrho, \sigma, \varsigma, \tau,\upsi
, , , , , , , , , , 1 $\Gamma,\Delta,\Theta,\Lambda,\Xi,\Pi,\Sigma,\Phi,\Psi,\Omega,\U
Note above that the capital alpha is not defined, and one must use the roman A symbol
instead. This is the case for the capital forms of: alpha, beta, epsilon, zeta, eta, iota,
kappa, mu, nu, omicron, rho, tau, and chi.
1.2.2 Arrows
, , , , , , , , 7-, (, ),
, , , =, =, , 7, ,, * 1 $\gets,\to,\leftarrow,\Leftarrow,\rightarrow, \Rightarr
, +, , , , , l, m, %, &, ., -
1.2.4 Accents
x, x, x, x, x, x, x, x, x, x, ~x, 3[
+ x, abc
f 1 $\hat{x},\check{x},\dot{x}, \breve{x},\acute{x},\ddot{x
N, Z, Q, R, C, L, H 1 $\mathbb{N},\mathbb{Z},\mathbb{Q},\mathbb{R},\mathbb{C}
3
x1 0, x10 1 $x^10, x^{10}$
Subscripts are exactly the same: x2 is given from the code $ x 2 $. The same applies as
above
regarding subscripts longer than one character. Finally, the square
root of variable
x, x is encoded $ \sqrt { x } $. One produces the nth root of x, n x with the code
$ \sqrt [n] { x } $ .
1.4 fractions
Although fractions can be obtained through using the forward slash, the exact way to
typeset a fraction is to use the \frac { } { } command. The numerator of the fraction
is placed in the first braces and the denominator in the second. Fractions can be easily
nested, as the example below shows:
1 1 1
1+ x1
= 2
2=1+ x
x=1 1 $\frac{1}{1 + \frac{1}{x}} = \frac{1}{2} \Leftrightarro
Fractions can of course be placed inline. When one uses the \frac command, LaTeX
automatically makes the fraction the same size as the text. This is problematic when
complex fractions are placed inline, since they become difficult to read. In such cases,
display fraction \dfrac is recommended. This case is illustrated below:
x2 x2
The fraction is difficult to read, whereas is easier. The fraction $\frac{x^{2}}{1
1+
x2 2 1
1 + x
1.5 Brackets
For simple cases, standard parentheses from the keyboard will suffice as brackets. For
example, $ (x+4) 3 $ is sufficient for (x + 4)3 . However, clearly ( )2 does not look
3
right, and we would prefer . In such cases, we use the \left( and \right) code.
The examples below show their use.
x1
3 1
2
, , xN| x
5 , hx, yi 1 $\left( \frac{\Upsilon^{3}}{\gamma^{2}} \right) ^{\frac
3
When using the \left(, it must always be paired with a \right). In the cases where one
only requires a right bracket for example, the left side must contain \left. The example
below illustrates a case where this is necessary:
y $\left. \dfrac{\partial y}{\partial x} \right|_{x=3} = 10$
= 10 1
x x=3
4
1.6 Common Functions
Some common functions are entered on LaTeX without any special code. A clear example
is how ex is simply coded $ e x $. However, however, most functions look better when
preceded by a backslash. It looks better if $ \tan ( x ) $ is used rather than $ tan (
x ) $. Other examples are shown below:
tan(x), tan(x), log(x), log(x), sin(x), sin(x), cos(x), 1 $tan(x), \tan(x), log(x), \log(x), sin(x), \si
sinh(x), sec(x), cosh(x) 2 $ \sinh(x), \sec(x), \cosh(x)$
n Z n
X 1 Y
j2 x
\ [ 1 $$\sum_{i=1}^{\infty} \dfrac{1}{i^{2}} \quad \
e f (x)e Ai Bi
i=1
i2 j=1 0 i=1 i=1
3 1 & 2 & 3 \\
44 & 5 & 6
5 \end{array} \right)
6=
7 \left(
1 2 3 a
8 \begin{array}{c}
= x y z
4 5 6 b 9 a \\
10 b \end{array}
11 \right)\left(
12 \begin{array}{ccc}
13 x & y & z
14 \end{array} \right)
15 $$
5
1 $$ D = \left[ \begin{array}{cccc}
1 0 . . . 0 2 \lambda_{1} & 0 & \dots & 0 \\
0 2 . . . 0 3 0 & \lambda_{2} & \dots & 0 \\
D=
.. .. . . . 4 \vdots & \vdots & \ddots & \vdots \\
. ..
. .
5 0 & 0 & \dots & \lambda_{n}
0 0 . . . n
6 \end{array} \right]$$
The latter example shows how to implement different kinds of dots inside your array.
\newtheorem{X}{Y}[Z]
Here, X will be the name that LaTeX will use to name the theorem, Y will be the outputted
text for the theorem, and Z the depth for which we choose to number the theorems by
(part / chapter / section / subsection). Two common examples are:
\newtheorem{Theorem}{Theorem}[chapter]
\newtheorem{Definition}{Definition}[chapter]
3 \end{Definition}
Definition 1.1. A number n is even if n = 2k for some integer k 4 \begin{Theorem}
5 32 is an even number
Theorem 1.1. 32 is an even number 6 \end{Theorem}
7 \begin{proof}
Proof. 32 = 2 16
8 $32
= 2 \times 16$
9 \end{proof}