// Numbas version: exam_results_page_options {"name": "How to substitute randomised raw LaTeX into question text", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variablesTest": {"maxRuns": 100, "condition": ""}, "rulesets": {}, "variables": {"a": {"group": "Ungrouped variables", "definition": "\"x\"", "description": "", "templateType": "anything", "name": "a"}}, "functions": {}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

A table showing how to substitute raw LaTeX code into question text.

\n

NOTE: You probably don't want to do this! There's usually a more robust way, where you get Numbas to make the expression for you.

"}, "name": "How to substitute randomised raw LaTeX into question text", "advice": "", "tags": [], "preamble": {"css": "td {\n padding-bottom: 0.6em !important;\n padding-top: 0.6em !important;\n}\ntr:not(:last-child) td {\n border-bottom: 1px dashed #ccc;\n}\ntd:first-child {\n text-align: left !important;\n}\ntd:nth-child(2) {\n text-align: center !important;\n}\ntd:last-child {\n padding-left: 2em !important;\n font-size: 0.8em;\n}", "js": ""}, "ungrouped_variables": ["a"], "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.
", "parts": [], "extensions": [], "type": "question", "variable_groups": [], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}