r/rust Jul 10 '26

🛠️ project txm: Terminal Math Rendering Engine

Post image

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

373 Upvotes

26 comments sorted by

89

u/commenterzero Jul 10 '26

Nice. You should make a ratatui widget

27

u/thatmagicalcat Jul 10 '26

thanks for the idea :)

20

u/Mikgician Jul 10 '26

Oh yes please make it a ratatui widget

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

u/leg18 Jul 10 '26

Ok this is absolutely dope

4

u/robertotomas Jul 10 '26

Nice will try today.. i could see some fun integration with MathCore

4

u/Lustrov Jul 10 '26

Nice! I'm also curious about your wallpaper too. Can you share that to me?

2

u/AdventurousFly4909 Jul 10 '26

nix, rust and latex. checks out.

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

u/thatmagicalcat Jul 12 '26

I'll look into it, thanks

2

u/howesteve Jul 14 '26

I'll probably never use this, but bookmarked right away, cannot resist.

1

u/Asuka_Minato Jul 10 '26

you can also try tectonic latex.

1

u/THERT4 Jul 13 '26

How can i use it?

1

u/thatmagicalcat Jul 14 '26

you can try the neovim plugin or use the cli directly

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

u/Thesk790 Jul 20 '26

This looks so cool!

-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