Markdown Equation: Write Math with LaTeX

September 15, 2026 · 7 min read

Markdown Equation: How to Write Math in Markdown

A markdown equation uses LaTeX syntax wrapped in dollar signs to render mathematical formulas inline or as display blocks. Inline math uses single dollars ($E = mc^2$), and display math uses double dollars ($$\sum_{i=1}^{n} x_i$$). This guide covers the syntax, platform support, common formulas, and troubleshooting tips for writing math in markdown.

What Is Math in Markdown?

Markdown itself does not include math syntax in the CommonMark 0.31 specification. Math support comes through extensions that parse LaTeX notation and render it using libraries like KaTeX or MathJax. GitHub added native math rendering in May 2022, making LaTeX equations available in issues, pull requests, discussions, and README files without any plugins.

The rendering pipeline works like this: you write LaTeX inside dollar-sign delimiters, the markdown parser identifies the math block, and a JavaScript library (KaTeX or MathJax) converts it to styled HTML or SVG in the browser. Our editor uses KaTeX for fast client-side rendering in the live preview.

How Do You Write an Equation in Markdown?

There are two types of math expressions in markdown: inline and display.

Inline Math

Inline math appears within a line of text. Wrap your LaTeX in single dollar signs:

The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ where $a \neq 0$.

The formula renders at the same size as the surrounding text and flows naturally within the paragraph.

Display Math (Block Equations)

Display math renders on its own line, centered, and at a larger size. Use double dollar signs on separate lines:

$$
\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
$$

The double-dollar syntax is the most widely supported. GitHub, Obsidian, Jupyter, and our editor all recognize it. Some platforms also support the LaTeX \[ and \] delimiters for display math, but dollar signs work more reliably across tools.

Common Markdown Equations and Formulas

Here are frequently used LaTeX expressions you can paste directly into your markdown:

Basic Operations

$a + b = c$
$a - b = c$
$a \times b = c$
$a \div b = c$
$\frac{a}{b} = c$

Exponents and Roots

$x^2$
$x^{n+1}$
$\sqrt{x}$
$\sqrt[3]{x}$

Greek Letters

$\alpha, \beta, \gamma, \delta, \epsilon$
$\theta, \lambda, \mu, \sigma, \omega$
$\Gamma, \Delta, \Theta, \Lambda, \Omega$

Summation and Products

$$\sum_{i=1}^{n} x_i = x_1 + x_2 + \cdots + x_n$$

$$\prod_{i=1}^{n} x_i = x_1 \cdot x_2 \cdots x_n$$

Matrices

$$
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
$$

Calculus

$$\frac{dy}{dx} = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$

$$\int_{a}^{b} f(x) \, dx$$

Statistics

$$\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i$$

$$\sigma = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (x_i - \bar{x})^2}$$

Platform Support for Markdown Math

Math rendering varies across platforms. Here is what we found in our testing as of April 2026:

PlatformInline $...$Display $$...$$Rendering EngineNotes
GitHubYesYesMathJaxAdded May 2022. Works in issues, PRs, README files
ObsidianYesYesMathJaxFull LaTeX support; TikZ via a community plugin
Jupyter NotebooksYesYesMathJaxNative support in markdown cells
VS Code PreviewYesYesKaTeXBuilt in; toggle with the markdown.math.enabled setting
Our EditorYesYesKaTeXRenders in the live preview and in PDF export
HugoConfigurableConfigurableKaTeX or MathJaxRequires config in hugo.toml
Jekyll (kramdown)No ($$ only)YesMathJaxkramdown parses $$ math; add the MathJax script to your layout
Standard CommonMarkNoNoNoneNo math in the base spec

KaTeX vs MathJax: Which Renderer Is Better?

Two JavaScript libraries dominate math rendering in markdown: KaTeX (by Khan Academy) and MathJax.

KaTeX renders faster. It works synchronously and produces HTML and CSS directly, so pages with many formulas feel noticeably quicker than with MathJax. Our editor uses KaTeX for this reason. The tradeoff is that KaTeX implements a smaller subset of LaTeX than MathJax.

MathJax supports more of LaTeX. If you rely on commands or environments that KaTeX does not implement, MathJax usually covers them. GitHub and Obsidian both use MathJax. MathJax 3.x improved performance significantly over version 2.x, narrowing the speed gap with KaTeX.

For most markdown documents, KaTeX handles everything you need. Switch to MathJax only if you need specialized LaTeX packages or are writing a full academic paper.

Common Mistakes with Markdown Equations

Mistake 1: Spaces inside dollar delimiters on GitHub.

$ x = 5 $    (may not render on GitHub)
$x = 5$      (renders correctly)

GitHub's parser can fail when there are spaces after the opening $ or before the closing $. Remove the spaces.

Mistake 2: Dollar signs in non-math text.

If your document mentions prices like $100 and $50, the parser might interpret these as inline math delimiters. Escape them with a backslash: \$100. On GitHub, the parser is smart enough to ignore single dollar amounts in most cases, but edge cases exist.

Mistake 3: Using wrong backslash count.

LaTeX commands use single backslashes (\frac, \sum), but some markdown contexts require double backslashes for escaping. In JSON content or JavaScript strings, you often need \\frac to produce a single backslash in the output. Test your rendering carefully.

Mistake 4: Forgetting blank lines around display math.

Some text
$$x = 5$$
More text

Some parsers need blank lines before and after $$ blocks. Always add them:

Some text

$$x = 5$$

More text

Try Markdown Math in Our Editor

Our editor supports KaTeX rendering. Type your equations below and see them rendered in the preview panel.

Math Examples

Inline: E=mc2E = mc^2

Display math:

∑i=1ni=n(n+1)2\sum_{i=1}^{n} i = \frac{n(n+1)}{2}

Quadratic formula:

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

Matrix:

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

32 words214 characters15 lines
Markdown

The preview above uses the same KaTeX renderer as the full editor, so what you see here matches the exported output.

Try free today

3 PDF exports/day, no sign-up required. Upgrade anytime for unlimited.

Get started free →

Frequently Asked Questions

Summary

Writing a markdown equation is straightforward once you know the LaTeX basics: $...$ for inline, $$...$$ for display blocks. GitHub, Obsidian, and Jupyter support this natively, while other platforms need KaTeX or MathJax configured. Start with the common formulas listed above and expand as needed. Use our markdown editor with built-in KaTeX support to test your equations, or download them as PDF with formatting preserved. See the markdown cheat sheet for the full syntax reference.

Written by the Markdown Editor Online team. Last updated April 2026.