In the accepted answer in for the question it is suggested how to add latexmk support to emacs. If I get it right, compiling the .tex file should be assigned to C-c C-c. However this doesn't work for me and I have to go to the menu and click the latexmk option.

My question is basically, how do I make the latexmk the default engine for the emacs+auctex?

EDIT 1: When hitting C-c C-c, and then typing latexmk I get the desired result, i.e. it compiles using latexmk. Thus, maybe a more specific question is how to set latexmk to be the default script/compiler.

2 Answers 2


First, look at TeX-command-list to ensure that it has an entry for latexmk. If not, you need to add a line to this variable to allow the executable to be invoked by Auctex; unfortunately this variable is not well-documented (see the manual); I explain a little later.

Second, the default program is specified by the variable TeX-command-default. Change this to the identifier used by TeX-command-list, that is, the string just before the specification of the latexmk command.

E.g., if one of the elements in TeX-command-list is shown (which you can see using C-h v):

 ("Latex Make" "latexmk %(-pdf) %t" TeX-run-TeX)

then TeX-command-default needs to be "Latex Make".

The Auctex variable TeX-command-default

This variable isn't, as I said, well-documented. It should be a list of lists, each of which takes the form:

 '("Handle" "external-command %(switches) %(arguments)" Auctex-handler)

where Handle introduces a handle for facility to be run from the C-c C-c dialog, so the list of handles in TeX-command-default is the list of possible completions at this prompt. The second option is a form specifying the executable to be run, and Auctex-handler is an Elisp function that handles the process and invokes the external command. TeX-run-TeX and TeX-run-command are the most common handlers, but there are special handlers for Bibtex, the spell checkers, etc.

  • 1
    This gave me a hint. In AUCTeX Group->TeX Command->TeX Command List I added (at the beginning of the list) an entry named LaTeXmk with command latexmk -pdf %t and value TeX-run-command. Then, after C-c C-c I could type LaTeXmk and it ran the right script and produced the right result. How can I make it the default? Assign a some key shortcut?
    – Dror
    Feb 9, 2011 at 8:43
  • How do I set this variable? I couldn't find it in AUCTeX Group->TeX Command...
    – Dror
    Feb 9, 2011 at 12:11
  • 2
    It's a buffer-local variable, so you can't customise it. You can see its contents using H-v in the buffer you are interested in. You are best off setting it in your file using an Emacs local variable, but the following will set the value in all TeX buffers if you add it to your preamble: (add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "LaTeX Make"))), changing "LaTeX Make" to whatever identifier is used in TeX-command-list. Feb 9, 2011 at 12:26
  • Seems that is produced what I wanted. Thanks!
    – Dror
    Feb 10, 2011 at 9:22
  • @CharlesStewart: What is H-v? C-h v?
    – SabreWolfy
    Dec 15, 2012 at 23:51

I guess you simply want to get all of the necessary file compiled, not necessarily by latexmk. The simplest way to achieve this is to run C-c C-a, which executes TeX-command-run-all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .