Preview LaTeX in Org Mode in MacOS

Using the right Emacs Version

I failed to preview LaTeX with emacs-plus. If you have installed d12frosted/emacs-plus, uninstall it and use emacs-mac.

brew tap railwaycat/emacsmacport
brew install emacs-mac

If you like the fancy spacemacs icon, install it with cask: brew cask install emacs-mac-spacemacs-icon

Install Tex

  • Download and install BasicTeX.pkg here.
  • Add /Library/TeX/texbin to PATH.
  • Install dvisvgm by sudo tlmgr update --self && sudo tlmgr install dvisvgm collection-fontsrecommended

Emacs settings

  • Add TeX related bin to path: (setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin"))
  • Tell Org Mode to create svg images: (setq org-latex-create-formula-image-program 'dvisvgm)

Now you can see the rendered LaTeX equation by calling org-preview-latex-fragment or using shortcut ,Tx.

If you want to load LaTeX previews automatically at startup, add this at the beginning of org file: #+STARTUP: latexpreview.

  • update 19-07-31

    _ and ... are not displayed in Emacs, as some fonts are missing. tlmgr install collection-fontsrecommended should fix this.

    Org Preview Latex buffer also warns processing of PostScript specials is disabled (Ghostscript not found), remove this message by brew install ghostscript.

comments powered by Disqus