Repository navigation
Upgrade sphinx-exercise to 1.2.2 and restore figure captions in solutions - #1121
Conversation
…ions sphinx-exercise 1.2.2 writes a captioned figure inside an exercise or solution box as [H], so the LaTeX build no longer stops with "Not in outer par mode". Restore the nine captions removed as the workaround in #1101, #1110 and #1119. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZoSvoQTbzkdmZiMnd
sphinx-exercise 1.2.2 writes a captioned figure inside an exercise or solution box as [H], so the LaTeX build no longer stops with "Not in outer par mode". This lands before QuantEcon/lecture-python.myst#1121, whose restored captions in solutions reach this repository through the translation sync. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZoSvoQTbzkdmZiMnd
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🔵 Needs a closer look
This change alters PDF build behavior via a dependency upgrade and explicitly requires cross-repo coordination (moving the lecture-python.zh-cn pin first), so a reviewer should verify CI PDF output and downstream sync impacts before approval.
No open issues 🎉
What changed in this PR
Upgrades sphinx-exercise to 1.2.2 to address LaTeX figure placement inside exercise/solution boxes, and restores MyST-NB figure captions/labels for solution-embedded figures so they render correctly again (including in PDF builds).
Changes:
- Bump
sphinx-exercisefrom1.2.1to1.2.2in the main environment and the Colab workflow. - Re-add
mystnbfigurecaption/namemetadata for 9 figures across 5 lectures (inside gated solutions).
| File | Description |
|---|---|
| lectures/lucas_prescott_search.md | Restores MyST-NB figure caption/name metadata for three figures produced in gated solution code cells. |
| lectures/learning_approximation.md | Restores MyST-NB figure caption/name metadata for two solution-embedded figures. |
| lectures/information_transfer.md | Restores MyST-NB figure caption/name metadata for one solution-embedded figure. |
| lectures/genetic_classifier.md | Restores MyST-NB figure caption/name metadata for one solution-embedded figure. |
| lectures/exchange_rate_learning.md | Restores MyST-NB figure caption/name metadata for two figures inside gated solutions. |
| environment.yml | Updates the pinned sphinx-exercise version to 1.2.2 in the project environment. |
| .github/workflows/collab.yml | Updates the workflow’s pinned sphinx-exercise version to 1.2.2 in the dependency install step. |
Review effort: Balanced
📖 Netlify Preview Ready!Preview URL: https://pr-1121--sunny-cactus-210e3e.netlify.app Commit: 📚 Changed Lectures
Build Info
|
## Why Lecture-matrix run [42942041680](https://github.com/QuantEcon/actions/actions/runs/42942041680), dispatched on `main` to test #307 on all eight legs, failed one: `lecture-python.myst · quantecon`, at "Build PDF (No Execution)". pdflatex stopped with `LaTeX Error: Not in outer par mode` at a `\begin{figure}[htbp]` inside an exercise solution. QuantEcon/lecture-python.myst#1121 (merged 2026-11-11 00:26 UTC) restored figure captions in its solutions and moved that repository to `sphinx-exercise==1.2.2`. [sphinx-exercise 1.2.2](https://github.com/executablebooks/sphinx-exercise/releases/tag/v1.2.2) (released 2026-11-10) writes a captioned figure inside an exercise or solution box as `\begin{figure}[H]`, as Sphinx does inside its own admonitions, which is what pdflatex needs there. The full `quantecon` image pins `sphinx-exercise==1.2.1` exactly, and the matrix doesn't apply a lecture's `environment.yml` to it, so that leg built with 1.2.1. The `quantecon-build` leg of the same repository ran 1.2.2 and passed its PDF build. ## Changes | File | Change | |---|---| | `containers/quantecon/environment.yml` | `sphinx-exercise==1.2.1` → `==1.2.2` | | `containers/quantecon-build/environment.yml` | `sphinx-exercise>=1.2.1` → `>=1.2.2`, so the lean image's floor matches, as #293 did for the theme | Both are pip entries, and 1.2.2 is on PyPI. No other file in the repository names a sphinx-exercise version. ## What I checked - The failing leg's log lists `sphinx-exercise 1.2.1`; the passing `lecture-python.myst · quantecon-build` leg lists `1.2.2`. - 1.2.2's release notes name this exact error for a captioned figure inside an exercise or solution, and say HTML output is unchanged. - #307 is not involved: every jupyter build step that ran in that matrix run passed (seven legs; the eighth was skipped after the PDF failure), and lecture-python.myst's jupyter build passed on `quantecon-build`. - lecture-python.myst's own `ci.yml` and `publish.yml` install its `environment.yml` with setup-miniconda, so its published site was never affected. ## After merge The merge rebuilds both images, promotes them to `:latest` once the smoke tests pass, and starts a lecture-matrix run, which should turn `lecture-python.myst · quantecon` green. Merge it on its own, not while a lecture-matrix run is in progress. Its CHANGELOG entry goes in the next release PR, as #293's did. ## Not in this PR Any other image dependency: Dependabot's weekly conda run covers those. _Claude Code (on behalf of mmcky)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WT8bMbZoC2dpGt3sPyBjyd Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upgrades sphinx-exercise from 1.2.1 to 1.2.2 and puts back the figure captions that were removed to keep the PDF build working.
sphinx-exercise 1.2.1 wrote a captioned figure inside an exercise or solution box as a floating
\begin{figure}[htbp], which LaTeX rejects there withNot in outer par mode. 1.2.2 writes it as[H], as Sphinx does inside its own admonitions; see executablebooks/sphinx-exercise#94 and executablebooks/sphinx-exercise#95. Until now the workaround was to drop themystnbfigure metadata from code cells inside solutions, as recorded on QuantEcon/meta#297.Changes
environment.ymland.github/workflows/collab.yml:sphinx-exercise==1.2.1→1.2.2. The release has the same dependencies as 1.2.1, and HTML output is unchanged.Testing
CI's Build PDF from LaTeX step (
jb build lectures --builder pdflatex -W --keep-going) is the test. If it passes with the nine captions back, 1.2.2 works on real lectures.Before merging
lecture-python.zh-cn builds HTML only (its PDF steps are commented out), so the restored captions need no change there; Dependabot will bring its pin to 1.2.2.
Part of QuantEcon/workspace-lectures#70.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMZoSvoQTbzkdmZiMnd