Open christianp opened 2 years ago
This happens because \var
and \simplify
are only evaluated once MathJax renders the LaTeX code, so that we don't have to parse/evaluate LaTeX twice.
One way round this would be to find \var
and \simplify
inside LaTeX in strings at the time they have plain-text substitutions applied, and evaluate them there. This used to be how it worked, but I must have encountered cases where a simple string-replace doesn't work. The most basic example of that that I can think of is \text{\var{a}}
- this should display plain text \var{a}
instead of interpreting it as a macro.
Constructing strings of LaTeX in variables is quite awkward: for example, if I want to randomise the coefficients in a polynomial, then I might try "\\simplify{ {a}x^2 + {b}x + {c} }"
. That isn't evaluated until MathJax sees it in the page, and the uses of the variables a
, b
and c
aren't detected by findvars
.
If I use
\var
in a feedback message and refer to a variable defined in the marking scope, such asincorrect("Your position is $\\var{pos}$")
, then it's not displayed correctly: the\var
handler doesn't have access to the marking scope when it displays the message.Actually, this could happen outside feedback, if a LaTeX string refers to a variable defined using
let
.