Skip to content

Commit b83d6da

Browse files
mmckyclaude
andauthored
five_preferences: enable usetex only where a latex binary exists (#378)
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>
1 parent 0c96791 commit b83d6da

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lectures/five_preferences.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ We begin with some that we'll use to create some graphs.
5454

5555
```{code-cell} ipython3
5656
# Package imports
57+
import shutil
5758
import numpy as np
5859
import matplotlib as mpl
5960
import matplotlib.pyplot as plt
@@ -67,7 +68,10 @@ from numba import njit
6768
```{code-cell} ipython3
6869
:tags: [hide-input]
6970
70-
plt.rc('text', usetex=True)
71+
# Render text with LaTeX only where a latex binary exists (the build has
72+
# texlive); on latex-less runtimes such as Colab, fall back to mathtext
73+
# instead of raising at the first rendered figure.
74+
plt.rc('text', usetex=bool(shutil.which('latex')))
7175
plt.rc('font', size=18)
7276
plt.rc('axes', labelsize=20, titlesize=24)
7377
plt.rc('xtick', labelsize=18)

0 commit comments

Comments
 (0)