List of commands

A consolidated reference of commands, including ones not listed anywhere else on this wiki.

This list can go stale. If a command you need isn't listed, or something here looks wrong, check the wiki page for that topic (linked below where available) before assuming it doesn't exist.

For worked examples and explanations, see the topic-specific pages: input.fields.md,
number-fields.md, Variables.md, Answer-types.md,
Feedback-and-Explanations.md, Randomquestionpool.md,
mc.questions.md, JSX-Visualizations.md.

Authoring commands for problems

Args is the number of mandatory arguments; Optional default (if present) is what an omitted
optional first argument defaults to.

Command Args Optional default Notes
\allMustBeCorrect 0 - Requires every answer in the question to be correct for any credit to be given at all.
\allowForConditionInput{...} 2 [true] Same as \allowForInput, but for the input used in an explanation condition rather than the main answer.
\allowForInput{symbols} 2 [true] Extends or restricts which symbols the student may type, e.g. \allowForInput{+ - * / pi} to permit π. Without it, only plain digits are accepted.
\allowIntervalUnionsForInput 1 [true] Lets the student's answer be a union of several disjoint intervals instead of just one. See Interval.md.
\assertion{...} 1 - Declares a boolean expression as a named assertion for later reference, similar in spirit to \condition.
\checkAsFunction{var(s)}{min}{max}{steps} 4 [epsilon] default 1e-8 Grades a function/interval answer by comparing it numerically to the solution at random points. var(s) accepts a comma-separated list for multivariate functions - see input.fields.md.
\checkCorrect{relation} 1 - Grades the answer as correct if the given relation (e.g. an equation between variables) holds; preferred over the deprecated \iscorrect.
\checkFuncForZero{...}{min}{max}{steps} 4 [epsilon] default 1e-8 Like \checkAsFunction, but checks that an expression evaluates to zero rather than comparing two functions.
\checkMatrixForZero{...}{min}{max}{steps} 4 [epsilon] default 1e-8 Matrix counterpart of \checkFuncForZero - checks that every entry of a matrix expression evaluates to zero.
\checkStringsForRelation{...}{...} 2 [] Grades a text/string answer by checking whether it satisfies a given relation to the solution.
\chooseRandomPools{...} 1 - Picks a random subset of the listed question pools to actually present to the student.
\columnTitle{...} / \rowTitle{...} 1 each - Labels a column or row header in an mc.matrix question.
\condition 0 (used as a value) - Placeholder used inside a condition expression to refer to the surrounding condition itself.
\consecutivequestions{...}{...}{...} 3 - Chains several questions so they must be answered one after another rather than freely.
\derivative{name}{fn}{var} 4 [] Defines a variable as the derivative of function fn with respect to var. The 4th (optional-looking) argument is actually mandatory - check a working example before using it.
\drawFromSet{name}{set} 3 [type=number separator=,] Randomly picks one value from a given set into a variable. The default is numeric - pass [type=string] for symbols/strings.
\duration{...}{...} 2 [] Sets a time limit for a question or problem.
\earlierAnswer{...}{...} 2 - Refers back to an answer given in an earlier question, e.g. for consecutive/follow-up questions.
\embedmathlet{name} 1 - Embeds the interactive applet for the problem; required at the end of \begin{content}.
\explanation{...} 1 or 2 - Shows feedback text to the student depending on their answer. The 2-arg form takes an optional condition as arg 1: \explanation[condition]{text} - see Feedback-and-Explanations.md.
\field{field} 1 - Sets the number field (real, rational, complex, ...) variables and answers are interpreted in - see Valid \field values below.
\followupQuestion{...}{...} 2 [1=1] Makes a question only appear depending on how an earlier question was answered.
\format{...}{...} 2 - Sets the display format of a matrix answer field; only valid inside \begin{answer} together with \matrixType.
\function{name}{expr} 2 or 3 [replace] (3-arg form) Defines a variable holding an algebraic expression, optionally transformed (calculate, normalize, expand, derivative, substitute, sort). expr must always be a pure arithmetic expression, never a relation (=, <, >) - see Function.md for the full syntax and gotchas (e.g. \var{} never simplifies signs, use [normalize] for that).
\functionNormalize{...}{...} 2 [true] Shorthand for normalizing a function expression into a canonical algebraic form; see the [normalize] note on \function above.
\inputAsFunction{vars}{name} 2 - Names a multivariate function input for later reference (e.g. in \checkStringsForRelation).
\inputAsMatrix{vars}{name} 2 - Matrix counterpart of \inputAsFunction - names a matrix input for later reference.
\inputAsString{name} 1 - Names a text input for later reference, analogous to \inputAsFunction.
\iscorrect{lhs}{rel}{rhs} 3 - Older form of \checkCorrect; deprecated, use \checkCorrect instead.
\levelrepeatable 0 - Allows a difficulty level of the problem to be repeated rather than always advancing.
\levelthreshold{...} 1 - Sets the score threshold needed to advance to the next difficulty level.
\matrix{...}... / \pmatrix{...}... / \rowVector{...}... 3 [replace] Defines a matrix (or row-vector) variable, optionally computed from other matrices. See Matrix-Variables.md.
\matrixType{...} 1 - Sets the display type (e.g. brackets style) for a matrix answer field, used together with \format.
\MCScoreType{...}{...} 2 [] Configures how partial credit is computed for a multiple-choice question.
\number{name}{value} 2 - Defines a fixed (non-random) numeric variable.
\partialScore{...}{...} 2 - Awards partial credit for an answer that is only partly correct.
\permutechoices{begin}{end} 4 [2{}{}] Randomly shuffles the order of multiple-choice options between the given indices. Optional [n][mandatory indices] form pins some options in place - see mc.questions.md.
\permutecolumns{...}{...} 2 - Randomly shuffles the columns of an mc.matrix question.
\permuterows{...}{...} 2 - Randomly shuffles the rows of an mc.matrix question.
\precision{...}{...} / \correctorprecision{...}{...} / \displayprecision{...} 2/2/1 [atleast] for the first two Controls how many decimal digits are shown to the student vs. required for a correct match - see number-fields.md.
\randadjust{vars}{script} 2 - Post-processes one or more random variables with a small script after they are drawn, e.g. to enforce a relationship between them.
\randadjustIf{vars}{condition} 2 - Re-draws random variables until a given condition on them is satisfied.
\randdouble{name}{min}{max} 3 - Draws a random decimal number between min and max into a variable.
\randint{name}{min}{max} 3 [4][z] variant excludes 0 Draws a random integer between min and max into a variable; the [z] variant excludes 0.
\randomquestionpool{...}{...} 2 - Presents one randomly chosen question out of a pool of equivalent questions - see Randomquestionpool.md.
\randrat{name}{...}{...}{...}{...} 5 - Draws a random rational number (fraction) into a variable, with bounds on numerator/denominator.
\relation{...}{...}{...} 3 - Defines a relation (e.g. <, =, >) between two expressions for use in grading or conditions.
\score{points} 2 [false] Sets the maximum score/points value for a question.
\scoreNotCanceledDown{...} 1 - For rational-field answers: still awards points if the student's fraction is mathematically correct but not fully canceled down.
\setRandomOne{...}{...} 2 - Randomly activates exactly one of several alternative blocks.
\showExplanation{always} 1 - Question-level only; makes explanations show even when the answer was correct, not just when it's wrong.
\showQuestionLabels{...} 1 - Controls whether automatic question numbering/labels are shown.
\showScore 0 - Displays the achieved score to the student after correction.
\solution{var} or \solution{var1,var2,...} 1 - Declares the correct-answer variable(s) for an answer field. A comma-separated list is used for input.finite-number-set (no separate set-building command exists).
\string{name}{value} 2 - Defines a fixed text/string variable.
\substitute{...}... 5 [] Defines a variable as another expression with one variable substituted by a value or sub-expression.
\text{...} 1 or 2 - The visible question/answer text shown to the student; exactly one \text per \lang/block.
\type{type} 1 - Sets the answer type (e.g. input.number, mc.unique, ...) for an answer block - see Valid \type values below.
\usedVars{...} 1 - Marks which variables were actually used/referenced, e.g. to avoid an "unused variable" warning.
\YesNoLabel{yes}{no} 3 [] Sets custom labels for the yes/no options of an mc.yesno question.

