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

时间:2018-06-25 18:35:16

标签: jupyter-notebook mathjax

我已将custom.js添加到〜。/ jupyter / custom。这是我的custom.js文件中mathjax config部分的开头:

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宏吗?

1 个答案:

答案 0 :(得分:0)

我有同样的问题。即使custom.js中的代码被执行,即使是the recommended way,MathJax也会忽略它。

然后我偶然发现了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}}"]
    }
  });
});