Skip to content

Questions

The question function is the core building block for exam content. Questions are automatically numbered, track points, and support arbitrary nesting for sub-parts.

#question(points: <int|float|dict>, aggregate: <bool>, inline: <bool>, body)
ParameterTypeDefaultDescription
pointsint, float, dictionary(:)Points for this question. A number is shorthand for (points: n). A dict maps categories to values.
aggregateboolfalseWhen true, points shown are the sum of nested sub-questions.
inlineboolfalseWhen true, renders inline (as a box with width: 1fr).
render-question-counterfunction or nonenoneLocal override for counter display.
render-pointsstr, function, or nonenoneLocal override for point formatting.
points-positionstr, function, or nonenoneLocal override for point positioning.

Questions can be nested to create lettered sub-parts:

#examst-set(
  render-question-counter: it => [
    #let depth = it.get().len()
    #let last = it.get().last()
    #if depth == 1 { numbering("1.", last) }
    #if depth == 2 { numbering("(a)", last) }
  ],
)

#question(aggregate: false)[
  Thermodynamics
  #question(points: 6)[State the first law.]
  #question(points: 4)[State the second law.]
  #question(points: 5)[State the third law.]
]

Use aggregate: true on a parent question to display the sum of its children’s points at the parent level:

#examst-set(
  render-question-counter: it => [
    #let depth = it.get().len()
    #let last = it.get().last()
    #if depth == 1 { numbering("1.", last) }
    #if depth == 2 { numbering("(a)", last) }
  ],
)

#question(points: 20, aggregate: true)[
  #question(inline: true)[Define the universe.]
  #question()[Give three examples.]
]

Control where points appear relative to the question text:

#examst-set(
  render-question-counter: it => numbering("1.", it.get().last()),
  points-position: "right-margin",
  render-points: "boxed",
)

#question(points: 10)[
  Explain why the sky is blue.
]
PositionDescription
"inline"After the counter, before the body (default)
"before-counter"Before the counter
"after-body"At the end of the question
"left-margin" / "right-margin"Placed in the page margin
"two-sided" / "two-sided-reversed"Alternates margins on odd/even pages