[Tex/LaTex] Auctex support for building using makefile in subdirectory

auctexemacsmakefile

I am editing my PhD thesis using Emacs & Auctex, but my elisp is quite weak. Additionally, I build my thesis in a subdirectory, using makefiles generated by CMake and the UseLATEX CMake package, which I highly recommend.

I can’t figure out how to tell auctex that when I build the document it should do something like: make -C build/digital and that the pdf file being output is going to be at build/digital/thesis.pdf even though the source is at ./thesis.tex

p.s. I HIGHLY recommend checking out UseLATEX, the CMake package for easily compiling LaTeX documents.

Best Answer

Add the following code to your init file:

(eval-after-load "tex" '(add-to-list 'TeX-command-list '("Make" "make" TeX-run-compile nil t)))

Then you'll be able to call the make program with C-c C-c Make RET.

Replace the second element of the list with "make -C build/digital" if you want "make -C build/digital" by default, and the fourth element to t instead of nil if you want to have the chance to modify the make command instead of sticking with the default (which you can change interactively with C-u C-c C-c anyway).

Related Question