Cirry's Blog

Markdown添加mathjax支持

2023-02-08
astro
astro
最后更新:2024-08-26
1分钟
192字

添加Mathjax

新建load-mathjax.js文件,然后在html中文件引入使用。

1
window.MathJax = {
2
tex: {
3
inlineMath: [['$', '$'], ['\\(', '\\)']]
4
},
5
svg: {
6
fontCache: 'global'
7
}
8
};
9
10
(function () {
11
var script = document.createElement('script');
12
script.src = 'https://cdn.bootcdn.net/ajax/libs/mathjax/3.2.2/es5/tex-svg.js';
13
script.async = true;
14
document.head.appendChild(script);
15
})();
1
<script async type="text/javascript" src="/load-mathjax.js"></script>

测试展示1

1
$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$

When $a \ne 0$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are $$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$

测试展示2

1
- $ \mathbf{x}\_{0} $: the orignal image
2
- $ \mathbf{x}\_{T} $: the latent variable. We want $ \mathbf{x}_{T}\sim \mathcal{N}(0,\mathbf{I}) $.
3
- $ \mathbf{x}\_{1},\dots,\mathbf{x}\_{T-1}$: the intermediate states.
  • $ \mathbf{x}_{0} $: the orignal image
  • $ \mathbf{x}_{T} $: the latent variable. We want $ \mathbf{x}_{T}\sim \mathcal{N}(0,\mathbf{I}) $.
  • $ \mathbf{x}_{1},\dots,\mathbf{x}_{T-1}$: the intermediate states.

优点:不需要添加其他插件即可在页面上直接显示公式。

缺点:添加了mathjax支持之后,网页加载会变慢。

参考文档

本文标题:Markdown添加mathjax支持
文章作者:Cirry
发布时间:2023-02-08
版权声明:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
感谢大佬送来的咖啡☕
alipayQRCode
wechatQRCode