Jupyter Notebook:为什么自定义Mathjax宏无法打开文件?

问题描述 投票:3回答:1

我已将custom.js添加到~./ jupyter / custom。这是我的custom.js文件的mathjax配置部分的开头:

MathJax.Hub.Config({
"tex2jax": {
inlineMath: [ ["$","$"], ["(",")"] ],
displayMath: [ ["$$","$$"], ["[","]"] ],
processEscapes: true,
},
"displayAlign": "center",
"extensions" ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js","TeX/color.js","TeX/cancel.js"],
"TeX": {
Macros: {
wes: "\blacksquare",
qes: "\frac{1}{8}",
qd: "\quad",
dq: "\quad\quad",
norm: ["{\lvert#1\rvert}", 1],

当我打开使用这些宏的笔记本时,笔记本似乎无法识别这些宏:

Notebook not recognizing mathjax custom macro

但是当我刷新页面时,通常会按预期识别和显示宏。我有什么办法可以让Notebook在打开文件时识别Mathjax宏吗?

jupyter-notebook mathjax
1个回答
0
投票

我有同样的问题。尽管custom.js中的代码被执行,但MathJax似乎忽略了它,即使这是the recommended way

然后我偶然发现了official documentation on defining TeX macros,并在我的custom.js中得到了以下片段:

MathJax.Hub.Register.StartupHook("TeX Jax Ready", function () {
  MathJax.InputJax.TeX.Definitions.Add({
    macros: {
      Expecto: ["Macro", "\\mathop{\\mathbb{E}}"]
    }
  });
});
© www.soinside.com 2019 - 2024. All rights reserved.