Lllm2doc
Math · 8 min read · Updated April 2026

LaTeX math in markdown

Two delimiters, one mental model. Here’s the syntax that works, the symbols you’ll actually use, and how each export format treats your equations.

Key facts
  • Renderer: KaTeX 0.16.45 in HTML and PDF; Pandoc --mathml → native Office Math (OMML) in DOCX.
  • Inline syntax: $E = mc^2$ — single dollar signs, same line as text.
  • Block syntax: $$E = mc^2$$ — double dollar signs, centered, full display size.
  • DOCX equations: Translated to OMML via Pandoc’s --mathml flag. Fully editable in Microsoft Word, Google Docs, and LibreOffice.
  • PDF equations: Rendered via SVG <foreignObject> — fixes the html2canvas fraction-bar-on-numerator bug present in earlier builds.
  • ChatGPT compatibility: ( x = 1 ) and [ x = 1 ] auto-rewritten to standard delimiters when content looks like LaTeX (contains \\, ^, or _).
Inline

$ ... $

Single dollar signs around an expression render it inline with surrounding text — same line, same baseline. Use sparingly: complex fractions look cramped at body-text size.

  • $E = mc^2$Mass–energy equivalence
  • $\alpha + \beta = \gamma$Greek letters
  • $P(A \mid B) = \dfrac{P(B \mid A) P(A)}{P(B)}$Bayes — display fraction inline
  • $x_i^2 + y_i^2 = r^2$Subscripts and superscripts
Block

$$ ... $$

Double dollar signs put the equation on its own centered line at full display size. Use for anything bigger than a single fraction or summation.

  • Definite integral$$\int_{-\infty}^{\infty} e^{-x^2}\, dx = \sqrt{\pi}$$
  • Sum$$\sum_{n=1}^{N} n = \frac{N(N+1)}{2}$$
  • Matrix$$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$$
  • Schrödinger equation$$i\hbar\,\frac{\partial}{\partial t}\Psi = \hat{H}\,\Psi$$

Symbol cheatsheet

The 80% — what you’ll reach for in everyday scientific writing.

Greek

  • \alpha
  • \beta
  • \gamma
  • \Delta
  • \theta
  • \lambda
  • \mu
  • \pi
  • \sigma
  • \Omega

Operators

  • \sum
  • \prod
  • \int
  • \oint
  • \lim
  • \infty
  • \partial
  • \nabla

Relations

  • \leq
  • \geq
  • \approx
  • \neq
  • \equiv
  • \sim
  • \propto
  • \in
  • \notin

Arrows

  • \to
  • \rightarrow
  • \Rightarrow
  • \leftrightarrow
  • \mapsto
  • \implies

Brackets

  • \left( ... \right)
  • \lvert x \rvert
  • \lVert v \rVert
  • \langle a, b \rangle

Fractions / roots

  • \frac{a}{b}
  • \dfrac{a}{b}
  • \sqrt{x}
  • \sqrt[n]{x}
  • x^{n}
  • x_{i}

What each format does with your equations

Ready

HTML / Preview

Rendered with KaTeX. Equations are CSS-styled spans — searchable, selectable, and copy-paste back as LaTeX source via KaTeX's MathML output.

Ready

DOCX (Word)

Equations translate to native Office Math (OMML). Word treats them as real equation objects — click into one and edit any term. Compatible with Word, Google Docs, and LibreOffice.

Recently fixed

PDF

Rendered via KaTeX, then rasterized via SVG <foreignObject> so fraction bars land in the right place. (Earlier builds mis-positioned the bar onto the numerator — that's fixed.)

Common gotchas

  • ChatGPT’s parenthesis math. ChatGPT sometimes wraps inline math in ( ... )and block math in [ ... ] instead of dollar signs. The converter’s preprocessor catches and rewrites the most common cases — but if math doesn’t render, search-and-replace those delimiters.
  • Backslash escaping inside backticks. If you wrap a LaTeX snippet in inline code (`$x$`), it renders as text, not math. Use math delimiters when you want it rendered.
  • Underscores in identifiers. Underscore is the subscript operator. $x_max$ only subscripts the m — wrap the subscript in braces: $x_{max}$.
  • Inline display fractions. Use \dfrac (display-frac) instead of \frac when you want a full-size fraction in inline math. Otherwise it shrinks to fit the line height.

Try the formulas example

The homepage has a one-click Formulas example loader — pre-loaded with the cases on this page so you can see them render and export.

Open the converter