-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Is there a way to load output/svg and output/chtml in sametime? #2705
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
Comments
MathJax uses a It is possible to have more than one MathJax = {
loader: {load: ['output/svg']},
startup: {
ready() {
//
// Get the MathJax modules that we need.
//
const {mathjax} = MathJax._.mathjax;
const {SVG} = MathJax._.output.svg_ts;
//
// Do the normal setup
//
MathJax.startup.defaultReady();
//
// Create an SVG output jax and a new MathDocument that uses it.
//
const svgOutput = new SVG(MathJax.config.svg);
const svgDocument = mathjax.document(document, {
...MathJax.config.options,
InputJax: MathJax.startup.input,
OutputJax: svgOutput
});
//
// Define the SVG-based conversion methods
//
MathJax.tex2svg = (math, options = {}) => {
options.format = svgDocument.inputJax[0].name;
return svgDocument.convert(math, options);
};
MathJax.tex2svgPromise = (math, options = {}) => {
options.format = svgDocument.inputJax[0].name;
return mathjax.handleRetriesFor(() => svgDocument.convert(math, options));
};
MathJax.svgStylesheet = () => svgOutput.styleSheet(svgDocument);
}
}
} With this configuration, you will get both |
This is very helpful, thanks! A quick follow-up question: how to make an analogous |
Got it! Nothing like a source dive! I added at the end of the ready() function the following: MathJax.typesetSVGPromise = (elements) => {
svgDocument.options.elements = elements;
svgDocument.reset();
return mathjax.handleRetriesFor(() => {
svgDocument.render();
});
}; |
@akhmerov, thank for the example code. One thing to keep in mind if you are using both Also, there are element ID values that may clash, since the two MathDocument instances will not know about the element created by each other. So there are potential problems with trying to use both documents at once. |
The use case here was integrating with Plotly, which grabs the SVG immediately after it's rendered, and deletes the DOM node. Therefore the limitations you mention don't have an adverse effect in practice. |
OK, but then I would have thought that |
|
I need to use output/svg and output/chtml in my project.
But i tried in several way:
All these ways don't working for me.
It's always show me a 'MathJax.tex2chtml is not a function'.
The text was updated successfully, but these errors were encountered: