Next主题使用Mathjax引擎书写LaTex数学公式

MathJax 支持配置

在Next主题配置文件_config.yml中,找到mathjax配置段,将enable开关打开,但per_page开关建议不要打开,每个文件都加载mathjax引擎影响速度。

1
2
3
4
mathjax:
enable: true
per_page: false
cdn: //cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML

在需要书写数学公式的页面的Fromt-Matter中打开mathjax开关即可。

1
2
3
title: Next主题使用Mathjax引擎书写LaTex数学公式
date: :year/:month/:day
mathjax: true

Mathjax引擎渲染数学公式举例:

$$ S = \pi r^2 $$

Mathjax引擎渲染为:$$ S = \pi r^2 $$

$$ f = \Sigma_1^{100} x $$

Mathjax引擎渲染为:$$ f = \Sigma_1^{100} x $$

1
2
3
4
5
6
7
8
$$
\begin {pmatrix}
1 & a_1 & a_1^2 & \cdots & a_1^n \\
1 & a_2 & a_2^2 & \cdots & a_2^n \\
\vdots & \vdots& \vdots & \ddots & \vdots \\
1 & a_m & a_m^2 & \cdots & a_m^n
\end {pmatrix}
$$

Mathjax引擎渲染为:
$$
\begin{pmatrix}
1 & a_1 & a_1^2 & \cdots & a_1^n \
1 & a_2 & a_2^2 & \cdots & a_2^n \
\vdots & \vdots& \vdots & \ddots & \vdots \
1 & a_m & a_m^2 & \cdots & a_m^n
\end{pmatrix}
$$

为什么不换行?????!!!!
好大一个大坑,原因是Markdown中\是转义符号,LaTex公式中的\\换行符,必须再重复一遍,输入\\\\才能得到\\

所以:

1
2
3
4
5
6
7
8
$$
\begin{pmatrix}
1 & a_1 & a_1^2 & \cdots & a_1^n \\\\
1 & a_2 & a_2^2 & \cdots & a_2^n \\\\
\vdots & \vdots& \vdots & \ddots & \vdots \\\\
1 & a_m & a_m^2 & \cdots & a_m^n
\end{pmatrix}
$$

Mathjax引擎才能渲染为:
$$
\begin{pmatrix}
1 & a_1 & a_1^2 & \cdots & a_1^n \\
1 & a_2 & a_2^2 & \cdots & a_2^n \\
\vdots & \vdots& \vdots & \ddots & \vdots \\
1 & a_m & a_m^2 & \cdots & a_m^n
\end{pmatrix}
$$

问题解决了,感觉非常爽,是不是?