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

gabrielpdp1979
  • 335
  • 1
  • 7

1 Answers1

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"))
justbur
  • 1,510
  • 9
  • 8
  • 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.

    – gabrielpdp1979 Dec 31 '16 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 '16 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... – Elliot Gorokhovsky Jan 01 '17 at 01: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? https://bugs.ghostscript.com/show_bug.cgi?id=694727 would suggest it doesn't. – giordano Jan 01 '17 at 18:06
  • @giordano it's only basic support for jumping to the right page – justbur Jan 01 '17 at 18:32