Tutorial
How to Write Math Equations in Markdown: A Complete KaTeX Guide
Everything you need to write professional math notation in Markdown — from basic fractions to advanced calculus. Live examples you can copy and paste into any KaTeX-enabled editor.
What is KaTeX Math Notation in Markdown?
KaTeX is a fast, lightweight JavaScript library that renders mathematical notation in web browsers. Originally developed by Khan Academy, KaTeX translates LaTeX-style math commands into beautifully typeset equations without requiring any server-side processing or plugins.
Unlike full LaTeX — which is a complete document preparation system requiring compilation — KaTeX focuses on one thing: rendering math expressions quickly in HTML. While LaTeX might take seconds to compile a document, KaTeX renders individual equations in under a millisecond, making it ideal for live-editing environments like the Prescosoft Markdown Editor.
The syntax for math in Markdown is simple:
- Inline math: Wrap expressions in single dollar signs:
$E = mc^2$renders within a sentence. - Display math: Wrap expressions in double dollar signs on their own line for centered, standalone equations.
Most modern Markdown processors — including GitHub, Obsidian, Notion, and the Prescosoft editor — support KaTeX math notation natively or through plugins.
Basic Math Operations
Start with the fundamentals: arithmetic operators, exponents, subscripts, fractions, and square roots. These building blocks combine to express virtually any mathematical idea.
Arithmetic
Standard operators work as you'd expect. For multiplication and division symbols, use \times and \div:
$$a + b - c = d \times e \div f$$
Renders: $a + b - c = d \times e \div f$
Exponents and Subscripts
Use ^ for superscripts and _ for subscripts. Wrap multi-character expressions in braces:
$$x^{2n+1} + y_{i,j} = z^3_0$$
Renders: $x^{2n+1} + y_{i,j} = z^3_0$
Fractions
The \frac command takes two arguments — numerator and denominator:
$$\frac{a + b}{c - d} + \frac{1}{2}$$
Renders: $$\frac{a + b}{c - d} + \frac{1}{2}$$
Square Roots
Use \sqrt for square roots, and \sqrt[n] for nth roots:
$$\sqrt{x^2 + y^2} \quad \sqrt[3]{27} = 3$$
Renders: $$\sqrt{x^2 + y^2} \quad \sqrt[3]{27} = 3$$
Try it now: Write math equations in Markdown
Prescosoft Markdown Editor renders KaTeX math instantly in your browser. No signup, no uploads, no account required.
Launch Markdown EditorGreek Letters and Mathematical Symbols
Greek Alphabet
Greek letters are essential in physics, engineering, statistics, and pure mathematics. Each letter has a lowercase and uppercase version. Capitalize the command name for uppercase variants:
| Letter | Code | Letter | Code |
|---|---|---|---|
| $\alpha$ | \alpha | $\nu$ | \nu |
| $\beta$ | \beta | $\xi$ | \xi |
| $\gamma$ | \gamma | $\pi$ | \pi |
| $\delta$ | \delta | $\rho$ | \rho |
| $\epsilon$ | \epsilon | $\sigma$ | \sigma |
| $\zeta$ | \zeta | $\tau$ | \tau |
| $\eta$ | \eta | $\phi$ | \phi |
| $\theta$ | \theta | $\chi$ | \chi |
| $\iota$ | \iota | $\psi$ | \psi |
| $\kappa$ | \kappa | $\omega$ | \omega |
Uppercase variants use capitalized names: \Gamma ($\Gamma$), \Delta ($\Delta$), \Sigma ($\Sigma$), \Omega ($\Omega$).
Mathematical Operators
Large operators like summation, product, integral, and limit accept bounds using subscript and superscript notation:
| Operator | Code | Example |
|---|---|---|
| $\sum$ | \sum | $\sum_{i=1}^{n} i^2$ |
| $\prod$ | \prod | $\prod_{k=1}^{n} k$ |
| $\int$ | \int | $\int_0^\infty e^{-x} dx$ |
| $\lim$ | \lim | $\lim_{x \to 0} \frac{\sin x}{x}$ |
For display mode, these operators render with limits above and below instead of as subscripts, creating the classic textbook appearance. See Advanced GitHub Flavored Markdown for more on display mode options.
Advanced Math Notation
Matrices and Arrays
Matrices use environment names that specify the type of bracket. Separate columns with & and rows with \\:
Parentheses (pmatrix):
$$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$$
Renders: $$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$$
Square brackets (bmatrix):
$$\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}$$
Renders: $$\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}$$
Vertical bars / determinant (vmatrix):
$$\begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc$$
Renders: $$\begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc$$
Calculus Notation
KaTeX supports the full range of calculus notation — derivatives, partial derivatives, single and multiple integrals:
Derivatives:
$$\frac{dy}{dx} = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$
Renders: $$\frac{dy}{dx} = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$
Partial derivatives:
$$\frac{\partial f}{\partial x} + \frac{\partial f}{\partial y} = 0$$
Renders: $$\frac{\partial f}{\partial x} + \frac{\partial f}{\partial y} = 0$$
Definite integrals:
$$\int_a^b f(x)\, dx = F(b) - F(a)$$
Renders: $$\int_a^b f(x)\, dx = F(b) - F(a)$$
Double integrals:
$$\iint_D f(x,y)\, dA = \int_a^b \int_{g(x)}^{h(x)} f(x,y)\, dy\, dx$$
Renders: $$\iint_D f(x,y)\, dA = \int_a^b \int_{g(x)}^{h(x)} f(x,y)\, dy\, dx$$
Common Academic Formulas
These frequently-used formulas appear across mathematics, physics, and engineering. Each is written in KaTeX notation you can copy directly into your Markdown documents:
Quadratic Formula:
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
Renders: $$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
Pythagorean Theorem:
$$a^2 + b^2 = c^2$$
Renders: $$a^2 + b^2 = c^2$$
Euler's Identity:
$$e^{i\pi} + 1 = 0$$
Renders: $$e^{i\pi} + 1 = 0$$
Binomial Theorem:
$$(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k$$
Renders: $$(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k$$
These examples demonstrate that even complex academic formulas can be expressed clearly with KaTeX. For additional formatting techniques like tables and task lists, check out our guide on Advanced GitHub Flavored Markdown.
How to Use Math in Markdown Documents
Inline Math in Paragraphs
Inline math flows naturally within a sentence. Use single dollar signs around short expressions that you reference in passing. For example, you might write "the area of a circle is $A = \pi r^2$" directly in your paragraph text. Keep inline expressions brief — if an equation is complex, promote it to display mode instead.
Display Math for Standalone Equations
Display math gets its own line, centered on the page, with larger symbols and properly-positioned limits. Use double dollar signs on separate lines. This is ideal for equations you want to emphasize, reference, or discuss. Display mode also renders fractions at full size rather than the compressed inline version.
Mixing Math with Regular Text
Effective mathematical writing alternates between prose and notation. Introduce a concept in plain language, then formalize it with an equation. For example: "By the chain rule, the derivative of a composite function is the product of the derivatives." Then show: $$\frac{d}{dx}[f(g(x))] = f'(g(x)) \cdot g'(x)$$
This pattern — explain in words, then show in symbols — makes your writing accessible to readers at different levels of mathematical sophistication.
Best Practices for Readability
- Add spacing: Use
\,or\quadto add space in expressions like\int f(x)\, dx - Number important equations: Use
\tag{1}at the end of display math to label equations for cross-reference - Align multi-line equations: Use the
alignedenvironment to line up equals signs across multiple lines - Preview as you write: Always use a live-rendering editor like the Prescosoft Markdown Editor to verify your equations render correctly before publishing
- Keep source readable: Add spaces around operators in your source code for easier editing, even though KaTeX ignores extra whitespace
Whether you're writing homework solutions, research papers, or technical blog posts, mastering math notation in Markdown saves time and produces publication-quality output. The Prescosoft Markdown Editor makes this process seamless with instant KaTeX rendering, export to HTML, and a distraction-free writing environment. If you want to explore more advanced Markdown features beyond math, our Advanced GFM guide covers tables, task lists, and footnotes.
Try it now: Write math equations in Markdown
Prescosoft Markdown Editor renders KaTeX math instantly in your browser. No signup, no uploads, no account required.
Launch Markdown EditorFrequently Asked Questions
How do I render math in Markdown?
Use dollar signs to delimit math expressions in Markdown. Single dollar signs ($) wrap inline math like $E = mc^2$, while double dollar signs ($$) create standalone display equations. You also need a rendering engine like KaTeX or MathJax. The Prescosoft Markdown Editor includes built-in KaTeX rendering so your equations display instantly as you type.
What's the difference between inline and display math?
Inline math (wrapped in single $) appears within a paragraph of text, sized to match the surrounding font. Display math (wrapped in $$) appears on its own line, centered, and uses larger symbols with full-size fractions and summation limits. Use inline for brief references like variables or short formulas, and display math for important equations that deserve visual emphasis.
Can I use LaTeX notation in Markdown?
Yes, partially. Markdown math renderers like KaTeX support a large subset of LaTeX math commands including fractions, integrals, Greek letters, matrices, and alignment environments. However, some advanced LaTeX features like custom macros, certain packages, and complex TikZ diagrams are not supported. For most academic and scientific notation, KaTeX covers everything you need.
How do I write fractions in Markdown math?
Use the \frac command with two arguments: \frac{numerator}{denominator}. For example, \frac{1}{2} produces a half fraction, and \frac{x^2 + 1}{x - 3} creates a complex rational expression. Fractions can be nested inside other fractions for continued fractions or compound expressions.
Does KaTeX support all LaTeX features?
No. KaTeX supports approximately 80–90% of commonly used LaTeX math commands, prioritizing speed over completeness. It covers most mathematical notation needed in academic writing: fractions, integrals, matrices, aligned equations, Greek letters, and operators. What it does not support includes full document formatting, bibliography management, TikZ graphics, and some obscure math packages. For web-based math rendering, KaTeX is faster than MathJax while covering the vast majority of use cases.
How do I preview math equations while writing?
Use a Markdown editor with built-in math rendering like the Prescosoft Markdown Editor. It renders KaTeX equations in real-time as you type, with a split-pane view showing your source code on the left and the rendered output on the right. This lets you catch syntax errors immediately and verify your equations look correct before exporting your document.
Related Guides
Advanced GitHub Flavored Markdown: Tables, Task Lists & More
Go beyond basic Markdown with GFM extensions — tables, strikethrough, footnotes, and syntax-highlighted code blocks.
Prescosoft Markdown Editor — Free Browser-Based Tool
Write, preview, and export Markdown with live KaTeX math rendering. No account required.