hexo 渲染数学公式(水一篇)

我用的是 butterfly 主题

使用这个即可,试过别的都搞不出

1. 安装插件

1
npm install hexo-filter-mathjax

2. 配置

在根目录下的_config.yml中添加以下配置:

1
2
3
4
5
6
7
8
9
10
11
12
mathjax:
tags: none # or 'ams' or 'all'
single_dollars: true # enable single dollar signs as in-line math delimiters
cjk_width: 0.9 # relative CJK char width
normal_width: 0.6 # relative normal (monospace) width
append_css: true # add CSS to pages rendered by MathJax
every_page: false # if true, every page will be rendered by MathJax regardless the `mathjax` setting in Front-matter
packages: # extra packages to load
extension_options:
{}
# you can put your extension options here
# see http://docs.mathjax.org/en/latest/options/input/tex.html#tex-extension-options for more detail

3. 在文章中使用

在文章的 Front-matter 中添加mathjax: true,然后在文章中使用$$包裹数学公式即可。

1
2
3
4
5
6
---
title: 文章标题
date:
tags:
mathjax: true # 添加这一行
---

4. 重新生成即可