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

查看:171
本文介绍了如何为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改为 scale: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",
  }
});

保存后,不要忘记完全刷新笔记本页面。这取代了(我猜的是) <$的默认值c $ c> 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天全站免登陆