Math
DocsLit renders LaTeX math with KaTeX when it builds a page. The result is plain HTML and CSS, so there is no math JavaScript in the browser. Math is on by default.
Inline and display math
Wrap a formula in double dollar signs. In a sentence it renders inline:
The Pythagorean theorem is for a right triangle.
A paragraph that contains only a $$ formula renders as display math. So does a $$ block over several lines:
A fenced block with the math language is also display math:
Single dollar signs
A single $ is not a delimiter by default, because prices and shell variables use it. Turn it on if your content needs it:
With that setting, $x_i$ is inline math. Double dollar signs keep working.
Turn math off
Set "math": false in docslit.json, or "math": { "enabled": false }. Then $$ is ordinary text.
Good to know
- KaTeX and its fonts are copied into the build output only when a page uses math.
- Text inside math is never treated as a
{{VARIABLE}}placeholder, so LaTeX with double braces is safe. - A formula KaTeX cannot parse still builds. The page shows the source text with a
katex-errorclass and the parse error as a tooltip.validatedoes not report it, so look at the page. - To show a literal double dollar sign in prose, put it in inline code.