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

new mathjax support, requires JS #418

Closed
wants to merge 1 commit into from

Conversation

GiggleLiu
Copy link

List of changes

MathJax support when rendering SVG in a browser

It works directly in Pluto notebooks.

compose(context(), mathjax(0.2, 0.2, 0.1, 0.1, "x+1\\over y-1"), fontsize(12pt))

image

If not using a Pluto notebook, one needs to add the following javascript in the HTML header

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG"></script>

Allowing inserting Raw SVG elements

I feel this provides flexibility to make an extension. Although most people do not need this. For example, the following code also renders the Mathjax

compose(context(), rawsvg(raw"""<foreignObject x="50" y="50" width="100" height="100">
    <div xmlns="http://www.w3.org/1999/xhtml" style="font-family:Times; font-size:15px">
		\(\displaystyle{x+1\over y-1}\)
    </div>
  </foreignObject>"""))

Notes

Please review this PR carefully because I am not quite familiar with Compose API.

Reference:
https://stackoverflow.com/questions/15962325/mathjax-inside-svg#:~:text=Currently%2C%20the%20only%20way%20to,'t%20support%20.

@GiggleLiu
Copy link
Author

I find a possible issue, the viewBox is too large for the latex to render correctly sometime. Because MathJax has a minimum superscript/subscript size.

image

@GiggleLiu
Copy link
Author

I feel this kind of rendering is not perfect. Maybe not a good fit for this package.

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.

1 participant