I am working on a document that requires multiple compilations as it has a TOC, page numbers and fancy headers with section titles in header.

How do I do this using AUCTeX? I am running spacemacs. And the only options available are ,a and ,b!


Since AUCTeX version 11.89, AUCTeX comes with a command called TeX-command-run-all. From the manual:

Command: TeX-command-run-all

(C-c C-a) Compile the current document until an error occurs or it is finished. If compilation finishes successfully, run the viewer at the end.

N.B. I don't use Spacemacs.


When you have multiple compilations to go through, latexmk is your friend. From its CTAN description

La­texmk com­pletely au­to­mates the pro­cess of gen­er­at­ing a LaTeX doc­u­ment. Given the source files for a doc­u­ment, la­texmk is­sues the ap­pro­pri­ate se­quence of com­mands to gen­er­ate a .dvi, .ps, .pdf or hard­copy ver­sion of the doc­u­ment.

An im­por­tant fea­ture is the “pre­view con­tin­u­ous mode”, where the script watches all of the source files (pri­mary file and in­cluded TeX and graph­ics files), and re­runs LaTeX, etc., when­ever a source file has changed. Thus a pre­viewer can of­fer a dis­play of the doc­u­ment’s lat­est state.

Works with most TeX engines (not context). IMO the best is to start latekmk once in the background, in your shell : you don't need to type any combo, each save makes latexmk running. If you run an Unix, my advice would be not to deal with AucTeX integration.

Anyway, there is an emacs package for AucTeX and latexmk interaction : auctex-latexmk. You can install it with MELPA install-package. I did not tried it but looks like it does the job. Changes in your .emacs are described in the project page.

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.