LaTeX docs
LaTeX basics
The most common LaTeX, with examples. Everything here works in both block and inline formulas.
LaTeX formulas are rendered with MathJax, the standard engine for math on the web. If a command works in MathJax with the packages listed below, it works in the app.
Common commands
| You want | Type | Notes |
|---|---|---|
| Power, index | x^2, x_i, x_i^2 | Use braces for more than one character: x^{10}, a_{ij} |
| Fraction | \frac{a}{b} | |
| Square root, n-th root | \sqrt{x}, \sqrt[3]{x} | |
| Greek letters | \alpha, \beta, \pi, \Omega | Capitalise for upper case: \Delta |
| Multiply, plus-minus | \times, \cdot, \pm | |
| Compare | \leq, \geq, \neq, \approx | |
| Sum, product | \sum_{i=1}^{n} x_i, \prod_{k=1}^{n} | |
| Integral | \int_0^1 f(x)\,dx | \, adds a small space |
| Limit | \lim_{x \to 0} | |
| Brackets that grow | \left( \frac{a}{b} \right) | Also \left[ … \right], \left\{ … \right\} |
| Text inside a formula | \text{if } x > 0 | |
| Bold, vectors | \mathbf{v}, \vec{v}, \boldsymbol{\alpha} | |
| Accents | \hat{x}, \bar{x}, \dot{x} | |
| Matrix | \begin{pmatrix} a & b \\ c & d \end{pmatrix} | bmatrix for square brackets, vmatrix for a determinant |
| Cases | \begin{cases} 1 & x > 0 \\ 0 & \text{otherwise} \end{cases} | |
| Colour | \color{red}{x} | |
| Cross out | \cancel{x} |
Several lines
Use aligned to align several equations inside one formula: & marks the alignment point and \\ starts a new line.
\begin{aligned}
a &= b + c \\
&= d
\end{aligned}
align, align*, gather, equation and multline are also supported, but as in LaTeX they must be the whole formula — not mixed with other content. To number an equation, use \tag{1}.
Chemistry
Write chemical formulas and reactions with \ce{…} (the mhchem package):
| Type | Result |
|---|---|
\ce{H2O} | water |
\ce{2H2 + O2 -> 2H2O} | a reaction with an arrow |
\ce{N2 + 3H2 <=> 2NH3} | an equilibrium |
Units
Write a value with a unit using \SI{value}{unit}, for example \SI{9.81}{m/s^2}. For units on their own, use \mathrm{kg}.
Physics
The physics package adds shortcuts such as \dv{f}{x} (derivative), \pdv{f}{x} (partial derivative), \abs{x}, \norm{v}, \bra{\psi} and \ket{\psi}.
Your own commands
Define a shortcut with \newcommand at the start of a formula, for example \newcommand{\R}{\mathbb{R}} f: \R \to \R. A definition applies only to the formula it’s in.
Supported packages
| Package | Adds |
|---|---|
| base, AMS | Standard LaTeX math, AMS symbols and environments (aligned, cases, matrices, align, gather…) |
| newcommand | \newcommand, \def |
| boldsymbol | \boldsymbol |
| color | \color |
| mhchem | \ce for chemistry |
| textmacros | Text commands inside \text{…} |
| cancel | \cancel, \bcancel, \xcancel |
| physics | Physics notation shortcuts |
Not supported: links (\href, \url) and HTML — formulas never contain links.
Full references
- MathJax: supported TeX commands — the complete list.
- MathJax basic tutorial and quick reference — a popular, friendly guide.
- Wikibooks: LaTeX/Mathematics — a longer introduction to math in LaTeX.
Not sure of a command? Search the symbol library in the editor — it shows each symbol and inserts the LaTeX for you.