How to use Auctex + preview-latex + orgmode in emacs

2.7k Views Asked by At

I use Emacs orgmode exclusively. I installed auctex from Melpa. My understanding is that preview-latex is packaged with auctex with no special setup required.

  1. I can't seem to summon preview-latex on any inline latex equations
  2. It seems like I have to change from orgmode to latex-mode to get the "latex" option in the toolbar.

What am I doing wrong here?

Thank you

3

There are 3 best solutions below

1
SeaDude On BEST ANSWER

The best method I found to preview latex in orgmode is:

  1. sudo apt-get install dvipng
  2. Restart emacs
  3. Place point at the beg of a latex inline equation in one of my .org files
  4. C-c C-x C-l

Equation goes from this:

$$\frac{a}{b} \cdot \frac{c}{d} = \frac{a \cdot c}{b \cdot d} = \frac{product\ of\ numerators}{product\ of\ denominators}$$

To this: enter image description here

Use C-c C-x C-l to revert.

I do have Auctex installed (though I don't think dvipng uses it at all. And in my emacs init file I have:

* AucTex: Require AucTex
(require 'tex-site') 

* LaTeX: Enable LaTeX Math mode by default
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

This is very sweet!

1
NickD On

You are not doing anything wrong: org-mode has its own latex preview mechanism and does not use (indeed, cannot use) preview-latex. There was talk a long time ago on the ML about integrating preview-latex into org-mode, but it has never been done.

0
jijing On

make sure dvipng dvisvgm installed correctly

(executable-find "dvipng")
(executable-find "dvisvgm")

then add

(setq org-latex-compiler "xelatex")

to your init.el
to make default latex compiler as xelatex