# Math

Write math in TeX, rendered with KaTeX.

To write math in TeX and render it with [KaTeX](https://katex.org), add the [markdown-it plugin](/markdown#markdown-it-plugins) `@mdit/plugin-katex`.

## Setup [#setup]

### Install KaTeX [#install-katex-step]

```npm
npm i @mdit/plugin-katex katex
```

### Add the Plugin [#add-the-plugin-step]

```ts title="vuesho.config.ts"
import { katex } from "@mdit/plugin-katex"; // [!code ++]

createSite(docs.toSource()).config({
  markdown: { markdownItPlugins: [katex] }, // [!code ++]
});
```

### Add the Stylesheet [#add-the-stylesheet-step]

```ts title="src/theme.ts"
import "katex/dist/katex.css"; // [!code ++]
import { defineTheme } from "vuesho/theme";
import defaultTheme from "vuesho/theme/default";

export default defineTheme({ extends: defaultTheme });
```

## Usage [#usage]

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

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

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

With [Type Checking](/markdown/type-checking#custom-syntax), list the plugin in the `vuesho/type-check` options, so TeX braces aren't parsed as Vue.
