Inline and display math
$…$ renders math inside a sentence; $$…$$ on its own lines renders a centred display equation. GitHub also accepts a fenced block with the language math, and an alternative inline form $`…`$ when the formula contains characters Markdown would otherwise interpret.
Where it works
GitHub (since 2022, using MathJax), GitLab, Obsidian, Jupyter notebooks, Typora, VS Code’s preview, Pandoc and this site’s editor and preview (using KaTeX). Plain CommonMark renderers show the dollar signs literally.
Quick LaTeX reference
- Superscript and subscript:
x^2,a_{ij} - Fractions:
\frac{a}{b} - Roots:
\sqrt{x},\sqrt[3]{x} - Greek:
\alpha \beta \pi \Omega - Sums and integrals:
\sum_{i=1}^n,\int_0^\infty - Relations:
\le \ge \ne \approx - Matrices:
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
Dollar signs that aren’t math
Prices like “$5 and $10” can be mistaken for an inline formula. Escape them as \$5. Most renderers also require no space right after the opening $.
Exporting math
Math renders in the editor, the viewer and PDF export. For LaTeX output, the Markdown to LaTeX converter keeps the formulas as source.