Math images

Typeset math in the terminal, the same size as the text around it.

In terminals that can show images, cdrm print and the TUI's preview draw math as images. Formulas are typeset with RaTeX, sized to match your terminal's font, and drawn on a transparent background.

  • Display math (between double dollar signs) becomes an image on its own lines.
  • Inline math (between single dollar signs) becomes an image one line tall, in the flow of the text. Formulas too tall to read at that size, like fractions or sums with limits, stay as text.
  • A formula RaTeX can't typeset stays as text.

Supported terminals

Terminal cdrm print TUI preview
Ghostty Yes (kitty protocol) Yes (kitty protocol)
kitty Yes (kitty protocol) Yes (kitty protocol)
Konsole Yes (kitty protocol) Yes, with the protocol Konsole reports
iTerm2 Yes (iTerm2 protocol) Yes (iTerm2 protocol)
WezTerm Yes (iTerm2 protocol) Yes, with the protocol WezTerm reports
Sixel terminals (foot, Windows Terminal, xterm with Sixel) No Yes (Sixel)
Anything else Math as text Math as text

How each finds out what your terminal supports:

  • cdrm print reads the environment: TERM_PROGRAM , TERM , KITTY_WINDOW_ID and KONSOLE_VERSION . Images are only written when the output is a terminal.
  • The TUI asks the terminal directly when it starts, so it also works in terminals cdrm print doesn't recognize. Terminals that can only draw images from colored blocks get text, which reads better than a blurred formula.
tmux Images don't work inside tmux yet: tmux doesn't pass image escapes through unless they're specially wrapped. Inside tmux, math is printed as text.

Math color

Math is drawn in light gray ( #e6e6e6 ), which reads well on dark themes. On a light theme, or to match your colors, set CDRM_MATH_COLOR to a hex color:

export CDRM_MATH_COLOR="#1f2328"    # dark gray, for light themes
cdrm print notes/relativity.cdrm

The value is six hex digits, with or without the # . An invalid value is ignored and the default is used. It applies to both cdrm print and the TUI; set it before starting the TUI.

Turning images off

cdrm print --no-images prints math as LaTeX text. Building cdrm without the tui feature removes image support entirely.

Troubleshooting

Math shows as text in a supported terminal. Check that the output is a terminal (not piped) and that you're not inside tmux. For cdrm print , check that TERM_PROGRAM or TERM identifies your terminal

: Ghostty sets TERM_PROGRAM=ghostty . Over SSH these variables may not be passed along; the TUI's direct check still works there.

Math is invisible. It's probably drawn in the default light gray on a light background. Set CDRM_MATH_COLOR as above. Images are the wrong size. Images are sized from the cell size the terminal reports. If the terminal doesn't report one, cdrm print assumes 40-pixel-tall cells and scales each image to the lines it takes up.