Loading AMSmath explicitly in IPython notebook cau

2019-02-28 17:19发布

问题:

I am a relatively new IPython Notebook user and I am using IPython 3.2.1. So upfront, my apologies if I did not read some documentation carefully!

I am trying to typeset some LaTeX in my Notebook intended for a presentation. I tried to utilize MathJax capabilities better than what's (supposedly) available by default and so tried incorporating other extensions that come with MathJax explicitly. In particular, I tried getting my IPython Notebook to load AMScd.js, AMSsymbols.js and unicode.js through the following sequence of steps:

  1. Obtain the .js files for these extensions from the latest MathJax (v2.5) source
  2. Add them to my ~/.ipython/nbextensions
  3. Modify custom.js in ~/.ipython/profile_<mine>/static/custom by appending IPython.load_extensions("AMScd"), etc.

Now, all these work fine, and I am able to typeset commutative diagrams nicely in my IPython notebook. So, while at all this, I decided to also include/load AMSmath.js that comes along with MathJax and this is problematic. (To me, this seems like a natural thing to do given that other extensions work well!) However, attempting to include AMSmath.js via IPython.load_extensions("AMSmath") causes LaTeX math in my Notebook to display [Math Processing Error] everywhere. Here's my minimal example and the output with and without including IPython.load_extensions("AMSmath").

Markup:

## A minimal working example

\\[
\Delta u = f \text{ on } \Omega
\\]

(I would totally like to include images here, alas, my not being an active participant in the community here leaves me with not even 10 reputation!)

So, what am I missing here? Why is this inclusion of AMSmath problematic? Any help would be appreciated! Thanks!

回答1:

It should work without extra configuration. Have a look here.

Your example in a markdown cell should be

(If you want the equation inline you can use $...$)

Inline equation $\Delta u = f \text{ on } \Omega$

(Or if you want the equation centered in their own line you can use $$...$$)

$$\Delta u = f \text{ on } \Omega$$

The result of both snippets in the same markdown cell is rendered as:

How it is loaded?

IPython/Jupyter notebook preloads some MathJax extensions including the extension you want to load. This extension is not an IPYthon/Jupyter extension so it shouldn't work if you try to load this MathJax extension as an IPython/Jupyter extension. See here to know more about how to load other MathJax extensions.