hexo+butterfly使用数学公式katex

1.更换插件

1
2
3
4
npm un hexo-renderer-marked --save # 卸载 marked 插件
npm un hexo-renderer-kramed --save # 卸载 kramed 插件
npm i hexo-renderer-markdown-it --save # 安装渲染插件
npm install @neilsustc/markdown-it-katex --save # 安装katex插件

2.butterfly配置启动latex插件

1
2
3
4
5
6
7
# Math (數學)

# KaTeX
katex:
enable: true
per_page: false
hide_scrollbar: true

3.博客yml配置中增加

1
2
3
4
5
6
markdown:
plugins:
- plugin:
name: '@neilsustc/markdown-it-katex'
options:
strict: false

4.博客页面配置开启latex

1
2
3
4
5
6
7
8
9
---
title: bert详解
date: 2025-04-13 14:51:21
katex: true
category:
- ai
tag:
- ai
---

5.letex语法如下:

1
$concurrency = cost_\text{avg} \times qps \quad (1)$
1
2
3
4
5
6
7
8
9
$$
\begin{equation}
\mathcal{F} = \begin{cases}
\infty & \text{if } \mathcal{M}_{measure} < \alpha \times \mathcal{M}_{expect} \\
\mathcal{M}_\text{expect} / \mathcal{M}_\text{measure} & \text{if } \alpha \times \mathcal{M}_{expect} < \mathcal{M}_{measure} < \mathcal{M}_{expect} \\
\sqrt{\frac{\mathcal{M}_{expect}}{\mathcal{M}_{measure}}} & \text{if } \mathcal{M}_{measure} \ge \mathcal{M}_{expect}
\end{cases}
\end{equation}
$$