Emacs, LaTeX and pdf viewer


A short note on how-to set a pdf-viewer for LaTeX-generated documents in Emacs.

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: http://www.gnu.org/software/auctexAUCTex (with Preview-latex) and http://staff.science.uva.nl/~dominik/Tools/cdlatexCDLaTeX.

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 http://projects.gnome.org/evinceEvince document viewer for pdf files. So, the code that should be added to .emacs is:

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

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

That's it!
Comments

latexman
WEDNESDAY, 25 AUGUST 2010, 09:36
Well if you want to wait forever while 99% of cpu is used to fire up a pdf viewer then evince is fine. Personally, I'll stick with xpdf.

Zaur
WEDNESDAY, 01 SEPTEMBER 2010, 09:39
Did you have any problems launching evince?


Leave a comment

Introduce yourself:
Comment: BB-codes
Captcha:
captcha