# Prevent a tex file from being compiled

I'm writing my thesis, and there's a overall file `overall.tex` together with several section files, which are `\input`ed in the `overall.tex`.

Could I write something in the section files to prevent them from being compiled, which will certainly fail, producing some unneeded aux files. In an other word, to prevent compiling the section file by mistake.

I'm using XeLaTeX and AuCTeX.

-
Welcome to TeX.sx! since you're using `\input`, there are two ways to avoid the processing of the section files: (1) comment out the reading in, i.e. `%\input{...}`; (2) at the beginning of the "unwanted" section file, insert `\endinput` as the first line. commenting out in the `overall` file may be easier to remember when you're under pressure, as it's more obvious. –  barbara beeton Dec 11 '12 at 13:17
@barbarabeeton I understand the question a bit different. I think the OP wants to prevent that he by mistake compiles one of the input files instead of the main document. Compiling an input file will certainly fail as it doesn't contain a preamble but produces a bunch of useless auxiliary files that have to be deleted afterwards. –  Benedikt Bauer Dec 11 '12 at 13:21
@barbarabeeton I'm sorry for misleading you, but what I want is like @ Benedikt says. –  Haocheng Dec 11 '12 at 13:24
@BenediktBauer -- i just tested what you suggest -- compiling a file without a preamble, the first line starting with `\section{...}`. it failed at once with the error `! Undefined control sequence.` after killing it with `x`, i checked what files were present. no `.aux` file was created. so i think we need a clarification from the OP. –  barbara beeton Dec 11 '12 at 13:27
And what about using the `%!TEX root = ` in the `\include/\input` files? It is useful and many TeX editors supports it. –  m0nhawk Dec 11 '12 at 13:32

This question on StackOverflow solves my problem, which requires function supplied by AuCTeX: Emacs/AUCTex: run command on file that is not currently open.

The simplest way is `M-x TeX-master-file-ask`, which is suggested by @Chris Conway in the comment of 1.

-

After I read all the comments, including the information of Haocheng that he employs Emacs and AUCTeX, the answer probably is to give Emacs the information about "multifile documents", see here: http://www.gnu.org/software/auctex/manual/auctex/Multifile.html#Multifile

In short something like:

``````%%% Local Variables: ***
%%% mode:latex ***
%%% TeX-master: "thesis.tex"  ***
%%% End: ***
``````
-
Are you sure about the asterisks? –  egreg Dec 11 '12 at 13:47
I took the whole example as it is from the documentation. –  Keks Dose Dec 12 '12 at 9:32