Release v1.2.2#

Release Date: November 10, 2026

This is a patch release that fixes LaTeX/PDF build failures when a captioned figure is placed inside an exercise or solution.

πŸ› Bug Fixes#

Figures inside exercises and solutions in LaTeX/PDF output#

A figure with a caption inside an exercise or solution directive, including the gated exercise-start / solution-start forms, stopped the LaTeX build with LaTeX Error: Not in outer par mode (#94). In Jupyter Book projects this usually came from a code-cell with mystnb: figure: caption: metadata inside a solution. HTML output was not affected.

Cause:

  • Sphinx writes figures inside its own admonitions as non-floating \begin{figure}[H], because LaTeX does not allow a floating figure inside the admonition box

  • sphinx-exercise draws exercises and solutions with the same box, but did not tell Sphinx’s LaTeX writer that it had opened one, so figures inside were written as floating \begin{figure}[htbp]

Fix:

  • Exercise and solution boxes now update the same counter that Sphinx uses for its own admonitions, so figures inside them are written as \begin{figure}[H] and stay in place inside the box (#95)

Impact:

  • LaTeX/PDF builds with captioned figures inside exercises or solutions now succeed

  • Figures outside exercise and solution boxes still float as before

  • HTML output is unchanged

Example Error (before fix):

! LaTeX Error: Not in outer par mode.
l.107 \begin{figure}[htbp]

CI Test Reliability#

Fixed CI test failures on Sphinx 6 and 7 caused by a newer pydata-sphinx-theme release, by switching the gated directive test root to the alabaster theme (#88). This change only affects the test suite.

πŸ“¦ Installation#

Install or upgrade via pip:

pip install --upgrade sphinx-exercise

πŸ”„ Migration Notes#

If you’re upgrading from v1.2.1:

  • No breaking changes

  • No action required

  • If you removed figure captions inside exercises or solutions to work around this LaTeX error, you can now restore them

Compatibility:

  • Python 3.10, 3.11, 3.12, 3.13

  • Sphinx 6, 7, 8

  • Sphinx 9 is not yet covered by the test suite (see #96)

πŸ“š Documentation#

For complete documentation, see: