|
|
LaTeX
From The Student RoomTSR Wiki > Study Help > Subjects and Revision > Subject Guides > Mathematics > 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, LaTeX is built in to TSR. 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 TSR:TSR currently have 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 TSR forums, simply enter the LaTeX code into [latex][/latex] tags. e.g. [latex]x = 5[/latex] gives Multiplication and divisionIf you need to use these symbols, use \times and \div respectively. e.g. [latex]3 \times 5 = 15[/latex] gives Plus or minus[latex]\pm[/latex] gives Indices[latex]x^a[/latex] gives If the exponent is more than one letter/number long, then you have to use curly brackets (i.e. { and } ) e.g. [latex]x^{10}[/latex] gives For square roots, you use the \sqrt command. e.g. [latex]\sqrt 2[/latex] gives Again, if whatever you want to square root is more than one letter or number, you have to use curly brackets (this is the case throughout LaTeX). e.g. [latex]\sqrt {b^2-4ac}[/latex] gives If you want to take the n-th root, use the \sqrt[n] command. e.g. [latex]\sqrt[3]{1+x^2}[/latex] gives Equals sign and inequalitiesTo get an equals sign, you simply use the ordinary = sign. e.g. [latex]2^4=16[/latex] gives For 'not equal to', use \not= e.g. [latex]2^4\not=2[/latex] gives For less than signs, we use <, and for greater than signs, we use > e.g. [latex]2^4>15[/latex] gives For 'less than or equal to' signs, we use \leq, and for 'greater than or equal to' signs we use \geq e.g. [latex]5x+3 \geq 8[/latex] gives As with the equals sign, the symbol for 'not less than or equal to', 'not greater than', etc. is just \not followed by the symbol (i.e. >, <, \leq, \geq). e.g. [latex]5x+3 \not\geq 8[/latex] gives For 'equivalent to' signs, we use \equiv e.g. [latex]1+ \cot^2 \equiv \mathrm{cosec}^2[/latex] gives FractionsWe use \frac{numerator}{denominator}. e.g. [latex]\frac{1}{2}[/latex] gives e.g.2 [latex]x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}[/latex] gives BracketsTo get brackets in LaTeX you simply use the parentheses you're used to using when typing Maths without LaTeX. e.g. [latex](x+1)^2[/latex] 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. [latex]f(x) = 3x^2\left(1+\frac{2x+1}{x^2-2} \right)[/latex] gives Normal textWhen 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, you could use the \mathrm{} tag. e.g. [latex]\mathrm{hello}[/latex] gives Supscripts and superscriptsSuperscripts are exactly the same as indices - we again use the ^ command. e.g. [latex]\mathrm{Cl}^-[/latex] gives For subscripts, we use the _ command. e.g. [latex]x_1+x_2+x_3 = 5[/latex] gives Sigma notationTo write sums, we use the \sum command. e.g. [latex]\sum_{i=1}^n i^2 = \frac{1}{6}n(n+1)(2n+1) [/latex] gives To make the first and last term appear above and below instead of to the side, use \displaystyle. e.g. [latex]\displaystyle\sum_{i=1}^n i^2 = \frac{1}{6}n(n+1)(2n+1) [/latex] gives DifferentiationAgain, we use \frac{}{} to write dy/dx. e.g. [latex]\frac{d}{dx} x^2 = 2x[/latex] gives For f'(x), simply write it out normally within LaTeX tags. e.g. [latex]f'(x)[/latex] gives For partial derivatives, use \partial instead of d. e.g. [latex]\displaystyle \frac{\partial}{\partial x} x^2y = 2xy[/latex] gives IntegrationFor the integral sign, use the \int command. e.g. [latex]\int 2x \, dx = x^2 + C[/latex] gives (Note the use of the \, command to create a space between the 2x and the dx. Other ways of creating space include the \; command and the \quad command.) For definite integrals, use the commands for subscripts and superscripts. e.g. [latex]\int^2_0 2x \, dx = 4[/latex] gives Again, like with sums, the \displaystyle command makes integrals look nicer: e.g. [latex]\displaystyle\int^2_0 2x \, dx = 4[/latex] gives Modulus signUse | for the modulus sign. e.g. [latex]\sqrt{x^2} = |x|[/latex] gives FactorialUse the exclamation mark like normal. e.g. [latex]4! = 24[/latex] gives n choose r[latex]^n\mathrm{C}_r[/latex] gives Or, you can use the \binom command: [latex]\displaystyle \binom{n}{r}[/latex] gives You could also, if you wanted, write it as a vector(see below). Greek LettersWrite \x where x is the written form of the Greek letter (i.e. alpha, beta, gamma, ... , omega). e.g. [latex]\pi[/latex] gives e.g. [latex]\theta[/latex] gives If you want the uppercase Greek letter, write the first letter as a capital. e.g. [latex]\Delta[/latex] gives Infinity\infty
e.g [latex]\displaystyle\sum_{i=1}^{\infty} \frac{1}{i^2} = \frac{\pi^2}{6}[/latex] gives Trigonometry[latex]\cos \theta[/latex] gives [latex]\sin \theta[/latex] gives [latex]\tan \theta[/latex] gives [latex]\sec \theta[/latex] gives [latex]\mathrm{cosec} \theta[/latex] gives Alternatively, [latex]\csc \theta[/latex] gives [latex]\cot \theta[/latex] gives For the trig functions exponentiated, use ^ after the trig function and before the \theta (or whatever you're using). e.g. [latex]\sin^2 \theta + \cos^2 \theta=1[/latex] gives To write 'degrees', you could use the \circ command. e.g. [latex]\sin 30^{\circ} = \frac{1}{2}[/latex] gives LogarithmsUse some of the previous commands. e.g. [latex]\ln x^k = k \ln x[/latex] gives and [latex]\log_a x^k = k \log_a x[/latex] gives Dots[latex]x_1+x_2+\cdots[/latex] gives [latex]x_1+x_2+\ldots[/latex] gives [latex]\dot{x}[/latex] gives [latex]\ddot{x}[/latex] gives [latex]\cdot[/latex] gives [latex]\bullet[/latex] gives Matrices and VectorsFor 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. [latex]\mathbf{i}[/latex] gives The \vec{} command can also be useful. e.g. [latex]\vec{AB}[/latex] gives To write a vector or a matrix, you could use either of the pairs
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: [latex]\begin{pmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{pmatrix}[/latex] gives
[latex]\begin{bmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{bmatrix}[/latex] gives
[latex]\begin{Bmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{Bmatrix}[/latex] gives
[latex]\begin{vmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{vmatrix}[/latex] gives
[latex]\begin{Vmatrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{Vmatrix}[/latex] gives
and [latex]\begin{matrix} 1 & 2 & 3 \\4 & 5 & 6 \\7 & 8 & 9 \end{matrix}[/latex] gives
For vectors, simply write a matrix with only one column: [latex]\begin{pmatrix} x \\ y \\ z \end{pmatrix}[/latex] gives
ArraysSometimes, 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. [latex]\begin{array}{rlc} n & n^2 & n^3 \\ 3 & 9 & 27 \\ 4 & 16 & 64 \\ 11 & 121 & 1331 \end{array}[latex] gives
You can have horisontal 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
Proofs[latex]\Rightarrow[/latex] gives [latex]\Leftrightarrow[/latex] gives The following are easier to remember but don't look as nice: [latex]\implies[/latex] gives [latex]\iff[/latex] gives Logic Symbols[latex]\forall[/latex] gives [latex]\land[/latex] gives [latex]\lor[/latex] gives [latex]\exists[/latex] gives
Other[latex]\to[/latex] gives [latex]\lim_{x\to 0}[/latex] gives [latex]\displaystyle\lim_{x\to 0}[/latex] gives |











, while [tex]4 \div 2 = 2[/tex] gives
(compare with [latex]f(x) = 3x^2(1+\frac{2x+1}{x^2-2})[/latex] which gives
(compare with [latex]hello[/latex] which gives
)
(Note that you could also use the [sup] [/sup] tags instead though.)
(i.e. central dots)
(i.e. dots at the bottom)
(i.e. dot above x)
(i.e. two dots above x)





