Skip to content
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

Latex in figure is not rendered in sphinx documentation #3152

Closed
atharva-2001 opened this issue Apr 16, 2021 · 6 comments
Closed

Latex in figure is not rendered in sphinx documentation #3152

atharva-2001 opened this issue Apr 16, 2021 · 6 comments

Comments

@atharva-2001
Copy link

Hello, thanks for making this awesome library!
I am trying to embed a plotly figure in sphinx documentation by plotting inside Jupyter Notebook, but Latex in the axes in the plotly figure is not rendered, and all I see is code that was supposed to generate the Latex-based axes title.
Something like this:
image
As mentioned here, MathJax is not loaded until a math object is detected in the sphinx documentation. So I tried adding a cell with latex in it and the axes titles are rendered properly.
image

However, I think this doesn't look appealing, and wondered if there is a different way to do it. If I export the figure in HTML using the include_mathjax argument, axes labels are rendered properly. It's just when I build the documentation using sphinx.
For references, please see:
spatialaudio/nbsphinx#369
sphinx-doc/sphinx#6981
and this

@nicolaskruchten
Copy link
Contributor

There's not much we can do on the Plotly side unfortunately... MathJax must be loaded for LaTeX to render in a figure. Maybe there's a sphinx flag to force it to load, or a way to hide that cell or something?

@atharva-2001
Copy link
Author

Thanks for answering! I will try finding a workaround. Also, the nbsphinx guys are working on force loading MathJax, so maybe that will fix this.

@mgeier
Copy link

mgeier commented Apr 26, 2021

Can you please check if spatialaudio/nbsphinx#551 fixes this?

@atharva-2001
Copy link
Author

@nicolaskruchten Could you please check if spatialaudio/nbsphinx#572 is something that you can help with?
It seems that the problem is Plotly inserting this:

 if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}

in the HTML page which is causing an error as MathJax.Hub no longer exists. This causes an error and plotly figures do not load. Downgrading to MathJax v2 fixes this issue because MathJax.Hub is supported by it.
Maybe you can see this HTML file to start with.
Here is the link to the comment with some more test documents I made for this.
Another reference: tardis-sn/tardis#1607

@nicolaskruchten
Copy link
Contributor

Hmmm are you using MathJax 3.x ? Plotly.js is only tested/developed against MathJax 2.x at the moment so that might be the problem right there.

@atharva-2001
Copy link
Author

Oh, I see.
Yes, MathJax 3 is what is loaded by default, and changing it back to MathJax v2 does the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants