Currently, I edit LaTeX files by running latexmk -pvc in the background to generate PDF automatically upon change to be previewed in Evince. However, when there is a syntax error, AucTeX is not able to show it. How can I complete this integration by jumping to errors given by the latexmk process?

  • So TeX-next-error and Tex-previous-errordo not work? Are you using auctex-latexmk? – Timm Nov 18 '16 at 8:57
  • @Timm No I'm not using it -- I'm running latexmk -pvc in the background so PDF gets rebuilt automatically upon saving. TeX-next-error won't work. – xuhdev Nov 18 '16 at 9:02
  • 1
    Do you know that AUCTeX can automatically compile the document in a way similar to latexmk and open the viewer at the end of a successful compilation just with C-c C-a? In this way you can use error reporting tools shipped with AUCTeX, including TeX-error-overview. Parsing the output of latexmk in AUCTeX is a bit tricky – giordano Nov 18 '16 at 9:10
  • I suggest to mention -pvc the question title. I'm using auctex-latexmk with (setq TeX-save-query nil) and the files are automatically saved when compiling with C-c C-c. I don't see much of an advantage of using latexmk -pvc instead. – Timm Nov 18 '16 at 9:25
  • @giordano Thank you for pointing it out, I didn't use it before. There is a drawback however: every time I run it, the focus switches to Evince. I have to manually switch back to Emacs. – xuhdev Nov 18 '16 at 18:26

I have dealing with the same issue. That is my solution, it is a bit late but it could be useful.

(defun brust-LaTeX-next-error (args)
  (interactive "p")
  (if-let ((active-buffer (TeX-active-buffer)))
      (if (< 15 args)
        (when (< 3 args)
            (set-buffer active-buffer)
            (if TeX-error-list
                (message ":::: WARNING :::: There are errors ::::")
              (message ":::: Be happy, your LaTeX code has no errors ::::"))))
        (call-interactively 'TeX-next-error))
    (message "There is no active buffer")))

I guess that AUCTeX creates the list of errors once the compiling precess is finish. So, the problem with latexmk -pvc is that the process never ends and the list is never created.

The idea is to replace TeX-next-error with previous function. First it checks whether there is an active process or not. When you call brust-LaTeX-next-error with prefix argument C-u it creates the list from the active buffer with the same functions that AUCTeX does when the process ends (again I guess). So, they should interact nicely. When you call it with no prefix argument it just calls TeX-next-error.

As an extra functionality when you call it with double prefix argument C-u C-u a buffer with all errors listed is created.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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