jsxgraph and mathjax issues

59 views
Skip to first unread message

Kyle Monette

unread,
May 24, 2026, 3:36:40 PM (5 days ago) May 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 AM (3 days ago) May 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 AM (3 days ago) May 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 AM (3 days ago) May 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 AM (3 days ago) May 26
to pretext...@googlegroups.com

OHappyDay

unread,
May 26, 2026, 10:42:40 AM (3 days ago) May 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 AM (3 days ago) May 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 PM (2 days ago) May 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 PM (2 days ago) May 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 PM (22 hours ago) May 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 PM (22 hours ago) May 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,
9:16 AM (4 hours ago) 9:16 AM
to PreTeXt support
I can confirm that the fix is also working in my local environment.
Reply all
Reply to author
Forward
0 new messages