Showing math in the terminal
The TUI renders GitHub-flavored markdown and cannot typeset LaTeX. Raw $...$
reaches the user as literal dollar signs and backslashes. Two presentation paths,
chosen by the complexity of the expression.
Short inline expressions: Unicode glyphs
Write them directly in prose. No LaTeX, no mathshow call.
τ, β, α, λ, ε, μ, σ, π, Δ, Σ, ∫, √, ≤, ≥, ≠, ≈, ∈, ∉, ⊂, ∼, →, ⇒, ∀, ∃, ±, ∞, ⊥ Subscripts: ᵢ ⱼ ₜ ₀ ₁ ₙ ₖ — Superscripts: ⁰ ¹ ² ³ ⁿ ᵀ ′
So: Yᵢₜ = αᵢ + λₜ + βDᵢₜ + εᵢₜ, E[ΔY | D=1], p(X) ∈ (0,1), √n, X ⊥ D | Z.
Division stays inline as p(X)/(1−p(X)) when it is a simple ratio.
Genuine display math: call mathshow
Use it for anything Unicode degrades: stacked fractions, integrals with limits,
multi-line aligned derivations, matrices, large operators with sub/superscripts,
nested brackets.
Do both of these, in this order:
- Emit the LaTeX in a fenced code block so it stays readable and copy-pasteable into Quarto or LaTeX.
- Call
mathshowwith the same LaTeX so the typeset version appears in the viewer.
```latex
\tau_{dr} = E\big[(w_1 - w_0)(\Delta Y - m_0(X))\big]
```
mathshow '\tau_{dr} = E\big[(w_1 - w_0)(\Delta Y - m_0(X))\big]'
If mathshow is not on PATH, it is at ${CLAUDE_PLUGIN_ROOT}/bin/mathshow.
Multi-line derivations use aligned (or a bare align; both work):
mathshow '\begin{aligned}
\tau_{ipw} &= E\left[\frac{D-p(X)}{\pi(1-p(X))}\Delta Y\right] \\
&= E[\Delta Y \mid D=1] - E\left[\frac{p(X)}{1-p(X)}\Delta Y \;\middle|\; D=0\right]
\end{aligned}'
Mechanics
- Single-quote the argument so bash leaves backslashes alone; stdin also works
(
mathshow < file.tex). - First call opens a kitty window titled
mathshow; later calls reuse it and the equations accumulate in its scrollback. The window may open behind the active one — mention this the first time in a session. amsmathandamssymbare loaded. Colors track the kitty theme automatically.- Renders are cached by content hash, so repeats are instant.
- It always exits 0. On a LaTeX error it prints the failing
!lines and the raw LaTeX to stderr — read them and fix the LaTeX rather than ignoring it.
Don't
- Don't emit bare LaTeX outside a code block — it renders as noise.
- Don't call
mathshowfor a lone symbol or simple ratio; Unicode is faster to read in context than a window switch. - Don't batch a whole response's math into one call; one call per display equation keeps the viewer scannable.