Skip to content
All Markdown syntax

Math equations in Markdown

Tables and code

Markdown syntax

Some tools only
$E = mc^2$

Inline math with single dollar signs.

Math is not part of CommonMark, but GitHub, GitLab, Jupyter, Obsidian, Typora and most documentation tools render LaTeX between dollar signs with KaTeX or MathJax. The commands are the same as in LaTeX.

All ways to write it

  • $E = mc^2$
    Inline math with single dollar signs.Some tools only
  • $$
    \sum_{i=1}^{n} i = \frac{n(n+1)}{2}
    $$
    Display math on its own lines.Some tools only
  • ```math
    \sqrt{2}
    ```
    GitHub also accepts a math code fence.Some tools only

Example

You type

The area is $A = \pi r^2$.

$$
\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}
$$

Renders the formula inline in the sentence, then the integral centered on its own line.

Questions

Where do I find the LaTeX command for a symbol?

The LaTeX symbol reference lists each one with its command and whether KaTeX renders it.

Why is my dollar sign turning into math?

Escape it as \$ when you mean a price, especially when a line has two dollar amounts.

Math (LaTeX) in Confluence

Markdown Macro+ renders $...$ inline and $$...$$ block math with KaTeX. For equations outside a Markdown macro, LaTeX Math for Confluence adds inline and block math macros. Look up commands in the LaTeX symbol reference.

Related syntax

Also in Tables and code

See all Markdown syntax