← All articles
Math · Markdown extension

How to Write LaTeX Math in Markdown

Use readable Markdown for the document and LaTeX-style commands for the equations—from a variable in a sentence to matrices and integrals.

12 min read·Updated July 17, 2026

In a Markdown renderer with math support, write inline math between single dollar signs, such as $E = mc^2$, and display math between double dollar signs, such as $$\frac{-b \pm \sqrt{b^2-4ac}}{2a}$$.

Important compatibility note

LaTeX math is not part of core Markdown or CommonMark. It is an extension. GitHub, Hashdraft, Jupyter, Obsidian, Pandoc, and static-site systems support overlapping—but not identical—delimiters and command sets.

Inline math with single dollar signs

Inline math stays inside a paragraph. Use it for variables, short expressions, units, and equations that belong grammatically to the sentence.

The mass–energy relation is $E = mc^2$.

For a right triangle, $a^2 + b^2 = c^2$.

Keep inline expressions compact. A fraction with several nested terms or an equation with limits is usually easier to read as a display block.

Display math with double dollar signs

Display math sits on its own line and is normally centered or otherwise separated from prose:

$$
\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$

Putting the opening and closing delimiters on separate lines makes the source easier to scan and works well for multi-line expressions. Some renderers also accept both delimiters and the equation on one line.

GitHub's fenced math block

GitHub supports a code fence labeled math as an alternative to double dollar signs:

```math
\left(\sum_{k=1}^{n} a_k b_k\right)^2
\leq
\left(\sum_{k=1}^{n} a_k^2\right)
\left(\sum_{k=1}^{n} b_k^2\right)
```

This syntax is not universal. Use $$ when your chosen renderer and destination both support it, or configure a publishing pipeline explicitly.

Essential LaTeX math commands

PurposeSourceMeaning
Superscriptx^2x squared
Subscriptx_ix sub i
Grouped scriptx_{n+1}multi-character subscript
Fraction\frac{a}{b}a divided by b
Square root\sqrt{x}square root of x
nth root\sqrt[n]{x}nth root of x
Sum\sum_{i=1}^{n} isum with limits
Integral\int_0^1 x^2\,dxdefinite integral
Greek letter\alpha, \beta, \piα, β, π
Comparison\leq, \geq, \neq≤, ≥, ≠
Infinity\infty
Vector\mathbf{v}bold vector v

Braces, spacing, and scalable delimiters

LaTeX commands often apply only to the next character. Use braces to group a longer expression:

x^10      % usually means x¹ followed by 0
x^{10}    % x raised to the tenth power

a_n+1     % a sub n, then plus one
a_{n+1}   % a sub (n plus one)

In math mode, spaces in the source are mostly ignored. Add deliberate spacing with commands such as \,, \;, or \quad when the renderer supports them:

\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}

Use \left and \right when parentheses or brackets need to grow around a tall fraction:

\left( \frac{a+b}{c+d} \right)

Fractions, roots, sums, and integrals

Fractions

$\frac{1}{2}$

$$
\frac{x^2 + 2x + 1}{x + 1}
$$

Roots

$\sqrt{2}$
$\sqrt[3]{8} = 2$

Sums and products

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

$$
\prod_{k=1}^{n} k = n!
$$

Integrals

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

Greek letters and common symbols

Write the command name after a backslash. Capitalization matters: \delta and \Delta produce different symbols.

SourceSymbolSourceSymbol
\alphaα\GammaΓ
\betaβ\DeltaΔ
\thetaθ\ThetaΘ
\lambdaλ\LambdaΛ
\piπ\PiΠ
\omegaω\OmegaΩ

Matrices

Matrix syntax uses an environment. Separate columns with & and rows with \\:

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

pmatrix uses parentheses, bmatrix uses square brackets, and vmatrix uses vertical bars in engines that implement those environments.

Math inside other Markdown elements

Many renderers allow inline math in headings, lists, tables, blockquotes, emphasis, and links. Code spans and code fences should preserve dollar signs literally:

- Wavelength: $\lambda = \frac{c}{f}$
- Area: $A = \pi r^2$

| Identity | Formula |
|---|---|
| Euler | $e^{i\pi} + 1 = 0$ |

`$E = mc^2$` stays code, not math.

Complex equations inside tables often make columns too wide. Prefer a short inline expression in the table and put the derivation below.

Dollar signs in normal prose

Dollar-delimited math can conflict with currency. A good parser avoids treating ordinary prices as equations, but edge cases differ. Escape a literal dollar sign where necessary:

The upgrade costs \$10.
The result is $x = 10$.

GitHub documents additional delimiter forms for expressions that overlap with Markdown punctuation. If a document targets one platform, follow that platform's exact rules.

Render LaTeX math in Hashdraft

Hashdraft supports inline $…$ and display $$…$$ math, rendered locally. Math rendering can be enabled or disabled in Settings. Equations work inside common document structures such as lists, tables, quotes, and headings.

Hashdraft provides a practical LaTeX math subset rather than a complete TeX distribution. If a command is malformed or unsupported, keep the expression small, check braces and environment names, and test it in the final publishing system.

Why LaTeX math is not rendering

  1. Confirm the renderer supports math. Standard Markdown alone does not.
  2. Check the setting. Some apps disable math or raw extensions by default.
  3. Balance every brace. Count opening and closing {}, especially inside fractions and scripts.
  4. Check delimiters. Do not mix a single opening dollar with a double closing delimiter.
  5. Keep code out of math. A fenced latex block displays source; it does not necessarily typeset it.
  6. Test supported environments. Full LaTeX packages and custom macros may not exist in a lightweight renderer.
  7. Simplify the expression. Reduce it until it renders, then restore one command at a time.

Frequently asked questions

Is LaTeX math part of Markdown?

No. It is a widely adopted extension, so portability depends on the renderer.

Should I use $…$ or \(…\)?

Use the delimiters documented by your destination. Dollar signs are common in Markdown apps; escaped parentheses are common in MathJax configurations but are not universally recognized by Markdown parsers.

Can I export Markdown equations to PDF?

Yes, when the PDF pipeline supports the math syntax. Hashdraft renders its supported equations before PDF export; Pandoc can route math through several publishing engines.

Can I use full LaTeX packages in Markdown?

Usually not. Markdown math renderers typically implement mathematical commands, not the complete LaTeX document and package system.

Typeset math locally

Write the equation and see it rendered beside you

Hashdraft displays inline and block LaTeX math in Preview and Split mode without a browser or cloud service.

Download Hashdraft ↓Windows · free & open source