Difference of displaying same "code" in different settings

Skip to first unread message

Julia Goedecke

Mar 9, 2021, 2:06:06 PMMar 9
to Numbas Users
I have discovered that a variable string with some maths in it is
displayed differently in the statement of a question than as one of the
choices of a multiple select part. Any ideas why this would be?

Minimal example:

I can make either display the curly braces, but not both with the same


Dr Julia Goedecke
Teaching Fellow in Mathematics
University of Leicester


Christian Lawson-Perfect

Mar 18, 2021, 10:23:17 AMMar 18
to numbas...@googlegroups.com
Thanks for spotting this. Curly braces in LaTeX in string variables caused me a lot of headaches years ago, before we had "safe" strings. The routine to substitute variables into content areas would strip the first slash before a curly brace, so you'd have to put double slashes in the string in order to end up with \{. In fact, since you need to escape slashes in the JME code, this meant that you'd need four slashes! This was all so that the substitution routine doesn't interpret the curly braces as delimiting another substitution when the string was evaluated.
The 'safe' function works much better: it marks a string so that the substitution routine doesn't modify it, no matter when or where the string is evaluated. I've changed the substitution-into-content-area routine so it doesn't modify 'safe' strings, so now you get the same behaviour in the statement as for the choices, if the string is marked as 'safe'.

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.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/e9e5fb57-a252-5454-b9d9-9e5f965f1d01%40cantab.net.
Reply all
Reply to author
0 new messages