Valid \type{} values

Complete list (17):

draganddrop, graphics.function, graphics.matrix, graphics.number, input.cases.function,
input.finite-number-set, input.function, input.generic, input.interval, input.matrix, input.number,
input.text, input.truth-table, mc.matrix, mc.multiple, mc.unique, mc.yesno

input.generic is a question-level "container" type used when one question has several
\begin{answer} blocks with different concrete types - each individual answer block then
carries its own concrete \type.

There is no input.set or input.finite-set - the real value is input.finite-number-set, and
it needs no dedicated check command at all: \solution{var1,var2,...} with individually-defined
variables is sufficient.

Valid \field{} values

real, rational, integer, complex, complex-rational, opnumber

Plus the calculation-only op-* variants (op-double, op-rational, op-complex,
op-complex-rational, op-integer) for computed op-number expressions - not typically used as a
typed answer field. See number-fields.md for details and caveats per field.

Valid comparison / check functions

equal, equalChoice, equalFormat, equalString, equalTrimmedString, equalIgnoreCaseString,
answerEqual, answerExactMatch

equalChoice works only for mc.unique/mc.yesno/mc.multiple (choice-index comparison) -
it does not generalize to other \type values.

Visualization commands

A separate command family for interactive geometry/graphing visualizations (JSXGraph/CindyJS-backed):
\point, \line, \circle, \segment, \vector, \polygon, \slider, \plot, and a
visualization-specific 4-argument \function overload (distinct from the problem-authoring
\function above). See JSX-Visualizations.md and CindyJS.md
for the full picture.

One command worth calling out explicitly: \set{name}{definition}{style}{bool} (4 arguments) is a
real command, but it defines a geometric set/locus object inside a visualization - it has no
relationship to solution-set answers in problems (for those, use \type{input.finite-number-set}
with \solution{var1,var2,...}).