reddit / emacs
Preview LaTeX equations on *.tex files
FourOmegaman · 2022-05-01 23:19
I have used some packages to preview LaTeX equations in org mode, such as org-fragtog, and I'm wondering if there is something similar for plain \*.tex files.
I mean, what I'm looking for is [something like this](https://github.com/io12/org-fragtog/blob/master/demo.gif) but while I am editing an \*.tex file. I have tried the [texfrag](https://github.com/TobiasZawada/texfrag/) package, but it doesn't seem to work or I'm too stupid to set it up. Can someone explain to me how can this be achieved?
I'm currently using Doom, pretty much vanilla, so I don't have much experience customizing Emacs.
YesterdayFit123 · 2022-05-02 00:29
i think i have this enabled in my ```config.el```, i'll update my comment when i find it... you can also check out [tecosaur's config](https://tecosaur.github.io/emacs-config/config.html) which is where i believe i borrowed it from.
FourOmegaman · 2022-05-02 01:01
That's the longest config file I've ever seen! I found and installed calctex from tecosaur's config, but it wasn't quite what I was looking for, so please let me know if you find something. Thanks!
karthink · 2022-05-02 04:45
Yes, use AucTeX. It has much better support for previewing maths in Tex files than org does for org files, even with org-fragtog.
The relevant commands (with AucTeX enabled) are named `preview-*`, such as `preview-section`.
To use AucTeX, you just need to enable the latex module in Doom emacs.
FourOmegaman · 2022-05-02 12:40
Ok, I have installed AucTeX using M-x package-list-packages, and now I can see the preview-* commands. However, nothing changes in my document, do I have to configure something in my config.el file?
karthink · 2022-05-02 16:54
Can you compile a latex document from Emacs? (It's bound to `C-c C-c`)
If yes then latex is set up correctly and the previews should just work.
BTW if you're on Doom you should not be using `package-list-packages`. Doom has a latex module configured (including previewing) already, you just enable it in `~/.doom.d/init.el`.
FourOmegaman · 2022-05-02 17:44
You are right, it was a problem with the document I was editing. I guess I don't have some packages installed in my system, and I didn't notice because I was compiling with Overleaf. Nonetheless, in a simple document, all I can see is a [black square](https://imgur.com/qUVnzni) where the preview should be.
I have uncommented the `latex` option in the `lang` section of my `~/.doom.d/init.el` file, but I couldn't use the `preview-*` commands until I installed them with `package-list-packages`. Therefore, I don't know if there is something else wrong with my LaTeX configuration. Do you know of any configuration guide for Doom? Thanks.
karthink · 2022-05-02 18:00
> I have uncommented the latex option in the lang section of my ~/.doom.d/init.el file...
You need to run some other command after for the required packages to be downloaded, probably `doom sync`. I don't use Doom, so I'm not sure. I would ask on the Doom emacs subreddit or discord.
mahmooz · 2022-05-04 14:15
im surprised noone has mentioned [https://github.com/dandavison/xenops](https://github.com/dandavison/xenops) which does exactly what you're looking for
FourOmegaman · 2022-05-04 14:35
That's everything I was looking for!! Thank you!!
opensrc-philosophy · 2022-05-05 19:50
If you do not necessarily want overlays: You may want to check out my package [magic-logic-buffer](https://github.com/opensource-philosophy/magic-logic-buffer) which makes LaTeX math commands look and behave like the characters they would print. It also allows conversion from LaTeX to unicode and the other way around.