2

I'd like to use PDFView mode as the default PDF reader when editing LaTeX code in AucTeX, using Emacs 24. For example, after compiling with C-c C-c, redoing this command would open the PDF file in a second buffer in the same window, using PDFView mode instead of Doc View.

2

I just set this up yesterday so all you need in your init file is.

 ;; to use pdfview with auctex
 (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
    TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
    TeX-source-correlate-start-server t) ;; not sure if last line is neccessary

 ;; to have the buffer refresh after compilation
 (add-hook 'TeX-after-compilation-finished-functions
        #'TeX-revert-document-buffer)

You can also use C-c C-a to compile and view at the same time. It also compiles bibtech if applicable. Its faster to press than C-c C-c C-c C-c. I ended up inverting the two keybindings

Update 1:

In respons to: why is tex-view-program-list not defined for me?

That variable is defined in the auctex package. It is essentially essential to using latex in emacs.

If it is not installed you should package-install auctex and then place (require 'latex). if you use use-package you can add

(use-package tex-site
  :ensure auctex
  :init
  (require 'latex)
  ;; to use pdfview with auctex
  (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
        TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
        TeX-source-correlate-start-server t) ;; not sure if last line is neccessary

  ;; to have the buffer refresh after compilation
  (add-hook 'TeX-after-compilation-finished-functions
            #'TeX-revert-document-buffer))

Update 2: Strikeout due to suggestion in comments

  • I've already tried something like that, but the problem is that I don't have any function or variable named TeX-pdf-tools-sync-view, so this doesn't work at all. Do you know why I don't have this name? – Spirine Apr 21 '16 at 19:22
  • I edited my answer with more information – Jules Apr 21 '16 at 20:11
  • Yes I'm using AucTex, installed through apt-get. – Spirine Apr 21 '16 at 20:11
  • Do you have (require 'latex) in your init file? – Jules Apr 21 '16 at 20:14
  • 1
    @JulesTamagnan Where did you find the line (require 'latex)? It should be never used explicitly. @Spirine install AUCTeX with Emacs package manager, don't use the outdated version present in repository of your distribution. – giordano Apr 21 '16 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.