Skip to Content
Vuesho

Math

Write math in TeX, rendered with KaTeX.

To write math in TeX and render it with KaTeX, add the markdown-it plugin @mdit/plugin-katex.

Setup

Install KaTeX

npm i @mdit/plugin-katex katex

Add the Plugin

vuesho.config.ts
import { katex } from "@mdit/plugin-katex"; 

createSite(docs.toSource()).config({
  markdown: { markdownItPlugins: [katex] }, 
});

Add the Stylesheet

src/theme.ts
import "katex/dist/katex.css"; 
import { defineTheme } from "vuesho/theme";
import defaultTheme from "vuesho/theme/default";

export default defineTheme({ extends: defaultTheme });

Usage

Wrap inline math in $, and a block in $$:

content/circle.md
The area of a circle is $\pi r^2$.

$$
c = \pm\sqrt{a^2 + b^2}
$$

With Type Checking, list the plugin in the vuesho/type-check options, so TeX braces aren't parsed as Vue.