7

How can I set MUPDF as the default viewer in AUCTeX (I mean setting it in the variable Tex-view-program-selection)?

Many thanks

1 Answer 1

5

Here is (I think) the simplest way to do this. The first adds mupdf as a new view program, while the second specifies it as the default for pdfs.

(with-eval-after-load "tex"
  (add-to-list 'TeX-view-program-list '("mupdf" "/path/to/mupdf %o"))
  (setcdr (assq 'output-pdf TeX-view-program-selection) '("mupdf")))

Adding basic synctex support

In response to a comment, here is how to add support for synctex with mupdf. This only makes mupdf jump to the correct page with C-c C-v. I believe doing more like inverse search requires some ugly hacks.

(with-eval-after-load "tex"
  ;; enable synctex support for latex-mode
  (add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
  ;; add a new view program
  (add-to-list 'TeX-view-program-list
        '(;; arbitrary name for this view program
          "my mupdf"
          (;; mupdf command (may need an absolute path)
           "mupdf"
           ;; %o expands to the name of the output file
           " %o"
           ;; insert page number if TeX-source-correlate-mode
           ;; is enabled
           (mode-io-correlate " %(outpage)")))
  ;; use the view command named "my mupdf" for pdf output
  (setcdr (assq 'output-pdf TeX-view-program-selection) '("my mupdf"))
5
  • Thanks for the solution, it works fine. Nevertheless, when I restart emacs I get the following warning message: Warning (initialization): An error occurred while loading /home/gabriel/.emacs': Symbol's value as variable is void: TeX-view-program-list To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the --debug-init' option to view a complete error backtrace. Any clue how to avoid it? Thanks once again. Dec 31, 2016 at 15:02
  • You need to make sure it's eval'd after the library is loaded. I just updated the answer to show how to do this.
    – justbur
    Dec 31, 2016 at 23:15
  • is there any way to get reverse/forward search working though? Because I would love to replace evince with mupdf but search is important... Jan 1, 2017 at 1:18
  • @justbur I tried your updated answer with forward/inverse search, but doesn't seem to work to work. Does MuPDF support SyncTeX at all? bugs.ghostscript.com/show_bug.cgi?id=694727 would suggest it doesn't.
    – giordano
    Jan 1, 2017 at 18:06
  • @giordano it's only basic support for jumping to the right page
    – justbur
    Jan 1, 2017 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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