[IPython-dev] mathjax not rendering in notebook

Matthias BUSSONNIER bussonniermatthias@gmail....
Mon Aug 13 03:42:34 CDT 2012


Le 13 août 2012 à 08:28, Matthew Brett a écrit :

> Hi,
> 
> On Sat, Aug 11, 2012 at 12:04 PM, Matthias BUSSONNIER
> <bussonniermatthias@gmail.com> wrote:
>> 
>> Le 11 août 2012 à 20:53, Matthew Brett a écrit :
>> 
>>> Yo,
>>> 
>>> On Fri, Aug 10, 2012 at 8:06 PM, Fernando Perez <fperez.net@gmail.com> wrote:
>>>> On Fri, Aug 10, 2012 at 4:21 PM, Matthew Brett <matthew.brett@gmail.com> wrote:
>>>>> 
>>>>> In the notebook this renders as "$$ \begin{array}{c} y_{11} \cr y_{12}
>>>>> \mathtt{t}i \cr y{13} \end{array} $$" - i.e. somehow rejected by
>>>>> mathjax.   The following make it render correctly:
>>>>> 
>>>>> 1) y_3 instead of y_{3}
>>>>> 2) removing _i of \mathtt{t}_i
>>>> 
>>>> It seems the thing that confuses it most is the mathtt call.  If I
>>>> remove it altogether (and using \\\ for line separators), then I can
>>>> use y_{3, 4} and t_{i, j} no problem.  Or, if there are no complex
>>>> subscripts, the mathtt call by itself is OK.  But there's something
>>>> very brittle inside that is messing up mathjax's processing of this.
>>>> 
>>>> Filed it here, b/c I'm out of ideas:
>>>> https://github.com/ipython/ipython/issues/2289
>>> 
>>> As a matter of interest, and from great ignorance, where in ipython
>>> would I look for explanations of different behavior of mathjax in a
>>> markdown cell in the notebook to mathjax in a standalone html page
>>> like the one above?  Is there a good track to follow for debugging?
>> 
>> a quick grep in the source tell me that the 2 places that triggers mathjax rendering are
>> IPython/frontend/html/notebook/static/js
>> cell.js:            MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
>> outputarea.js:            MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
>> 
>> You could try to deactivate auto rendering and do it manually to check the source before/after rendering if you see an error in what is published.
> 
> I'm afraid I am not sure what you mean by the sentence above, is there
> any chance you could unpack it a little?  Sorry, I am completely
> unfamiliar with the notebook internals, but I'm happy to give it a go
> if someone can give me a few lines of orientation,

Sorry, I'm not a pro of mathjax either.
in sum up, you publish latex in a div with a special class, then call 

MathJax.Hub.Queue(["Typeset",MathJax.Hub]);

which will scan the page for theses div and 'render' it. 

MathJax.Hub.Queue(["Typeset",MathJax.Hub]); 
is called when a cell is rendered or, when something is pushed in an output area. 

commenting those line in 
in IPyhton/frontend/html/notebook/static/js/(cell | outputarea).js
 will publish the "raw" latex that you would have a chance to inspect/modify before calling 
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); 
From the JS console yourself to render.

at least that where I would look first using firefox firebug, or Chrome/Safari development panel.

Does this make more sense ? 
-- 
Matthias




More information about the IPython-dev mailing list