ipython/ipython — Issue #1359: [sympyprinting] MathJax can't render \root{m}{n}
Author: miham
Created: 2012-01-31 20:20:15+00:00
State: open

When running IPython notebook (0.12 or git) with sympy profile, latex representation of higher order roots in the output cell doesn't get rendered. To reproduce the problem, run `$ ipython2 notebook --profile=sympy` and then execute

```python
In [6]: a = 3**(S(1)/4)
a

Out[6]: \root{4}{3} # I should see nicely rendered root here, not LaTex code.
```

SymPy 0.7.1. is used for this examples. The problem is that sympyprinting extension uses iTex markup instead of regular Latex. Why is that good? Here's the difference in root representation:

```python
In [7]: latex(a)
Out[7]: \sqrt[4]{3} # MathJax can render this.

In [8]: latex(a, itex=True)
Out[8]: \root{4}{3} # MathJax can't render this.
```

There are two workarounds:

* You can set `itex=False` in `extensions.sympyprinting.print_latex()`, but that will probably break something else, or
* add a line that replaces iTex form with LaTex form, `import re; s = re.sub(r'\\root\{(.*?)\}\{(.*?)\}', r'\\sqrt[\1]{\2}', s)`