Skip to content
数学公式

数学公式

发表于 更新于
作者 廿四2 min 阅读

让你的 VitePress 站点中的 Markdown 文件支持 TEX 语法。

配置

在项目中安装相关的 TEXmarkdown-it-mathjax3:

bash
$ pnpm add -D markdown-it-mathjax3
bash
$ npm add -D markdown-it-mathjax3
bash
$ yarn add -D markdown-it-mathjax3
bash
$ bun add -D markdown-it-mathjax3

之后启用它:

.vitepress/config.ts
ts
import { defineConfig } from 'vitepress-theme-niansi'

export default defineConfig({
  markdown: {
    math: true,
  }
})

案例

输入

When a0, there are two solutions to (ax2+bx+c=0) and they are

x=b±b24ac2a
Demo
md
When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$

更新日志

2026-04-18 23:33
查看所有更新日志