Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs/AUCTeX: run command on file that is not currently open

I edit my LaTeX files in Emacs using AUCTeX. To compile, I press C-c C-c, which will run pdflatex root, if root.tex is the file displayed in the current buffer.

But what if I want it to run pdflatex on a file that is not displayed in the current buffer?

For example, I am editing an included .tex file, chapter2.tex, and press C-c C-c. The command I want it to run is still pdflatex root, since chapter2.tex is just included in root.tex.

How can I do that?

like image 295
Frank Avatar asked Feb 04 '10 12:02

Frank


2 Answers

When you create a new file AUCTeX will ask you about the "master" document for it. If you define a master, C-c C-c will compile the master instead of the currently open file.

AUCTeX keeps track of this by adding a footer with the information it needs. Assuming you have a master document index.tex, the footer would look like this:

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "index"
%%% End: 
like image 154
Benjamin Bannier Avatar answered Sep 17 '22 13:09

Benjamin Bannier


C-c _ creates this footer automatically

like image 36
João Paulo Avatar answered Sep 20 '22 13:09

João Paulo