3

I'm running Emacs v25.1 + Orgmode v9.0.9 on a Mac.

Based on this stack, I changed my org-latex-create-formula-image-program to dvisvgm by adding the following to my init.el:

(setq org-latex-create-formula-image-program 'dvisvgm)

I am trying to use C-c C-x C-l to preview some equations: latex equations to preview

Problem: The images seem to be properly generated (they appear in the folder ltximg) ... svg properly generated but they are not displayed ... svg images not displayed

Question: What is going on? Previewing the equations worked fine with dvipng (albeit at a lower resolution, that's why I'm trying to use dvisvgm), but with dvisvgm they are not being displayed and I don't get any errors. How can I fix it?

Thanks for helping!

  • Generating seems to work. Are those Images valid svg images? Did you try to show an inline svg image in an org-mode file? Is this working? Do you have the program imagemagic installed? – jue Jul 8 '17 at 13:10
  • Generating image works, at least it generates svg files with the correct latex equations. The problem is that these images aren't displayed overlaying the equations. Following your suggestion, I tried showing an svg image using C-c C-x C-v and got Invalid image type 'svg'. Not sure about imagemagic (k?), how can I check that? – Guilherme Salomé Jul 9 '17 at 2:26
  • Imagemagick :) It should be installed on your system via brew? I do not use a Mac, so I do not know. I see by comments, you found the other question about this topic. But did you also found this answer about installing SVG capable Emacs on Mac: apple.stackexchange.com/a/157144 ? – jue Jul 9 '17 at 10:05
  • @jue Yes! Your comments led me to finding out that Emacs has to be compiled with svg support, as there is no other way to add svg support to it after compilation (don't know why, though). I first got my Emacs from emacsformacosx.com, but I find out that a much much better Emacs is available from github.com/railwaycat/homebrew-emacsmacport. This other version is called Emacs Mac Port and it has svg support built-in, and many other "utilities" for Mac users. Thanks for helping!!! :D – Guilherme Salomé Jul 9 '17 at 10:28
  • you are welcome. You could write an answer and mark your question as answered, so the next Mac user can easily see your solution. – jue Jul 9 '17 at 19:01
3

Why You Cannot Display SVG Images in Your Emacs

In order to use dvisvgm properly, and have Emacs actually overlay the svg images, Emacs must be able to not only generate svg files, but also display them.

If you have a Latex package installed on your machine, like MacTex, then you already have dvisvgm installed, and Emacs will be able to generate the svg images. The real problem lies in displaying the svg images in Emacs. To do so, the Emacs binary you are using must have been built with svg support.

If your Emacs has not been built with svg support, then it is not possible to add svg support by installing a package or modifying your init.el file (to the best of my knowledge). This is the case with the Emacs version from emacsformacosx.com. This was the Emacs I was using, and it does not have svg support.

Solution

The easiest solution is to download another Emacs binary that has been compiled with svg support. I found another great Emacs binary for Mac users, that not only has svg support, but also extra utilities that can make use of a Mac's higher resolution displays. This binary can be found on this github (Yamamoto's Emacs a.k.a. Emacs Mac Port).

If you download the most recent Emacs from the link above (at the time of writing it was Emacs 25.2 Mac 6.4), and add (setq org-latex-create-formula-image-program 'dvisvgm) to your init.el, then C-c C-x C-l will work, and the overlayed svg image will look great on your display:

svg now works and equation looks great

If you want to keep Emacs "lean", you can compile Emacs yourself, adding only support to svg.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.