数据引擎
数据引擎
分类
- MathJax
- Katex
- 还有其他,见:Kramdown库的笔记
- SsKaTeX
- Mathjax-Node
- Ritex
- intex2MML
比较
katex: true, // TeX数学公式渲染工具 (二选一,katex), install katex before enabling it
mathjax: true, // TeX数学公式渲染工具 (二选一,mathjax), mathjax-full before enabling it
如何知道用的哪个?
在VuePress-Hope-Theme中,Katex和MathJax都是可选可用的。
在Obsidian中用哪个?
可在控制台得知:
console.log("Using MathJax version:", MathJax.version);
# Using MathJax version: 3.2.2
console.log("Using KaTeX version:", window.KaTeX.VERSION);
# Uncaught TypeError: Cannot read properties of undefined (reading 'VERSION') at <anonymous>:2:50
另一种方式是在Source中app.js里搜。结果是没搜到 KaTex
只搜到了 MathJax
控制台使用:(失败)
// 检查 MathJax 是否可用
if (typeof MathJax !== 'undefined') {
// 获取 .cm-contentContainer 元素
var container = document.querySelector('.cm-contentContainer');
if (container) {
// 创建一个新的 <div> 元素来容纳公式
var div = document.createElement('div');
div.style.border = '1px solid #ccc'; // 添加边框以清晰显示
div.style.padding = '10px';
div.style.backgroundColor = '#f9f9f9'; // 添加背景色
div.style.display = 'inline-block';
// 定义数学公式
div.innerHTML = '\\[\\frac{a}{b}\\]';
// 将 <div> 元素添加到 .cm-contentContainer 中
container.appendChild(div);
// 初始化 MathJax
MathJax.typesetPromise([div])
.then(function () {
console.log('Formula rendered successfully.');
})
.catch(function (error) {
console.error('Error rendering formula:', error);
});
} else {
console.error('.cm-contentContainer not found on the page.');
}
} else {
console.error('MathJax is not available on this page.');
}
链接到当前文件 0
没有文件链接到当前文件