Skip to content

kalman_2: drop usetex, render CJK + math via font-manager + mathtext (#22) - #181

Merged
mmcky merged 1 commit into
mainfrom
fix/kalman_2-drop-usetex
Jul 19, 2026
Merged

mmcky merged 1 commit into
mainfrom
fix/kalman_2-drop-usetex

Conversation

@mmcky

@mmcky mmcky commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Standardises kalman_2.md on the zh edition's font-manager rendering approach and removes text.usetex, per the #22 decision.

Why: kalman_2 and two_auctions were the only two lectures in the edition using text.usetex=True. During the 2026-07-18 resync, the usetex path produced a cascade of failures — the resync dropped the cjk() helper (→ NameError in every figure cell), and once restored the LaTeX preamble was missing amsfonts so upstream's \mathbb titles raised "Undefined control sequence" and tight_layout() crashed. All of it was invisible until a cold (uncached) build. The other ~38 lectures render Chinese via plt.rcParams['font.family'] (Source Han Serif) with no usetex, and never hit this class of problem.

What changed: removed the CJKutf8/amsmath/amsfonts preamble and the def cjk() helper; unwrapped the 13 cjk(...) call sites to plain strings; the two \mathbb{E}[...] plot titles are now raw strings rendered via matplotlib mathtext (which supports \mathbb). The Chinese in plot labels now uses Source Han Serif — the same family as the rest of the edition — instead of the CJK LaTeX gbsn font.

Companion: the same change on two_auctions (the other usetex lecture) in the current resync wave.

🤖 Generated with Claude Code

Standardises kalman_2 on the zh edition's font-manager approach (the
convention on ~38 other lectures), removing the fragile usetex+CJKutf8+
cjk() machinery that caused a cascade of failures during the resync
(dropped cjk() def -> NameError; missing amsfonts -> LaTeX Undefined
control sequence). Chinese now renders via Source Han Serif; the
\mathbb{E}[...] plot titles render via matplotlib mathtext.

Implements the #22 decision to move away
from usetex (see issue discussion). two_auctions is the only other
usetex lecture and is handled the same way.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 19, 2026 02:19
@netlify

netlify Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for astonishing-narwhal-a8fc64 ready!

Name Link
🔨 Latest commit d26d3a8
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a5c34169f110a0008874998
😎 Deploy Preview https://deploy-preview-181--astonishing-narwhal-a8fc64.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

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 updates lectures/kalman_2.md to stop using text.usetex + a custom cjk() LaTeX wrapper, and instead rely on the lecture’s existing Matplotlib font-manager setup (Source Han Serif SC) with MathText for inline math rendering.

Changes:

  • Removed the pdfLaTeX/CJKutf8 preamble, text.usetex=True, and the cjk() helper.
  • Replaced all cjk(...) label/title call sites with plain Chinese strings and MathText strings (e.g., r'$\mathbb{E}[\cdot]$ ...').

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 19, 2026 02:42 Inactive
@mmcky
mmcky merged commit 3d3289b into main Jul 19, 2026
6 checks passed
@mmcky
mmcky deleted the fix/kalman_2-drop-usetex branch July 19, 2026 02:42

This branch was previously deployed

1 inactive deployment
pull request — d26d3a80 Deployed Jul 19, 2026 by github-actions[bot]
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