[ < ] [ > ]   [ << ] [ 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.

Command: LaTeX-command-section

(C-c C-z) Query the user for a command, and apply it to the current section (or part, chapter, subsection, paragraph, or subparagraph). What makes the current section is determined by LaTeX-command-section-level which can be enlarged/shrunken using LaTeX-command-section-change-level (C-c M-z). The given numeric prefix arg is added to the current value of LaTeX-command-section-level. By default, LaTeX-command-section-level is initialized with the current document’s LaTeX-largest-level. 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 TeX-command-region for details.

It is also possible to compile automatically the whole document until it is ready with a single command: TeX-command-run-all.

Command: TeX-command-run-all

(C-c C-a) Compile the current document until an error occurs or it is finished. If compilation finishes successfully, run the viewer at the end.

Here are some relevant variables.

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 plain 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 plain 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.

If the last process you started was on the region, the commands described in Debugging and Control will work on that process, otherwise they will work on the process associated with the current document.

Don’t run more than one process at the same time. AUCTeX doesn’t support simultaneous typeset including region typeset. Wait for the previous process to finish before you start a new process, in particular when you are editing multiple documents in parallel. This limitation applies for preview by preview-latex as well.


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

This document was generated on January 17, 2024 using texi2html 1.82.