# LaTex

LaTeX (pronounced Latec - the x is actually a chi symbol) is an electronic typesetter used mainly for technical or scientific documents but it can be used for almost any form of publishing.

LaTeX is not a word processor! Instead, LaTeX encourages authors not to worry too much about the appearance of their documents but to concentrate on getting the right content. For example, consider this document:

The purpose is not primarily aesthetics as with a word processor, but correct content.

LaTeX contains features for:

   * Typesetting
* Control over large documents containing sectioning, cross-references,
tables and figures.
* Typesetting of complex mathematical formulas.
* Advanced typesetting of mathematics with AMS-LaTeX.
* Automatic generation of bibliographies and indexes.
* Multi-lingual typesetting.
* Inclusion of artwork, and process or spot colour.
* Using PostScript or Metafont fonts.


LaTeX is built in to The Student Room. It helps enormously getting people to help you out if you format your mathematical queries using this method. Below are some basic commands to get you started:

## Using LaTeX on The Student Room:

The Student Room currently has two LaTeX packages installed, one called TeXLive and an older one called MimeTeX. In terms of functionality and typographical quality the former is better, and this guide will assume you use TeXLive.

To use LaTeX on the The Student Room forums, simply enter the LaTeX code into  tags.

e.g. $x = 5$ gives

