3

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?

Kirk Walla
  • 219
  • 1
  • 8

2 Answers2

5

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

INS DEL :
            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."
            INS

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.

Andrew Swann
  • 3,436
  • 2
  • 15
  • 43
  • 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](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24771). 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
3

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

(with-eval-after-load 'tex
  (add-to-list
   'TeX-command-list
   '("LaTeXmk" "latexmk %s" TeX-run-TeX nil t :help "Run latexmk.")))
Tobias
  • 32,569
  • 1
  • 34
  • 75