Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
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 '11 at 8:43
How do I set this variable? I couldn't find it in AUCTeX Group->TeX Command... –  Dror Feb 9 '11 at 12:11
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. –  Charles Stewart Feb 9 '11 at 12:26
Seems that is produced what I wanted. Thanks! –  Dror Feb 10 '11 at 9:22
@CharlesStewart: What is H-v? C-h v? –  SabreWolfy Dec 15 '12 at 23:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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