hexo 数学公式 mathjax

math

更换渲染工具为 hexo-renderer-pandoc

首先需要安装 pandoc

1
brew install pandoc

更换渲染工具为 hexo-renderer-pandoc

1
2
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-pandoc --save

hexo-renderer-mathjax

1
2
npm uninstall hexo-math --save
npm install hexo-renderer-mathjax --save

在hexo 博客中的 _config.yml 中添加 hexo-math 插件

1
2
3
4
5
6
7
8
9
10
11
math:
engine: 'mathjax' # or 'katex'
mathjax:
src: custom_mathjax_source
config:
# MathJax config
katex:
css: custom_css_source
js: custom_js_source # not used
config:
# KaTeX config

硬换行

1
2
3
pandoc:
extensions:
- "+hard_line_breaks"

打开 主题 的 mathjax 开关

vim themes/landscape/_config.yml 文件,找到 mathjax 位置, 设置为以下

1
2
3
4
# MathJax Support
mathjax:
enable: true
per_page: true

在每一个博客中都打开 mathjax 开关

1
2
3
4
5
6
7
8
9
10
11
---
title: 2020
date: 2020-02-20 18:39:08
tags:
- tag1
- tag2
categories:
- parent
- child
mathjax: true
---

重新生成

1
2
3
hexo clean
hexo generate
hexo s

测试

\(h(\theta) = \alpha\)

\[ \begin{array}{l} {u_{i} \leftarrow\left[u_{i}-\gamma_{t}\left(\lambda-\left(y_{t}-w^{\top} \Phi\left(x_{t}\right)\right) \Phi_{i}\left(x_{t}\right)\right)\right]_{+}} \\ {v_{i} \leftarrow\left[v_{i}-\gamma_{t}\left(\lambda+\left(y_{t}-w_{t}^{\top} \Phi\left(x_{t}\right)\right) \Phi_{i}\left(x_{t}\right)\right)\right]_{+}} \end{array} \]

\[ f^{\prime}\left(x_{0}\right)=\lim _{\Delta x \rightarrow 0} \frac{f\left(x_{0}+\Delta x\right)-f\left(x_{0}\right)}{\Delta x} \]

\[\begin{equation} w \leftarrow w-\gamma_{t}\left\{\begin{array}{ll} {\lambda w} & {\text { if } y_{t} w^{\top} \Phi\left(x_{t}\right)>1} \\ {\lambda w-y_{t} \Phi\left(x_{t}\right)} & {\text { otherwise }} \end{array}\right. \end{equation}\]