6 ms·
RaTeX: KaTeX-compatible LaTeX rendering engine in pure Rust
- Rochus 5mo agoInteresting. Reminds me of Typst (both implemented in Rust and replacing TeX to some degree) and Microtex.
- el_sinchi 5mo ago[dead]
- jason_s 5mo agoI greatly prefer Typst's clean architecture than TeX's macro-centric hell pounded into passable utility.
- deleted 5mo ago[deleted]
- evilmonkey19 5mo agoI have been using Typst for creating notes and it is an awesome tool. I use it to create notes on welding for my students. It makes my life so much easier compared to badsoft and its not-word-ing (you understand me).
- ocimbote 5mo agoI've discovered typst in the last year and used to build a resume and cover letter template that feeds from a YAML file. After a bit of tinkering and understanding the idiosyncracies of Typst, the joy of having reliable, consistent, beautiful, data-driven resumes and cover letters is not measurable. It basically lifted any barrier to applications, while whatever I had before I had always considered a burden. On top of that, I can add hiring process data directly to the yaml file to run further analysis. Can LaTeX do this? Most probably, but the learning curve is the difference.
- DominikPeters 5mo agoThe landing page (clearly to a large part written by LLM) does not mention that both KaTeX and mathjax can render to SVG in node. This wasm approach might still be lighter, but the advantage is not as clear as the page makes it seem. (It also contains LLM dishonesties like that the bundle size is 0 KB.)
- nicoburns 5mo agoWhere this clearly wins is native rendering use cases where there is no browser or JS engine involved at all.
- westurner 5mo agoA sphinxdoc ratex Makefile task for building from .rst and .md doctrees to PDF? There are probably enough tests for a Rust rewrite of docutils and sphinx with Python extension compatibility; docutils.rs and sphinxdoc.rs?
- rafram 5mo agoIf RaTeX gets to brag about having a 0 KB JS bundle, the other libraries should be able to say they have 0 KB WASM bundles!
- stusmall 5mo ago> It also contains LLM dishonesties like that the bundle size is KB That one jumped out to me too. The phrasing is so wiggly but technically correct it feels intentional. When I saw it I didn't blame it on the LLM, which is worse. Otherwise it's a super cool looking project
- tabbott 5mo agoIt's interesting to me that the page doesn't describe the size of the rust binary (relevant for mobile app use cases where you would need to add the Rust binary to your app) or performance. The webpage also does read like it was at least heavily LLM assisted, which makes it a bit hard to trust it. That all said, this is definitely something I'd be interested in using for Zulip if is indeed going to be a well maintained open source project. (We currently have a node server component that the Zulip server runs only the render LaTeX).
- ethmarks 5mo ago> the size of the rust binary The `render` binary weighed 4.0 MB on disk when I compiled it a few minutes ago. Not sure if that's what you were looking for, but just in case it is, there you go. Here's the logs, if you want: https://gist.github.com/ethmarks/8df92a68c3076ea2f4a5aedba9fefa28 https://gist.github.com/ethmarks/8df92a68c3076ea2f4a5aedba9f...
- umvi 5mo agoWe recently switched from Node.js + Mathjax for rendering latex to Goja (https://github.com/dop251/goja https://github.com/dop251/goja) + Mathjax, and surprisingly it worked really well. We did this because the app is already 99% golang, and this allows us to eliminate the remaining non-go pieces, greatly simplifying the SBOM. And yes, we tried go-latex, but it's not nearly as feature complete as Mathjax. Not to mention using goja + Mathjax adds 10MB to binary size while Node.js adds 200MB+
- azverev 5mo agoPixel-diff CI against a golden suite is the right discipline for layout libraries, and it's noticeably rare in the JS ecosystem. Most "matches KaTeX" claims I've seen in the wild rely on screenshot eyeballing, which collapses on edge cases like spacing primes, integral subscripts, and matrix delimiters that scale. One thing I'd be curious about: how are font fallbacks handled when the same Rust core ships to platforms with different system font availability? KaTeX bundles fonts and assumes they load cleanly; CoreGraphics and Skia bring their own glyph caches and metrics. Does the display list carry metric snapshots from the host text shaper, or does the core compute layout from a bundled metric file independent of the backend?
- Terretta 5mo agoIn this case it doesn't eyeball same as it scores itself It self scores: 157 \char"263a as strong, while left is black circle smiley and right is full color emoji.
- Hendrikto 5mo agoI used LaTeX for approximately 10 years, for little things to relatively complex, including my bachelor’s and master’s theses. It never felt natural at reliable or consistent. Every customization required weird \makeatletter \makeatother hacks and was very brittle. Everything seemed more complicated than necessary and hard to grok, with weird interdependencies and interactions. There are probably good reasons for all of that, but it is just both bad DX and bad UX. It feels like you need to be a hardcore LaTeX expert or consult with one, in order to accomplish the most mundane things. Especially in a reliable way, that won’t break upon making seemingly unrelated changes, or won’t break other things itself. I used Typst for a few weeks. It already feels much more understandable, consistent, hackable, and customizable. I guess that is the difference between an ad hoc macro system and an actually thought through programming language. The only drawback I can see is the ecosystem being smaller and less mature. That is, however, counteracted by being able to do things on your own, without immersing yourself deeply in LaTeX for years. Also, it will improve with time. LaTeX is great, don’t get me wrong. But its heritage and historical baggage is really dragging it down.
- mcookly 5mo agoI agree re. LaTeX. I've tried Typst for some complex projects, and it's just not quite there yet. ConTeXt on the other hand ... chef's kiss.
- krater23 5mo agoI know exactly what you mean, and that paired with a community that is absolutely sure that they know exactly how things need to be done and everyone that wants it in another way is dumb.
- noelwelsh 5mo agoThis mirrors my experience. It's worth noting that TeX was developed in the same time period that the details of lexical scope were being nailed down by Guy Steele in the Rabbit compiler for Scheme. It's not that TeX is an ad hoc system; it's more the case that people didn't actually know how to implement a better system at the time.
- colechristensen 5mo agoAnybody embed it in a markdown renderer yet?
- Piterniel 5mo ago> JS bundle (typical) 0 kB JS (core is WASM) I guess you should mention how much is WASM, right?
- deleted 5mo ago[deleted]
- huflungdung 5mo ago[dead]
- marvinified 5mo agoInteresting! Would love to see how RaTeX evolves.
- mrichman 5mo agoI switched to Typst a year ago and never looked back
- ceayo 5mo agoI'm sorry but the only thing that truly understands TeX, is, and will forever be, TeX.
- flossly 5mo agoAnd 64kb should be enough for anyone.
- xworld21 5mo agoI suppose somebody has to ask (and most likely complain) about this: what does RaTeX do for accessibility? I gather that it produces images. I checked the demo, and there's not even an alternative text or an ARIA label, so this seems completely invisible to anybody relying on a screen reader. This is quite a step backwards compared to modern LaTeX, which can now tag equations with MathML within the PDF, or using MathJax, or any other serious tool targeting HTML, like pandoc or LaTeXML. Is accessibility anywhere on the roadmap for RaTeX?
- nkmnz 5mo agoAFAIK, KaTex has accessibility via MathML included, but it doesn't provide an export as image - it rather renders as html. So why would you want the utility that you use to render an additional image to take care of something that KaTeX already does?
- xworld21 5mo agoTrue, my knee jerk reaction came from seeing this run in the browser... but that does not change the question. RaTeX advertises itself as a renderer for native apps, but how are those apps supposed to implement accessible controls? Does RaTeX offer anything towards that?
- nkmnz 5mo agoHonestly, I have no idea how native apps for desktop or mobile handle accessibility. There is katex-rs[0] that outputs html and mathML. I'd assume the two could work together and the mathML would be fed to whatever the screen reader receives instead of the image? On a related note: is mathML more accessible than an AI generated text of how a human would read the mathematical or chemical formula? [0] https://crates.io/crates/katex-rs https://crates.io/crates/katex-rs
- xworld21 5mo ago> On a related note: is mathML more accessible than an AI generated text of how a human would read the mathematical or chemical formula? Yes, screen readers would typically allow you to navigate the formulas in ways that are more sophisticated than text (not to mention the issues with translating to Braille, which I don't claim to understand, at all). In fact alternative text is a poor substitute for structured information about the formula, which is what you get with MathML. Plus, the MathML + screen reader combo is deterministic and debuggable, as opposed to OCR'ing an image. > There is katex-rs[0] that outputs html and mathML. I'd assume the two could work together and the mathML would be fed to whatever the screen reader receives instead of the image? Maybe! You are parsing the input twice, but it could be a pragmatic solution. I don't know myself how native apps are supposed to expose MathML to screen readers (or if it is even possible without an embedded browser!).
- TheRealPomax 5mo agoI am so confused. There's already a native version of LaTeX... it's... it's LaTeX. Why would a Rust implementation need to match KaTeX instead of properly implementing a real (and modern, so unicode-out-of-the-box) TeX engine, that LaTeX (which is a set of convenience macros) then trivially runs on top of?
- red_trumpet 5mo agoBtw, the unicode-out-of-the-box version of LaTeX is called LuaLaTeX and ships with TeX Live.
- TheRealPomax 5mo agoI think you'll find XeTeX (with XeLaTeX because no sane person uses plain TeX except for package authors of course ;) predates LuaTeX by almost a decade. (Something I ran into in 2008 when I was writing a multilingual book and heard about LuaTeX, only to find out it was still extremely incomplete and was roadmapped to not be done until 2012. And I couldn't wait 4 years)
- jedberg 5mo agoI don't know why but this chain amuses me: RaTeX -> KaTeX -> LaTeX. I guess it shows how everyone loves but hates LaTeX and is always trying to bolt on that one last thing that will make it good.
- blenderob 5mo agoAren't these 3 different implementations with totally different use cases? Katex is latex-like implementation for web. Ratex is really 'rewrite katex in rust'. I don't understand what is getting "bolted on" to what here.
- flakiness 5mo ago> JS bundle (typical) 0 kB JS (core is WASM) Hello? Trolling aside, I found this kind of Rust-powered typeset modernization promising. I used Typst and liked it. This one would have its own niche too.
- danborn26 5mo agoA native Rust alternative to KaTeX is a welcome addition. This should make math rendering much easier to integrate into Rust based static site generators.
- thangalin 5mo agoWhen developing KeenWrite[1], I opted to support only plain TeX. This is because I wanted math typesetting to work for either LaTeX or ConTeXt[2]. To render TeX in the preview panel, I forked NTS[3] into a highly optimized Java version. The lack of cross-platform event-based UI system is what kept me from writing the entire application in Rust (some ten years ago). Has the Rust ecosystem improved with respect to Markdown processing, event-based UIs, and now TeX support? [1]: https://keenwrite.com/screenshots.html https://keenwrite.com/screenshots.html [2]: https://wiki.contextgarden.net https://wiki.contextgarden.net [3]: https://ctan.org/tex-archive/systems/nts https://ctan.org/tex-archive/systems/nts
- nixpulvis 5mo agoI'm not sure how much overlap there is between this project and Tectonic [1], but that's what I use personally for local PDF generation, and it's also using a good bit of Rust. Just thought I'd mention since it's related and I really like the project. [1] https://github.com/tectonic-typesetting/tectonic https://github.com/tectonic-typesetting/tectonic
- IshKebab 5mo agoI wish it was standard for projects to say the extent to which they were vibe coded, in the same way that they give a license.
- mockbuild 5mo ago[dead]
- eXpl0it3r 5mo agoDespite the "Gold-suite" comparison, when looking at the KaTeX and RaTeX output [1], the KaTeX output is consistently better. RaTeX has either a lot of aliasing going on or appears blurry. But the native and library nature of RaTeX is very interesting, especially with the provided C ABI. [1] https://ratex.lites.dev/demo/support-table https://ratex.lites.dev/demo/support-table
- xymostech 5mo agoAre you viewing on a HiDPI monitor? I imagine this is mostly because RaTeX renders to an image whereas KaTeX is rendering HTML, so can scale to arbitrary dpi. I imagine the RaTeX people could have rendered to a higher resolution and it would look better.