Skip to content

Commit b97449f

Browse files
committed
更新 LaTaX 文档
1 parent 4fbd6e1 commit b97449f

File tree

2 files changed

+49
-84
lines changed

2 files changed

+49
-84
lines changed

docs/en/guide/README.md

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,27 @@ if `specific`: true,you should add `math: true` into [Front-matter](https://he
829829

830830
Because the default engine of hexo doesn't support math typesetting, it should be changed by other better engine.
831831

832-
Uninstall the former engine:
833-
834-
`npm uninstall hexo-renderer-marked --save`
835-
836-
Then change your engine, such as:
837-
838-
mathjax: `npm install hexo-renderer-pandoc --save` **also need to [install Pandoc](https://github.com/jgm/pandoc/blob/master/INSTALL.md)**
832+
:::tip mathjax
833+
```bash
834+
npm uninstall hexo-renderer-marked --save
835+
npm install hexo-renderer-pandoc --save
836+
```
837+
**Also need to [install Pandoc](https://github.com/jgm/pandoc/blob/master/INSTALL.md)**
838+
:::
839839

840-
katex: `npm install @upupming/hexo-renderer-markdown-it-plus --save`
840+
:::tip katex
841+
```bash
842+
npm uninstall hexo-renderer-marked --save
843+
npm install hexo-renderer-markdown-it --save
844+
npm install @traptitech/markdown-it-katex --save
845+
```
846+
Then append to **blog config**:
847+
```yaml
848+
markdown:
849+
plugins:
850+
- "@traptitech/markdown-it-katex"
851+
```
852+
:::
841853

842854
**3. After installing, run `hexo clean`**
843855

@@ -850,41 +862,9 @@ $$
850862
```
851863

852864
:::warning
853-
854-
You can't install more than one renderer, and can't install plugins such as `hexo-math` or `hexo-katex`.
855-
856-
If your typesetting can't display correctly, you can check the below steps.
857-
858-
The custom page doesn't load math by default, you need to specify `math: true` into [Front-matter](https://hexo.io/docs/front-matter) to ues it.
859-
860-
:::
861-
862-
863-
:::tip
864-
865-
Different formula engines have different advantages and disadvantages.
866-
867-
**MathJax**
868-
869-
Advantages:
870-
871-
- full support for LaTeX syntax.
872-
- right-click formula has extended function.
873-
874-
Shortcomings:
875-
876-
- need to load JS, pages will be slow to load, and there will be rendering changes.
877-
- the kramed renderer does not support the escape character `\` of inline formulas.
878-
879-
**Katex**
880-
881-
Advantages:
882-
883-
- No JS will not affect page loading.
884-
- the renderer works well (relative to kramed's inline formula for MathJax).
885-
Shortcomings.
886-
- A small part of LaTeX do not support it.
887-
865+
- You can't install more than one renderer, and can't install plugins such as `hexo-math` or `hexo-katex`.
866+
- If your typesetting can't display correctly, you can check the below steps.
867+
- The custom page doesn't load math by default, you need to specify `math: true` into [Front-matter](https://hexo.io/docs/front-matter) to ues it.
888868
:::
889869

890870
<InArticleAdsense :data-ad-client=$themeConfig.ads.client :data-ad-slot=$themeConfig.ads.inSlot is-new-ads-code="yes"></InArticleAdsense>

docs/guide/README.md

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ n1-n2-...:每行的图片数量,可以省略,默认单行最多 3 张图
902902
### LaTeX 数学公式
903903

904904
:::tip
905-
Hexo 5.0 以上,可尝试 Hexo 官方的 [hexo-math](https://github.com/hexojs/hexo-math) 插件,支持更多定制化参数,使用方式参照仓库内的文档,以下介绍的是主题内置的 LaTeX 功能。
905+
Hexo 5.0 以上,可尝试 Hexo 官方的 [hexo-math](https://github.com/hexojs/hexo-math) 插件,支持更多定制化参数,使用方式参照链接内的文档,以下介绍的是主题内置的 LaTeX 功能。
906906
:::
907907

908908
当需要使用 [LaTeX](https://www.latex-project.org/help/documentation/) 语法的数学公式时,可手动开启本功能,需要完成三步操作:
@@ -925,15 +925,29 @@ post:
925925

926926
由于 Hexo 默认的 Markdown 渲染器不支持复杂公式,所以需要更换渲染器(mathjax 可选择性更换)。
927927

928-
先卸载原有渲染器:
929-
930-
`npm uninstall hexo-renderer-marked --save`
931-
932928
然后根据上方配置不同的 `engine`,推荐更换如下渲染器:
933929

934-
mathjax(可选):`npm install hexo-renderer-pandoc --save` **并且还需[安装 Pandoc](https://github.com/jgm/pandoc/blob/master/INSTALL.md)**
930+
:::tip mathjax
931+
```bash
932+
npm uninstall hexo-renderer-marked --save
933+
npm install hexo-renderer-pandoc --save
934+
```
935+
**并且还需[安装 Pandoc](https://github.com/jgm/pandoc/blob/master/INSTALL.md)**
936+
:::
935937

936-
katex(必须): `npm install @upupming/hexo-renderer-markdown-it-plus --save`
938+
:::tip katex
939+
```bash
940+
npm uninstall hexo-renderer-marked --save
941+
npm install hexo-renderer-markdown-it --save
942+
npm install @traptitech/markdown-it-katex --save
943+
```
944+
然后在**博客配置**中添加:
945+
```yaml
946+
markdown:
947+
plugins:
948+
- "@traptitech/markdown-it-katex"
949+
```
950+
:::
937951

938952
**3. 安装完成后执行 `hexo clean`**
939953

@@ -946,40 +960,11 @@ $$
946960
```
947961

948962
:::warning
949-
950-
如果公式没有被正确渲染,请仔细检查是否符合上面三步操作。
951-
952-
不可以同时安装多个渲染插件,包括 `hexo-math` 或者 `hexo-katex` 这类插件,请注意检查 `package.json`。
953-
954-
如果更换公式引擎,对应渲染器也要一并更换。
955-
956-
另外不同的渲染器,可能会导致一些 Markdown 语法不支持。
957-
958-
自定义页面默认不加载渲染,如需使用,需在 Front-matter 中指定 `math: true`
959-
960-
:::
961-
962-
:::tip
963-
964-
不同的公式引擎有不同的优缺点。
965-
966-
**MathJax**
967-
968-
优点
969-
- 对 LaTeX 语法支持全面
970-
- 右键点击公式有扩展功能
971-
972-
缺点
973-
- 需要加载 JS,页面加载会比较慢
974-
975-
**KaTeX**
976-
977-
优点
978-
- 没有 JS 不会影响页面加载
979-
980-
缺点
981-
- 小部分 LaTeX 不支持
982-
963+
- 如果公式没有被正确渲染,请仔细检查是否符合上面三步操作。
964+
- 不可以同时安装多个渲染插件,包括 `hexo-math` 或者 `hexo-katex` 这类插件,请注意检查 `package.json`。
965+
- 如果更换公式引擎,对应渲染器也要一并更换。
966+
- 不同的渲染器,可能会导致一些 Markdown 语法不支持,或者渲染样式有细微差异。
967+
- 自定义页面默认不加载渲染,如需使用,需在 Front-matter 中指定 `math: true`
983968
:::
984969

985970
<InArticleAdsense :data-ad-client=$themeConfig.ads.client :data-ad-slot=$themeConfig.ads.inSlot is-new-ads-code="yes"></InArticleAdsense>

0 commit comments

Comments
 (0)