LaTeX Math in Markdown — Live Preview
Write equations with $...$ and $$...$$ and see them typeset as you type. Below the editor: a complete, copy-ready KaTeX cheat sheet.
How to write math in Markdown
Two delimiters cover almost everything: single dollars for math inside a sentence, double dollars for an equation on its own line.
Inline math
The area of a circle is $A = \pi r^2$.
Display math
$$
\int_0^1 x^2\,dx = \frac{1}{3}
$$| Syntax | Use | GitHub | VS Code | Obsidian | This site |
|---|---|---|---|---|---|
| $...$ | Inline math | ||||
| $$...$$ | Display (block) math | ||||
| $`...`$ | Inline math containing Markdown characters | — | — | ||
| ```math … ``` | Display math as a code block | — | — | ||
| \( ... \) \[ ... \] | LaTeX-style delimiters | — | — | — | — |
KaTeX cheat sheet
Every symbol below is rendered by KaTeX — the same engine as the previewer — so if it shows here, it works in your Markdown. Copy a command and paste it between dollar signs.
Greek letters
Capitalize the command for uppercase: \delta → δ, \Delta → Δ. Uppercase letters that look Latin (A, B, E…) are just typed as letters.
\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\upsilon\phi\varphi\chi\psi\omega\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\OmegaBinary operators
\pm\mp\times\div\cdot\ast\star\circ\bullet\oplus\otimes\cap\cup\setminus\wedge\vee\negRelations
\neq\approx\equiv\sim\simeq\cong\propto\leq\geq\ll\gg\subset\supset\subseteq\supseteq\in\notin\ni\perp\parallel\midArrows
\to\gets\rightarrow\leftarrow\Rightarrow\Leftarrow\leftrightarrow\Leftrightarrow\implies\iff\mapsto\longrightarrow\hookrightarrow\uparrow\downarrow\nearrowSums, integrals & calculus
Use _{…} for lower limits and ^{…} for upper limits.
\sum_{i=1}^{n} x_i\prod_{i=1}^{n} a_i\int_{a}^{b} f(x)\,dx\iint_{D} f\,dA\oint_{C} F \cdot dr\lim_{x \to 0} \frac{\sin x}{x}\frac{d}{dx} f(x)f'(x)\frac{\partial f}{\partial x}\nabla f\infty\Delta xFractions, roots & exponents
Group with braces: x^{10} — without them only the first character is raised (x^10 → x¹0).
\frac{a}{b}\dfrac{a}{b}\tfrac{a}{b}\sqrt{x}\sqrt[n]{x}x^{2}x_{i}x_i^{2}e^{i\pi}\binom{n}{k}10^{-3}Accents & decorations
\hat{x}\bar{x}\overline{AB}\vec{v}\dot{x}\ddot{x}\tilde{x}\widehat{xy}\underline{x}\overbrace{a+b}^{n}\underbrace{a+b}_{n}Brackets & delimiters
\left and \right make brackets grow to fit their content.
(x)[x]\{x\}\langle x \rangle|x|\|x\|\lfloor x \rfloor\lceil x \rceil\left( \frac{a}{b} \right)Functions
Use \sin, \log, … so names are upright; \operatorname{name} for your own.
\sin x\cos x\tan x\log x\ln x\exp x\max_{i} a_i\min_{i} a_i\operatorname*{arg\,max}_{x} f(x)\det A\gcd(a, b)Sets & logic
\emptyset\varnothing\mathbb{N}\mathbb{Z}\mathbb{Q}\mathbb{R}\mathbb{C}\forall\exists\nexists\therefore\because\top\botFonts & text
\mathbf{x}\mathit{x}\mathrm{d}x\mathcal{L}\mathfrak{g}\mathsf{A}\mathtt{x}\boldsymbol{\alpha}\text{if } x > 0\color{red}{x}Spacing
Math mode ignores normal spaces; add space explicitly.
a\!ba\,ba;ba\quad ba\qquad bMatrices, cases & alignment
Use these in display math ($$…$$). & separates columns, \\ starts a new row.
\begin{pmatrix} a & b \\ c & d \end{pmatrix}\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\begin{vmatrix} a & b \\ c & d \end{vmatrix}f(x) = \begin{cases} x^2 & x \geq 0 \\ -x & x < 0 \end{cases}\begin{aligned} y &= 2x + 1 \\ y &= -x + 4 \end{aligned}\begin{array}{c|c} x & f(x) \\ \hline 0 & 1 \end{array}Why your equation isn’t rendering
These five mistakes cause most “raw LaTeX” problems in Markdown.
Using \( \) or \[ \] delimiters
\( E = mc^2 \)
$E = mc^2$
Markdown treats the backslash as an escape character, so these never reach the math renderer. Use $ and $$.
Space right inside the dollar signs
$ x^2 + y^2 $
$x^2 + y^2$
Most renderers (including GitHub) require the opening $ to be followed — and the closing $ preceded — by a non-space character.
Missing braces around multi-character exponents
$x^10$
$x^{10}$Without braces only the first character is raised, so x^10 renders as x¹0.
Single backslash for a new matrix row
\begin{pmatrix} a & b \ c & d \end{pmatrix}\begin{pmatrix} a & b \\ c & d \end{pmatrix}Rows are separated by \\ (two backslashes). A single \ is an escape.
Dollar signs in normal text
It costs $5 and $10 per user
It costs \$5 and \$10 per user
Escape literal dollar signs with a backslash when a line might be read as math. On GitHub, use <span>$</span> on lines that also contain an equation.
Works here but not on GitHub? See why GitHub math doesn’t render.
KaTeX vs. MathJax
The two engines behind almost all math on the web.
KaTeX
- Renders synchronously and very fast, no layout jumps
- Supports a large, well-documented subset of LaTeX math
- Used by this site, VS Code’s preview, and many docs tools
MathJax
- Broadest LaTeX coverage, plus MathML and AsciiMath input
- Strong accessibility extensions (speech, exploration)
- Used by GitHub and Obsidian
Frequently asked questions
How do I write math in Markdown?
What is the difference between LaTeX and KaTeX?
Does GitHub support LaTeX math?
Why is my equation showing as raw text?
How do I write a matrix or a piecewise function?
Can I export math to PDF?
More Markdown Tools & Guides
All tools are free, run in your browser, and require no account.
Edit Markdown with a real-time preview, Mermaid, KaTeX math, drag-and-drop files, and one-click export.
Load any public README, test it, and look up any GitHub syntax in the complete cheat sheet.
13 diagram types with examples, live rendering, and SVG/PNG download.
Pick sections, fill in your project, and download a GitHub-ready README.md with badges and a TOC.
Paste ChatGPT, Claude, or Gemini output and read it formatted, with tables, code, and math.
A plain-English introduction: what Markdown and .md files are, where it came from, and where it is used.
Preview .md files in Drive, edit in Docs' Markdown mode, and paste, convert, or export Markdown.
Six free tools tested with the same document: rendering, privacy, and phone support compared.
16 causes found by symptom — tables, lists, image paths, code fences, alerts, Mermaid, math — with tested fixes.
Preview shortcuts, settings verified on VS Code 1.141, built-in Mermaid and math, extensions, and fixes.
Open and read Markdown files formatted on Windows, Mac, Linux, iPhone, Android, Word, and Google Docs.
Exact preview shortcuts for Visual Studio, JetBrains, Zed, Xcode, Sublime, Neovim, Obsidian, and more.
Six free ways to read .md files in Chrome, Edge, Firefox, or Safari — compared for privacy and features.