Skip to content

Upgrade sphinx-exercise to 1.2.2 and restore figure captions in solutions - #1121

Open
mmcky wants to merge 1 commit into
mainfrom
maint/sphinx-exercise-1.2.2
Open

mmcky wants to merge 1 commit into
mainfrom
maint/sphinx-exercise-1.2.2

Conversation

@mmcky

@mmcky mmcky commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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 with Not 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 the mystnb figure metadata from code cells inside solutions, as recorded on QuantEcon/meta#297.

Changes

  • environment.yml and .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.
  • Restores the caption and name on nine figures, each from a code cell inside a gated solution, exactly as they were before the workaround:
Lecture Figures Removed in
exchange_rate_learning fig-xr-ex4, fig-xr-ex5 #1101
genetic_classifier fig-gc-bray-ga #1101
learning_approximation fig-la-bandwidth, fig-la-rate #1101
lucas_prescott_search fig-lps-two-state, fig-lps-undirected, fig-lps-phillips #1110
information_transfer fig-it-riley #1119

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

…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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WT8bMZoSvoQTbzkdmZiMnd
Copilot AI balanced review requested due to automatic review settings November 10, 2026 05:34
mmcky added a commit to QuantEcon/lecture-python.zh-cn that referenced this pull request Nov 10, 2026
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WT8bMZoSvoQTbzkdmZiMnd

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-exercise from 1.2.1 to 1.2.2 in the main environment and the Colab workflow.
  • Re-add mystnb figure caption/name metadata 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

@github-actions

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants