安装和使用
csdn和npm均可
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- katex核心包 -->
<link href="https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.2/katex.min.css" rel="stylesheet" />
<script defer src="https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.2/katex.min.js"></script>
<!-- katex辅助包:自动渲染 -->
<script defer src="https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.2/contrib/auto-render.min.js"></script>
<title>Document</title>
</head>
<body>
<div>$\sum_{i=0}^{n}i^2$</div> // 这个表达式就是LaTex规定的宏
<div>\(\sum_{i=0}^{n}i^2\)</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, { // renderMathInElement这个函数就是 auto-render.js提供的
delimiters: [
// 意思是匹配页面上 以$开头和结尾的元素。 display决定是否占一整行
{left: '$', right: '$', display: false},
{left: '\\(', right: '\\)', display: false}
],
throwOnError : false
});
});
</script>
</body>
</html>
标签:right,false,sum,katex1,初步,使用,document,display
From: https://www.cnblogs.com/dingshaohua/p/16805334.html