Multiple choice
Multiple choice questions can be written with #choices[..] for an automatically formatted list, or with #choice[..] and #bubble() for finer-grained control.
A #choices[..] accepts a mixed list with both - and + starting a line or an array of content. Lines starting with + are recorded as correct choices. Alternatively, correct choices can be given with correct:, by their 0-based index (correct: 1), by their label when the bubbles are labelled (correct: "B"), or as an array of these (correct: (0, 2, 3)).
#question(points: 1)[
What is the capital of Canada? _Select one._
#choices[
- Toronto
+ Ottawa
- Montreal
- Vancouver
]
]
#question(points: 1)[
Which cities lie on Canada's southern border? _Select all that apply._
#choices(
bubble: "square",
correct: (0,2,3),
([Toronto], [Ottawa], [Montreal], [Vancouver])
)
]#import "@preview/examy:1.1.0": *
#show: exam.with(show-solutions: false) // true for the answer key
#question(points: 1)[
What is the capital of Canada? _Select one._
#choices[
- Toronto
+ Ottawa
- Montreal
- Vancouver
]
]
#question(points: 1)[
Which cities lie on Canada's southern border? _Select all that apply._
#choices(
bubble: "square",
correct: (0,2,3),
([Toronto], [Ottawa], [Montreal], [Vancouver])
)
]Rows and columns
By default, choices are listed one per line, but they can also be laid out in a paragraph or in columns.
inline: true- Run the choices side by side, wrapping like words. This suits short choices.
columns: n- Lay the choices out in
nequal columns, filled row by row. gap- The space between choices. Inline,
gap: 1frspreads the choices across the line.
#question(points: 1)[
Which of these numbers is prime?
#choices(inline: true, correct: 1, (9, 11, 15, 21))
]
#question(points: 2)[
Which of these functions are continuous at $x = 0$?
_Select all that apply._
#choices(bubble: "square", columns: 2)[
+ $sin x$
- $1/x$
+ $abs(x)$
- $floor(x)$
]
]#import "@preview/examy:1.1.0": *
#show: exam.with(show-solutions: false) // true for the answer key
#question(points: 1)[
Which of these numbers is prime?
#choices(inline: true, correct: 1, (9, 11, 15, 21))
]
#question(points: 2)[
Which of these functions are continuous at $x = 0$?
_Select all that apply._
#choices(bubble: "square", columns: 2)[
+ $sin x$
- $1/x$
+ $abs(x)$
- $floor(x)$
]
]Round, square, and labelled bubbles
The shape of a choice’s bubble can be set using bubble: "circle" (default) or bubble: "square" (often used for select-all-that-apply questions).
Setting enumerate: true will label the bubbles with the letters A, B, C, … in sequence. For custom lettering, you can supply a numbering string, an array, or a function that determines the label.
#question(points: 1)[
Which planet is largest?
#choices(enumerate: true)[
- Mars
+ Jupiter
- Venus
]
]
#question(points: 1)[
Which planet is your favorite?
#choices(enumerate: "i", inline: true)[
+ Mars
- Jupiter
- Venus
]
]#import "@preview/examy:1.1.0": *
#show: exam.with(show-solutions: false) // true for the answer key
#question(points: 1)[
Which planet is largest?
#choices(enumerate: true)[
- Mars
+ Jupiter
- Venus
]
]
#question(points: 1)[
Which planet is your favorite?
#choices(enumerate: "i", inline: true)[
+ Mars
- Jupiter
- Venus
]
]If you would like to set exam-wide defaults for choices, use the global config.
#show: exam.with(choices-enumerate: "a", bubble-stroke: .06em)Relevant options are:
choices-enumerate- Label each bubble in a choice
#choices[..]with letters. choices-inline,choices-columns,choices-gap- Effects the layout
choices. bubble-label-font- The font of letters used when
choices-enumerateis set to true (by default, the monospace). bubble-size- The size of every round bubble (by default,
1em). Square bubbles are drawn a little smaller, in the same proportion as by default. bubble-stroke- The outline of every bubble, as a stroke: a thickness (by default,
.1em), a color, or both (e.g..06em + gray). bubble-outset- The space around every bubble, as
outsetgives it.
A single choice takes size, stroke, and outset itself, and a single choices takes those and label-font for all its bubbles. Each wins over the global option, and a stroke that gives only a color (e.g. stroke: blue) keeps the global thickness. Both also take solution-color and solution-background-color, which set the colors of a correct bubble on the answer key in place of the global config options of the same names.
Custom layouts
To fully customize layouts, you can use the #choice[..] function directly to draw choices one at a time, or the #bubble() and #square-bubble() functions to draw bubbles without associated content.
#question(points: 1)[
Let $f(x) = 1/x$. Which statement is true?
#table(
columns: (auto, 1fr),
align: (center + horizon, left),
[#bubble()], [$f$ is increasing on $(0, 1)$.],
[#bubble(correct: true)], [$f$ is decreasing on $(0, 1)$.],
)
]
#question[
#choice[Agree] #h(1em)
#choice(correct: true)[Disagree] #h(1em)
#choice[Unsure]
]#import "@preview/examy:1.1.0": *
#show: exam.with(show-solutions: false) // true for the answer key
#question(points: 1)[
Let $f(x) = 1/x$. Which statement is true?
#table(
columns: (auto, 1fr),
align: (center + horizon, left),
[#bubble()], [$f$ is increasing on $(0, 1)$.],
[#bubble(correct: true)], [$f$ is decreasing on $(0, 1)$.],
)
]
#question[
#choice[Agree] #h(1em)
#choice(correct: true)[Disagree] #h(1em)
#choice[Unsure]
]