[Tex/LaTex] Emacs + Auctex, Latex environment

auctexemacspreview

I'm writing a document in LaTeX. The document is divided in .tex documents and compiled using a Makefile.

My question is, could I see the dvi/PDF for the section of the document that I'm already writing in an Emacs buffer? I mean: dividing the Emacs window in two buffers using C-x 3, with one buffer with the document and the other with the preview of the document (and sync with the changes I'm introducing on it if possible). When I try to do that the only thing I get is a floating window with the document, in another program.

Best Answer

I'm not sure you'll be happy with the results (I'm not), but if you have DocView mode properly installed (it's part of Emacs 23), you can use it by adding

(alist-set 'TeX-command-list "View"
           '("(lambda ()
               (let ((f \"%o\"))
                 (find-file-other-window f)
                 (doc-view-mode)))"
             TeX-run-function nil t))

to your .emacs. I don't think DocView can do forward or inverse searching which means that you'll have to search for the correct page yourself—unlike using an external viewer. Also zooming and searching are inferior to a capable external viewer.

This will completely overwrite the regular View method, so you will not be able to use an external viewer without removing it from your .emacs and restarting. You could of course change the normal View command to have a different name, thereby preserving the capability. This is left as an exercise to the reader. :-)

Related Question