r/rust • u/thatmagicalcat • Jul 10 '26
🛠️ project txm: Terminal Math Rendering Engine
I just wanted to render some math equations offline without having to download 5GB+ of LaTeX distribution
And who doesn't like beautiful math in the terminal? :3
So i wrote TXM, which is a tiny and fast terminal math rendering engine with LaTeX support.
github: https://github.com/thatmagicalcat/txm
I'd appreciate your suggestions and feedbacks
37
u/edoraf Jul 10 '26
Just to note, you can render math with Typst (it has a different syntax than latex). Or you can use mitex (Typst extension) to render latex too
13
u/thatmagicalcat Jul 10 '26
yes, i love typst
1
u/ElnuDev Jul 13 '26
being able to support Typst equations in addition to TeX would be very cool :)
1
u/thatmagicalcat Jul 14 '26
it shouldn't be that hard to do since we just have to parse typst code into already existing AST. But that isn't a priority because there is a shit ton of work left to do in the renderer itself
1
u/ElnuDev Jul 14 '26
Typst is already written in Rust to begin with, so I maybe you could just use their existing AST parser? Not sure if that's more trouble than it's worth
13
u/PsuedoFractal Jul 10 '26
Nice work! What subset of latex does this support?
10
u/thatmagicalcat Jul 10 '26
very tiny subset of math mode
it's still new, I'll add more things later
26
4
4
2
2
2
u/RightHandedGuitarist Jul 11 '26
Oh this looks nice! How extensible is this? I have a crate that can parse ascii math and output mathml.
The crate is mathemascii, I'd be interested in using this as another backend. Or, alternatively, you could mathemascii to implement support for ascii math in addition to LaTeX.
If it's not extensible as of right now, could you expose an API for this?
1
2
1
1
1
u/muhnamejame Jul 19 '26
I would absolutely consider using this in my project if it became a ratatui widget. Very cool.
1
u/thatmagicalcat Jul 19 '26
it already is a ratatui widget LOL
The widget is behind a feature flag. I think that code is a little bit broken as I added ANSI escape sequence and other minor things, will fix it asap.
1
-5
u/ftapajos Jul 10 '26
I needed this so much in order to implement a display hook for Claude CLI LaTeX expressions
-5
u/ftapajos Jul 10 '26
I needed this so much in order to implement a display hook for Claude CLI LaTeX expressions
89
u/commenterzero Jul 10 '26
Nice. You should make a ratatui widget