TeX
Let the Markdown file in your VuePress site support the
Settings
Install related
pnpm add -D katex
# or
pnpm add -D mathjax-full
yarn add -D katex
# or
yarn add -D mathjax-full
npm i -D katex
# or
npm i -D mathjax-full
Then enabling via:
// .vuepress/config.ts
import { mdEnhancePlugin } from "vuepress-plugin-md-enhance";
export default {
plugins: [
mdEnhancePlugin({
// Enable Tex Support using katex
katex: true,
// Enable Tex Support using mathjax
mathjax: true,
}),
],
};
// .vuepress/config.js
import { mdEnhancePlugin } from "vuepress-plugin-md-enhance";
export default {
plugins: [
mdEnhancePlugin({
// Enable Tex Support using katex
katex: true,
// Enable Tex Support using mathjax
mathjax: true,
}),
],
};
You can only enable ONE of them, and katex has a higher priority.
Syntax
Inline mode:
$xxx$
Display mode:
$$xxx$$ $$ xxx $$
Escaping can be done by using \
before the $
character, or adding space both before and after the $
character.
The
Escaping can be done by using `\` before the `$` character, or adding space both before and after the `$` character.
The $a=1$ is a TeX equation, while $ a=1 $ and \$a=1$ is not.
Demo
Euler's identity
Euler's identity $e^{i\pi}+1=0$ is a beautiful formula in $\mathbb{R}^2$.
$$
\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right)
= \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^ Ir \cdots (r-i+1) (\log y)^{ri}} {\omega^i} \right\}
$$
Playground
Input
Output
Support List
Katex:
Mathjax:
Advanced
KaTeX
When using KaTeX, you can pass an object to katex
as KatexOptions
. It will be passed to KaTeX. Please see KaTeX Docs for available options.
Also, 2 special options are supported:
copy
: enable copy extension by setting it totrue
.mhchem
: enable mhchem extension by setting it totrue
.
Mathjax
When using mathjax, you can pass an object to mathjax
.
You can set output
option to either svg
(default) or chtml
to change between SVG and HTML output.
Also, you can set tex
option which is passed to TeX input parser, and you can set chtml
or svg
option based on your output syntax which is passed to Common HTML output parser and SVG output parser.