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

(WIP) LateX rendering #696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

(WIP) LateX rendering #696

wants to merge 1 commit into from

Conversation

rmenegaux
Copy link
Contributor

This aims to enable LateX rendering to titles, legends, ticks and labels (#678).

@rmenegaux
Copy link
Contributor Author

With the current code, MathJax runs but does not render anything.

import bqplot.pyplot as plt

plt.figure(title='L$\\alpha$tex')
plt.show()

outputs 'Ltex'.

Here is what the html looks like:
screen shot 2018-08-02 at 21 05 21

However, it does render correctly if I wrap the svg text in a foreignElement (commented JS code in the PR). That is something we might want to avoid though because it would mean manually rendering axis ticks rather than using d3's inbuilt ones.

@jasongrout any ideas on this?

@jasongrout
Copy link
Member

Is this in classic notebook, jupyterlab, or on a web page?

@jasongrout
Copy link
Member

I'm not sure what is going on at first glance. If I understand correctly, you have the mathjax getting rendered into the svg (i.e., mathjax is creating nodes inside the svg), but it isn't showing up on the page?

@rmenegaux
Copy link
Contributor Author

Yes that's right. The issue is the same in both notebook and lab.

@rmenegaux
Copy link
Contributor Author

So the problem is that SVG refuses to render anything that is not an SVG element, unless it is inside a foreignObject.
Good news: there is a MathJax configuration which outputs SVG, which would be the beginning of the answer to all our problems.
Bad news: that configuration is set by the notebook (or the lab) and cannot be changed afterwards. Unfortunately for us, the current MathJax output configuration is common html/css.

Unless the notebook MathJax configuration is changed, it seems we have 2 choices:

  • Wrap the Tex in a foreignObject tag. That would work fine for the figure title, legend and axis labels, but would be more problematic for axis ticks and the Label Mark (we'd have to hack the d3 ticks or write our own, and even then SVG transforms like scale, rotation would not apply)
  • Manually convert the MathJax output into something digestible by SVG. That would be a lot of work and probably ugly.

Thoughts?

@maartenbreddels
Copy link
Member

I thought of https://khan.github.io/KaTeX/ but it does not have svg output
The alternative would be (similar to what I do with scattermega) to render to an image, and include that.

@jasongrout
Copy link
Member

MathJax 3 (in beta) is also way more flexible in these regards. However, we probably shouldn't be in the business of providing a mathjax implementation?

@maartenbreddels
Copy link
Member

@jasongrout any idea on how beta is beta, and what their timeline is?
Also, what do you mean with the last sentence? That bqplot shouldn't include a latex renderer (mathjax) but that the environment should provide it?

@jasongrout
Copy link
Member

jasongrout commented Aug 6, 2018

That bqplot shouldn't include a latex renderer (mathjax) but that the environment should provide it?

Yes. To me that makes sense (if possible).

@jasongrout
Copy link
Member

@jasongrout any idea on how beta is beta, and what their timeline is?

@dpvc is one of the most careful individuals I've ever met (that's a good thing!). I don't know the precise timeline for mathjax 3, but there has been steady progress, and given past experience, I am confident that whatever is implemented/published is pretty high quality.

@edwinytgoh
Copy link

Hi there! I was wondering what the current status of this WIP is?

@JuanCab
Copy link

JuanCab commented Jul 8, 2020

Just checking to see if any movement is possible on this feature request (has the state of MathJax support for SVG changed)?

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

Successfully merging this pull request may close these issues.

None yet

5 participants