Skip to content

Math

MDLeaf renders LaTeX math with KaTeX.

  • Inline math: $E = mc^2$. The opening $ must not be followed by a space and the closing $ must not be followed by a digit, so prices such as $5 and $10 stay text.
  • Display math: $$ on its own line, the formula, and $$ on its own line. A one-line $$x^2$$ also works.
math-and-footnotes/document.md
# Math and footnotes
The area of a circle is $A = \pi r^2$.[^1]
$$
\int_0^1 x^2\,dx = \frac{1}{3}
$$
Euler's identity, $e^{i\pi} + 1 = 0$, links five constants.[^euler]
[^1]: For a circle of radius $r$.
[^euler]: Named after Leonhard Euler.
Inline and display math with KaTeX, and footnotes collected as endnotes.
Download sample (.mdl)

Open it in MDLeaf with Library → Import .mdl. If MDLeaf is installed, you can also open the file directly.

KaTeX supports most of LaTeX math mode but not every package. Invalid math is shown as red error text and reported in the problems panel as math-error with KaTeX’s message. Commands that would load external resources (\href, \url, \includegraphics) are not allowed.

Display formulas are never split across pages. If one is taller than a page, MDLeaf warns about it.