LaTeX writes maths as plain text: you type a description of the formula, and LaTeX sets it like a printed textbook. In this course you type into boxes on the page and see the result at once, so there is nothing to install.
Two ways into maths mode
In a LaTeX document, maths lives in maths mode. There are two ways in:
$...$for maths inside a sentence, such as .\[...\]for a formula on a line of its own, centred.
The line $y = mx + c$ crosses the y-axis at $c$.
\[ y = mx + c \]You may meet $$...$$ in older documents. It does the same job as \[...\], but \[...\] is the one to use.
In the boxes on this course you are always in maths mode already, so you type just the maths: y = mx + c, without the dollar signs. (Type them anyway and they are ignored.)
What you type as it is
Letters, digits and most of the symbols on your keyboard go in as they are:
- Letters come out italic, because in maths a letter is a variable: , , .
- Digits stay upright: .
+ - = < > ( ) [ ] / ! ' , . : ;all work as they are. A typed-becomes a proper minus sign, longer than a hyphen.
Edit the formula below: change a number, add a term, and watch it update.
Spaces do not count
In maths mode LaTeX ignores the spaces you type. 2x+3=7 and 2 x + 3 = 7 give exactly the same result, because LaTeX spaces a formula by itself, from what each symbol is: more room around than around , and none between and . Type spaces only to keep your LaTeX easy to read.
Try it: add or remove spaces in the box, and nothing moves.
The flip side: a word typed in maths mode turns into italic letters multiplied together. Here the word "area" reads as :
Words inside maths need \text{...}, which comes in lesson 11.
Commands start with a backslash
Anything that is not on your keyboard has a command: a backslash followed by a name. \pi gives , \times gives and \infty gives .
A command's name ends at the first character that is not a letter. So \pi r is times , but \pir is a command LaTeX does not know, and you get an error. Leave a space after a command when a letter follows it.
Two things catch everyone out:
*is not a times sign: it prints an asterisk. Use\timesfor , or\cdotfor a centred dot, as in .%starts a comment, so LaTeX ignores everything after it on the line. Write\%for a percent sign.
Braces group, and are not printed
Curly braces { } group things for LaTeX and never appear in the output. From the next lesson on you will use them all the time, as in . To print a brace, put a backslash before it: \{ and \} give and .
Practise
Type each formula in the box under it. It is marked as you type, and Enter takes you to the next one.
Type it as you see it.
2x + 3 = 7Letters come out italic by themselves.
y = mx + cBrackets and the minus sign are typed as they are.
f(x) = 3x - 1\pigives π. Leave a space after it, or the r joins the command.C = 2\pi r\timesgives the times sign. A*would print an asterisk.6 \times 7 = 42\cdotgives the centred dot.a \cdot b = b \cdot aBraces need a backslash to be printed:
\{and\}.A = \{1, 2, 3\}%starts a comment, so write\%.x = 50\%
In short
$...$puts maths in a sentence,\[...\]on a line of its own.- Letters, digits and most keyboard symbols are typed as they are, and spaces are ignored.
- Commands start with a backslash.
*is not multiplication: use\timesor\cdot. - Braces group without being printed.
\{and\}print them, and\%prints a percent sign.
Next, in lesson 2: powers and subscripts, with ^ and _.