<script type="text/x-mathjax-config">
window.MathJax = {loader: {load: ['[tex]/cancel']},tex: {packages: {'[+]': ['cancel']}}};
</script>
<script> MathJax = {chtml: {displayAlign: 'left'}}; </script>
<script>
MathJax = {loader: {load: ['[tex]/cancel']},
tex: {packages: {'[+]': ['cancel']}},output: {displayAlign: 'left'},};</script>
--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/d67f5804-bb44-4135-bc24-274bb202f995n%40googlegroups.com.
I copied the window.MathJax etc. instruction from the MathJax documentation for MathJax 4:
Your answer makes it clear that for MathJax4 that instruction/syntax is incorrect.
It could be that the information on that documenation page is outdated.
As a novel user I did not have the knowledge which version of MathJax uses which syntax.
I intend to contact the JSXGraph team, and inform them of the desirability of moving to MathJax.typesetPromise()(Of course I will first search the JSXGraph issue tracker.)
(I have over the years submitted bug reports to the JSXGraph team; I have a cordial relation with the lead developer. )
On Sunday, November 2, 2025 at 5:33:07 PM UTC+1 Davide Cervone wrote:Cleon:There are several issues with the use of MathJax on the page you link to. First, you are loading MathJax v4, but are using what looks like a v2 configuration block:<script type="text/x-mathjax-config">window.MathJax = {loader: {load: ['[tex]/cancel']},tex: {packages: {'[+]': ['cancel']}}};</script>(but this would not actually work in v2, either, since the type="text/x-mathjax-config" would mean that it would not be executed until after MathJax is loaded, and then it would replace the MathJax object that has been set up (and includes all the MathJax functions) with this configuration object, rendering MathJax inoperable.For v3 and v4, you don't use type="text/x-mathjax-config" but instead use a plain <script> tag, like the one that follows the above tag:<script> MathJax = {chtml: {displayAlign: 'left'}}; </script>Note that this doesn't load or configure the cancel package. For v4, I would also use the generic output block rather than the chtml block, in case anyone switched the render to the SVG output. So you might use<script>MathJax = {loader: {load: ['[tex]/cancel']},tex: {packages: {'[+]': ['cancel']}},output: {displayAlign: 'left'},};</script>instead. Because the cancel package is autoloaded when it is first used, you don't technically have to load it explicitly (though doing so correctly probably would resolve your problem).I see that you are also leading jsxgraphcore.js, part of the JSXGraph package. It turns out that this package includes calls to MathJax to perform typesetting, and so there is a race condition between MathJax itself and JSXGRaph as to who does the typesetting first. The result depends on the state of the browser cache and the timing of network requests, which is why you may only see this problem sometimes. If MathJax does the typesetting, then it should work out, but if JSXGraph does, then that can lead to the problem you are seeing.When MathJax v3/v4 is available, jsxgraphcore.js calls MathJax.typeset() to perform the typesetting, but this is the non-promise-based typesetting call that doesn't handle dynamic loading of extensions, and instead throws a "retry" error that signals the caller that it needs to wait for the dynamic load to complete before trying again. The typeset() call in jsxgraphcore.js is enclosed in a try/catch structure that traps the retry error but doesn't properly respond to it, and instead issues a "MathJax (not yet) loaded" console error (I generally see 3 of these on your page). An error will occur in the try/catch block if MathJax isn't available yet, but also if it needs to load an extension, like the cancel package.To properly handle this, jsxgraphcore.js should be calling MathJax.typesetPromise() instead, and you may be able to resolve the issue by changing that call in the jsxgraphcore.js file. I didn't look further to see if jsxgraphcore.js uses the result of the typesetting, but if so, then this change would require more work, as other parts of the code would have to deal with promises that currently don't; that takes care and an understanding of their workflow that I don't have.Pre-loading the cancel extension should allow it to work, so give that a try.Davide
--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/25f9d0f3-40ee-4662-9b7d-a01d60854a78n%40googlegroups.com.
<script>// User sets global Option valueJXG.Options.text.useMathJax = true;window.addEventListener('load', () => {//// If not using MathJax, just do the user code//if (!JXG.Options.text.useMathJax) {userCode();return;}//// If user hasn't provided a config, set one up.//window.MathJax ??= {};//// MathJax already loaded, no need to wait.//if (MathJax.version) {console.log("[useMJ] MathJax already loaded");MathJax.startup.promise.then(userCode);return;}//// Cache the user's ready function, if any, and add our own.//window.MathJax.startup ??= {};const ready = MathJax.startup.ready;MathJax.startup.ready = () => {(ready || MathJax.startup.defaultReady)();console.log("MathJax setup.ready");MathJax.startup.promise.then(() => {console.log("MathJax startup.promise resolved");userCode();});}//// Load MathJax//const script = document.createElement('script');script.src = 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js';document.head.appendChild(script);console.log("MathJax script added");});function userCode() {const board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-0.5, 3.5, 5, -2],axis: true,grid: true,showNavigation: true,showCopyright: false});board.create('text',[0.1, 2, "\\begin{equation} \\begin{split} e^x & = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6} + \\cdots \\\\ & = \\sum_{n\\geq 0} \\frac{x^n}{n!} \\end{split} \\end{equation}"],{fontsize: 18,parse: false});board.create('text',[1, -1, "$y=x^2$"],{fontsize: 20,parse: false});console.log("Board and text defined");}</script>
window.addEventListener('load', () => {new Promise((resolve) => {//// If not using MathJax, just do the user code//if (!JXG.Options.text.useMathJax) {resolve();return;}//// If user hasn't provided a config, set one up.//window.MathJax ??= {};//// MathJax already loaded, no need to wait.//if (MathJax.version) {console.log("[useMJ] MathJax already loaded");MathJax.startup.promise.then(resolve);return;}//// Cache the user's ready function, if any, and add our own.//window.MathJax.startup ??= {};const ready = MathJax.startup.ready;MathJax.startup.ready = () => {(ready || MathJax.startup.defaultReady)();console.log("MathJax setup.ready");MathJax.startup.promise.then(() => {console.log("MathJax startup.promise resolved");resolve();});}//// Load MathJax//const script = document.createElement('script');script.src = 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js';document.head.appendChild(script);console.log("MathJax script added");}).then(userCode);});
<script src="https://cdn.jsdelivr.net/npm/jsxgraph/distrib/jsxgraphcore.js"></script><script>(() => {let board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-0.5, 3.5, 5, -2],axis: true,grid: true,showNavigation: true,showCopyright: false});let mj_txt = board.create('text',[0.1, 2, "\\begin{equation} \\begin{split} e^x & = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6} + \\cdots \\\\ & = \\sum_{n\\geq 0} \\frac{x^n}{n!} \\end{split} \\end{equation}"],{fontsize: 18,parse: false});let mj_txt_2 = board.create('text',[1, -1, "$y=x^2$"],{fontsize: 20,parse: false});console.log("Board and text defined");})();</script><script>// User sets global Option valueJXG.Options.text.useMathJax = true;window.addEventListener('load', () => {//// If not using MathJax, we're done//if (!JXG.Options.text.useMathJax) return;//// Load MathJax if it isn't already configured or loaded.// (This assumes that if there is a MathJax configuration,// the page will also load MathJax itself.)//if (!window.MathJax) {const script = document.createElement('script');script.src = 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js';document.head.appendChild(script);console.log("loading MathJax");}});</script>
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/7faa179e-2864-4687-b8fe-f025530a1e93n%40googlegroups.com.
<script>
const board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-0.5, 3.5, 5, -2],axis: true,grid: true,showNavigation: true,showCopyright: false});board.create('text',[0.1, 2, "\\begin{equation} \\begin{split} e^x & = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6} + \\cdots \\\\ & = \\sum_{n\\geq 0} \\frac{x^n}{n!} \\end{split} \\end{equation}"],{fontsize: 18,parse: false});board.create('text',[1, -1, "$y=x^2$"],{fontsize: 20,parse: false});
// User sets global Option valueJXG.Options.text.useMathJax = true;window.addEventListener('load', () => {//
// If using MathJax and it is not already loaded, load it.//if (JXG.Options.text.useMathJax && !window.MathJax?.version) {
const script = document.createElement('script');script.src = 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js';document.head.appendChild(script);}
});</script>
<script>
const board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-0.5, 3.5, 5, -2],axis: true,grid: true,showNavigation: true,showCopyright: false});board.create('text',[0.1, 2, "\\begin{equation} \\begin{split} e^x & = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6} + \\cdots \\\\ & = \\sum_{n\\geq 0} \\frac{x^n}{n!} \\end{split} \\end{equation}"],{fontsize: 18,parse: false});board.create('text',[1, -1, "$y=x^2$"],{fontsize: 20,parse: false});
// User sets global Option valueJXG.Options.text.useMathJax = true;window.addEventListener('load', () => {
new Promise((resolve, reject) => {//// If not using MathJax or it is already loaded,// resolve the promise,// otherwise// load MathJax.//if (!JXG.Options.text.useMathJax || window.MathJax?.version) {resolve();} else {
const script = document.createElement('script');script.src = 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js';
script.onerror = reject;script.onload = () => MathJax.startup.promise.then(resolve);document.head.appendChild(script);}}).then(() => {console.log("MathJax ready"); // do your MathJax-based stuff here}).catch((err) => {console.error("Can't load MathJax");});});</script>
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/1f8b4bac-cf69-4c03-b82f-fa0da27c27fdn%40googlegroups.com.