plugin-katex
Plugin @renovamen/vuepress-plugin-katex@next
for adding KaTeX to VuePress 2 to support mathematical formulas rendering in Markdown. This plugin is based on waylonflinn/markdown-it-katex.
KaTeX is a faster alternative to MathJax (see here).
Install
pnpm install @renovamen/vuepress-plugin-katex@next
yarn add @renovamen/vuepress-plugin-katex@next
npm install @renovamen/vuepress-plugin-katex@next
Then add it to your .vuepress/config.js
:
const { katexPlugin } = require("@renovamen/vuepress-plugin-katex");
module.exports = {
plugins: [
katexPlugin()
]
}
You can also enable it with some KaTeX options:
const { katexPlugin } = require("@renovamen/vuepress-plugin-katex");
module.exports = {
plugins: [
katexPlugin({
"throwOnError": false,
"errorColor": "#cc0000"
})
]
}
Usage
Here is a list of TeX functions supported by KaTeX.
Example:
Inline math:
Display math:
Code
Inline math: E = mc^2
Display math:
$$
i\hbar\frac{\partial \psi}{\partial t} = \frac{-\hbar^2}{2m} ( \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} + \frac{\partial^2}{\partial z^2} ) \psi + V \psi.
$$