Cirry's Blog

Markdown添加mathjax支持

Feb 8, 2023
技术 astro
1分钟
192字

添加Mathjax

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

window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
svg: {
fontCache: 'global'
}
};
(function () {
var script = document.createElement('script');
script.src = 'https://cdn.bootcdn.net/ajax/libs/mathjax/3.2.2/es5/tex-svg.js';
script.async = true;
document.head.appendChild(script);
})();
<script async type="text/javascript" src="/load-mathjax.js"></script>

测试展示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

- $ \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.
  • $ \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
发布时间:Feb 8, 2023
感谢大佬送来的咖啡☕
alipayQRCode
wechatQRCode
总访问量
总访客数人次