Skip to content

five_preferences: enable usetex only where a latex binary exists - #378

Merged
mmcky merged 1 commit into
mainfrom
guard-usetex
Aug 19, 2026
Merged

five_preferences: enable usetex only where a latex binary exists#378
mmcky merged 1 commit into
mainfrom
guard-usetex

Conversation

@mmcky

@mmcky mmcky commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Option 1 from the issue: guard the rc setting with shutil.which('latex') so the published site keeps its current typography (CI installs texlive and renders exactly as before) while Colab and other latex-less runtimes fall back to matplotlib's mathtext instead of raising RuntimeError: Failed to process string with tex at the first rendered figure. This was the last blocker on the "open in Colab" path for the downloadable five_preferences.ipynb — the 2026-08-18 human Colab run got past the repointed data read and died here.

This lecture is the only usetex=True user in the repo (checked 2026-08-18 across lectures/*.md). The byte-identical copy in lecture-tools-techniques carries the same setting twice and gets the same guard together with its .mat repoint — see QuantEcon/lecture-tools-techniques#11.

After this publishes, a clean human Colab run of the downloadable notebook closes the last box on QuantEcon/data-lectures#84.

Closes #377

🤖 Generated with Claude Code

The only usetex lecture in the repo. Colab ships no LaTeX, so the
downloadable notebook raised at the first rendered figure (~50 cells
before the data read the wave-C2 repoint fixed). shutil.which('latex')
keeps the published site's typography — CI installs texlive — and lets
latex-less runtimes fall back to mathtext.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 18, 2026 23:16
@netlify

netlify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Deploy Preview for lustrous-melomakarona-3ee73e ready!

Name Link
🔨 Latest commit 7045c7a
🔍 Latest deploy log https://app.netlify.com/projects/lustrous-melomakarona-3ee73e/deploys/6a84e7d7d689d800087b7de2
😎 Deploy Preview https://deploy-preview-378--lustrous-melomakarona-3ee73e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

Pull request overview

This PR prevents matplotlib from erroring in LaTeX-less runtimes (e.g., Google Colab) by enabling usetex=True only when a latex binary is available, while preserving the existing TeX-rendered typography on the published site where TeX is installed.

Changes:

  • Import shutil in five_preferences to enable runtime detection of the latex executable.
  • Replace unconditional plt.rc('text', usetex=True) with a guarded plt.rc('text', usetex=bool(shutil.which('latex'))).
  • Add an explanatory comment describing the Colab fallback behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

@mmcky
mmcky merged commit b83d6da into main Aug 19, 2026
10 checks passed
@mmcky
mmcky deleted the guard-usetex branch August 19, 2026 04:03
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.

five_preferences: downloadable notebook cannot run in Colab — usetex=True requires a system LaTeX the runtime does not have

2 participants