# 数学公式的渲染
# 2025年3月21日 周五, 天气眼光明媚
怎样在网页上渲染数学公式

第一步, 定义公式配置
window.MathJax = {
tex: {
inlineMath: [
['$', '$'],
['\(', '\)'],
],
displayMath: [
['$$', '$$'],
['\[', '\] '],
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
第二步, 引入文件
https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js
第三步: 在页面更新的时候强制渲染
if (window.MathJax && typeof window.MathJax.typeset === 'function') {
window.MathJax.typeset();
}
1
2
3
2
3