Note Most, if not all, of the LaTeX commands on this page also work using the tags $$and$$ (which saves you quite a bit of typing if you're doing lots of it!) TeX is just the earlier version of LaTeX

## Multiplication and division

If you need to use these symbols, use \times and \div respectively.

e.g. $3 \times 5 = 15$ gives , while $$4 \div 2 = 2$$ gives

## Complex notation

Polar form

$$\langle r , \theta \rangle$$ gives

## Plus or minus

$\pm$ gives

$\mp$ gives

## Indices

$$x^{10}$$ gives

If the exponent is more than one character long, then you have to use curly brackets (i.e. { and } ) This is the case throughout LaTeX.

e.g. $x^{10}$ gives

For square roots, you use the \sqrt command.

e.g. $\sqrt 2$ gives

## Fractions

We use \frac{numerator}{denominator}.

e.g. $$\frac{1}{2}$$ gives

e.g. $$x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$$ gives

For fractions which aren't squashed onto one line, use \dfrac{numerator}{denominator}.

e.g. $$x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$$ gives

## Brackets

To get brackets in LaTeX you simply use the parentheses you're used to using when typing Maths without LaTeX.

e.g. $(x+1)^2$ gives

If you've got a huge expression with multiple brackets or roots, fractions, etc., you can get larger brackets, using the \left( and \right) commands.

e.g.$$f(x)=3x^2 \left( 1+ \frac{2x+1}{x^2-2} \right)$$ gives  (compare with $$f(x)=3x^2 (1+ \frac{2x+1}{x^2-2} )$$ which gives

Square brackets and curly brackets can also be used. For example, $$\displaystyle \int_{1}^{2} \{ x^2+1 \} .dx = \left[ \frac{x^3}{3} + x \right]_{1}^{2}$$ gives

## Normal text

When writing within TeX tags, it is assumed that any letters denote variables, and hence are italicised. If you want the letters to be written normally (for example, if you are quoting units), use the \mathrm{} tag. The \text{} tag can also be used to perform this function on The Student Room.

e.g. $\mathrm{hello}$ gives  (compare with $hello$ which gives )

For spaces, use "\ ".

e.g. $$\mathrm{With \ spaces \ without spaces}$$ gives

and $v=1.2\text{\ m/s}$ gives

## Subscripts and superscripts

Superscripts are exactly the same as indices - we again use the ^ command.

e.g. $$\mathrm{Cl}^-$$ gives  (Note that you could also use the [sup] [/sup] tags instead though.)

For subscripts, we use the _ command.

e.g. $x_1+x_2+x_3 = 5$ gives

## Sigma notation

To write sums, we use the \sum command.

e.g. $$\sum_{i=1}^{n} i^2 = \frac{1}{6}n(n+1)(2n+1)$$ gives

To make the first and last term appear above and below instead of to the side, use \displaystyle.

e.g. $$\displaystyle \sum_{i=1}^{n} i^2 = \frac{1}{6}n(n+1)(2n+1)$$ gives

Alternatively use \limits to add limits while keeping the size of the text the same.

$$\sum\limits_{i=1}^{n} i^2 = \frac{1}{6}n(n+1)(2n+1)$$ gives

To write the mean of x, x-bar, use the \bar{x}. E.g.

## Differentiation

Again, we use \frac{}{} to write dy/dx.

e.g. $\frac{d}{dx} x^2 = 2x$ gives

For f'(x), simply write it out normally within LaTeX tags.

e.g. $f'(x)$ gives

For partial derivatives, use \partial instead of d.

e.g. $\displaystyle \frac{\partial}{\partial x} x^2y = 2xy$ gives

## Integration

For the integral sign, use the \int command.

e.g. $\int 2x\ dx = x^2 + C$ gives

For definite integrals, use the commands for subscripts and superscripts.

e.g. $\int^2_0 2x\ dx = 4$ gives

Again, like with sums, the \displaystyle command makes integrals look nicer:

e.g. $\displaystyle\int^2_0 2x\ dx = 4$ gives

## Modulus sign

Use | for the modulus sign.

e.g. $\sqrt{x^2} = |x|$ gives

or \lvert and \rvert (in case you don't have a | key on your keyboard)

## Factorial

Use the exclamation mark like normal.

e.g. $4! = 24$ gives

## n choose r

$^n\mathrm{C}_r$ gives

Or, you can use the \binom command:

$\displaystyle \binom{n}{r}$ gives

You could also, if you wanted, write it as a vector(see below).

## Greek Letters

Write \x where x is the written form of the Greek letter (i.e. alpha, beta, gamma, ... , omega).

e.g. $\pi$ gives

e.g. $\theta$ gives

If you want the uppercase Greek letter, write the first letter as a capital.

e.g. $\Delta$ gives

Some Greek letters look identical to their Roman equivalents, and so are not provided; e.g. for lowercase omicron, simply write o.

## Infinity

To insert the infinity symbol, use \infty.

e.g $\displaystyle\sum_{i=1}^{\infty} \frac{1}{i^2} = \frac{\pi^2}{6}$ gives

## Trigonometry

$\cos \theta$ gives

$\sin \theta$ gives

$\tan \theta$ gives

$\sec \theta$ gives

$\mathrm{cosec} \theta$ gives

Alternatively, $\csc \theta$ gives

$\cot \theta$ gives

For the trig functions exponentiated, use ^ after the trig function and before the \theta (or whatever you're using).

e.g. $\sin^2 \theta + \cos^2 \theta=1$ gives

To write 'degrees', you could use the \circ command.

e.g. $\sin 30^{\circ} = \frac{1}{2}$ gives

## Logarithms

Use some of the previous commands.

e.g. $\ln x^k = k \ln x$ gives

and $\log_a x^k = k \log_a x$ gives

## Dots

$x_1+x_2+\cdots$ gives  (i.e. central dots)

$x_1+x_2+\ldots$ gives (i.e. dots at the bottom)

$\dot{x}$ gives  (i.e. dot above x)

$\ddot{x}$ gives  (i.e. two dots above x)

$\cdot$ gives

$\bullet$ gives

## Matrices and Vectors

For a bold letter, you could use normal text and make it bold (e.g. [b]i[/b] gives i), or if you wanted to use LaTeX, use the \mathbf{} command.

e.g. $\mathbf{i}$ gives

The \vec{} command can also be useful.

e.g. $\vec{AB}$ gives

To write a vector or a matrix, you could use either of the pairs

• \begin{pmatrix} \end{pmatrix}
• \begin{bmatrix} \end{bmatrix}
• \begin{Bmatrix} \end{Bmatrix}
• \begin{vmatrix} \end{vmatrix}
• \begin{Vmatrix} \end{Vmatrix}
• \begin{matrix} \end{matrix}

which enclose the matrix/vector in ( ), [ ], { }, | |, || || and nothing, respectively. Between these \begin{} and \end{} commands, enter the coefficients of the matrix/vector row by row, separating coefficients on the same row with & and separating rows by \\.

Examples:

$\begin{pmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{pmatrix}$ gives

$\begin{bmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{bmatrix}$ gives

$\begin{Bmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{Bmatrix}$ gives

$\begin{vmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{vmatrix}$ gives

$\begin{Vmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{Vmatrix}$ gives

and

$\begin{matrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{matrix}$ gives

For vectors, simply write a matrix with only one column:

$\begin{pmatrix} x \\ y \\ z \end{pmatrix}$ gives

## Arrays

Sometimes, it could be useful to lay out what you write nicely in a table. For many cases, the \begin{matrix} \end{matrix} commands will suffice for this, but a little more control is offered by the \begin{array} \end{array} commands.

When using this, you need to decide beforehand how many columns you want to have, and include a string of letters, one for each column, enclosed in {} directly after the \begin{array} command. The letters indicate what alignment you want of the entries in that column, l for left, c for centre, and r for right.

e.g.

\begin{array}{rlc} n & n^2 & n^3 \\ 3 & 9 & 27 \\ 4 & 16 & 64 \\ 11 & 121 & 1331 \end{array}[latex] gives You can have horizontal and vertical lines in your table. For a horizontal line, use the \hline command , and for a vertical, put a | in the list of column alignments. e.g. [latex]\begin{array}{r|lc} n & n^2 & n^3 \\ \hline 3 & 9 & 27 \\ 4 & 16 & 64 \\ 11 & 121 & 1331 \end{array}[latex] gives ## Arrows e.g. [latex]\Rightarrow gives

e.g. $$\not\Rightarrow$$ gives

e.g. $\rightarrow$ gives

e.g. $\Longrightarrow$ gives

e.g. $\longrightarrow$ gives

e.g. $\mapsto$ gives

Arrows can point left by replacing "right" with "left", or they can point both ways by replacing "right" with "leftright".

e.g. $\longleftarrow$ gives

e.g. $\Leftrightarrow$ gives

## Logic Symbols

$\forall$ gives

$\land$ gives

$\lor$ gives

$\exists$ gives

$$\neg$$ gives

## Other

$$\displaystyle\underbrace{10^2 + 14^2 + 18^2 +\cdots}_{41\text{ terms}}$$ gives

$\lim_{x\to 0}$ gives

$\displaystyle\lim_{x\to 0}$ gives

$\Re$ gives

$\Im$ gives

## Sets

$\cup$ gives  eg.

$\cap$ gives  eg.

$\subset$ gives

$\subseteq$ gives

$\nsubseteq$ gives

$\in$ gives

$\not\in$ gives

$\mathbb{P}$ gives

$\mathbb{N}$ gives

$\mathbb{Z}$ gives

$\mathbb{I}$ gives

$\mathbb{Q}$ gives

$\mathbb{R}$ gives

$\mathbb{C}$ gives

$\forall$ gives

## Accents

$\bar{x}$ gives

$\hat{x}$ gives

$\dot{x}$ gives

$\ddot{x}$ gives

$\vec{x}$ gives