[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The most powerful features of AUCTeX may be those allowing you to run
TeX, LaTeX, ConTeXt and other external commands like BibTeX
and makeindex
from within Emacs, viewing and printing the
results, and moreover allowing you to debug your documents.
AUCTeX comes with a special tool bar for TeX and LaTeX which
provides buttons for the most important commands. You can enable or
disable it by customizing the options plain-TeX-enable-toolbar
and LaTeX-enable-toolbar
in the TeX-tool-bar
customization
group.
4.1 Executing Commands | Invoking external commands. | |
4.2 Viewing the Formatted Output | Invoking external viewers. | |
4.3 Catching the errors | Debugging TeX and LaTeX output. | |
4.4 Checking for problems | Checking the document. | |
4.5 Controlling the output | Controlling the processes. | |
4.6 Cleaning intermediate and output files | ||
4.7 Documentation about macros and packages |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
4.1.1 Starting a Command on a Document or Region | ||
4.1.2 Selecting and Executing a Command | ||
4.1.3 Options for TeX Processors |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
(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
.
(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
.
(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.
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.
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).
(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] | [ ? ] |
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).
The default command to run in this buffer. Must be an entry in
TeX-command-list
.
In case you use biblatex in a document, AUCTeX switches from
BibTeX to Biber for bibliography processing. In case you want to
keep using BibTeX, set the variable LaTeX-biblatex-use-Biber
to nil.
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
.
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] | [ ? ] |
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.
(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.
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.
(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.
(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.
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.
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.
If non-nil, the output of TeX compilation is shown in another window.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
AUCTeX allows you to start external programs for previewing the formatted output of your document.
4.2.1 Starting Viewers | Starting viewers | |
4.2.2 Forward and Inverse Search | Forward and inverse search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Viewers are normally invoked by pressing C-c C-c once the document
is formatted, which will propose the View command, or by activating the
respective entry in the Command menu. Alternatively you can type
C-c C-v which calls the function TeX-view
.
(C-c C-v) Start a viewer without confirmation. The viewer is
started either on a region or the master file, depending on the last
command issued. This is especially useful for jumping to the location
corresponding to point in the viewer when using
TeX-source-correlate-mode
.
AUCTeX will try to guess which type of viewer (DVI, PostScript or PDF) has to be used and what options are to be passed over to it. This decision is based on the output files present in the working directory as well as the class and style options used in the document. For example, if there is a DVI file in your working directory, a DVI viewer will be invoked. In case of a PDF file it will be a PDF viewer. If you specified a special paper format like ‘a5paper’ or use the ‘landscape’ option, this will be passed to the viewer by the appropriate options. Especially some DVI viewers depend on this kind of information in order to display your document correctly. In case you are using ‘pstricks’ or ‘psfrag’ in your document, a DVI viewer cannot display the contents correctly and a PostScript viewer will be invoked instead.
The association between the tests for the conditions mentioned above and
the viewers is made in the variable TeX-view-program-selection
.
Therefore this variable is the starting point for customization if you
want to use other viewers than the ones suggested by default.
This is a list of predicates and viewers which is evaluated from front
to back in order to find out which viewer to call under the given
conditions. In the first element of each list item you can reference
one or more predicates defined in TeX-view-predicate-list
or
TeX-view-predicate-list-builtin
. In the second element you can
reference a viewer defined in TeX-view-program-list
or
TeX-view-program-list-builtin
. The viewer of the first item with
a positively evaluated predicate is selected.
So TeX-view-program-selection
only contains references to the
actual implementations of predicates and viewer commands respectively
which can be found elsewhere. AUCTeX comes with a set of
preconfigured predicates and viewer commands which are stored in the
variables TeX-view-predicate-list-builtin
and
TeX-view-program-list-builtin
respectively. If you are not
satisfied with those and want to overwrite one of them or add your own
definitions, you can do so via the variables
TeX-view-predicate-list
and TeX-view-program-list
.
This is a list of predicates for viewer selection and invocation. The first element of each list item is a symbol and the second element a Lisp form to be evaluated. The form should return nil if the predicate is not fulfilled.
A built-in predicate from TeX-view-predicate-list-builtin
can be
overwritten by defining a new predicate with the same symbol.
This is a list of viewer specifications each consisting of a symbolic
name and either a command line or a function to be invoked when the
viewer is called. If a command line is used, parts of it can be
conditionalized by prefixing them with predicates from
TeX-view-predicate-list
or
TeX-view-predicate-list-builtin
. (See the doc string for the
exact format to use.) The command line can also contain placeholders as
defined in TeX-expand-list
which are expanded before the viewer
is called.
A built-in viewer spec from TeX-view-program-list-builtin
can be
overwritten by defining a new viewer spec with the same name.
Note that the viewer selection and invocation as described above will
only work if certain default settings in AUCTeX are intact. For one,
the whole viewer selection machinery will only be triggered if the
‘%V’ expander in TeX-expand-list
is unchanged. So if you
have trouble with the viewer invocation you might check if there is an
older customization of the variable in place. In addition, the use of a
function in TeX-view-program-list
only works if the View command
in TeX-command-list
makes use of the hook
TeX-run-discard-or-function
.
Note also that the implementation described above replaces an older one
which was less flexible. This old implementation works with the
variables TeX-output-view-style
and TeX-view-style
which
are used to associate file types and style options with viewers. If
desired you can reactivate it by using the placeholder ‘%vv’ for
the View command in TeX-command-list
. Note however, that it is
bound to be removed from AUCTeX once the new implementation proved to
be satisfactory. For the time being, find a short description of the
mentioned customization options below.
List of output file extensions, style options and view options. Each
item of the list consists of three elements. If the first element (a
regular expression) matches the output file extension, and the second
element (a regular expression) matches the name of one of the style
options, any occurrence of the string %V
in a command in
TeX-command-list
will be replaced with the third element.
List of style options and view options. This is the predecessor of
TeX-output-view-style
which does not provide the possibility to
specify output file extensions. It is used as a fallback in case none
of the alternatives specified in TeX-output-view-style
match. In
case none of the entries in TeX-view-style
match either, no
suggestion for a viewer is made.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Forward and inverse search refer to the correlation between the document source in the editor and the typeset document in the viewer. Forward search allows you to jump to the place in the previewed document corresponding to a certain line in the document source and inverse search vice versa.
AUCTeX supports three methods for forward and inverse search: source
specials (only DVI output), the pdfsync LaTeX package (only PDF
output) and SyncTeX (any type of output). If you want to make use of
forward and inverse searching with source specials or SyncTeX, switch
on TeX-source-correlate-mode
. See section Options for TeX Processors, on how
to do that. The use of the pdfsync package is detected automatically if
document parsing is enabled.
Forward search happens automatically upon calling the viewer, e.g. by
typing C-c C-v (TeX-view
). This will open the viewer or
bring it to front and display the output page corresponding to the
position of point in the source file. AUCTeX will automatically pass
the necessary command line options to the viewer for this to happen.
Upon opening the viewer you will be asked if you want to start a server
process (Gnuserv or Emacs server) which is necessary for inverse search.
This happens only if there is no server running already. You can
customize the variable TeX-source-correlate-start-server
to
inhibit the question and always or never start the server respectively.
If TeX-source-correlate-mode
is active and a viewer is invoked,
the default behavior is to ask if a server process should be started.
Set this variable to t
if the question should be inhibited and
the server should always be started. Set it to nil
if the server
should never be started. Inverse search will not be available in the
latter case.
Inverse search, i.e. jumping to the part of your document source in Emacs corresponding to a certain position in the viewer, is triggered from the viewer, typically by a mouse click. Refer to the documentation of your viewer to find out how it has to be configured and what you have to do exactly. In xdvi you normally have to use C-down-mouse-1.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Once you’ve formatted your document you may ‘debug’ it, i.e. browse through the errors (La)TeX reported.
(C-c `) Go to the next error reported by TeX. The view will be split in two, with the cursor placed as close as possible to the error in the top view. In the bottom view, the error message will be displayed along with some explanatory text.
Normally AUCTeX will only report real errors, but you may as well ask it to report ‘bad boxes’ and warnings as well.
(C-c C-t C-b) Toggle whether AUCTeX should stop at bad boxes (i.e. overfull and underfull boxes) as well as normal errors.
(C-c C-t C-w) Toggle whether AUCTeX should stop at warnings as well as normal errors.
As default, AUCTeX will display a special help buffer containing the error reported by TeX along with the documentation. There is however an ‘expert’ option, which allows you to display the real TeX output.
If t AUCTeX will automatically display a help text whenever an error
is encountered using TeX-next-error
(C-c `). If nil a
terse information about the error is displayed in the echo area. If
expert
AUCTeX will display the output buffer with the raw
TeX output.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Running TeX or LaTeX will only find regular errors in the
document, not examples of bad style. Furthermore, description of the
errors may often be confusing. The utility lacheck
can be used
to find style errors, such as forgetting to escape the space after an
abbreviation or using ‘...’ instead of ‘\ldots’ and many other
problems like that. You start lacheck
with C-c C-c Check
<RET>. The result will be a list of errors in the
‘*compilation*’ buffer. You can go through the errors with
C-x ` (next-error
, see (emacs)Compilation section ‘Compilation’ in The Emacs Editor), which will move point to the location of the next error.
Another newer program which can be used to find errors is chktex
.
It is much more configurable than lacheck
, but doesn’t find all
the problems lacheck
does, at least in its default configuration.
You must install the programs before using them, and for chktex
you may also need modify TeX-command-list
unless you use its
lacheck
compatibility wrapper. You can get lacheck
from
‘<URL:ftp://ftp.ctan.org/tex-archive/support/lacheck/>’ or
alternatively chktex
from
‘<URL:ftp://ftp.ctan.org/tex-archive/support/chktex/>’.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A number of commands are available for controlling the output of an application running under AUCTeX
(C-c C-k) Kill currently running external application. This may be either of TeX, LaTeX, previewer, BibTeX, etc.
(C-c C-l) Recenter the output buffer so that the bottom line is visible.
(C-c ^) Go to the ‘master’ file in the document associated with the current buffer, or if already there, to the file where the current process was started.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Remove generated intermediate files. In case a prefix argument is given, remove output files as well.
Canonical access to the function is provided by the ‘Clean’ and
‘Clean All’ entries in TeX-command-list
, invokable with
C-c C-c or the Command menu.
The patterns governing which files to remove can be adapted separately
for each AUCTeX mode by means of the variables
plain-TeX-clean-intermediate-suffixes
,
plain-TeX-clean-output-suffixes
,
LaTeX-clean-intermediate-suffixes
,
LaTeX-clean-output-suffixes
,
docTeX-clean-intermediate-suffixes
,
docTeX-clean-output-suffixes
,
Texinfo-clean-intermediate-suffixes
,
Texinfo-clean-output-suffixes
,
ConTeXt-clean-intermediate-suffixes
and
ConTeXt-clean-output-suffixes
.
Control if deletion of intermediate and output files has to be confirmed before it is actually done. If non-nil, ask before deleting files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
(C-c ?) Get documentation about macros, packages or TeX & Co. in general. The function will prompt for the name of a command or manual, providing a list of available keywords for completion. If point is on a command or word with available documentation, this will be suggested as default.
In case no documentation could be found, a prompt for querying the ‘texdoc’ program is shown, should the latter be available.
The command can be invoked by the key binding mentioned above as well as the ‘Find Documentation...’ entry in the mode menu.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Build Daemon user on January 17, 2013 using texi2html 1.82.