Anand Surampudi
Anand Surampudi

Reputation: 131

Typesetting Math using MathJax for IPython Notebook Web page

I chose to learn to write mathematical expressions in IPython Notebook and sat to explore learning resources. I found this official link.

I reproduced the whole tutorial on my IPython NoteBook locally and then published it on my website. I also explained the whole struggle I went into while trying to achieve this in my blog post.

Unfortunately, whatever I do, I am not able to get the web page render/display the math expressions at all. I am not sure why the whole notebook failed to show the display of equations when the last couple cells gave the right output.

I also checked both the html codes of the source web page and my web page to find that the <script> code is where it has to be in mine.

I do not know JavaScript and LATEX at all! Can someone help please!

Again, this is the Source link. And this is my webpage where I copied the source tutorial.

Also, is the ipython nbconvert the best and the right way to convert .ipynb files into html?

Upvotes: 0

Views: 897

Answers (1)

Jakob
Jakob

Reputation: 20811

The problem you face is that currently pandoc (the document converter) strips raw latex when converting the markdown cells to html, see docu. Math in pandoc needs to be inside $..$ or $$..$$ delimiters.
The last couple of cells have explicit $s and thus convert fine. The other cells don't have this latex markup and thus get stripped during the conversion. You can try to embed the not working equations in $$s to prevent their removal (not tested).

There is a very recent PR to pandoc, to not strip raw latex when converting to html if the --mathjax option is supplied. Nevertheless, it will take some time to get this feature available unless you build pandoc from source.

And yes, nbconvert is the right (and best) tool to convert .ipynb files to html!

Upvotes: 3

Related Questions