# 设置hexo支持Latex公式
网页上对Latex的支持需要借助能够解析Latex语法的插件引擎,将Latex语法转成HTML元素,常用的
Latex公式引擎有Katex,mathjax引擎等,如CSDN使用的就是Katex。
- 渲染引擎改成
pandoc
npm uninstall hexo-rendered-marked
npm install hexo-rendered-pandoc
- 安装mathjax插件
npm install hexo-filter-mathjax
- 修改站点
_config.yaml文件,注意不是themes中的_config.yaml
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
- 每个页面
.md头部设置mathjax=true
# 效果
$$
f(x) = \frac{x^2}{x+y}
$$
渲染结果为: