You may wish spread a document over many files (as you are likely to do if there are multiple authors, or if you have not yet discovered the power of the outline commands (see section Outlining the Document)). This can be done by having a "master" file in which you include the various files with the TeX macro `\input' or the LaTeX macro `\include'. These files may also include other files themselves. However, to format the document you must run the commands on the top level master file.
When you, for example, ask AUC TeX to run a command on the master file, it has no way of knowing the name of the master file. By default, it will assume that the current file is the master file. If you insert the following in your `.emacs' file AUC TeX will use a more advanced algorithm.
(setq-default TeX-master nil) ; Query for master file.
If AUC TeX finds the line indicating the end of the header in a
master file (TeX-header-end
), it can figure out for itself that
this is a master file. Otherwise, it will ask for the name of the
master file associated with the buffer. To avoid asking you again, AUC
TeX will automatically insert the name of the master file as a file
variable (see section `File Variables' in The Emacs Editor). You can
also insert the file variable yourself, by putting the following text at
the end of your files.
% Local Variables: % TeX-master: "master" % End:
You should always set this variable to the name of the top level document. If
you always use the same name for your top level documents, you can set
TeX-master
in your `.emacs' file.
(setq-default TeX-master "master") ; All master files called "master".
If this variable is nil
, AUC TeX will query you for the
name.
If the variable is t
, then AUC TeX will assume the file is a master
file itself.
If the variable is shared
, then AUC TeX will query for the name,
but will not change the file.
It is suggested that you use the File Variables (see section `File Variables' in The Emacs Editor) to set this variable permanently for each file.
You should set this variable to match the name of all files, for which
it is a good idea to append a TeX-master
file variable entry
automatically. When AUC TeX adds the name of the master file as a
file variable, it does not need to ask next time you edit the file.
If you dislike AUC TeX automatically modifying your files, you can set this variable to `"<none>"'. By default, AUC TeX will modify any file with an extension of `.tex'.
AUC TeX keeps track of macros, environments, labels, and style
files that are used in a given document. For this to work with
multifile documents, AUC TeX has to have a place to put the
information about the files in the document. This is done by having an
`auto' subdirectory placed in the directory where your document is
located. Each time you save a file, AUC TeX will write information
about the file into the `auto' directory. When you load a file,
AUC TeX will read the information in the `auto' directory
about the file you loaded and the master file specified by
TeX-master
. Since the master file (perhaps indirectly) includes
all other files in the document, AUC TeX will get information from
all files in the document. This means that you will get from each file,
for example, completion for all labels defined anywhere in the document.
AUC TeX will create the `auto' directory automatically if
TeX-auto-save
is non-nil. Without it, the files in the document
will not know anything about each other, except for the name of the
master file. See section Automatic Customization for a Directory.
TeX-save-document
.