The Complete Guide to KaTeX Math in Markdown: Inline, Blocks & Formulas

Rahul Tungariya · Nov 4, 2026 · 6 min read

Master mathematical typesetting in Markdown. Learn LaTeX syntax for equations, matrices, integrals, and avoid common currency symbol parsing traps.

# The Complete Guide to KaTeX Math in Markdown

Mathematical documentation is critical for machine learning researchers, physicists, computer science students, and engineers. While traditional LaTeX tools are heavy and slow, **KaTeX** brings sub-millisecond mathematical typesetting directly to modern Markdown editors.

## 1. Inline vs Display Math

In standard LaTeX notation within WriterMD: - **Inline equations** use single dollar signs: `$E = mc^2$` renders as $E = mc^2$. - **Display math blocks** use double dollar signs: ```latex $$ \int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi} $$ ```

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

## 2. The Currency Symbol Trap ($50 and $100)

Many standard markdown parsers fail when writers discuss money: > *"The subscription costs $20 for students and $50 for professionals."*

Naïve parsers assume `$20 for students and $` is an inline LaTeX equation! WriterMD's custom tokenizer isolates numerical currency mentions using lookahead regex, ensuring financial text remains pure text while mathematical expressions render perfectly.

## 3. Essential Formula Reference

### Fractions and Square Roots ```latex $$ f(x) = \frac{a + b}{\sqrt{c^2 + d^2}} $$ ```

$$ f(x) = \frac{a + b}{\sqrt{c^2 + d^2}} $$

### Sums, Products & Limits ```latex $$ \sum_{k=1}^{n} k = \frac{n(n+1)}{2}, \quad \lim_{x \to 0} \frac{\sin(x)}{x} = 1 $$ ```