Mathjax 添加化学方程式支持

效果

$$\ce{4Al + 3O2 \xlongequal{\Delta} 2Al2O3}$$

1
$$\ce{4Al + 3O2 \xlongequal{\Delta} 2Al2O3}$$ 

原理

Mathjax支持插件,我们在其中安装mhchem插件导入即可。

该项目在Github上开源,项目在这里。

BootCDN也提供了该项目的加速服务,下面的代码也使用了他们的服务。

方法

在主题的header.php内添加找到mathjax代码段,然后添加下列代码。

1
2
3
4
5
6
7
8
9
<script type="text/x-mathjax-config">
MathJax.Hub.Config({messageStyle: "none",tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
MathJax.Ajax.config.path["mhchem"]="https://cdn.bootcss.com/mathjax-mhchem/3.3.2/";
MathJax.Hub.Config({
TeX: {
extensions: ["[mhchem]/mhchem.js","extpfeil.js"]
}
});
</script>

对于Handsome主题:

在主题的header.php约$44$行处找到下列代码段,然后在修改为下列代码。

1
2
3
4
5
6
7
8
9
10
11
12
<!--mathjax-->
<?php if (@in_array('mathJax',$this->options->featuresetup)): ?>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({messageStyle: "none",tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
MathJax.Ajax.config.path["mhchem"]="https://cdn.bootcss.com/mathjax-mhchem/3.3.2/";
MathJax.Hub.Config({
TeX: {
extensions: ["[mhchem]/mhchem.js","extpfeil.js"]
}
});
</script>
<?php endif; ?>

Mathjax 添加化学方程式支持

https://www.ariels.xyz/blog/3812186561.html

作者

Ariel Xiong

发布于

2020-01-17

更新于

2025-08-12

许可协议

CC BY-NC-ND 4.0

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×