How to Write Math in Markdown
LaTeX equations between dollar signs, GitHub's two extra forms, a symbol cheat sheet, and a table of which platforms render math and which print the dollar signs.
Short answer
Write $x^2$ for inline math and put display math between $$ lines. That works on GitHub, GitLab, Obsidian, VS Code, Jupyter, Typora and Pandoc. Notion uses $$...$$ for inline. Discord, Slack and Reddit render no math at all.
Inline Math
Put LaTeX between single dollar signs to set math inside a sentence. Keep the dollar signs tight against the formula: most parsers will not start math on $ with a space after it.
The area of a circle is $\pi r^2$.By Pythagoras, $a^2 + b^2 = c^2$.Block (Display) Math
Double dollar signs on their own lines make a centered display equation. Fractions are full size and the limits of sums and integrals move above and below the symbol. Do not leave a blank line inside the block.
$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$$$
\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}
$$$$
\int_0^1 x^2 \, dx = \frac{1}{3}
$$$$
A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}
$$$$
\begin{aligned}
(a+b)^2 &= (a+b)(a+b) \\
&= a^2 + 2ab + b^2
\end{aligned}
$$GitHub Math
GitHub renders math with MathJax everywhere Markdown renders: README files, issues, pull requests, discussions and wikis. On top of the dollar-sign forms it adds two that cannot collide with Markdown, which matters when a formula contains * or _.
The theorem says $`a^2 + b^2 = c^2`$.```math
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
```This costs <span>$</span>4 and the root is $`\sqrt{\$4}`$.$5 and $10, can pair up and render as math. GitHub's fix is <span>$</span> outside math and \$ inside it. Math also works as a text color workaround on GitHub: $\color{red}{\text{red}}$. More GFM detail is on the GitHub Markdown guide.LaTeX Math Syntax Cheat Sheet
Everything between the dollar signs is LaTeX. These commands work in both MathJax and KaTeX, so they are safe on every platform in the support table.
| You want | Write | Note |
|---|---|---|
| Superscript / power | x^2 x^{10} | Braces for more than one character |
| Subscript | a_1 a_{ij} | Combine: x_i^2 |
| Fraction | \frac{a}{b} | \dfrac forces display size inline |
| Square / nth root | \sqrt{x} \sqrt[3]{x} | |
| Sum | \sum_{i=1}^{n} i | Limits sit above and below in display math |
| Product | \prod_{i=1}^{n} x_i | |
| Integral | \int_0^1 x^2 \, dx | \, adds the thin space before dx |
| Limit | \lim_{x \to 0} f(x) | |
| Text inside math | \text{if } x > 0 | Keeps words upright with real spaces |
| Upright letters | \mathrm{H_2O} | For units and chemistry |
| Bold vector | \mathbf{v} | |
| Growing brackets | \left( \frac{a}{b} \right) | Brackets stretch to fit the content |
| Matrix | \begin{pmatrix} a & b \\ c & d \end{pmatrix} | bmatrix for square brackets |
| Cases | \begin{cases} 1 & x > 0 \\ 0 & \text{else} \end{cases} | Piecewise functions |
| Aligned lines | \begin{aligned} a &= b \\ &= c \end{aligned} | aligned works in MathJax and KaTeX |
| Color | \color{red}{x} | Works on GitHub, a common text-color hack |
Markdown Math Symbols
The LaTeX command goes inside the dollar signs: $\alpha \leq \beta$. Capitalize a Greek command for the uppercase letter where one exists.
Greek letters
| Command | Symbol |
|---|---|
| \alpha | α |
| \beta | β |
| \gamma \Gamma | γ Γ |
| \delta \Delta | δ Δ |
| \epsilon \varepsilon | ϵ ε |
| \theta \Theta | θ Θ |
| \lambda \Lambda | λ Λ |
| \mu | μ |
| \pi \Pi | π Π |
| \sigma \Sigma | σ Σ |
| \phi \varphi | ϕ φ |
| \omega \Omega | ω Ω |
Operators
| Command | Symbol |
|---|---|
| \pm \mp | ± ∓ |
| \times | × |
| \div | ÷ |
| \cdot | ⋅ |
| \sqrt{x} | √x |
| \sum | ∑ |
| \prod | ∏ |
| \int \iint \oint | ∫ ∬ ∮ |
| \partial | ∂ |
| \nabla | ∇ |
| \infty | ∞ |
| \circ | ∘ |
Relations
| Command | Symbol |
|---|---|
| \neq | ≠ |
| \leq \geq | ≤ ≥ |
| \ll \gg | ≪ ≫ |
| \approx | ≈ |
| \equiv | ≡ |
| \sim \simeq | ∼ ≃ |
| \propto | ∝ |
| \in \notin | ∈ ∉ |
| \subset \subseteq | ⊂ ⊆ |
| \cup \cap | ∪ ∩ |
| \forall \exists | ∀ ∃ |
| \emptyset | ∅ |
Arrows and logic
| Command | Symbol |
|---|---|
| \to \rightarrow | → |
| \leftarrow | ← |
| \leftrightarrow | ↔ |
| \Rightarrow | ⇒ |
| \Leftrightarrow | ⇔ |
| \implies \iff | ⟹ ⟺ |
| \mapsto | ↦ |
| \uparrow \downarrow | ↑ ↓ |
| \land \lor | ∧ ∨ |
| \neg | ¬ |
| \therefore | ∴ |
| \ldots \cdots | … ⋯ |
Platform Support
The dollar-sign convention is shared, but not universal. Check the inline form in particular before you paste math between platforms.
| Platform | Inline | Block | Notes |
|---|---|---|---|
| GitHub | $...$ or $`...`$ | $$...$$ or ```math | MathJax. On in READMEs, issues, PRs, discussions, wikis. |
| GitLab | $`...`$ or $...$ | $$...$$ or ```math | KaTeX. Only the first 1,000 inline expressions render, except in wikis and repository files. |
| Obsidian | $...$ | $$...$$ | MathJax. On by default. |
| VS Code preview | $...$ | $$...$$ | KaTeX, built in. Toggle with markdown.math.enabled. |
| Jupyter | $...$ | $$...$$ or \begin{equation} | MathJax in Markdown cells. |
| Notion | $$...$$ or Cmd/Ctrl+Shift+E | /math block | KaTeX. Note the doubled dollars for inline. |
| Typora | $...$ | $$ then Enter | MathJax. Inline math is a setting: Preferences > Markdown. |
| Pandoc / Quarto | $...$ | $$...$$ | No space after the opening $, no digit after the closing $. |
| Hugo | \(...\) | \[...\] or $$...$$ | Off until you enable Goldmark passthrough and load MathJax or KaTeX. |
| Discord, Slack, Reddit | None | None | No math rendering. Use Unicode symbols or an image. |
Platform specifics live in the Obsidian, Notion and VS Code guides. AI chat apps such as ChatGPT and Claude render LaTeX in their replies, but neither documents which delimiters it accepts; Markdown for AI covers how they format output.
Common Mistakes
Almost every broken equation is one of these.
Broken
$ x^2 $Fixed
$x^2$Broken
$x^10$Fixed
$x^{10}$Broken
It costs $5, or $10 with tax.Fixed
It costs <span>$</span>5, or <span>$</span>10 with tax.Broken
$$
x = 1
y = 2
$$Fixed
$$
\begin{aligned}
x &= 1 \\
y &= 2
\end{aligned}
$$Broken
\begin{align} ... \end{align}Fixed
\begin{aligned} ... \end{aligned}Frequently Asked Questions
How do you write math in Markdown?
Standard Markdown has no math syntax, but GitHub, GitLab, Obsidian, VS Code, Jupyter, Typora and Pandoc all add the same LaTeX convention: put inline math between single dollar signs, $x^2$, and display math between double dollar signs on their own lines, $$...$$. The text between the delimiters is LaTeX, rendered by MathJax or KaTeX.
Does GitHub Markdown support LaTeX?
Yes. GitHub renders LaTeX with MathJax in README files, issues, pull requests, discussions and wikis. Use $...$ or $`...`$ for inline math, and $$...$$ on its own lines or a ```math code block for display math. The backtick form exists because it cannot clash with Markdown syntax inside the formula.
How do I write a dollar sign without starting math on GitHub?
Outside math, wrap it in a span: <span>$</span>5. Inside math, escape it with a backslash: $`\sqrt{\$4}`$. Both forms come from GitHub's documentation.
What is the difference between $ and $$ in Markdown?
A single pair of dollar signs is inline math: it sits inside the sentence at text size. A double pair is display math: it becomes its own centered block, with large fractions and with limits placed above and below sums and integrals. Notion is the exception: it uses $$...$$ for inline equations and /math for blocks.
Is the math LaTeX, MathJax or KaTeX?
You write LaTeX math commands. MathJax and KaTeX are the JavaScript libraries that render them. GitHub, Obsidian, Jupyter and Typora use MathJax; GitLab, VS Code and Notion use KaTeX. KaTeX is faster but supports a smaller subset, so prefer aligned over align and check less common macros.
How do I write math in Obsidian?
Type $...$ for inline math and $$...$$ for a block. Obsidian renders both with MathJax in Live Preview and Reading view, with no plugin or setting needed.
Why is my math not rendering?
The usual causes: a space right after the opening dollar sign, a blank line inside a $$ block, a platform with no math support (Discord, Slack, Reddit, and plain CommonMark sites), a static site generator where math is off by default (Hugo needs the passthrough extension and a MathJax or KaTeX script), or a KaTeX-only platform receiving a MathJax-only command.
Can I use math in Discord, Slack or Reddit?
No. None of the three renders LaTeX in messages or posts. Paste Unicode symbols such as ², √ and π for short expressions, or share an image of the rendered equation.