When I hit C-c C-c to compile a document, my system is set up such that LaTeXmk is default typesetting option, and I just hit Enter to run it.

The next time I do C-c C-c (without any changes in the document), however, BibTeX is the default, not LaTeXmk. If I choose LaTeXmk, it runs, and says "LaTeXmk: nothing to do", which is fine. I'd just like to avoid writing LaTeXmk in the second run, if possible.

Any ideas how I can do this?

  • How do you define the 'second run'? – Marijn Mar 5 '18 at 15:33
  • Well, actually I just mean pressing C-c C-c again. I guess what I'd like is to be able to define what happens the second time the command is issued. – martinweiss Mar 6 '18 at 19:39
  • But what would you like to happen when you change something between the two compilations that needs a rerun of latexmk? – Marijn Mar 6 '18 at 20:16
  • Let's say I compile my document, then i go away for a cup of coffee, and when I return, I forgot if I am looking at the most recent version. So I compile again. I guess I'd like to just make C-c C-C invoke latexmk every time. I'm unsure how to do it. Is it possible to remove the other entries in TeX-command-list somehow? – martinweiss Mar 8 '18 at 7:42

Short answer: AUCTeX doesn't play very well with latexmk, by default.

Long answer: AUCTeX has its own system to decide what command to run next, when building a document. This is based on reading the output of compilation program, but it expects only one command has been actually run. Instead, latexmk runs multiple commands in a row, making AUCTeX confused. That's why the short answer.

One solution could be to write a parser specific to latexmk, but this isn't super-easy.

However, note that AUCTeX is capable of automatically running all commands needed to build a document. Just issue C-c C-a and you're done (the output document will also be shown automatically). See also the manual. In order for this to work, "LaTeX" should be the default command to be run, not the custom entry you added for latexmk. The existence of this feature of AUCTeX is the reason why no one ever had the need to write the parser to make latexmk play nicer with AUCTeX

  • Thanks for the clear explanation. Then, I wonder what the proper AUCTeX way is to switch default commands depending on the directory or project? With latexmk, you can place a configuration file in the current directory to change the behavior of latexmk . – Ryo Aug 29 at 3:17
  • What you mean by command? The engine (like tex, xetex, luatex)? If so, you can set TeX-engine, see gnu.org/software/auctex/manual/auctex.html#Processor-Options – giordano Aug 29 at 7:08

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.