Skip to content

fix(app): stop shrinking KaTeX in the Preview markdown (#2092) - #2181

Open
jacktrnr wants to merge 1 commit into
mainfrom
fix/2092-katex-size
Open

jacktrnr wants to merge 1 commit into
mainfrom
fix/2092-katex-size

Conversation

@jacktrnr

Copy link
Copy Markdown
Contributor

Closes #2092

Problem

In the sidebar's Preview tab, LaTeX rendered noticeably smaller than the markdown text around it.

Root cause

The Preview markdown wrapper (preview-file-view.tsx) carried [&_.katex]:text-[0.9em]. KaTeX sizes math with .katex { font: 1.21em … } in the base layer, because its glyphs have a small x-height. The Tailwind utility sits in the utilities layer, so it replaced that 1.21em instead of scaling it. Math ended up at 0.9 × body size instead of 1.21 × body size.

I measured it in headless Chrome against the built app CSS, with the Preview's text-12-regular markdown:

body text .katex
before 13px 11.7px
after 13px 15.73px (same 1.21 ratio as chat messages: 14px → 16.94px)

Fix

Remove the override. The .katex-display overflow guards stay. No new styling and no tokens touched.

Tests

  • New preview-katex-size.test.ts: a source-structure assertion (same pattern as preview-find-in-sidebar.test.ts) that the Preview markdown keeps its display overflow guards and sets no font-size utility on .katex or .katex-display. It failed before the fix and passes after.
  • bun test --conditions=solid --preload ./happydom.ts src/components/session/preview (materialized tree): 95 pass, 0 fail.
  • refresh_manifest.mjs was run, and drift_gate.mjs PASSES.

Manual check

Open a .md file that has inline math (for example $\Omega_x = 2\pi \cdot 5\,\mathrm{MHz}$) in the side panel's Preview tab. The math should now match the height of the surrounding text, as it already does in chat messages.

🤖 Generated with Claude Code

The Preview tab wrapper carried [&_.katex]:text-[0.9em]. That utility
replaces KaTeX's own .katex { font: 1.21em } rather than scaling it, so
math rendered at 0.9x body size instead of 1.21x: about 25% smaller than
KaTeX intends next to 13px body text (11.7px vs 15.73px measured in Chrome).
Drop the override so KaTeX keeps its intended proportion; the display-math
overflow guards stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3c81ebdc-a84e-4667-a1da-7166cc964c2e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@jacktrnr
jacktrnr marked this pull request as ready for review November 23, 2026 22:23
@jacktrnr

Copy link
Copy Markdown
Contributor Author

Verified hands-on in the combined 0.4.1-beta test build (test/0.4.1-beta, Developer Tools → Rebuild Locally, macOS arm64) on 2026-11-23: all checks in this PR's manual checklist pass.

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.

BUG: LaTeX rendered disproportionately small vs normal text in sidebar markdown

1 participant