latex typesetting in jsxgraph

126 views
Skip to first unread message

Peter Johnston

unread,
Feb 24, 2019, 9:17:57 PM2/24/19
to Numbas Users
Hello,

I have the following piece of latex code to label a vector in a jsxgraph extension function:

{size:'none',name:'\\[\\underline{v}\\]'} (this is part of a point definition)

This produces an underlined letter "v" in a latex math font.

However when I use

{size:'none',name:'\\[\\underline{v}_{\\perp}\\]'}

to indicate the perpendicular component of v, I get the following string on my image: \[\underline{v}\perp\] (note that the string \perp\] looks like a subscript in my image.

I was wondering what it is that I have missed.

Thanks,

Peter.

Christian Lawson-Perfect

unread,
Feb 25, 2019, 3:33:54 AM2/25/19
to numbas...@googlegroups.com
Can you give me a link to a question that shows this behaviour, please?

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Johnston

unread,
Feb 26, 2019, 3:54:29 AM2/26/19
to Numbas Users
Thanks Christian,

I'm not sure how to do this, but from the firefox address window I have:


Please let me know if this helps.

Thanks,

Peter.

Peter Johnston

unread,
Mar 1, 2019, 1:48:11 AM3/1/19
to Numbas Users
I found the answer to my own query (amazingly I had already used it once before!!!)

One needs to include the lines:

// option to use mathjax to render latex
JXG.Options.text.useMathJax = true;

(well at least the second line) at the top of the function definition.

Peter.

Christian Lawson-Perfect

unread,
Mar 4, 2019, 3:50:38 AM3/4/19
to numbas...@googlegroups.com
Glad you sorted it. I suppose the extension should turn that option on by default.

--

Peter Johnston

unread,
Mar 4, 2019, 6:10:17 AM3/4/19
to Numbas Users
I have now discovered a weirdness introduced by the JXG option as listed below. It seems to screw up the latex typesetting in the statement of the problem and the advice section. For example $\underline{u}$ produces the letter u typeset in latex math font, but the underline is almost a full line of text underneath the letter. I am still working with example entitled "Projecting Vectors".

Thanks,

Peter.

Peter Johnston

unread,
Mar 11, 2019, 2:15:07 AM3/11/19
to Numbas Users
Hello,

I would like to follow up this weirdness some more.

I have created and assigned (through a SCORM file under BlackBoard) a quiz for my students where the question involving the JXG option mentioned below has been included. My students intermittently get the result as shown in fig1.png. Here the latex typesetting is not rendered and the numerical variables are not displayed. Does this imply that there is something missing on their computers? Having said that, I have not be able to reproduce the same problem on my own computer using firefox, chrome and safari, as well as several other computers. The only time I did reproduce the error was in our university library common computing area (Windows 10 under firefox and chrome). However, here, it did not happen all the time. I could shut down the quiz and restart it and it would be fine, but then I shut that down, restart again and the error came back.

Now, going back to the original question which prompted this discussion. Fig2.png shows the effect of including the JXG option line

JXG.Options.text.useMathJax = true;

in the extension code for a Numbas test run. The figure shows the advice section of the question. Note that the latex is typeset correctly in the graph, but the latex in the advice text is not correctly typeset. Fig3.png shows a similar figure generated with the JXG option line removed, also for a Numbas test run. Here the latex in the graph is not typeset correctly, but it is in the advice text. To make things more complicated, fig4.png shows a similar figure that was generated using the final quiz that I developed, downloaded as a SCORM file and uploaded to blackboard at our university. Here, both the graph and the advice latex are typeset correctly.

This is all very confusing to me. It is more than a little frustrating for my students. If anyone has any insights or any suggestions to make things clearer, that would be great. Is it a matter of a bad browser version? missing or incorrectly installed software (eg javascript)? Or is it something more fundamental.

Thanks very much,

Peter.
fig1.png
fig2.png
fig3.png
fig4.png

Christian Lawson-Perfect

unread,
Jun 24, 2019, 3:53:36 AM6/24/19
to numbas...@googlegroups.com
I've come back to this, and I can't reproduce the problem in Firefox. Did you fix it? If not, I'll need to test with more browsers.

Peter Johnston

unread,
Mar 4, 2020, 1:44:16 AM3/4/20
to numbas...@googlegroups.com
Dear Christian,

Thanks for your reply. I have only just got back to this problem myself.

It would appear that if I use the option 

JXG.Options.text.useMathJax = true;

in my JXG function under the extensions and scripts tab, then the latex is rendered correctly in the figure generated. However, this affects the behaviour of the subsequent latex typesetting in the normal advice section.

If I set the above option to false, then the latex is not correctly typeset in the figure, but the remaining advice text is fine.

Any thoughts?

Regards,

Peter.

Associate Professor Peter Johnston (FAustMS, FIMA)
School of Environment and Science
Griffith University | Nathan | QLD 4111 | Technology (N44) Room 3.19
T +61 7 373 57748| F +61 7 373 57656 Email 
p.joh...@griffith.edu.au

From: numbas...@googlegroups.com <numbas...@googlegroups.com> on behalf of Christian Lawson-Perfect <christia...@gmail.com>
Sent: Monday, 24 June 2019 5:53 PM
To: numbas...@googlegroups.com <numbas...@googlegroups.com>
Subject: Re: latex typesetting in jsxgraph
 
You received this message because you are subscribed to a topic in the Google Groups "Numbas Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/numbas-users/IulaLp-FBaM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/CAEMHSOjzetTwbJ9W7%3DLPHUyMgm50uHFQ2s1O6hkqr3mCgB6xMw%40mail.gmail.com.

Christian Lawson-Perfect

unread,
Jul 2, 2020, 9:13:33 AM7/2/20
to numbas...@googlegroups.com
Peter, I think I've finally worked this out!
MathJax has a queue system, written before JS Promises were a thing, to let you ask for elements to be typeset without hanging the whole page.
It lets you create your own queues, so I'd set up Numbas to make its own queue for typesetting elements. It turns out that MathJax doesn't try to resolve race conditions between queues, so JSXGraph was using the standard queue and having its work overridden by the Numbas one shortly after. I've made Numbas use the standard MathJax queue, and it all now seems to render properly. Phew!

Peter Johnston

unread,
Jul 5, 2020, 8:32:30 PM7/5/20
to numbas...@googlegroups.com
Thanks Christian,

That is great news.

I enjoyed the EAMS conference presentations.

Regards,

Peter.

Associate Professor Peter Johnston (FAustMS, FIMA)
School of Environment and Science
Griffith University | Nathan | QLD 4111 | Technology (N44) Room 3.19
T +61 7 373 57748| F +61 7 373 57656 Email 
p.joh...@griffith.edu.au

From: numbas...@googlegroups.com <numbas...@googlegroups.com> on behalf of Christian Lawson-Perfect <christia...@gmail.com>
Sent: Thursday, 2 July 2020 11:13 PM
Reply all
Reply to author
Forward
0 new messages