MDUtil

Math and LaTeX in Markdown

Put LaTeX between dollar signs to write a formula: $E = mc^2$ inside a sentence, $$ … $$ on lines of their own for a centered equation. This guide covers the syntax, common notation and where it works.

Quick answer

How do you write math in Markdown?

Wrap LaTeX in single dollar signs for a formula inside a sentence, $a^2 + b^2 = c^2$, and in double dollar signs on their own lines for a displayed equation. Math is an extension: GitHub, Obsidian, Typora, Jupyter and many editors render it with KaTeX or MathJax.

Markdown
The area of a circle is $A = \pi r^2$.

$$
\int_0^1 x^2 \, dx = \frac{1}{3}
$$

Result

The area of a circle is A=πr2A = \pi r^2.

∫01x2 dx=13\int_0^1 x^2 \, dx = \frac{1}{3}

Math syntax and examples

Everything between the dollar signs is LaTeX math. These examples cover the notation people need most.

Common notation

Superscripts with ^, subscripts with _, fractions with \frac, roots with \sqrt and Greek letters by name. Group several characters in braces.

Markdown
$x^2$, $x_i$, $e^{i\pi}$, $\frac{a}{b}$, $\sqrt{2}$, $\alpha + \beta$

Result

x2x^2, xix_i, eiπe^{i\pi}, ab\frac{a}{b}, 2\sqrt{2}, α+β\alpha + \beta

Sums, limits and integrals

Limits go in subscripts and superscripts, and display equations show them above and below.

Markdown
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2} \qquad \lim_{x \to 0} \frac{\sin x}{x} = 1
$$

Result

∑i=1ni=n(n+1)2lim⁡x→0sin⁡xx=1\sum_{i=1}^{n} i = \frac{n(n+1)}{2} \qquad \lim_{x \to 0} \frac{\sin x}{x} = 1

Aligned equations

Inside an aligned block, & marks the column to line up and \\ starts a new line.

Markdown
$$
\begin{aligned}
(a+b)^2 &= a^2 + 2ab + b^2 \\
(a-b)^2 &= a^2 - 2ab + b^2
\end{aligned}
$$

Result

(a+b)2=a2+2ab+b2(a−b)2=a2−2ab+b2\begin{aligned} (a+b)^2 &= a^2 + 2ab + b^2 \\ (a-b)^2 &= a^2 - 2ab + b^2 \end{aligned}

Matrices

pmatrix adds parentheses and bmatrix square brackets; & separates columns.

Markdown
$$
A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
$$

Result

A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}

A math code block

A fenced block marked math works like $$, which keeps long equations easy to read in the source.

Markdown
```math
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
```

Result

x=−b±b2−4ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

GitHub's backtick form

GitHub also reads inline math written as dollar signs around backticks, which keeps Markdown symbols inside the formula safe.

Markdown
$`\sqrt{x_1 * x_2}`$

GitHub and GitLab only. Other Markdown apps display this differently, so there is no preview.

Math in popular apps

Math is an extension, so check that your app renders it before you rely on it.

AppSupportNotes
GitHubSupported$…$, $$…$$ and math code blocks in files, issues and comments.
ObsidianSupported$…$ and $$…$$, rendered with MathJax.
TyporaSupported$$ blocks; inline $…$ after turning on inline math in the settings.
JupyterSupported$…$ and $$…$$ in Markdown cells.
NotionDiffersA formula typed between $$ becomes an inline equation; the /math command adds a block equation.
Discord / SlackNot supportedNo math; the LaTeX is shown as typed.

Questions and answers

Does GitHub support math in Markdown?

Yes. GitHub renders $…$ inline, and $$…$$ and ```math blocks as displayed equations, in files, issues and comments.

Why does my formula show as plain text?

The app may not render math; Discord, Slack and plain CommonMark do not. Also check the delimiters: most apps expect $ and $$, not the \( \) and \[ \] that ChatGPT often writes.

How do I paste formulas from ChatGPT?

Turn on "Clean up AI output" in Markdown to Word or Markdown to PDF, which converts \( \) and \[ \] to dollar signs, or replace them yourself.

How do I write a dollar sign without starting a formula?

Escape it with a backslash: \$5. See escaping characters.

Which LaTeX commands work?

Renderers use KaTeX or MathJax, which cover common math: fractions, roots, sums, integrals, Greek letters, matrices and aligned equations. LaTeX packages and document commands are not available.

Can I number equations?

Add \tag{1} inside a displayed equation: $$ E = mc^2 \tag{1} $$. KaTeX and MathJax both support it.

Do formulas survive a Word or LaTeX export?

Markdown to Word turns them into editable Word equations, and Markdown to LaTeX keeps them as LaTeX.

Does Notion support LaTeX?

Yes. Type a formula between double dollar signs, as in $$x^2$$, for an inline equation, or use the /math command for a block equation.