Writing maths with LaTeX
LaTeX is the standard way to write mathematics as text. Scientists, engineers and students type \frac{a}{b} instead of drawing a fraction, and the result looks the same in a paper, on a slide or on a web page. Markdown editors such as Obsidian, Jupyter notebooks, GitHub and many forums accept the same notation.
Type an expression here and see it rendered instantly with KaTeX, a fast maths renderer, inline or as a centred display equation. Copy the TeX source when it looks right.
How to use it
- Type a LaTeX expression, without dollar signs.
- Switch between inline and display mode to see how it sits in text or on its own line.
- Fix anything shown in red; KaTeX marks commands it cannot read.
- Use Copy TeX to paste the source into your document, notebook or post.
Example: the quadratic formula
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}Rendered without errors
\frac makes the fraction, \pm the plus-minus sign and \sqrt the root; ^ raises the 2 and the braces group what belongs together.
The commands you need most
Use ^ for superscripts and _ for subscripts, with braces for more than one character: x^{10}, a_{ij}. \frac{top}{bottom} makes a fraction, \sqrt{x} a root and \sqrt[3]{x} a cube root. Greek letters are written by name, \alpha, \pi, \Sigma. Sums and integrals take limits: \sum_{i=1}^{n} i and \int_0^1 x\,dx. \cdot, \times, \leq, \geq, \neq and \infty cover most other symbols.
Inline or display
Inline maths sits within a line of text and is compressed so it does not push lines apart; in documents it is usually written between single dollar signs. Display maths stands on its own line, larger and centred, and is written between double dollar signs or \[ and \]. Use display mode for important equations and anything with tall fractions or sums.
KaTeX and full LaTeX
KaTeX supports the maths commands of LaTeX and the common amsmath extras, but not whole-document features such as \documentclass, figures or bibliographies. If an expression works here, it will almost always work in Jupyter, Obsidian and GitHub, which use KaTeX or the similar MathJax.
Questions
Why does my expression show in red?
KaTeX found a command it does not know or a brace that does not close. Check spelling and that every { has a matching }.
How do I add normal words inside maths?
Wrap them in \text{}, for example x > 0 \text{ for all } x. Without it, letters are set in italic as variables and spaces disappear.
Is anything loaded from the internet?
No. KaTeX is bundled with the page and renders in your browser.