AUCTeX and preview-latex

AUCTeX is a TeX mode for Emacs that adds various conveniences for editing LaTeX (and other macro packages). One of its killer features is inline previews of math and graphics, using preview-latex:

With AUCTeX and preview-latex, you can properly edit your document and equations in their high-level (TeX source) representation, while getting near-instant confirmation that your equations will turn out the way you want. It's pretty much the best of both worlds.

AUCTeX is easy to set up on Ubuntu, although it takes slightly more work than the usual apt-get invocation. Here is a HOWTO for my future reference (and yours). This has been tested on Ubuntu 9.04 with a post-v23-release emacs-snapshot:

Install AUCTeX.

$ sudo aptitude install auctex

Add the following init code to your .emacs file.

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)

Open a LaTeX file in Emacs and press C-c C-p C-b (M-x preview-buffer) to generate math/graphics previews for the entire buffer. After you update an equation, press C-c C-p C-p (M-x preview-at-point) to refresh the preview.

Further reading: AUCTeX, AUCTeX manual


  1. How rare to see something here I already knew about! AucTeX, that is, not preview mode. Though I'm fluent enough with LaTeX that I don't think I'm going to have much use for it.

    The main thing I use AucTeX for is C-c `, to jump to the compilation error. I wish it would jump to undefined references, when there are no actual errors.

    Poking around, I just discovered RefTeX (M-x reftex-mode), which with C-c = displays your \tableofcontents, pretty much, and lets you jump around in the document based on that. Handy!

  2. Yeah, I think AucTeX's error-handling support could also be more helpful on those instances when TeX bails out in the middle of the file.

    Thanks for the RefTeX tip. I'll check it out.

  3. Or just use LyX.
    LyX can be setup to have Emacs key-bindings.

  4. This comment has been removed by the author.

  5. Thanks! I'm on 12.10, running emacs 24. The ubuntu software center installs AUCTex into the emacs 23 site-lisp. Rather than fight all of that, I found it easier to manually install AUCTex, running ./configure with the option --with-lispdir=/home/felipe/.emacs.d/vendor/ (I have that in my loadpath already) and then add those two lines to my .emacs.