-
Notifications
You must be signed in to change notification settings - Fork 947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTMLMath widget in JupyterLab doesn't render LaTeX until MathJax has been loaded externally #2253
Comments
Also seeing the same. I have some Latex in widgets to produce plots. Is there any way to initialise Mathjax without using a markdown cell? It would be nice if my widgets could run properly in new notebooks, not needing the users to markdown cells. |
It seems that ipywidgets/packages/controls/src/utils.ts Lines 48 to 50 in 2b91eac
A simple fix might be the jupyterlab manager requiring the ILatexTypesetter plugin:
(which presumably would load mathjax into the global namespace) A more comprehensive fix might be the widget manager providing the typesetting functionality itself, and taking responsibility for interacting with the environment to get the typesetting done. As always, PRs are more than welcome. Let me know if someone wants to work on this and I can help them get started. |
Note that if there are any markdown cells in the notebook, jlab loads mathjax and things work. I don't have to edit the markdown cells and render them explicitly. |
@jonmmease - what I describe above about requiring the ILatexTypesetter plugin should be enough to get jlab to initialize mathjax. |
Thanks, @jasongrout! I'll give it a try |
Except of course if you use an |
Workaround for jupyter-widgets/ipywidgets#2253
Do you want to put in a PR to have the jlab manager do that? Something like what was noted above in #2253 (comment) |
Perhaps the widget manager should provide a typeset utility function, which could use something instead of mathjax if needed. |
@jasongrout Sure, hopefully next week. For now and until I can rely on this being available I use this workaround (in a project where I know the mathjax implementation is used): https://github.com/vidartf/phoila/blob/1168c4890178c3efad1a0d54431cd21a4fcc61f7/ts/src/plugins.ts#L110-L115 |
Hmm.. I possibly have an unrelated issue? Or not. Google brought me here after all. I have to use the following:
then it renders my text. I have to then use: And then it sends that to the renderer. But tex just sitting there? Nope. |
In the process of adding MathJax / LaTeX support to the plotly.py ipywidget, I realized that JupyterLab doesn't seem to automatically initialize MathJax the way the classic notebook did. I was able to reproduce this same situation using the built-in
HTMLMath
widget.Steps to reproduce
HTMLMath
widget that contains LaTeX. It will display in raw form (not typeset)Here is a screenshot of the end-result of this process

Is it possible for a widget (or a general JupyterLab extension for that matter) to request that JupyterLab perform its MathJax initialization?
This is also something I'd like to add to the plotly mime type renderer (https://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension) and chart editor (https://github.com/plotly/jupyterlab-chart-editor) extensions, so let me know if this is a discussion we should move somewhere else. Thanks!
The text was updated successfully, but these errors were encountered: