2

I am running AUCTeX in Emacs 25 (latest version) on arch linux. I have searched some configuration online, but they don't work. Here is the relevant configuration:

(setq TeX-view-program-selection
      '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
      '(("PDF Viewer" "okular --unique %o#src:%n%b")))
(server-start)
(setq LaTeX-command-style '(("" "%(PDF)%(latex) -shell-escape %S%(PDFout)")))
;; use Sumatra PDF to preview pdf
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
;; Enable synctex generation. Even though the command shows
;; as "latex" pdflatex is actually called
(custom-set-variables '(LaTeX-command "latex -synctex=1") )

What's going wrong? Thanks!

  • Welcome to TeX.SX! – Bobyandbob Mar 6 '18 at 11:42
  • Assuming that you're using AUCTeX 12, can you reduce your configuration to (server-start) (setq TeX-view-program-selection '((output-pdf "Okular"))) (setq TeX-source-correlate-mode t), restart Emacs and try it again? – Arash Esbati Mar 6 '18 at 20:29
  • It does work! Thank you sooo much! But why? – user9450761 Mar 7 '18 at 0:08
2

Assuming that you have AUCTeX 12 installed, it will be sufficient to replace your configuration with these lines:

(server-start)
(setq TeX-view-program-selection '((output-pdf "Okular")))
(setq TeX-source-correlate-mode t)

The main reason why your configuration doesn't work is this line:

(setq TeX-view-program-list
      '(("PDF Viewer" "okular --unique %o#src:%n%b")))

AUCTeX has builtin support for Okular, you only need to pick it with TeX-view-program-list as mentioned above (see here for details).

Some comments regarding the rest of your code:

  • (setq LaTeX-command-style '(("" "%(PDF)%(latex) -shell-escape %S%(PDFout)")))
    This one can be considered harmful; it will allow execution of external commands from a .tex file per default. I suggest you solve this one on a per file basis with a file local variable, e.g.

    %%% Local Variables:
    %%% mode: latex
    %%% TeX-master: t
    %%% TeX-command-extra-options: "-shell-escape"
    %%% End:
    
  • (setq TeX-source-correlate-method 'synctex)
    Also not really needed, AUCTeX has a sensible default which uses synctex with pdfLaTeX.

  • (custom-set-variables '(LaTeX-command "latex -synctex=1") )
    Again not needed, AUCTeX does that automatically when TeX-source-correlate-mode it t and LaTeX-command-style is not changed.

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.