jsxgraph and mathjax issues

76 views
Skip to first unread message

Kyle Monette

unread,
May 24, 2026, 3:36:40 PMMay 24
to PreTeXt support
Hi folks,

I made some interactive graphs using Jsxgraph, where I use mathjax for text labels. Everything builds okay, but the latex is only "compiled" after the user moves a point, glider, etc on the plot. Which is obviously not desired.

Take this graph, for example. The latex only compiles once a point is moved. I tested this on Chrome and Safari.

It appears that pretext is loading a script for jsxgraph that is out of date, based on their documentation. See attached screenshot. An example on their website loads MJ4 as it should.

I am using version 2.39.0 of Pretext CLI.

Thank you for any help and insights!
Attachment.png

OHappyDay

unread,
May 26, 2026, 2:28:00 AMMay 26
to PreTeXt support

Hi,

can you post a snippet of pretext code for your example? Maybe it is an issue with github but it would be working with a local installation of pretext.

Klaus  

Kyle Monette

unread,
May 26, 2026, 7:33:13 AMMay 26
to pretext...@googlegroups.com
Hi Klaus,

Thanks for looking into this. Here is the pretext code that I used in the section file for the book:

<figure xml:id="fig_1_5_arc_graph">
<interactive platform="jsxgraph" source="jsxgraph/jsx_1_5_arc_graph.js" width="60%">
 <slate xml:id="jsx_1_5_arc_graph_fig" surface="jsxboard"/>
 <instructions>
 <p>Change the values of <m>a</m> and <m>b</m> to see how the <m>\aroc</m> changes.</p>
 </instructions>
</interactive>
</figure>

Here is the jsx file that is linked to from above.

Thanks,
Kyle 
--
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/6WPUi-lfsLM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/f5cdc216-1f2a-4813-811a-084b3d6fafa6n%40googlegroups.com.

OHappyDay

unread,
May 26, 2026, 8:10:13 AMMay 26
to PreTeXt support
Hi Kyle,
sorry, I am unable to run your example. I don't know where to put the .js file before building the sample project (first time I use JSXGraph).

Klaus

Kyle Monette

unread,
May 26, 2026, 9:42:46 AMMay 26
to pretext...@googlegroups.com

OHappyDay

unread,
May 26, 2026, 10:42:40 AMMay 26
to PreTeXt support
Ok, thanks. The .js file goes into assets/jsxgraph/ 

After building I see the same behaviour as you see it so it is not github related but an issue of pretext itself.

The .js file that you mention in the first post is the .js file for loading MathJax 4 per their official documentation. So this is not the root cause.
I can't see any references in the HTML code to JSXGraph so I am lost about how JSXGraph is loaded at all.

Klaus

OHappyDay

unread,
May 26, 2026, 11:00:31 AMMay 26
to PreTeXt support
Alas, I found a file (output/web/fig_1_5_arc_graph-1-if.html) that contains the code for inclusion for JSXGraph as described on their homepage. Pretext loads version 1.8.0 but the actual version is 1.12.2.
I manually changed the two lines (for .js and .css files) so that version 1.12.2 is loaded but the behaviour does not change. The build process generates an additional .js file that contains jsx related code: output/web/external/jsxgraph/jsx_1_5_arc_graph.js. Maybe this file contains code based on version 1.8.0 but would be different if generated off of version 1.12.2.


Klaus

OHappyDay

unread,
May 27, 2026, 5:55:29 PMMay 27
to PreTeXt support
I investigated further and found this: 

When I inidividually open the the file that contains the JSXGraph (fig_1_5_arc_graph-1-if.html) the Javascript console logs the information "MathJax (not yet) loaded"! 
This means that MathJax is not yet active and explains why the text inside the graph is shown as is.

MathJax is loaded using the "defer" keyword:

When I remove the "defer" keyword and try again, the previous behaviour is gone and everything works as expected.

Klaus

OHappyDay

