plugin-katex

Gungnir
2020-03-26
3 min

npm github license

Plugin @renovamen/vuepress-plugin-katex for adding KaTeX to VuePress 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

yarn add @renovamen/vuepress-plugin-katex
# or
npm install @renovamen/vuepress-plugin-katex

Then add it to your .vuepress/config.js:

module.exports = {
  plugins: [
    [
      '@renovamen/vuepress-plugin-katex'
    ]
  ]
}

You can alsp enable it with some KaTeX options:

module.exports = {
  plugins: [
    [
      '@renovamen/vuepress-plugin-katex', {
        'throwOnError': false,
        'errorColor': '#cc0000'
      }
    ]
  ]
}

# Usage

Here is a list of TeX functions supported by KaTeX.

Example:

Inline math: E = mc^2

Display math:

iψt=22m(2x2+2y2+2z2)ψ+Vψ.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.

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.
$$

# License

MIT