Skip to main content

TeX

Less than 1 minuteMarkdownMarkdownTEX

Let the Markdown file in your VuePress site support the TEX syntax.

Settings

Install related TEX package katexopen in new window or mathjax-fullopen in new window in your project:

pnpm
pnpm add -D katex
# or
pnpm add -D mathjax-full

Then enabling via:

TS
import { defineUserConfig } from "vuepress";
import { hopeTheme } from "vuepress-theme-hope";

export default defineUserConfig({
  theme: hopeTheme({
    plugins: {
      mdEnhance: {
        // 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

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.

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

Inline

Euler's identity eiπ+1=0 is a beautiful formula in R2.

Euler's identity $e^{i\pi}+1=0$ is a beautiful formula in $\mathbb{R}^2$.
Display
rωr(yωω)=(yωω){(logy)r+i=1r(1)Ir(ri+1)(logy)riωi}
$$
\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

rωr(yωω)=(yωω){(logy)r+i=1r(1)Ir(ri+1)(logy)riωi}\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\}

Support List

Plugin tutorial and FAQs: Texopen in new window

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 Docsopen in new window for available options.

Also, 2 special options are supported:

  • copy: enable copy extension by setting it to true.
  • mhchem: enable mhchem extension by setting it to true.

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.

Tex Tutorial