r/LaTeX • • 4d ago

Open sourcing my live-preview TeX engine (write-up, benchmarks, VS Code extension and npm library!)

A while ago I made a post here on my Rust TeX engine, made for showing changes as fast as possible (https://www.reddit.com/r/LaTeX/comments/1wrvhig/realtime_latex_preview_in_wasm/). The project is now called TeXyoN (after tachyon, a hypothetical faster-than-light particle).

Today, I'm happy to release the source code, as well as a detailed write up with all the decisions I made, performance benchmarks, upstream bugs I found that I’m reporting and answers to some questions I got last time. All of that can be found on my blog: https://yendric.be/introducing-texyon/ (it is quite long, you may pick out the sections that seem interesting). The source code can be found here: https://github.com/texyon-org/texyon (feel free to leave a star :))

Together with the source code release, I'm releasing a vscode extension that demos TeXyoN's capabilities by running the engine natively & locally. It can be found here.

I'm also releasing an npm package that allows the community to create their own interactive TeX experiences in the browser. It compiles TeXyoN to wasm and bundles it with an easy to use API for live preview.

This is the initial release, so bugs are to be expected. Feel free to create issues on the repository. If you're concerned about correctness: I compared full-compile output on more than 9,000 documents against upstream TexLive. More on that is in the blog post.

I hope you enjoy the write-up, as well as using TeXyoN. Curious to hear what you think!

35 Upvotes

27 comments sorted by

23

u/Electrical_Juice_446 4d ago edited 4d ago

Lots of hammers available nowadays for the same nail huh. Thanks, Claude!

(I can just use the auto-compile flag on TexStudio, if you hate pressing F5 after every keypress đŸ¤£)

4

u/Yendric 4d ago

The auto compile flag will leave you waiting when you’re working on a big document with, say, a heavy tikz diagram you want quick feedback on (both visuals and errors).

Yes, the engine rewrite was done by models like claude, but I started working on the project well before claude code even existed (see the post). I tried my best writing a detailed blog post with everything I learned about TeX and making it fast along the way, and how I’m trying to clean up an old legacy codebase. It’s disappointing to see you put this away as something I just slopped together without too much effort.

-7

u/Electrical_Juice_446 4d ago edited 4d ago

I don't trust AI-generated software in as much as I trust long-standing TeX editors and compilers such as TeXStudio and TexLive that have stood the test of time.

Given the vast amounts of code that have to be validated by humans for security purposes from AI-generated code, I wouldn't touch any software from 2022 onwards with the introductory remarks of "I made this...".

No, you didn't make it. Claude did. Your ideas were yours (might be). But you're just a meat proxy.

For sure, I wouldn't want to install some rando slopware with no established communities whatsoever, for security purposes and for my peace of mind. I will always use TeXStudio and TexLive and always will be.

16

u/AntiProton- 4d ago

Another day, another "I coded this new LaTeX engine/editor/compiler"...

8

u/AnxiousDoor2233 4d ago

Not really. It is quite far from a standard "AI vibecoded" stuff.

-1

u/Yendric 4d ago

:) Hopefully the design challenges and tex concepts explained in the blog post were interesting

1

u/maxzang 2d ago

don't get discouraged, this just isn't the subreddit for this type of stuff. people here are tired of it. Post on youtube, X, etc.

3

u/Zombie_Shostakovich 4d ago

This is impressive and an interesting read. I'll be sure to try it.

1

u/Yendric 4d ago

Thank you!

2

u/AnxiousDoor2233 4d ago

That's impressive! Is there any way to integrate it in rmd/qmd workflow.

1

u/Yendric 3d ago

Thanks! I'm not very familiar with rmd/qmd so don't hesitate to give me some more insights on your current workflow, but I suppose you could point your workflow at a tex file (and configure it so it doesn't delete it), and then preview that tex file using the vscode extension (which gives you a preview pane you can also turn into a window). Then, when your workflow modifies the tex file, you should immediately see the result in that pane.

2

u/ShabbyBandwidth 4d ago

comparing against 9000 documents is the kind of check i want to see. what did the failures look like when they happened?

1

u/Yendric 3d ago

Most differences I had to fix were tiny (like a glyph being 1sp off, a missing kern). I initially only compared XDV output (the intermediary format xetex uses before passing onto xdvipdfmx), but sometimes there were subtle differences in the commands that still give the same visual output. For those cases, when XDV differs only a little, a pixel compare happens to ensure the document renders identically.

I also compare logs (used for example by the latex test suite I test against), a failure here was that it needed wrapping and file paths to be normalized, nothing serious.

A 'big' set of differences is caused by actual upstream bugs in XeTeX. These are usually bugs were old/too new state is used (because everything is passed around in global variables) or where types are confused. I have a list of them in the repo, and will be reporting them to the xetex team (they are fixed in texyon). The testing harness normalizes against these bugs or marks them as known.

Finally there can be subtle differences because texyon uses the ICU library that comes with your system (just like tectonic I forked from), while texlive bundles it. Again, this is nothing serious.

If you do happen to find anything I missed, please report it and I'll be happy to take a look at it.

1

u/mkeee2015 4d ago

Forgive me for the stupid question. When multi-pass compilation is needed (for BibTex references, section number cross-referencing, equations number cross referencing), how do I force TeXyoN to perform the multipass?

1

u/Yendric 3d ago

In live preview you cannot force it yet. I will be adding it soon (probably this week), and I have discussed how I will be doing it in the blog post.

Full compilations (or export if using the vscode extension) should keep doing passes until the document doesn't change any more, as expected.

3

u/mkeee2015 4d ago

Super interesting.

2

u/apfelkuchen06 4d ago

stopped reading at "based on xetex".

0

u/PercyLives 4d ago

Well done!

2

u/Yendric 4d ago

Thanks!

1

u/always_Smell_It_1st 4d ago

Iiiiinterrresting…..

-5

u/maxzang 4d ago

this is really cool. I did something similar in https://turbotex.app, i think we ended up on almost the same architecture. i would love to chat about it!

I tried both with snapshots and without snapshots just basically patching in the change optimistically and handling every edge case (which maybe now possible with LLMs to just build the massive edge case engine), snapshots is the way.

1

u/Opussci-Long 4d ago

Any plans to open-source it?

-1

u/MrReevers 4d ago

latexmk