Proper LaTeX support for formulas

Proposal: Obsidian should recognize [latex] … [/latex] blocks, take the content, throw it into some .tex template, run it through a compiler, make it an image, and in preview replace the latex block with the image.

This is basically how Anki handles LaTeX.

The imagefile could be names with some checksum of the latex block to recognize if there already is a corresponding image. Then there would also need to be a way to delete unused latex files, e.g. if one changes something, and so an old image is not implemented anywhere anymore.

The trade-off is that this would take a few moments to do, when switching to preview mode for the first time, and the image has to be generated.

I think that could however be a killer feature, because no web-based competitor is likely to do something like this, and it really makes use of people storing their stuff on their own machine, with their own latex settings. This could easily live besides the current latex support which is faster and completely fine for short things, and if one does not need a lot of custom commands.

If this is worth the effort probably depends on how many people are working with sciency-stuff in the community.

15 Likes

I have to agree. It would be very beneficial to have an implementation that grants the user access to the full capabilities of latex.

5 Likes

I had exactly the same wish. I’d like to keep all my notes viewable in Obsidian but I sometimes necessarily need equation blocks or more complicated latex functions that the current editor does not support. Compiling surely would take longer but it can be a feature that’s turned on only when these code blocks are detected. When they are necessary, it’s worth the wait.

4 Likes

This is material for a plugin, not the base application.

4 Likes

Sorry, I may be misunderstanding this but is this not a thread in plugin ideas? Are you suggesting someone would need to pick up on this and develop it as a plugin as opposed to the obsidian dev team doing it?

2 Likes

For science-related notes, latex is essential, and mathjax is good for most people, but is not a complete substitute for latex.

This is a very practical solution, which simply means calling the latex compiler on your computer, converting the latex into an svg image, and then embedding the image into the notes.

Anki, emacs, all handle latex this way

Now I do it manually, I use klatexformula to convert the latex into an image and then copy the image into the notes.

However, there is a problem with this method that klatexformula’s copy and drag does not seem to work on obsidian, so this workflow is not perfect.

It would be great to have a plugin to do this.

3 Likes

Do you know similar tools to Obsidian that have this functionality by any chance?