6

I'm writing my thesis, and there's a overall file overall.tex together with several section files, which are \inputed 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.

Haocheng
  • 565
  • 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
  • @barbarabeeton It generated 2 files in my case, .rel and .log, and didn't failed until reaching 100 errors. – Haocheng Dec 11 '12 at 13:29
  • 1
    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
  • @Haocheng -- apologies; i took the mention of .aux files literally. yes, a .log file will be created, is certainly unwanted, and i know no way to avoid that. i've no idea what caused the .rel file. – barbara beeton Dec 11 '12 at 13:32
  • @m0nhawk It doesn't work in my AuCTeX w/ Emacs. Also, I'm curious about whether the editor, or the TeX program itself read this instruction? – Haocheng Dec 11 '12 at 13:39
  • @m0nhawk Thanks for your hint, and I've found a solution, posted as an answer. – Haocheng Dec 11 '12 at 13:44
  • @Haocheng Oh! I found it faster! =) – m0nhawk Dec 11 '12 at 13:46

2 Answers2

5

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.

Haocheng
  • 565
2

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: ***

See here http://www.gnu.org/software/auctex/manual/reftex/Multifile-Documents.html as well.

Keks Dose
  • 30,892