Emacs, LaTeX and pdf viewer

Posted on Tue 14 April 2009 in Articles

My favourite editor Emacs provides a great support for LaTeX document preparation system. There are several modes that extend the default latex-mode. My favourite ones are: AUCTex (with Preview-latex) and CDLaTeX.

By-default LaTeX outputs DVI files and uses xdvi viewer with "View" command. However it's possible to configure LaTeX to outpud pdf files. In Emacs, you have to execute (M-x tex-pdf-mode) command to set the LaTeX's output to pdf. If you'd like to have a pdf output for all LaTeX documents, add

1
(setq TeX-PDF-mode t)

to your .emacs.

Now, let's add a pdf-viwer to be executed on "View" command (C-c C-v). I use GNOME's default Evince document viewer for pdf files. So, the code that should be added to .emacs is:

1
2
3
4
5
(defun pdfevince ()
   (add-to-list 'TeX-output-view-style
                 '("^pdf$" "." "evince %o %(outpage)")))

(add-hook  'LaTeX-mode-hook  'pdfevince  t) ; AUCTeX LaTeX mode

That's it!