// Numbas version: exam_results_page_options {"name": "How to substitute randomised raw LaTeX into question text", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"showfrontpage": false, "allowregen": true, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"extensions": [], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "

In the following, the variable `a` has the value `\"x\"`

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
CodeDisplayExplanation
`\$\\simplify{ {a} }\$`\$\\simplify{ {a} }\$`a` is a string, so set in \\textrm
`\$\\var{a}\$`\$\\var{a}\$`a` is a string, so set in \\textrm
`\${a}\$`\${a}\$No substitution - this is plain LaTeX
`{a}`{a}Substituted in plain text, not LaTeX
`\$\\simplify{ {latex(a)} }\$`\$\\simplify{ {latex(a)} }\$`\\simplify` can't have bits of stray LaTeX inside it since it needs to rearrange the expression, so the `latex()` function is ignored.
`\$\\var{latex(a)}\$`\$\\var{latex(a)}\$The `latex()` function marks the string as raw LaTeX code
`\${latex(a)}\$`\${latex(a)}\$No substitution - this is plain LaTeX
`{latex(a)}`{latex(a)}Substituted in plain text, not LaTeX
`\$\\simplify{{a_undefined}}\$`\$\\simplify{{a_undefined}}\$The variable `a_undefined` is not defined, so the name is rendered as-is without substitution.
`\$\\var{a_undefined}\$`\$\\var{a_undefined}\$The variable `a_undefined` is not defined, so the name is rendered as-is without substitution.
`\$\\var{latex(a_undefined)}\$`Math Processing ErrorThe `latex()` function expects a string, not an unbound variable name, so fails.
`{a_undefined}`{a_undefined}The variable `a_undefined` is not defined, so the name is rendered as-is without substitution.