## Executing Commands

Formatting the document with TeX or LaTeX, viewing with a a previewer, printing the document, running BibTeX, making an index, or checking the document with lacheck all require running an external command.

There are two ways to run an external command, you can either run it on all of the current document with TeX-command-master, or on the current region with TeX-command-region.

Command: TeX-command-master

(C-c C-c) Query the user for a command, and run it on the master file associated with the current buffer. The name of the master file is controlled by the variable TeX-master. The available commands are controlled by the variable TeX-command-list.

See section Installation of AUC TeX for a discussion about TeX-command-list and section Multifile Documents for a discussion about TeX-master.

Command: TeX-command-region

(C-c C-c) Query the user for a command, and run it on the "region file". Some commands (typically those invoking TeX or LaTeX) will write the current region into the region file, after extracting the header and tailer from the master file. The name of the region file is controlled by the variable TeX-region. The name of the master file is controlled by the variable TeX-master. The header is all text up to the line matching the regular expression TeX-header-end. The trailer is all text from the line matching the regular expression TeX-trailer-start. The available commands are controlled by the variable TeX-command-list.

AUC TeX will allow one process for each document, plus one process for the region file to be active at the same time. Thus, if you are editing n different documents, you can have n plus one processes running at the same time. If the last process you started was on the region, the commands described in section Catching the errors and section Controlling the output will work on that process, otherwise they will work on the process associated with the current document.

User Option: TeX-region

The name of the file for temporarily storing the text when formatting the current region.

A regular expression matching the end of the header. By default, this is \begin{document}' in LaTeX mode and %**end of header' in TeX mode.

User Option: TeX-trailer-start

A regular expression matching the start of the trailer. By default, this is \end{document}' in LaTeX mode and \bye' in TeX mode.

AUC TeX will try to guess what command you want to invoke, but by default it will assume that you want to run TeX in TeX mode and LaTeX in LaTeX mode. You can overwrite this by setting the variable TeX-command-default.

User Option: TeX-command-default

The default command to run in this buffer. Must be an entry in TeX-command-list.

If you want to overwrite the values of TeX-header-end, TeX-trailer-start, or TeX-command-default, you can do for all files by setting them in either TeX-mode-hook, plain-TeX-mode-hook, or LaTeX-mode-hook. To overwrite them for a single file, define them as file variables (see section File Variables' in The Emacs Editor). You do this by putting special formatted text i near the end of the file.

% Local Variables:
`