Skip to content

feat: LaTeX rendering #36233

Description

@haskallcurry

What variant of Codex are you using?

CLI

What feature would you like to see?

Proposal: render LaTeX in the Codex TUI

Image

Background

LaTeX rendering has been requested previously. I recently shared a prototype on twitter, which was positively received, and @fcoury invited me to contribute it.

I cannot open a PR as it is restricted to collaborators, however my implementation can be found here:

https://github.com/haskallcurry/codex/tree/feat/kitty-latex-ratex

Implementation

The implementation:

  • recognizes explicitly delimited display and inline math while excluding Markdown code;
  • renders it in-process using RaTeX, a Rust implementation of KaTeX-style mathematical layout;
  • displays the resulting images using the Kitty graphics protocol, similar to the existing /pets feature;
  • does not require an external TeX installation or renderer process.

Using KaTeX directly would require an HTML/CSS layout and rasterization engine.

Known limitations

  • Inline images must fit terminal-cell geometry, and their baseline alignment varies somewhat between terminal implementations. Inline math is therefore rendered in Unicode whenever possible.
  • Native terminal selection copies the Kitty Unicode-placeholder cells rather than the original LaTeX source.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLITUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displayenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions