Fast Latex previews in Org-mode

This is a post in my Latex editing series, a quick package announcement for better Latex previews.

After complaining the other day about Latex previews in org-mode being unbearably slow, I decided to take a crack at adapting Org-mode to use AucTeX’s preview library, which is blazing fast in comparison:

It was both easier and more annoying than I expected it to be, but perhaps less annoying on balance than org-latex-preview locking up Emacs for a good minute on every fresh invocation in medium sized documents.

For now the package is available online in its fledgling state. It’s intended for use as a drop-in replacement for org-latex-preview. Turn on org-auctex-mode and use your keybinding for org-latex-preview (or call org-auctex-preview-dwim), and it should use the Auctex-based backend instead. This is very early, everything including the name of the package might change in the future.

Interestingly, there’s very little Org-specific code in there. It should be trivial to extend the preview library to work in Markdown and other text buffers.

Add a comment, or comment via email

Omar Antolín Camarena
2022-02-28
This is great! If it really isn’t too hard to extend to other text buffers it would be absolutely fabulous to have this as a minor mode. I’d use it for arXiv RSS feeds in Elfeed and to read MathOverflow and Math StackExchange in sx.
Karthik
2022-02-28

@oatolin I need to extract the org-specific bits and provide a more general API, and it should work anywhere. In elfeed or eww, we’ll have to manually provide a general enough Latex preamble to cover most common expressions.

It’ll be a while though, the package is a bit of a hack and needs a lot of testing (hint, hint) to cover the edge cases first!

Sterling
2022-03-04
Check out xenops-mode for asynchronous rendering. I prefer for live notetaking.
Karthik
2022-03-04
@Sterling: I’m aware of Xenops, but I had assumed it reused AucTeX’s preview machinery. From the code it appears to be a from-scratch solution. This is quite neat, thanks! I plan to study it in more detail later.
shelper
2022-04-30
I wonder if this setup works with org-appear (https://github.com/awth13/org-appear)