Search code examples
pythonjupyter-notebookmathjaxpandoc

Pandoc IPython notebook loses some Mathjax


The problem I have is that I have an IPython notebook with some formulas written in MathJax. It is rendered fine in the notebook itself, but when I try to export it, most of my formula is gone!

Here's a small reproducible example:

I type

$ \int \cfrac{ 2 p(\vec{x}) d\vec{x}}  { \frac{1}{P(\omega_1 | \vec{x})} + \frac{1}{P(\omega_2 | \vec{x})} }$

It renders well inside the notebook:

enter image description here

But when I click file -> print preview, what I get is just a lonely plus sign:

enter image description here

In the sources I see this:

<p>$  {  +  }$</p>

So the entire formula is gone! What could be the reason?

My environment:

  • Windows 7
  • Anaconda-2.0.1-Windows-x86_64
  • Python 2.7.7
  • IPython 2.3.0
  • pandoc 1.13.1

Solution

  • In pandoc you require a non-space character after the opening dollar and a non-space chacter before the closing dollar.

    From the documentation

    Anything between two $ characters will be treated as TeX math. The opening $ must have a character immediately to its right, while the closing $ must have a character immediately to its left. Thus, $20,000 and $30,000 won’t parse as math. If for some reason you need to enclose text in literal $ characters, backslash-escape them and they won’t be treated as math delimiters.