I was wondering if anyone knows if C-c C-a in AucTeX is using behind the scenes latexmk or not? I've tried looking into the source files for both C-c C-c and C-c C-a but I couldn't find in any those traces of latexmk.

On a side note what best way to integrate latexmk in AucTeX workflow?


C-c C-a uses AuCTeX's heuristics for deciding which list of commands to run. The usual case is to use the function TeX-command-default which is defined in tex-buf.el. So no, latexmk is not used.

You can make latexmk accessible from C-c C-c by customizing TeX-command-list. One possibility is to a add an element of the form

            Name: LaTeXmk
            Command: latexmk %s
            How: Value Menu TeX-run-TeX
                    Create a process for NAME using COMMAND to format FILE with TeX.
            Prompt: Toggle  off (nil)
            Modes: Value Menu All
            Menu elements:
            INS DEL Lisp expression: :help
            INS DEL Lisp expression: "Run latexmk."

which adds

 ("LaTeXmk" "latexmk %s" TeX-run-TeX nil t :help "Run latexmk.")

to TeX-command-list. Once this is done, on typing C-c C-c you can choose LaTeXmk as the command to run. Next time you type C-c C-c this will be offered as the default, so can be accepted with just RET.

Look at the other elements in TeX-command-list to get an idea of ways to pass further options to latexmk should you need them.

  • Did you actually want to write "C-c C-a uses AuCTeX's own..."? – Tobias Jan 24 '20 at 14:47
  • Thanks, Andrew, neat explanation, the reason I was initially asking is because C-c C-a sometimes fails to properly compile if you've changed the .bib file by adding new entries, but latexmk breezes over that. – Kirk Walla Jan 24 '20 at 14:48
  • 1
    @KirkWalla This is worth a bug-report via M-x TeX-submit-bug-report. As far as I see, the last related error is one with multiply defined labels in the document. If you submit a bug-report add a minimal example for reconstruction of the problem to it! Thanks for making AucTeX better! – Tobias Jan 24 '20 at 15:01

Why not just add it directly to ~/.emacs?

(with-eval-after-load 'tex
   '("LaTeXmk" "latexmk %s" TeX-run-TeX nil t :help "Run latexmk.")))

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.