[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Executing Commands

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


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.1 Starting a Command on a Document or Region

There are two ways to run an external command, you can either run it on the current document with TeX-command-master, or on the current region with TeX-command-region. A special case of running TeX on a region is TeX-command-buffer which differs from TeX-command-master if the current buffer is not its own master file.

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.

Command: TeX-command-region

(C-c C-r) Query the user for a command, and run it on the contents of the selected region. The region contents are written into the region file, after extracting the header and trailer from the master file. If mark is inactive (which can happen with Transient Mark mode), use the old region. See also the command TeX-pin-region about how to fix a region.

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.

Command: TeX-command-buffer

(C-c C-b) Query the user for a command, and apply it to the contents of the current buffer. The buffer contents are written into the region file, after extracting the header and trailer from the master file. The command is then actually run on the region file. See above for details.

User Option: TeX-region

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

User Option: TeX-header-end

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.

If you want to change the values of TeX-header-end and TeX-trailer-start you can do this for all files by setting the variables in a mode hook or per file by specifying them as file variables (see (emacs)File Variables section ‘File Variables’ in The Emacs Editor).

Command: TeX-pin-region

(C-c C-t C-r) If you don’t have a mode like Transient Mark mode active, where marks get disabled automatically, the region would need to get properly set before each call to TeX-command-region. If you fix the current region with C-c C-t C-r, then it will get used for more commands even though mark and point may change. An explicitly activated mark, however, will always define a new region when calling TeX-command-region.

AUCTeX 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 Catching the errors and Controlling the output will work on that process, otherwise they will work on the process associated with the current document.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.2 Selecting and Executing a Command

Once you started the command selection with C-c C-c, C-c C-s or C-c C-b you will be prompted for the type of command. AUCTeX will try to guess which command is appropriate in the given situation and propose it as default. Usually this is a processor like ‘TeX’ or ‘LaTeX’ if the document was changed or a viewer if the document was just typeset. Other commands can be selected in the minibuffer with completion support by typing <TAB>.

The available commands are defined by the variable TeX-command-list. Per default it includes commands for typesetting the document (e.g. ‘LaTeX’), for viewing the output (‘View’), for printing (‘Print’), for generating an index (‘Index’) or for spell checking (‘Spell’) to name but a few. You can also add your own commands by adding entries to TeX-command-list. Refer to its doc string for information about its syntax. You might also want to look at TeX-expand-list to learn about the expanders you can use in TeX-command-list.

Note that the default of the variable occasionally changes. Therefore it is advisable to add to the list rather than overwriting it. You can do this with a call to add-to-list in your init file. For example, if you wanted to add a command for running a program called ‘foo’ on the master or region file, you could do this with the following form.

 
(eval-after-load "tex"
  '(add-to-list 'TeX-command-list
		'("Foo" "foo %s" TeX-run-command t t :help "Run foo") t))

As mentioned before, AUCTeX will try to guess what command you want to invoke. If you want to use another command than ‘TeX’, ‘LaTeX’ or whatever processor AUCTeX thinks is appropriate for the current mode, set the variable TeX-command-default. You can do this for all files by setting it in a mode hook or per file by specifying it as a file variable (see (emacs)File Variables section ‘File Variables’ in The Emacs Editor).

User Option: TeX-command-default

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

After confirming a command to execute, AUCTeX will try to save any buffers related to the document, and check if the document needs to be reformatted. If the variable TeX-save-query is non-nil, AUCTeX will query before saving each file. By default AUCTeX will check emacs buffers associated with files in the current directory, in one of the TeX-macro-private directories, and in the TeX-macro-global directories. You can change this by setting the variable TeX-check-path.

User Option: TeX-check-path

Directory path to search for dependencies.

If nil, just check the current file. Used when checking if any files have changed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.3 Options for TeX Processors

There are some options you can customize affecting which processors are invoked or the way this is done and which output they produce as a result. These options control if DVI or PDF output should be produced, if TeX should be started in interactive or nonstop mode, if source specials or a SyncTeX file should be produced for making inverse and forward search possible or which TeX engine should be used instead of regular TeX, like PDFTeX, Omega or XeTeX.

Command: TeX-PDF-mode

(C-c C-t C-p) This command toggles the PDF mode of AUCTeX, a buffer-local minor mode. You can customize TeX-PDF-mode to give it a different default. The default is used when AUCTeX does not have additional clue about what a document might want. This option usually results in calling either PDFTeX or ordinary TeX.

User Option: TeX-DVI-via-PDFTeX

If this is set, DVI will also be produced by calling PDFTeX, setting \pdfoutput=0. This makes it possible to use PDFTeX features like character protrusion even when producing DVI files. Contemporary TeX distributions do this anyway, so that you need not enable the option within AUCTeX.

Command: TeX-interactive-mode

(C-c C-t C-i) This command toggles the interactive mode of AUCTeX, a global minor mode. You can customize TeX-interactive-mode to give it a different default. In interactive mode, TeX will pause with an error prompt when errors are encountered and wait for the user to type something.

Command: TeX-source-correlate-mode

(C-c C-t C-s) Toggles support for forward and inverse search. Forward search refers to jumping to the place in the previewed document corresponding to where point is located in the document source and inverse search to the other way round. See section Forward and Inverse Search.

You can permanently activate TeX-source-correlate-mode by customizing the variable TeX-source-correlate-mode. There is a bunch of customization options for the mode, use M-x customize-group <RET> TeX-view <RET> to find out more.

AUCTeX is aware of three different means to do I/O correlation: source specials (only DVI output), the pdfsync LaTeX package (only PDF output) and SyncTeX. The choice between source specials and SyncTeX can be controlled with the variable TeX-source-correlate-method.

Should you use source specials it has to be stressed very strongly however, that source specials can cause differences in page breaks and spacing, can seriously interfere with various packages and should thus never be used for the final version of a document. In particular, fine-tuning the page breaks should be done with source specials switched off.

AUCTeX also allows you to easily select different TeX engines for processing, either by using the entries in the ‘TeXing Options’ submenu below the ‘Command’ menu or by calling the function TeX-engine-set. These eventually set the variable TeX-engine which you can also modify directly.

User Option: TeX-engine

This variable allows you to choose which TeX engine should be used for typesetting the document, i.e. the executables which will be used when you invoke the ‘TeX’ or ‘LaTeX’ commands. The value should be one of the symbols defined in TeX-engine-alist-builtin or TeX-engine-alist. The symbols ‘default’, ‘xetex’, ‘luatex’ and ‘omega’ are available from the built-in list.

Note that TeX-engine is buffer-local, so setting the variable directly or via the above mentioned menu or function will not take effect in other buffers. If you want to activate an engine for all AUCTeX modes, set TeX-engine in your init file, e.g. by using M-x customize-variable <RET>. If you want to activate it for a certain AUCTeX mode only, set the variable in the respective mode hook. If you want to activate it for certain files, set it through file variables (see (emacs)File Variables section ‘File Variables’ in The Emacs Editor).

Should you need to change the executable names related to the different engine settings, there are some variables you can tweak. Those are TeX-command, LaTeX-command, TeX-Omega-command, LaTeX-Omega-command, ConTeXt-engine and ConTeXt-Omega-engine. The rest of the executables is defined directly in TeX-engine-alist-builtin. If you want to override an entry from that, add an entry to TeX-engine-alist that starts with the same symbol as that the entry in the built-in list and specify the executables you want to use instead. You can also add entries to TeX-engine-alist in order to add support for engines not covered per default.

User Option: TeX-engine-alist

Alist of TeX engines and associated commands. Each entry is a list with a maximum of five elements. The first element is a symbol used to identify the engine. The second is a string describing the engine. The third is the command to be used for plain TeX. The fourth is the command to be used for LaTeX. The fifth is the command to be used for the ‘--engine’ parameter of ConTeXt’s ‘texexec’ program. Each command can either be a variable or a string. An empty string or nil means there is no command available.

You can customize AUCTeX to show the processor output as it is produced.

User Option: TeX-show-compilation

If non-nil, the output of TeX compilation is shown in another window.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated on September 2, 2010 using texi2html 1.82.