unread,
May 27, 2026, 6:04:55 PMMay 27
to PreTeXt support
Wait a moment: this is getting even weirder. Now without the "defer" keyword the previous behaviour is reversed: on loading the page the text is interpreted by MathJax but after moving one of the points in the graph the text escapes back to the literal version without being interpreted by MathJax (console again shows "MathJax (not yet) loaded".

Crazy stuff :-(

Andrew Scholer

unread,
May 28, 2026, 3:37:47 PMMay 28
to pretext...@googlegroups.com
It looks like PreTeXt was not marking the JSXGraph interactive as needing MathJax processing. (It is opt-in for parts of the page).

I made a pull request with a fix here: 

Andrew Scholer

You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/236bb966-d494-4495-9781-4b5ce34b4603n%40googlegroups.com.

Kyle Monette

unread,
May 28, 2026, 3:58:58 PMMay 28
to PreTeXt support
Hi Andrew,

This appears to be working brilliantly! Huge thanks to you and Klaus for looking into this issue.

Kyle 

OHappyDay

unread,
May 29, 2026, 9:16:07 AMMay 29
to PreTeXt support
I can confirm that the fix is also working in my local environment.

Kyle Monette

unread,
May 29, 2026, 4:38:06 PMMay 29
to pretext...@googlegroups.com
So as a (hopefully quick) follow-up to this …. I noticed that the preview images for the graphs are not rendering the latex. Namely, when I run:
pretext generate -t print interactive

Rob Beezer

unread,
May 30, 2026, 5:49:31 PMMay 30
to pretext...@googlegroups.com
Thanks, Kyle, Klaus, and Andrew for your work on this. I'd been meaning to hop
in, but have been distracted with some larger PreTeXt tasks, so I'm glad to see
this sorted out. Andrew's PR, of course, made it easier to see what was happening.

Fix is in: https://github.com/PreTeXtBook/pretext/pull/2880

and there is now an example in the sample article (thanks, Andrew, for placing
that!):

Figure 14.17
https://pretextbook.org/examples/sample-article/html/section-interactive-authored.html#interactive-jsx-arc-graph

Rob

On 5/29/26 06:16, 'OHappyDay' via PreTeXt support wrote:
> I can confirm that the fix is also working in my local environment.
>
>
>
> kmon...@uri.edu schrieb am Donnerstag, 28. Mai 2026 um 21:58:58 UTC+2:
>
> Hi Andrew,
>
> This appears to be working brilliantly! Huge thanks to you and Klaus for
> looking into this issue.
>
> Kyle
>
>
> On Thursday, May 28, 2026 at 3:37:47 PM UTC-4 asch...@chemeketa.edu wrote:
>
> It looks like PreTeXt was not marking the JSXGraph interactive as
> needing MathJax processing. (It is opt-in for parts of the page).
>
> I made a pull request with a fix here:
> https://github.com/PreTeXtBook/pretext/pull/2880 <https://github.com/
> PreTeXtBook/pretext/pull/2880>
>
> Andrew Scholer
>
> On Wed, May 27, 2026 at 3:04 PM 'OHappyDay' via PreTeXt support
> <pretext...@googlegroups.com> wrote:
>
> Wait a moment: this is getting even weirder. Now without the "defer"
> keyword the previous behaviour is reversed: on loading the page the
> text is interpreted by MathJax but after moving one of the points in
> the graph the text escapes back to the literal version without being
> interpreted by MathJax (console again shows "MathJax (not yet) loaded".
>
> Crazy stuff :-(
>
> OHappyDay schrieb am Mittwoch, 27. Mai 2026 um 23:55:29 UTC+2:
>
> I investigated further and found this:
>
> When I inidividually open the the file that contains the
> JSXGraph (fig_1_5_arc_graph-1-if.html) the Javascript console
> logs the information "MathJax (not yet) loaded"!
> This means that MathJax is not yet active and explains why the
> text inside the graph is shown as is.
>
> MathJax is loaded using the "defer" keyword:
>
> <scriptdefersrc="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-
> chtml.js <https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-
> chtml.js>"></script>
> Here is a minimal GitHub repo <https://github.com/
> kylemonette/jsx-example> that contains the jsx file.
>> Here is the jsx file <https://urldefense.com/
>> v3/__https://pastebin.com/UkS2pg32__;!!Jh1S!
>> mU28rln65Tx1onDCkfLpWsBUkI_nZseNsuIEGbpo3bnWEnxs6NeeIvw24N3nT9fVRmSYoHpzAgWjMxc7Oiy_17VUTGtifc4$> that is linked to from above.
>>
>> Thanks,
>> Kyle
>> On May 26, 2026 at 2:28 AM -0400, 'OHappyDay'
>> via PreTeXt support
>> <pretext...@googlegroups.com>, wrote:
>>>
>>> Hi,
>>>
>>> can you post a snippet of pretext code for
>>> your example? Maybe it is an issue with
>>> github but it would be working with a local
>>> installation of pretext.
>>>
>>> Klaus
>>> kmon...@uri.edu schrieb am Sonntag, 24. Mai
>>> 2026 um 21:36:40 UTC+2:
>>>
>>> Hi folks,
>>>
>>> I made some interactive graphs using
>>> Jsxgraph, where I use mathjax for text
>>> labels. Everything builds okay, but the
>>> latex is only "compiled" after the user
>>> moves a point, glider, etc on the plot.
>>> Which is obviously not desired.
>>>
>>> Take this graph <https://urldefense.com/
>>> v3/__https://kylemonette.github.io/
>>> mth103-book/fig_1_5_arc_graph-1.html__;!!
>>> Jh1S!
>>> jp78lxVL1X2KEoCWQvSD_fEPG0Vk8qxrjSzToKq-
>>> KFiR6Bgs7rsXy6r18gjBM85aVmsIyoYT8x7rNXVih3oo-9GwAy00ldY$>, for example. The latex only compiles once a point is moved. I tested this on Chrome and Safari.
>>>
>>> It appears that pretext is loading a
>>> script for jsxgraph that is out of date,
>>> based on their documentation <https://
>>> urldefense.com/v3/__https://jsxgraph.org/
>>> home/learn/gettingstarted/__;!!Jh1S!
>>> jp78lxVL1X2KEoCWQvSD_fEPG0Vk8qxrjSzToKq-
>>> KFiR6Bgs7rsXy6r18gjBM85aVmsIyoYT8x7rNXVih3oo-9GwnFXtGLk$>. See attached screenshot. An example <https://urldefense.com/v3/__https://jsxgraph.org/home/learn/templates/__;!!Jh1S!jp78lxVL1X2KEoCWQvSD_fEPG0Vk8qxrjSzToKq-KFiR6Bgs7rsXy6r18gjBM85aVmsIyoYT8x7rNXVih3oo-9GwFIKpx7Y$> on their website loads MJ4 as it should.
>>>
>>> I am using version 2.39.0 of Pretext CLI.
>>>
>>> Thank you for any help and insights!
>>>
>>> --
>>> You received this message because you are
>>> subscribed to a topic in the Google Groups
>>> "PreTeXt support" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/pretext-
>>> support/6WPUi-lfsLM/unsubscribe <https://
>>> urldefense.com/v3/__https://
>>> groups.google.com/d/topic/pretext-
>>> support/6WPUi-lfsLM/unsubscribe__;!!Jh1S!
>>> jp78lxVL1X2KEoCWQvSD_fEPG0Vk8qxrjSzToKq-
>>> KFiR6Bgs7rsXy6r18gjBM85aVmsIyoYT8x7rNXVih3oo-9GwIbiJSvI$>.
>>> To unsubscribe from this group and all its
>>> topics, send an email to pretext-
>>> suppo...@googlegroups.com.
>>> To view this discussion visit https://
>>> groups.google.com/d/msgid/pretext-support/
>>> f5cdc216-1f2a-4813-811a-084b3d6fafa6n%40googlegroups.com <https://urldefense.com/v3/__https://groups.google.com/d/msgid/pretext-support/f5cdc216-1f2a-4813-811a-084b3d6fafa6n*40googlegroups.com?utm_medium=email&utm_source=footer__;JQ!!Jh1S!jp78lxVL1X2KEoCWQvSD_fEPG0Vk8qxrjSzToKq-KFiR6Bgs7rsXy6r18gjBM85aVmsIyoYT8x7rNXVih3oo-9Gw7JDzLCo$>.
>>
>> --
>> You received this message because you are
>> subscribed to a topic in the Google Groups
>> "PreTeXt support" group.
>> To unsubscribe from this topic, visit https://
>> groups.google.com/d/topic/pretext-support/6WPUi-
>> lfsLM/unsubscribe <https://urldefense.com/v3/
>> __https://groups.google.com/d/topic/pretext-
>> support/6WPUi-lfsLM/unsubscribe__;!!Jh1S!
>> mU28rln65Tx1onDCkfLpWsBUkI_nZseNsuIEGbpo3bnWEnxs6NeeIvw24N3nT9fVRmSYoHpzAgWjMxc7Oiy_17VUrutXlRg$>.
>> To unsubscribe from this group and all its topics,
>> send an email to pretext-suppo...@googlegroups.com.
>> To view this discussion visit https://
>> groups.google.com/d/msgid/pretext-
>> support/693b1e72-9680-47e9-
>> ae12-1d2f10f5b750n%40googlegroups.com <https://
>> urldefense.com/v3/__https://groups.google.com/d/
>> msgid/pretext-support/693b1e72-9680-47e9-
>> ae12-1d2f10f5b750n*40googlegroups.com?
>> utm_medium=email&utm_source=footer__;JQ!!Jh1S!
>> mU28rln65Tx1onDCkfLpWsBUkI_nZseNsuIEGbpo3bnWEnxs6NeeIvw24N3nT9fVRmSYoHpzAgWjMxc7Oiy_17VUdYi-t9Y$>.
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to pretext-suppo...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/
> pretext-support/236bb966-
> d494-4495-9781-4b5ce34b4603n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/236bb966-
> d494-4495-9781-4b5ce34b4603n%40googlegroups.com?
> utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/7d580193-1529-4fed-b6aa-da5459bb6486n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/7d580193-1529-4fed-b6aa-
> da5459bb6486n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages