如何为 iPython 笔记本配置 mathjax? [英] How do I configure mathjax for iPython notebooks?

查看:24
本文介绍了如何为 iPython 笔记本配置 mathjax?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法,让 mathjax 在我的 iPython 笔记本中不使用 STIX 字体进行数学运算.相反,我更愿意让它使用TeX"字体.根据我应该使用的 Mathjax 文档:

I'm trying to find a way for mathjax to not use STIX fonts for math in my iPython notebook. Instead, I'd much rather have it use the 'TeX' fonts. According to the documentation for Mathjax I should use:

MathJax.Hub.Config({
  "HTML-CSS": {
    preferredFont: "TeX"
  }
});

话虽如此,我不知道该把它放在哪里.我已经尝试将这段代码放入与我自己的 ipython 配置文件相关的 custom.js 文件中,但它不起作用.理想情况下,我想对 mathjax 进行 ipython 配置文件特定的调整.

That being said, I'm not sure where to put this. I've already tried putting this chunk of code into my custom.js file pertaining to my own ipython profile, but it doesn't work. Ideally, I'd like to make ipython profile specific adjustments for mathjax.

推荐答案

确保配置正确的一个简单测试是将 preferredFont: "TeX" 更改为 规模:200.然后保存并重新加载笔记本.数学显然应该比以前大得多.所以假设这有效,这意味着您的 config.js 正在做它需要做的事情.

A simple test to make sure that you're getting the configuration correct is to change preferredFont: "TeX" to scale: 200. Then save and reload a notebook. The math should be obviously way bigger than before. So assuming that worked, it means your config.js is doing what it needs to.

现在,更重要的是,尝试添加另一行,使您的配置看起来像

Now, more to the point, try adding another line so that your configuration looks like

MathJax.Hub.Config({
  "HTML-CSS": {
    availableFonts: ["TeX"],
    preferredFont: "TeX",
  }
});

保存后不要忘记完全刷新笔记本页面.这会覆盖(我猜是)availableFonts 变量,如果 mathjax 找不到 TeX,它将允许 STIX.我不确定为什么它似乎忽略了首选字体,但这似乎更像是 mathjax 问题而不是 ipython 问题.

Don't forget to fully refresh the notebook page after you've saved that. This overrides (what I'm guessing is) the default value of that availableFonts variable, which would allow STIX if mathjax can't find TeX. I'm not sure why it seems to ignore the preferred font, but this seems more like a mathjax issue than an ipython issue.

所以现在,如果它仍然不是 TeX 字体(mathjax 似乎调用 MathJax_Math-Italic.otf 或类似的字体),我猜想 mathjax 只是找不到该字体,并且可能已经退回到其他东西.如果是这种情况,则说明您的 mathjax 安装出现了问题.

So now, if it still isn't in TeX font (which mathjax seems to call MathJax_Math-Italic.otf, or similar), I would guess that mathjax just can't find that font, and may have fallen back on something else. If that is the case, there's something messed up about your mathjax installation.

这篇关于如何为 iPython 笔记本配置 mathjax?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