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?
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:
C-c _ creates this footer automatically
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With