answer directive#

The answer directive creates a styled admonition for displaying answers to problems. By default it is collapsed (dropdown) so students can reveal the answer when ready.

Basic usage#

:::{answer}
$x = 3$
:::

which yields:

Custom title#

You can provide a custom title as the directive argument:

:::{answer} Solution to Exercise 1
$f'(x) = 2x - 3$, so $f'(x) = 0$ gives $x = \frac{3}{2}$.
:::

which yields:

Expanded by default#

Set dropdown: 0 to show the answer expanded instead of collapsed:

:::{answer} Quick check
:dropdown: 0
The answer is 42.
:::

which yields:

Quick check

The answer is 42.

Options#

Option

Meaning

dropdown

1 (default) to collapse, 0 to expand

Source#

The implementation lives in src/munchboka_edutools/directives/admonitions.py.