Hexo

Hexo中的数学公式

2020-05-27  本文已影响0人  洗洗睡吧i

0. 官方文档

Next 介绍了两种方案: mathjax / katex 。

https://theme-next.js.org/docs/third-party-services/math-equations

这里用的是 mathjax。

1. mathjax配置

1.1 正文 Front-matter

---
title: Hexo中的数学公式
date: 2020-04-25 01:46:39
mathjax: true
---

1.2 Next主题配置

math:
  # Default (true) will load mathjax / katex script on demand.
  # That is it only render those page which has `mathjax: true` in Front-matter.
  # If you set it to false, it will load mathjax / katex srcipt EVERY PAGE.
  per_page: true

  # hexo-renderer-pandoc (or hexo-renderer-kramed) required for full MathJax support.
  mathjax:
    enable: true
    # See: https://mhchem.github.io/MathJax-mhchem/
    mhchem: false

1.3 替换插件(貌似可以不换,默认的也能用)

先卸载 hexo-renderer-marked, 再安装 hexo-renderer-pandoc

npm un hexo-renderer-marked
npm i hexo-renderer-pandoc

2. 坑

遇到了公式无法正常显示的问题。

hexo-math-error.png

最后发现是 \hat{y}_i 这里出了问题,原因不明。

\hat{y}_i 下标符号 _ 前加了一个反斜杠 \ ,搞定。

# 显示错误
$RMSE = 1 - \dfrac{\sum_{i=1}^n (y_i - \hat{y}_i)^2} {\sum_{i=1}^n (y_i - \bar{y})^2}$

# 修改后的公式
$RMSE = 1 - \dfrac{\sum_{i=1}^n (y_i - \hat{y}\_i)^2} {\sum_{i=1}^n (y_i - \bar{y})^2}$
上一篇下一篇

猜你喜欢

热点阅读