Fetching contributors…
Cannot retrieve contributors at this time
8969 lines (7209 sloc) 401 KB
This is, produced by makeinfo version 6.3 from auctex.texi.
This manual is for AUCTeX (version 11.90.2 from 2017-04-21), a
sophisticated TeX environment for Emacs.
Copyright (C) 1992-1995, 2001, 2002, 2004-2017 Free Software
Foundation, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, no Front-Cover Texts and no
Back-Cover Texts. A copy of the license is included in the section
entitled "GNU Free Documentation License."
* AUCTeX: (auctex). A sophisticated TeX environment for Emacs.
* AUCTeX: (auctex). A sophisticated TeX environment for Emacs.

File:, Node: Top, Next: Copying, Up: (dir)
This manual may be copied under the conditions spelled out in *note
Copying this Manual::.
AUCTeX is an integrated environment for editing LaTeX, ConTeXt,
docTeX, Texinfo, and TeX files.
Although AUCTeX contains a large number of features, there are no
reasons to despair. You can continue to write TeX and LaTeX documents
the way you are used to, and only start using the multiple features in
small steps. AUCTeX is not monolithic, each feature described in this
manual is useful by itself, but together they provide an environment
where you will make very few LaTeX errors, and makes it easy to find the
errors that may slip through anyway.
It is a good idea to make a printout of AUCTeX's reference card
'tex-ref.tex' or one of its typeset versions.
If you want to make AUCTeX aware of style files and multi-file
documents right away, insert the following in your '.emacs' file.
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
Another thing you should enable is RefTeX, a comprehensive solution
for managing cross references, bibliographies, indices, document
navigation and a few other things. (*note (reftex)Installation::)
For detailed information about the preview-latex subsystem of AUCTeX,
see *note Introduction: (preview-latex)Top.
There is a mailing list for general discussion about AUCTeX: write a
mail with "subscribe" in the subject to <> to join
it. Send contributions to <>.
Bug reports should go to <>, suggestions for new
features, and pleas for help should go to either <>
(the AUCTeX developers), or to <> if they might have
general interest. Please use the command 'M-x TeX-submit-bug-report
RET' to report bugs if possible. You can subscribe to a low-volume
announcement list by sending "subscribe" in the subject of a mail to
* Menu:
* Copying:: Copying
* Introduction:: Introduction to AUCTeX
* Editing:: Editing the Document Source
* Display:: Controlling Screen Display
* Processing:: Starting Processors, Viewers and Other Programs
* Customization:: Customization and Extension
* Appendices:: Copying, Changes, Development, FAQ, Texinfo mode
* Indices:: Indices
-- The Detailed Node Listing --
* Summary:: Overview of AUCTeX
* Installation:: Installing AUCTeX
* Quick Start:: Quick Start
Editing the Document Source
* Quotes:: Inserting double quotes
* Font Specifiers:: Inserting Font Specifiers
* Sectioning:: Inserting chapters, sections, etc.
* Environments:: Inserting Environment Templates
* Mathematics:: Entering Mathematics
* Completion:: Completion of macros
* Commenting:: Commenting text
* Indenting:: Reflecting syntactic constructs with whitespace
* Filling:: Automatic and manual line breaking
Inserting Environment Templates
* Equations:: Equations
* Floats:: Floats
* Itemize-like:: Itemize-like Environments
* Tabular-like:: Tabular-like Environments
* Customizing Environments:: Customizing Environments
Controlling Screen Display
* Font Locking:: Font Locking
* Folding:: Folding Macros and Environments
* Outline:: Outlining the Document
* Narrowing:: Restricting display and editing to a portion of the buffer
* Prettifying:: Displaying Greek and math macros as Unicode characters
Font Locking
* Fontification of macros:: Fontification of macros
* Fontification of quotes:: Fontification of quotes
* Fontification of math:: Fontification of math constructs
* Verbatim content:: Verbatim macros and environments
* Faces:: Faces used by font-latex
Starting Processors, Viewers and Other Programs
* Commands:: Invoking external commands.
* Viewing:: Invoking external viewers.
* Debugging:: Debugging TeX and LaTeX output.
* Checking:: Checking the document.
* Control:: Controlling the processes.
* Cleaning:: Cleaning intermediate and output files.
* Documentation:: Documentation about macros and packages.
Viewing the Formatted Output
* Starting Viewers:: Starting viewers
* I/O Correlation:: Forward and inverse search
Catching the errors
* Ignoring warnings:: Controlling warnings to be reported
* Error overview:: List of all errors and warnings
Customization and Extension
* Multifile:: Multifile Documents
* Parsing Files:: Automatic Parsing of TeX Files
* Internationalization:: Language Support
* Automatic:: Automatic Customization
* Style Files:: Writing Your Own Style Support
Language Support
* European:: Using AUCTeX with European Languages
* Japanese:: Using AUCTeX with Japanese
Automatic Customization
* Automatic Global:: Automatic Customization for the Site
* Automatic Private:: Automatic Customization for a User
* Automatic Local:: Automatic Customization for a Directory
Writing Your Own Style Support
* Simple Style:: A Simple Style File
* Adding Macros:: Adding Support for Macros
* Adding Environments:: Adding Support for Environments
* Adding Other:: Adding Other Information
* Hacking the Parser:: Automatic Extraction of New Things
Copying, Changes, Development, FAQ
* Copying this Manual::
* Changes::
* Development::
* FAQ::
* Texinfo mode::
Copying this Manual
* GNU Free Documentation License:: License for copying this manual.
* Key Index::
* Function Index::
* Variable Index::
* Concept Index::

File:, Node: Copying, Next: Introduction, Prev: Top, Up: Top
AUCTeX primarily consists of Lisp files for Emacs (and XEmacs), but
there are also installation scripts and files and TeX support files.
All of those are "free"; this means that everyone is free to use them
and free to redistribute them on a free basis. The files of AUCTeX are
not in the public domain; they are copyrighted and there are
restrictions on their distribution, but these restrictions are designed
to permit everything that a good cooperating citizen would want to do.
What is not allowed is to try to prevent others from further sharing any
version of these programs that they might get from you.
Specifically, we want to make sure that you have the right to give
away copies of the files that constitute AUCTeX, that you receive source
code or else can get it if you want it, that you can change these files
or use pieces of them in new free programs, and that you know you can do
these things.
To make sure that everyone has such rights, we have to forbid you to
deprive anyone else of these rights. For example, if you distribute
copies of parts of AUCTeX, you must give the recipients all the rights
that you have. You must make sure that they, too, receive or can get
the source code. And you must tell them their rights.
Also, for our own protection, we must make certain that everyone
finds out that there is no warranty for AUCTeX. If any parts are
modified by someone else and passed on, we want their recipients to know
that what they have is not what we distributed, so that any problems
introduced by others will not reflect on our reputation.
The precise conditions of the licenses for the files currently being
distributed as part of AUCTeX are found in the General Public Licenses
that accompany them. This manual specifically is covered by the GNU
Free Documentation License (*note Copying this Manual::).

File:, Node: Introduction, Next: Editing, Prev: Copying, Up: Top
1 Introduction
* Menu:
* Summary:: Overview of AUCTeX
* Installation:: Installing AUCTeX
* Quick Start:: Quick Start

File:, Node: Summary, Next: Installation, Up: Introduction
1.1 Overview of AUCTeX
AUCTeX is a comprehensive customizable integrated environment for
writing input files for TeX, LaTeX, ConTeXt, Texinfo, and docTeX using
Emacs or XEmacs.
It supports you in the insertion of macros, environments, and
sectioning commands by providing completion alternatives and prompting
for parameters. It automatically indents your text as you type it and
lets you format a whole file at once. The outlining and folding
facilities provide you with a focused and clean view of your text.
AUCTeX lets you process your source files by running TeX and related
tools (such as output filters, post processors for generating indices
and bibliographies, and viewers) from inside Emacs. AUCTeX lets you
browse through the errors TeX reported, while it moves the cursor
directly to the reported error, and displays some documentation for that
particular error. This will even work when the document is spread over
several files.
One component of AUCTeX that LaTeX users will find attractive is
preview-latex, a combination of folding and in-source previewing that
provides true "What You See Is What You Get" experience in your
sourcebuffer, while letting you retain full control.
More detailed information about the features and usage of AUCTeX can
be found in the remainder of this manual.
AUCTeX is written entirely in Emacs Lisp, and hence you can easily
add new features for your own needs. It is a GNU project and
distributed under the 'GNU General Public License Version 3'.
The most recent version is always available at
WWW users may want to check out the AUCTeX page at
For comprehensive information about how to install AUCTeX *Note
Installation::, or *note Installation under MS Windows::, respectively.
If you are considering upgrading AUCTeX, the recent changes are
described in *note Changes::.
If you want to discuss AUCTeX with other users or its developers,
there are several mailing lists you can use.
Send a mail with the subject "subscribe" to <>
in order to join the general discussion list for AUCTeX. Articles
should be sent to <>. In a similar way, you can subscribe
to the <> list for just getting important
announcements about AUCTeX. The list <> is for bug
reports which you should usually file with the 'M-x
TeX-submit-bug-report <RET>' command. If you want to address the
developers of AUCTeX themselves with technical issues, they can be found
on the discussion list <>.

File:, Node: Installation, Next: Quick Start, Prev: Summary, Up: Introduction
1.2 Installing AUCTeX
The modern and strongly recommended way of installing AUCTeX is by using
the Emacs package manager integrated in Emacs 24 and greater (ELPA).
Simply do 'M-x list-packages RET', mark the auctex package for
installation with 'i', and hit 'x' to execute the installation
procedure. That's all. This installation procedure has several
advantages. Besides being platform and OS independent, you will receive
intermediate releases between major AUCTeX releases conveniently. For
past ELPA releases, see <>.
Once the installation is completed, you can skip the rest of this
section and proceed to *note Quick Start::.
The remainder of this section is about installing AUCTeX from a
release tarball or from a checkout of the AUCTeX repository.
Installing AUCTeX should be simple: merely './configure', 'make', and
'make install' for a standard site-wide installation (most other
installations can be done by specifying a '--prefix=...' option).
On many systems, this will already activate the package, making its
modes the default instead of the built-in modes of Emacs. If this is
not the case, consult *note Loading the package::. Please read through
this document fully before installing anything. The installation
procedure has changed as compared to earlier versions. Users of
MS Windows are asked to consult *Note Installation under MS Windows::.
* Menu:
* Prerequisites::
* Configure::
* Build/install and uninstall::
* Loading the package::
* Advice for package providers::
* Advice for non-privileged users::
* Installation under MS Windows::
* Customizing::

File:, Node: Prerequisites, Next: Configure, Up: Installation
1.2.1 Prerequisites
* A recent version of Emacs, alternatively XEmacs
Emacs 20 is no longer supported, and neither is XEmacs with a
version of 'xemacs-base' older than 1.84 (released in sumo from
02/02/2004). Using preview-latex requires a version of Emacs
compiled with image support. While the X11 version of Emacs 21
will likely work, Emacs 22 and later is preferred.
Precompiled versions are available from
Mac OS X
For an overview of precompiled versions of Emacs for Mac OS X
see for example
Most GNU/Linux distributions nowadays provide a recent variant
of Emacs via their package repositories.
Compiling Emacs yourself requires a C compiler and a number of
tools and development libraries. Details are beyond the scope
of this manual. Instructions for checking out the source code
can be found at <>.
If you really need to use Emacs 21 on platforms where this implies
missing image support, you should disable the installation of
preview-latex (see below).
While XEmacs (version 21.4.15, 21.4.17 or later) is supported,
doing this in a satisfactory manner has proven to be difficult.
This is mostly due to technical shortcomings and differing API's
which are hard to come by. If AUCTeX is your main application for
XEmacs, you are likely to get better results and support by
switching to Emacs. Of course, you can improve support for your
favorite editor by giving feedback in case you encounter bugs.
* A working TeX installation
Well, AUCTeX would be pointless without that. Processing
documentation requires TeX, LaTeX and Texinfo during installation.
preview-latex requires Dvips for its operation in DVI mode. The
default configuration of AUCTeX is tailored for teTeX or
TeXlive-based distributions, but can be adapted easily.
* A recent Ghostscript
This is needed for operation of preview-latex in both DVI and PDF
mode. Most versions of Ghostscript nowadays in use should work
fine (version 7.0 and newer).
* The 'texinfo' package
Strictly speaking, you can get away without it if you are building
from the distribution tarball, have not modified any files and
don't need a printed version of the manual: the pregenerated info
file is included in the tarball. At least version 4.0 is required.
For some known issues with various software, see *note
(preview-latex)Known problems::.

File:, Node: Configure, Next: Build/install and uninstall, Prev: Prerequisites, Up: Installation
1.2.2 Configure
The first step is to configure the source code, telling it where various
files will be. To do so, run
./configure OPTIONS
(Note: if you have fetched AUCTeX from Git rather than a regular
release, you will have to first follow the instructions in
On many machines, you will not need to specify any options, but if
'configure' cannot determine something on its own, you'll need to help
it out with one of these options:
All automatic placements for package components will be chosen from
sensible existing hierarchies below this: directories like 'man',
'share' and 'bin' are supposed to be directly below PREFIX.
Only if no workable placement can be found there, in some cases an
alternative search will be made in a prefix deduced from a suitable
'/usr/local' is the default PREFIX, intended to be suitable for a
site-wide installation. If you are packaging this as an operating
system component for distribution, the setting '/usr' will probably
be the right choice. If you are planning to install the package as
a single non-priviledged user, you will typically set PREFIX to
your home directory.
If you are using a pretest which isn't in your '$PATH', or
'configure' is not finding the right Emacs executable, you can
specify it with this option.
Configure for generation under XEmacs (Emacs is the default).
Again, the name of the right XEmacs executable can be specified,
complete with path if necessary.
This XEmacs-only option configures the directory for XEmacs
packages. A typical user-local setting would be
'~/.xemacs/xemacs-packages'. If this directory exists and is below
PREFIX, it should be detected automatically. This will install and
activate the package.
This XEmacs-only option switches the detection of a package
directory and corresponding installation off. Consequently, the
Emacs installation scheme will be used. This might be appropriate
if you are using a different package system/installer than the
XEmacs one and want to avoid conflicts.
The Emacs installation scheme has the following options:
This Emacs-only option specifies the location of the 'site-lisp'
directory within 'load-path' under which the files will get
installed (the bulk will get installed in a subdirectory).
'./configure' should figure this out by itself.
This is the name of the respective startup files. If LISPDIR
contains a subdirectory 'site-start.d', the start files are placed
there, and 'site-start.el' should load them automatically. Please
be aware that you must not move the start files after installation
since other files are found _relative_ to them.
This is the directory where the bulk of the package gets located.
The startfile adds this into LOAD-PATH.
You can use this option to specify the directory containing
automatically generated information. It is not necessary for most
TeX installs, but may be used if you don't like the directory that
configure is suggesting.
This is not an option specific to AUCTeX. A number of standard
options to 'configure' exist, and we do not have the room to
describe them here; a short description of each is available, using
'--help'. If you use '--help=recursive', then also
preview-latex-specific options will get listed.
This disables configuration and installation of preview-latex.
This option is not actually recommended. If your Emacs does not
support images, you should really upgrade to a newer version.
Distributors should, if possible, refrain from distributing AUCTeX
and preview-latex separately in order to avoid confusion and
upgrade hassles if users install partial packages on their own.
This option is used for specifying a TDS-compliant directory
hierarchy. Using '--with-texmf-dir=/DIR' you can specify where the
TeX TDS directory hierarchy resides, and the TeX files will get
installed in '/DIR/tex/latex/preview/'.
If you use the '--without-texmf-dir' option, the TeX-related files
will be kept in the Emacs Lisp tree, and at runtime the 'TEXINPUTS'
environment variable will be made to point there. You can install
those files into your own TeX tree at some later time with 'M-x
preview-install-styles RET'.
If you want to specify an exact directory for the preview TeX
files, use '--with-tex-dir=/DIR'. In this case, the files will be
placed in '/DIR', and you'll also need the following option:
This option may be used to specify where the TeX documentation
goes. It is to be used when you are using '--with-tex-dir=/DIR',
but is normally not necessary otherwise.

File:, Node: Build/install and uninstall, Next: Loading the package, Prev: Configure, Up: Installation
1.2.3 Build/install and uninstall
Once 'configure' has been run, simply enter
at the prompt to byte-compile the lisp files, extract the TeX files and
build the documentation files. To install the files into the locations
chosen earlier, type
make install
You may need special privileges to install, e.g., if you are installing
into system directories.
Should you want to completely remove the installed package, in the
same directory you built AUCTeX run
make uninstall
You will need administration privileges if you installed the package
into system directories.

File:, Node: Loading the package, Next: Advice for package providers, Prev: Build/install and uninstall, Up: Installation
1.2.4 Loading the package
You can detect the successful activation of AUCTeX and preview-latex in
the menus after loading a LaTeX file like 'preview/circ.tex': AUCTeX
then gives you a 'Command' menu, and preview-latex gives you a 'Preview'
For XEmacs, if the installation occured into a valid package
directory (which is the default), then this should work out of the box.
With Emacs (or if you explicitly disabled use of the package system),
the startup files 'auctex.el' and 'preview-latex.el' may already be in a
directory of the 'site-start.d/' variety if your Emacs installation
provides it. In that case they should be automatically loaded on
startup and nothing else needs to be done. If not, they should at least
have been placed somewhere in your 'load-path'. You can then load them
by placing the lines
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
into your init file.
If you explicitly used '--with-lispdir', you may need to add the
specified directory into Emacs' 'load-path' variable by adding something
(add-to-list 'load-path "~/elisp")
before the above lines into your Emacs startup file.
For site-wide activation in GNU Emacs, see *Note Advice for package
Once activated, the modes provided by AUCTeX are used per default for
all supported file types. If you want to change the modes for which it
is operative instead of the default, use
M-x customize-variable <RET> TeX-modes <RET>
If you want to remove a preinstalled AUCTeX completely before any of
its modes have been used,
(unload-feature 'tex-site)
should accomplish that.

File:, Node: Advice for package providers, Next: Advice for non-privileged users, Prev: Loading the package, Up: Installation
1.2.5 Providing AUCTeX as a package
As a package provider, you should make sure that your users will be
served best according to their intentions, and keep in mind that a
system might be used by more than one user, with different preferences.
There are people that prefer the built-in Emacs modes for editing TeX
files, in particular plain TeX users. There are various ways to tell
AUCTeX even after auto-activation that it should not get used, and they
are described in *note Introduction to AUCTeX: Introduction.
So if you have users that don't want to use the preinstalled AUCTeX,
they can easily get rid of it. Activating AUCTeX by default is
therefore a good choice.
If the installation procedure did not achieve this already by placing
'auctex.el' and 'preview-latex.el' into a possibly existing
'site-start.d' directory, you can do this by placing
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
in the system-wide 'site-start.el'.
If your package is intended as an XEmacs package or to accompany a
precompiled version of Emacs, you might not know which TeX system will
be available when preview-latex gets used. In this case you should
build using the '--without-texmf-dir' option described previously. This
can also be convenient for systems that are intended to support more
than a single TeX distribution. Since more often than not TeX packages
for operating system distributions are either much more outdated or much
less complete than separately provided systems like TeX Live, this
method may be generally preferable when providing packages.
The following package structure would be adequate for a typical fully
supported Unix-like installation:
Style files and documentation for 'preview.sty', placed into a TeX
tree where it is accessible from the teTeX executables usually
delivered with a system. If there are other commonly used TeX
system packages, it might be appropriate to provide separate
packages for those.
This package will require the installation of 'preview-tetex' and
will record in 'TeX-macro-global' where to find the TeX tree. It
is also a good idea to run
emacs -batch -f TeX-auto-generate-global
when either AUCTeX or teTeX get installed or upgraded. If your
users might want to work with a different TeX distribution
(nowadays pretty common), instead consider the following:
This package will be compiled with '--without-texmf-dir' and will
consequently contain the 'preview' style files in its private
directory. It will probably not be possible to initialize
'TeX-macro-global' to a sensible value, so running
'TeX-auto-generate-global' does not appear useful. This package
would neither conflict with nor provide 'preview-tetex'.
Those are the obvious XEmacs equivalents. For XEmacs, there is the
additional problem that the XEmacs sumo package tree already
possibly provides its own version of AUCTeX, and the user might
even have used the XEmacs package manager to updating this package,
or even installing a private AUCTeX version. So you should make
sure that such a package will not conflict with existing XEmacs
packages and will be at an appropriate place in the load order
(after site-wide and user-specific locations, but before a
distribution-specific sumo package tree). Using the
'--without-packagedir' option might be one idea to avoid conflicts.
Another might be to refrain from providing an XEmacs package and
just rely on the user or system administrator to instead use the
XEmacs package system.

File:, Node: Advice for non-privileged users, Next: Installation under MS Windows, Prev: Advice for package providers, Up: Installation
1.2.6 Installation for non-privileged users
Often people without system administration privileges want to install
software for their private use. In that case you need to pass more
options to the 'configure' script. For XEmacs users, this is fairly
easy, because the XEmacs package system has been designed to make this
sort of thing practical: but GNU Emacs users (and XEmacs users for whom
the package system is for some reason misbehaving) may need to do a
little more work.
The main expedient is using the '--prefix' option to the 'configure'
script, and let it point to the personal home directory. In that way,
resulting binaries will be installed under the 'bin' subdirectory of
your home directory, manual pages under 'man' and so on. It is
reasonably easy to maintain a bunch of personal software, since the
prefix argument is supported by most 'configure' scripts.
You'll have to add something like
'/home/myself/share/emacs/site-lisp' to your 'load-path' variable, if it
isn't there already.
XEmacs users can achieve the same end by pointing 'configure' at an
appropriate package directory (normally
'--with-packagedir=~/.xemacs/xemacs-packages' will serve). The package
directory stands a good chance at being detected automatically as long
as it is in a subtree of the specified PREFIX.
Now here is another thing to ponder: perhaps you want to make it easy
for other users to share parts of your personal Emacs configuration. In
general, you can do this by writing '~myself/' anywhere where you
specify paths to something installed in your personal subdirectories,
not merely '~/', since the latter, when used by other users, will point
to non-existent files.
For yourself, it will do to manipulate environment variables in your
'.profile' resp. '.login' files. But if people will be copying just
Elisp files, their copies will not work. While it would in general be
preferable if the added components where available from a shell level,
too (like when you call the standalone info reader, or try using
'preview.sty' for functionality besides of Emacs previews), it will be a
big help already if things work from inside of Emacs.
Here is how to do the various parts:
Making the Elisp available
In GNU Emacs, it should be sufficient if people just do
(load "~myself/share/emacs/site-lisp/auctex.el" nil t t)
(load "~myself/share/emacs/site-lisp/preview-latex.el" nil t t)
where the path points to your personal installation. The rest of the
package should be found relative from there without further ado.
In XEmacs, you should ask the other users to add symbolic links in
the subdirectories 'lisp', 'info' and 'etc' of their
'~/.xemacs/xemacs-packages/' directory. (Alas, there is presently no
easy programmatic way to do this, except to have a script do the
symlinking for them.)
Making the Info files available
For making the info files accessible from within Elisp, something like
the following might be convenient to add into your or other people's
startup files:
(eval-after-load 'info
'(add-to-list 'Info-directory-list "~myself/info"))
In XEmacs, as long as XEmacs can see the package, there should be no
need to do anything at all; the info files should be immediately
visible. However, you might want to set 'INFOPATH' anyway, for the sake
of standalone readers outside of XEmacs. (The info files in XEmacs are
normally in '~/.xemacs/xemacs-packages/info'.)
Making the LaTeX style available
If you want others to be able to share your installation, you should
configure it using '--without-texmf-dir', in which case things should
work as well for them as for you.

File:, Node: Installation under MS Windows, Next: Customizing, Prev: Advice for non-privileged users, Up: Installation
1.2.7 Installation under MS Windows
In a Nutshell
The following are brief installation instructions for the impatient. In
case you don't understand some of this, run into trouble of some sort,
or need more elaborate information, refer to the detailed instructions
further below.
1. Install the prerequisites, i.e. Emacs or XEmacs, MSYS or Cygwin, a
TeX system, and Ghostscript.
2. Open the MSYS shell or a Cygwin shell and change to the directory
containing the unzipped file contents.
3. Configure AUCTeX:
For Emacs: Many people like to install AUCTeX into the pseudo file
system hierarchy set up by the Emacs installation. Assuming Emacs
is installed in 'C:/Program Files/Emacs' and the directory for
local additions of your TeX system, e.g. MiKTeX, is
'C:/localtexmf', you can do this by typing the following statement
at the shell prompt:
./configure --prefix='C:/Program Files/Emacs' \
--infodir='C:/Program Files/Emacs/info' \
For XEmacs: You can install AUCTeX as an XEmacs package. Assuming
XEmacs is installed in 'C:/Program Files/XEmacs' and the directory
for local additions of your TeX system, e.g. MiKTeX, is
'C:/localtexmf', you can do this by typing the following command at
the shell prompt:
./configure --with-xemacs='C:/Program Files/XEmacs/bin/xemacs' \
The commands above are examples for common usage. More on
configuration options can be found in the detailed installation
instructions below.
If the configuration script failed to find all required programs,
make sure that these programs are in your system path and add
directories containing the programs to the 'PATH' environment
variable if necessary. Here is how to do that in W2000/XP:
1. On the desktop, right click "My Computer" and select
2. Click on "Advanced" in the "System Properties" window.
3. Select "Environment Variables".
4. Select "path" in "System Variables" and click "edit". Move to
the front in the line (this might require scrolling) and add
the missing path including drive letter, ended with a
4. If there were no further error messages, type
In case there were, please refer to the detailed description below.
5. Finish the installation by typing
make install
Detailed Installation Instructions
Installation of AUCTeX under Windows is in itself not more complicated
than on other platforms. However, meeting the prerequisites might
require more work than on some other platforms, and feel less natural.
If you are experiencing any problems, even if you think they are of
your own making, be sure to report them to <> so
that we can explain things better in future.
Windows is a problematic platform for installation scripts. The main
problem is that the installation procedure requires consistent file
names in order to find its way in the directory hierarchy, and Windows
path names are a mess.
The installation procedure tries finding stuff in system search paths
and in Emacs paths. For that to succeed, you have to use the same
syntax and spelling and case of paths everywhere: in your system search
paths, in Emacs' 'load-path' variable, as argument to the scripts. If
your path names contain spaces or other 'shell-unfriendly' characters,
most notably backslashes for directory separators, place the whole path
in '"double quote marks"' whenever you specify it on a command line.
Avoid 'helpful' magic file names like '/cygdrive/c' and
'C:\PROGRA~1\' like the plague. It is quite unlikely that the scripts
will be able to identify the actual file names involved. Use the full
paths, making use of normal Windows drive letters like ' 'C:/Program
Files/Emacs' ' where required, and using the same combination of upper-
and lowercase letters as in the actual files. File names containing
shell-special characters like spaces or backslashes (if you prefer that
syntax) need to get properly quoted to the shell: the above example used
single quotes for that.
Ok, now here are the steps to perform:
1. You need to unpack the AUCTeX distribution (which you seemingly
have done since you are reading this). It must be unpacked in a
separate installation directory outside of your Emacs file
hierarchy: the installation will later copy all necessary files to
their final destination, and you can ultimately remove the
directory where you unpacked the files.
Line endings are a problem under Windows. The distribution
contains only text files, and theoretically most of the involved
tools should get along with that. However, the files are processed
by various utilities, and it is conceivable that not all of them
will use the same line ending conventions. If you encounter
problems, it might help if you try unpacking (or checking out) the
files in binary mode, if your tools allow that.
If you don't have a suitable unpacking tool, skip to the next step:
this should provide you with a working 'unzip' command.
2. The installation of AUCTeX will require the MSYS tool set from
<> or the Cygwin tool set from
<>. The latter is slower and larger (the
download size of the base system is about 15 MB) but comes with a
package manager that allows for updating the tool set and
installing additional packages like, for example, the spell checker
If Cygwin specific paths like '/cygdrive/c' crop up in the course
of the installation, using a non-Cygwin Emacs could conceivably
cause trouble. Using Cygwin either for everything or nothing might
save headaches, _if_ things don't work out.
3. Install a current version of XEmacs from <>
or Emacs from <>. Emacs is the
recommended choice because it is currently the primary platform for
AUCTeX development.
4. You need a working TeX installation. One popular installation
under Windows is MiKTeX ( Another much more
extensive system is TeX Live ( which is
rather close to its Unix cousins.
5. A working copy of Ghostscript ( is
required for preview-latex operation. Examining the output from
gswin32c -h
on a Windows command line should tell you whether your Ghostscript
supports the 'png16m' device needed for PNG support. MiKTeX
apparently comes with its own Ghostscript called 'mgs.exe'.
6. Perl ( is needed for rebuilding the
documentation if you are working with a copy from Git or have
touched documentation source files in the preview-latex part. If
the line endings of the file 'preview/latex/preview.dtx' don't
correspond with what Perl calls '\n' when reading text files,
you'll run into trouble.
7. Now the fun stuff starts. If you have not yet done so, unpack the
AUCTeX distribution into a separate directory after rereading the
instructions for unpacking above.
8. Ready for takeoff. Start some shell (typically 'bash') capable of
running 'configure', change into the installation directory and
call './configure' with appropriate options.
Typical options you'll want to specify will be
which tells 'configure' where to perform the installation. It
may also make 'configure' find Emacs or XEmacs automatically;
if this doesn't happen, try one of '--with-emacs' or
'--with-xemacs' as described below. All automatic detection
of files and directories restricts itself to directories below
the PREFIX or in the same hierarchy as the program accessing
the files. Usually, directories like 'man', 'share' and 'bin'
will be situated right under PREFIX.
This option also affects the defaults for placing the Texinfo
documentation files (see also '--infodir' below) and
automatically generated style hooks.
If you have a central directory hierarchy (not untypical with
Cygwin) for such stuff, you might want to specify its root
here. You stand a good chance that this will be the only
option you need to supply, as long as your TeX-related
executables are in your system path, which they better be for
AUCTeX's operation, anyway.
if you are installing for a version of Emacs. You can use
'--with-emacs=DRIVE:/PATH/TO/EMACS' to specify the name of the
installed Emacs executable, complete with its path if
necessary (if Emacs is not within a directory specified in
your 'PATH' environment setting).
if you are installing for a version of XEmacs. Again, you can
use '--with-xemacs=DRIVE:/PATH/TO/XEMACS' to specify the name
of the installed XEmacs executable complete with its path if
necessary. It may also be necessary to specify this option if
a copy of Emacs is found in your 'PATH' environment setting,
but you still would like to install a copy of AUCTeX for
is an XEmacs-only option giving the location of the package
directory. This will install and activate the package. Emacs
uses a different installation scheme:
This Emacs-only option tells a place in 'load-path' below
which the files are situated. The startup files 'auctex.el'
and 'preview-latex.el' will get installed here unless a
subdirectory 'site-start.d' exists which will then be used
instead. The other files from AUCTeX will be installed in a
subdirectory called 'auctex'.
If you think that you need a different setup, please refer to
the full installation instructions in *note Configure::.
If you are installing into an Emacs directory, info files have
to be put into the 'info' folder below that directory. The
configuration script will usually try to install into the
folder 'share/info', so you have to override this by
specifying something like '--infodir='C:/Program Files/info''
for the configure call.
Directory containing automatically generated information. You
should not normally need to set this, as '--prefix' should
take care of this.
Use this option if your Emacs version is unable to support
image display. This will be the case if you are using a
native variant of Emacs 21.
This will specify the directory where your TeX installation
sits. If your TeX installation does not conform to the TDS
(TeX directory standard), you may need to specify more options
to get everything in place.
For more information about any of the above and additional options,
see *note Configure::.
Calling './configure --help=recursive' will tell about other
options, but those are almost never required.
Some executables might not be found in your path. That is not a
good idea, but you can get around by specifying environment
variables to 'configure':
GS="DRIVE:/PATH/TO/GSWIN32C.EXE" ./configure ...
should work for this purpose. 'gswin32c.exe' is the usual name for
the required _command line_ executable under Windows; in contrast,
'gswin32.exe' is likely to fail.
As an alternative to specifying variables for the 'configure' call
you can add directories containing the required executables to the
'PATH' variable of your Windows system. This is especially a good
idea if Emacs has trouble finding the respective programs later
during normal operation.
9. Run 'make' in the installation directory.
10. Run 'make install' in the installation directory.
11. With XEmacs, AUCTeX and preview-latex should now be active by
default. With Emacs, activation depends on a working
'site-start.d' directory or similar setup, since then the startup
files 'auctex.el' and 'preview-latex.el' will have been placed
there. If this has not been done, you should be able to load the
startup files manually with
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
in either a site-wide 'site-start.el' or your personal startup file
(usually accessible as '~/.emacs' from within Emacs and
'~/.xemacs/init.el' from within XEmacs).
The default configuration of AUCTeX is probably not the best fit
for Windows systems with MiKTeX. You might want to add
(require 'tex-mik)
after loading 'auctex.el' and 'preview-latex.el' in order to get
more appropriate values for some customization options.
You can always use
M-x customize-group RET AUCTeX RET
in order to customize more stuff, or use the 'Customize' menu.
12. Load 'preview/circ.tex' into Emacs or XEmacs and see if you get
the 'Command' menu. Try using it to LaTeX the file.
13. Check whether the 'Preview' menu is available in this file. Use
it to generate previews for the document.
If this barfs and tells you that image type 'png' is not supported,
you can either add PNG support to your Emacs installation or choose
another image format to be used by preview-latex.
Adding support for an image format usually involves the
installation of a library, e.g. from <>.
If you got your Emacs from <> you might want to
check its README file (
for details.
A different image format can be chosen by setting the variable
'preview-image-type'. While it is recommended to keep the 'dvipng'
or 'png' setting, you can temporarily select a different format
like 'pnm' to check if the lack of PNG support is the only problem
with your Emacs installation.
Try adding the line
(setq preview-image-type 'pnm)
to your init file for a quick test. You should remove the line
after the test again, because PNM files take away *vast* amounts of
disk space, and thus also of load/save time.
Well, that about is all. Have fun!

File:, Node: Customizing, Prev: Installation under MS Windows, Up: Installation
1.2.8 Customizing
Most of the site-specific customization should already have happened
during configuration of AUCTeX. Any further customization can be done
with customization buffers directly in Emacs. Just type 'M-x
customize-group RET AUCTeX RET' to open the customization group for
AUCTeX or use the menu entries provided in the mode menus. Editing the
file 'tex-site.el' as suggested in former versions of AUCTeX should not
be done anymore because the installation routine will overwrite those
You might check some variables with a special significance. They are
accessible directly by typing 'M-x customize-variable RET <variable>
-- User Option: TeX-macro-global
Directories containing the site's TeX style files.
Normally, AUCTeX will only allow you to complete macros and
environments which are built-in, specified in AUCTeX style files or
defined by yourself. If you issue the 'M-x TeX-auto-generate-global'
command after loading AUCTeX, you will be able to complete on all macros
available in the standard style files used by your document. To do
this, you must set this variable to a list of directories where the
standard style files are located. The directories will be searched
recursively, so there is no reason to list subdirectories explicitly.
Automatic configuration will already have set the variable for you if it
could use the program 'kpsewhich'. In this case you normally don't have
to alter anything.

File:, Node: Quick Start, Prev: Installation, Up: Introduction
1.3 Quick Start
AUCTeX is a powerful program offering many features and configuration
options. If you are new to AUCTeX this might be deterrent. Fortunately
you do not have to learn everything at once. This Quick Start Guide
will give you the knowledge of the most important commands and enable
you to prepare your first LaTeX document with AUCTeX after only a few
minutes of reading.
In this introduction, we assume that AUCTeX is already installed on
your system. If this is not the case, you should read the file
'INSTALL' in the base directory of the unpacked distribution tarball.
These installation instructions are available in this manual as well,
*note Installation::. We also assume that you are familiar with the way
keystrokes are written in Emacs manuals. If not, have a look at the
Emacs Tutorial in the Help menu.
If AUCTeX is installed in any other way than from the Emacs package
manager (ELPA), you might still need to activate it, by inserting
(load "auctex.el" nil t t)
in your user init file.(1)
If AUCTeX is installed from ELPA, the installation procedure already
cares about loading AUCTeX correctly and you *must not* have the line
above in your init file. Note that this also applies if you have the
following line in your init file
In order to get support for many of the LaTeX packages you will use
in your documents, you should enable document parsing as well, which can
be achieved by putting
(setq TeX-auto-save t)
(setq TeX-parse-self t)
into your init file. Finally, if you often use '\include' or
'\input', you should make AUCTeX aware of the multi-file document
structure. You can do this by inserting
(setq-default TeX-master nil)
into your init file. Each time you open a new file, AUCTeX will then
ask you for a master file.
* Menu:
* Editing Facilities:: Functions for editing TeX files
* Processing Facilities:: Creating and viewing output, debugging
---------- Footnotes ----------
(1) This usually is a file in your home directory called '.emacs' if
you are utilizing GNU Emacs or '.xemacs/init.el' if you are using

File:, Node: Editing Facilities, Next: Processing Facilities, Up: Quick Start
1.3.1 Functions for editing TeX files
------------------------------------- Making your TeX code more readable
AUCTeX can do syntax highlighting of your source code, that means
commands will get special colors or fonts. You can enable it locally by
typing 'M-x font-lock-mode RET'. If you want to have font locking
activated generally, enable 'global-font-lock-mode', e.g. with 'M-x
customize-variable RET global-font-lock-mode RET'.
AUCTeX will indent new lines to indicate their syntactical
relationship to the surrounding text. For example, the text of a
'\footnote' or text inside of an environment will be indented relative
to the text around it. If the indenting has gotten wrong after adding
or deleting some characters, use <TAB> to reindent the line, 'M-q' for
the whole paragraph, or 'M-x LaTeX-fill-buffer RET' for the whole
buffer. Entering sectioning commands
Insertion of sectioning macros, that is '\chapter', '\section',
'\subsection', etc. and accompanying '\label' commands may be eased by
using 'C-c C-s'. You will be asked for the section level. As nearly
everywhere in AUCTeX, you can use the <TAB> or <SPC> key to get a list
of available level names, and to auto-complete what you started typing.
Next, you will be asked for the printed title of the section, and last
you will be asked for a label to be associated with the section. Inserting environments
Similarly, you can insert environments, that is '\begin{}'-'\end{}'
pairs: Type 'C-c C-e', and select an environment type. Again, you can
use <TAB> or <SPC> to get a list, and to complete what you type.
Actually, the list will not only provide standard LaTeX environments,
but also take your '\documentclass' and '\usepackage' commands into
account if you have parsing enabled by setting 'TeX-parse-self' to 't'.
If you use a couple of environments frequently, you can use the up and
down arrow keys (or 'M-p' and 'M-n') in the minibuffer to get back to
the previously inserted commands.
Some environments need additional arguments. Often, AUCTeX knows
about this and asks you to enter a value. Inserting macros
'C-c C-m', or simply 'C-c RET' will give you a prompt that asks you for
a LaTeX macro. You can use <TAB> for completion, or the up/down arrow
keys (or 'M-p' and 'M-n') to browse the command history. In many cases,
AUCTeX knows which arguments a macro needs and will ask you for that.
It even can differentiate between mandatory and optional arguments--for
details, see *note Completion::.
An additional help for inserting macros is provided by the
possibility to complete macros right in the buffer. With point at the
end of a partially written macro, you can complete it by typing 'M-TAB'. Changing the font
AUCTeX provides convenient keyboard shortcuts for inserting macros which
specify the font to be used for typesetting certain parts of the text.
They start with 'C-c C-f', and the last 'C-' combination tells AUCTeX
which font you want:
'C-c C-f C-b'
Insert bold face '\textbf{-!-}' text.
'C-c C-f C-i'
Insert italics '\textit{-!-}' text.
'C-c C-f C-e'
Insert emphasized '\emph{-!-}' text.
'C-c C-f C-s'
Insert slanted '\textsl{-!-}' text.
'C-c C-f C-r'
Insert roman \textrm{-!-} text.
'C-c C-f C-f'
Insert sans serif '\textsf{-!-}' text.
'C-c C-f C-t'
Insert typewriter '\texttt{-!-}' text.
'C-c C-f C-c'
Insert SMALL CAPS '\textsc{-!-}' text.
'C-c C-f C-d'
Delete the innermost font specification containing point.
If you want to change font attributes of existing text, mark it as an
active region, and then invoke the commands. If no region is selected,
the command will be inserted with empty braces, and you can start typing
the changed text.
Most of those commands will also work in math mode, but then macros
like '\mathbf' will be inserted. Other useful features
AUCTeX also tries to help you when inserting the right "quote" signs for
your language, dollar signs to typeset math, or pairs of braces. It
offers shortcuts for commenting out text ('C-c ;' for the current region
or 'C-c %' for the paragraph you are in). The same keystrokes will
remove the % signs, if the region or paragraph is commented out yet.
With 'TeX-fold-mode', you can hide certain parts (like footnotes,
references etc.) that you do not edit currently. Support for Emacs'
outline mode is provided as well. And there's more, but this is beyond
the scope of this Quick Start Guide.

File:, Node: Processing Facilities, Prev: Editing Facilities, Up: Quick Start
1.3.2 Creating and viewing output, debugging
-------------------------------------------- One Command for LaTeX, helpers, viewers, and printing
If you have typed some text and want to run LaTeX (or TeX, or other
programs--see below) on it, type 'C-c C-c'. If applicable, you will be
asked whether you want to save changes, and which program you want to
invoke. In many cases, the choice that AUCTeX suggests will be just
what you want: first 'latex', then a viewer. If a 'latex' run produces
or changes input files for 'makeindex', the next suggestion will be to
run that program, and AUCTeX knows that you need to run 'latex' again
afterwards--the same holds for BibTeX.
When no processor invocation is necessary anymore, AUCTeX will
suggest to run a viewer, or you can chose to create a PostScript file
using 'dvips', or to directly print it.
Actually, there is another command which comes in handy to compile
documents: type 'C-c C-a' ('TeX-command-run-all') and AUCTeX will
compile the document for you until it is ready and then run the viewer.
This is the same as issuing repeatedly 'C-c C-c' and letting AUCTeX
guess the next command to run.
At this place, a warning needs to be given: First, although AUCTeX is
really good in detecting the standard situations when an additional
'latex' run is necessary, it cannot detect it always. Second, the
creation of PostScript files or direct printing currently only works
when your output file is a DVI file, not a PDF file.
Ah, you didn't know you can do both? That brings us to the next
topic. Choosing an output format
From a LaTeX file, you can produce DVI output, or a PDF file directly
via 'pdflatex'. You can switch on source specials for easier navigation
in the output file, or tell 'latex' to stop after an error (usually
'\noninteractive' is used, to allow you to detect all errors in a single
These options are controlled by toggles, the keystrokes should be
easy to memorize:
'C-c C-t C-p'
This command toggles between DVI and PDF output
'C-c C-t C-i'
toggles interactive mode
'C-c C-t C-s'
toggles source specials support
'C-c C-t C-o'
toggles usage of Omega/lambda.
There is also another possibility: compile the document with 'tex'
(or 'latex') and then convert the resulting DVI file to PDF using
'dvips'-'ps2pdf' sequence. If you want to go by this route, when
'TeX-PDF-via-dvips-ps2pdf' variable is non-nil, AUCTeX will suggest you
to run the appropriate command when you type 'C-C C-c'. For details,
see *note Processor Options::. Debugging LaTeX
When AUCTeX runs a program, it creates an output buffer in which it
displays the output of the command. If there is a syntactical error in
your file, 'latex' will not complete successfully. AUCTeX will tell you
that, and you can get to the place where the first error occured by
pressing 'C-c `' (the last character is a backtick). The view will be
split in two windows, the output will be displayed in the lower buffer,
and both buffers will be centered around the place where the error
ocurred. You can then try to fix it in the document buffer, and use the
same keystrokes to get to the next error. This procedure may be
repeated until all errors have been dealt with. By pressing 'C-c C-w'
('TeX-toggle-debug-boxes') you can toggle whether AUCTeX should notify
you of overfull and underfull boxes in addition to regular errors.
If you have a recent version of GNU Emacs (24 or later), issue 'M-x
TeX-error-overview RET' to see a nicely formatted list of all errors and
warnings reported by the compiler.
If a command got stuck in a seemingly infinite loop, or you want to
stop execution for other reasons, you can use 'C-c C-k' (for "kill").
Similar to 'C-l', which centers the buffer you are in around your
current position, 'C-c C-l' centers the output buffer so that the last
lines added at the bottom become visible. Running LaTeX on parts of your document
If you want to check how some part of your text looks like, and do not
want to wait until the whole document has been typeset, then mark it as
a region and use 'C-c C-r'. It behaves just like 'C-c C-c', but it only
uses the document preamble and the region you marked.
If you are using '\include' or '\input' to structure your document,
try 'C-c C-b' while you are editing one of the included files. It will
run 'latex' only on the current buffer, using the preamble from the
master file.

File:, Node: Editing, Next: Display, Prev: Introduction, Up: Top
2 Editing the Document Source
The most commonly used commands/macros of AUCTeX are those which simply
insert templates for often used TeX, LaTeX, or ConTeXt constructs, like
font changes, handling of environments, etc. These features are very
simple, and easy to learn, and help you avoid mistakes like mismatched
braces, or '\begin{}'-'\end{}' pairs.
Apart from that this chapter contains a description of some features
for entering more specialized sorts of text, for formatting the source
by indenting and filling and for navigating through the document.
* Menu:
* Quotes:: Inserting quotes, dollars, and braces
* Font Specifiers:: Inserting Font Specifiers
* Sectioning:: Inserting chapters, sections, etc.
* Environments:: Inserting Environment Templates
* Mathematics:: Entering Mathematics
* Completion:: Completion of macros
* Marking:: Marking Environments, Sections, or Texinfo Nodes
* Commenting:: Commenting text
* Indenting:: Reflecting syntactic constructs with whitespace
* Filling:: Automatic and manual line breaking

File:, Node: Quotes, Next: Font Specifiers, Up: Editing
2.1 Insertion of Quotes, Dollars, and Braces
Quotation Marks
In TeX, literal double quotes '"like this"' are seldom used, instead two
single quotes are used '``like this'''. To help you insert these
efficiently, AUCTeX allows you to continue to press '"' to insert two
single quotes. To get a literal double quote, press '"' twice.
-- Command: TeX-insert-quote COUNT
('"') Insert the appropriate quote marks for TeX.
Inserts the value of 'TeX-open-quote' (normally '``') or
'TeX-close-quote' (normally '''') depending on the context. With
prefix argument, always inserts '"' characters.
-- User Option: TeX-open-quote
String inserted by typing '"' to open a quotation. (*Note
European::, for language-specific quotation mark insertion.)
-- User Option: TeX-close-quote
String inserted by typing '"' to close a quotation. (*Note
European::, for language-specific quotation mark insertion.)
-- User Option: TeX-quote-after-quote
Determines the behavior of '"'. If it is non-nil, typing '"' will
insert a literal double quote. The respective values of
'TeX-open-quote' and 'TeX-close-quote' will be inserted after
typing '"' once again.
The 'babel' package provides special support for the requirements of
typesetting quotation marks in many different languages. If you use
this package, either directly or by loading a language-specific style
file, you should also use the special commands for quote insertion
instead of the standard quotes shown above. AUCTeX is able to recognize
several of these languages and will change quote insertion accordingly.
*Note European::, for details about this feature and how to control it.
In case you are using the 'csquotes' package, you should customize
'LaTeX-csquotes-open-quote', 'LaTeX-csquotes-close-quote' and
'LaTeX-csquotes-quote-after-quote'. The quotation characters will only
be used if both variables--'LaTeX-csquotes-open-quote' and
'LaTeX-csquotes-close-quote'--are non-empty strings. But then the
'csquotes'-related values will take precedence over the
language-specific ones.
Dollar Signs
In AUCTeX, dollar signs should match like they do in TeX. This has been
partially implemented, we assume dollar signs always match within a
paragraph. By default, the first '$' you insert in a paragraph will do
nothing special. The second '$' will match the first. This will be
indicated by moving the cursor temporarily over the first dollar sign.
-- Command: TeX-insert-dollar ARG
('$') Insert dollar sign.
Show matching dollar sign if this dollar sign end the TeX math
With optional ARG, insert that many dollar signs.
TeX and LaTeX users often look for a way to insert inline equations
like '$...$' or '\(...\)' simply typing '$'. AUCTeX helps them through
the customizable variable 'TeX-electric-math'.
-- User Option: TeX-electric-math
If the variable is non-nil and you type '$' outside math mode,
AUCTeX will automatically insert the opening and closing symbols
for an inline equation and put the point between them. The opening
symbol will blink when 'blink-matching-paren' is non-nil. If
'TeX-electric-math' is nil, typing '$' simply inserts '$' at point,
this is the default.
Besides 'nil', possible values for this variable are '(cons "$"
"$")' for TeX inline equations '$...$', and '(cons "\\(" "\\)")'
for LaTeX inline equations '\(...\)'.
If the variable is non-nil and point is inside math mode right
between a couple of single dollars, pressing '$' will insert
another pair of dollar signs and leave the point between them.
Thus, if 'TeX-electric-math' is set to '(cons "$" "$")' you can
easily obtain a TeX display equation '$$...$$' by pressing '$'
twice in a row. (Note that you should not use double dollar signs
in LaTeX because this practice can lead to wrong spacing in typeset
In addition, when the variable is non-nil and there is an active
region outside math mode, typing '$' will put around the active
region symbols for opening and closing inline equation and keep the
region active, leaving point after the closing symbol. By pressing
repeatedly '$' while the region is active you can toggle between an
inline equation, a display equation, and no equation. To be
precise, '$...$' is replaced by '$$...$$', whereas '\(...\)' is
replaced by '\[...\]'.
If you want to automatically insert '$...$' in plain TeX files, and
'\(...\)' in LaTeX files by pressing '$', add the following to your init
(add-hook 'plain-TeX-mode-hook
(lambda () (set (make-variable-buffer-local 'TeX-electric-math)
(cons "$" "$"))))
(add-hook 'LaTeX-mode-hook
(lambda () (set (make-variable-buffer-local 'TeX-electric-math)
(cons "\\(" "\\)"))))
To avoid unbalanced braces, it is useful to insert them pairwise. You
can do this by typing 'C-c {'.
-- Command: TeX-insert-braces
('C-c {') Make a pair of braces and position the cursor to type
inside of them. If there is an active region, put braces around it
and leave point after the closing brace.
When writing complex math formulas in LaTeX documents, you sometimes
need to adjust the size of braces with pairs of macros like
'\left'-'\right', '\bigl'-'\bigr' and so on. You can avoid unbalanced
pairs with the help of 'TeX-insert-macro', bound to 'C-c C-m' or 'C-c
<RET>' (*note Completion::). If you insert left size adjusting macros
such as '\left', '\bigl' etc. with 'TeX-insert-macro', it asks for left
brace to use and supplies automatically right size adjusting macros such
as '\right', '\bigr' etc. and corresponding right brace in addtion to
the intended left macro and left brace.
The completion by 'TeX-insert-macro' also applies when entering
macros such as '\langle', '\lfloor' and '\lceil', which produce the left
part of the paired braces. For example, inserting '\lfloor' by 'C-c
C-m' is immediately followed by the insertion of '\rfloor'. In
addition, if the point was located just after '\left' or its friends,
the corresponding '\right' etc. will be inserted in front of '\rfloor'.
In both cases, active region is honored.
As a side effect, when 'LaTeX-math-mode' (*note Mathematics::) is on,
just typing '`(' inserts not only '\langle', but also '\rangle'.
If you do not like such auto completion at all, it can be disabled by
a user option.
-- User Option: TeX-arg-right-insert-p
If this option is turned off, the automatic supply of the right
macros and braces is suppressed.
When you edit LaTeX documents, you can enable automatic brace pairing
when typing '(', '{' and '['.
-- User Option: LaTeX-electric-left-right-brace
If this option is on, just typing '(', '{' or '[' immediately adds
the corresponding right brace ')', '}' or ']'. The point is left
after the opening brace. If there is an active region, braces are
put around it.
They recognize the preceeding backslash or size adjusting macros
such as '\left', '\bigl' etc., so the following completions will
* (when typing single left brace)
- '(' -> '()'
- '{' -> '{}'
- '[' -> '[]'
* (when typing left brace just after a backslash)
- '\(' -> '\(\)'
- '\{' -> '\{\}'
- '\[' -> '\[\]'
* (when typing just after '\left' or '\bigl')
- '\left(' -> '\left(\right)'
- '\bigl[' -> '\bigl[\bigr]'
* (when typing just after '\Bigl\')
- '\Bigl\{' -> '\Bigl\{\Bigr\}'
This auto completion feature may be a bit annoying when editing an
already existing LaTeX document. In that case, use 'C-u 1' or
'C-q' before typing '(', '{' or '['. Then no completion is done
and just a single left brace is inserted. In fact, with optional
prefix ARG, just that many open braces are inserted without any

File:, Node: Font Specifiers, Next: Sectioning, Prev: Quotes, Up: Editing
2.2 Inserting Font Specifiers
Perhaps the most used keyboard commands of AUCTeX are the short-cuts
available for easy insertion of font changing macros.
If you give an argument (that is, type 'C-u') to the font command,
the innermost font will be replaced, i.e. the font in the TeX group
around point will be changed. The following table shows the available
commands, with '-!-' indicating the position where the text will be
'C-c C-f C-b'
Insert bold face '\textbf{-!-}' text.
'C-c C-f C-i'
Insert italics '\textit{-!-}' text.
'C-c C-f C-e'
Insert emphasized '\emph{-!-}' text.
'C-c C-f C-s'
Insert slanted '\textsl{-!-}' text.
'C-c C-f C-r'
Insert roman \textrm{-!-} text.
'C-c C-f C-f'
Insert sans serif '\textsf{-!-}' text.
'C-c C-f C-t'
Insert typewriter '\texttt{-!-}' text.
'C-c C-f C-c'
Insert SMALL CAPS '\textsc{-!-}' text.
'C-c C-f C-d'
Delete the innermost font specification containing point.
-- Command: TeX-font replace what
('C-c C-f') Insert template for font change command.
If REPLACE is not nil, replace current font. WHAT determines the
font to use, as specified by 'TeX-font-list'.
-- User Option: TeX-font-list
List of fonts used by 'TeX-font'.
Each entry is a list with three elements. The first element is the
key to activate the font. The second element is the string to
insert before point, and the third element is the string to insert
after point. An optional fourth element means always replace if
not nil.
-- User Option: LaTeX-font-list
List of fonts used by 'TeX-font' in LaTeX mode. It has the same
structure as 'TeX-font-list'.

File:, Node: Sectioning, Next: Environments, Prev: Font Specifiers, Up: Editing
2.3 Inserting chapters, sections, etc.
Insertion of sectioning macros, that is '\chapter', '\section',
'\subsection', etc. and accompanying '\label''s may be eased by using
'C-c C-s'. This command is highly customizable, the following describes
the default behavior.
When invoking you will be asked for a section macro to insert. An
appropriate default is automatically selected by AUCTeX, that is either:
at the top of the document; the top level sectioning for that document
style, and any other place: The same as the last occurring sectioning
Next, you will be asked for the actual name of that section, and last
you will be asked for a label to be associated with that section. The
label will be prefixed by the value specified in 'LaTeX-section-hook'.
-- Command: LaTeX-section ARG
('C-c C-s') Insert a sectioning command.
Determine the type of section to be inserted, by the argument ARG.
* If ARG is nil or missing, use the current level.
* If ARG is a list (selected by C-u), go downward one level.
* If ARG is negative, go up that many levels.
* If ARG is positive or zero, use absolute level:
+ 0 : part
+ 1 : chapter
+ 2 : section
+ 3 : subsection
+ 4 : subsubsection
+ 5 : paragraph
+ 6 : subparagraph
The following variables can be set to customize the function.
Hooks to be run when inserting a section.
Prefix to all section references.
The precise behavior of 'LaTeX-section' is defined by the contents of
-- User Option: LaTeX-section-hook
List of hooks to run when a new section is inserted.
The following variables are set before the hooks are run
Numeric section level, default set by prefix arg to
Name of the sectioning command, derived from LEVEL.
The title of the section, default to an empty string.
Entry for the table of contents list, default nil.
Position of point afterwards, default nil meaning after the
inserted text.
A number of hooks are already defined. Most likely, you will be
able to get the desired functionality by choosing from these hooks.
Query the user about the name of the sectioning command.
Modifies LEVEL and NAME.
Query the user about the title of the section. Modifies
Query the user for the toc entry. Modifies TOC.
Insert LaTeX section command according to NAME, TITLE, and
TOC. If TOC is nil, no toc entry is inserted. If TOC or
TITLE are empty strings, DONE-MARK will be placed at the point
they should be inserted.
Insert a label after the section command. Controlled by the
variable 'LaTeX-section-label'.
To get a full featured 'LaTeX-section' command, insert
(setq LaTeX-section-hook
in your '.emacs' file.
The behavior of 'LaTeX-section-label' is determined by the variable
-- User Option: LaTeX-section-label
Default prefix when asking for a label.
If it is a string, it is used unchanged for all kinds of sections.
If it is nil, no label is inserted. If it is a list, the list is
searched for a member whose car is equal to the name of the
sectioning command being inserted. The cdr is then used as the
prefix. If the name is not found, or if the cdr is nil, no label
is inserted.
By default, chapters have a prefix of 'cha:' while sections and
subsections have a prefix of 'sec:'. Labels are not automatically
inserted for other types of sections.

File:, Node: Environments, Next: Mathematics, Prev: Sectioning, Up: Editing
2.4 Inserting Environment Templates
A large apparatus is available that supports insertions of environments,
that is '\begin{}' -- '\end{}' pairs.
AUCTeX is aware of most of the actual environments available in a
specific document. This is achieved by examining your '\documentclass'
command, and consulting a precompiled list of environments available in
a large number of styles.
Most of these are described further in the following sections, and
you may easily specify more. *Note Customizing Environments::.
You insert an environment with 'C-c C-e', and select an environment
type. Depending on the environment, AUCTeX may ask more questions about
the optional parts of the selected environment type. With 'C-u C-c C-e'
you will change the current environment.
-- Command: LaTeX-environment ARG
('C-c C-e') AUCTeX will prompt you for an environment to insert.
At this prompt, you may press <TAB> or <SPC> to complete a
partially written name, and/or to get a list of available
environments. After selection of a specific environment AUCTeX may
prompt you for further specifications.
If the optional argument ARG is not-nil (i.e. you have given a
prefix argument), the current environment is modified and no new
environment is inserted.
AUCTeX helps you adding labels to environments which use them, such
as 'equation', 'figure', 'table', etc... When you insert one of the
supported environments with 'C-c C-e', you will be automatically
prompted for a label. You can select the prefix to be used for such
environments with the 'LaTeX-label-alist' variable.
-- User Option: LaTeX-label-alist
List the prefixes to be used for the label of each supported
This is an alist whose car is the environment name, and the cdr
either the prefix or a symbol referring to one.
If the name is not found, or if the cdr is nil, no label is
automatically inserted for that environment.
If you want to automatically insert a label for a environment but
with an empty prefix, use the empty string '""' as the cdr of the
corresponding entry.
As a default selection, AUCTeX will suggest the environment last
inserted or, as the first choice the value of the variable
-- User Option: LaTeX-default-environment
Default environment to insert when invoking 'LaTeX-environment'
first time. When the current environment is 'document', it is
overriden by 'LaTeX-default-document-environment'.
-- Variable: LaTeX-default-document-environment
Default environment when invoking 'LaTeX-environment' and the
current environment is 'document'. It is intended to be used in
LaTeX class style files. For example, in 'beamer.el' it is set to
'frame', in 'letter.el' to 'letter', and in 'slides.el' to 'slide'.
If the document is empty, or the cursor is placed at the top of the
document, AUCTeX will default to insert a 'document' environment
prompting also for the insertion of '\documentclass' and '\usepackage'
macros. You will be prompted for a new package until you enter nothing.
If you do not want to insert any '\usepackage' at all, just press <RET>
at the first 'Packages' prompt.
AUCTeX distinguishes normal and expert environments. By default, it
will offer completion only for normal environments. This behavior is
controlled by the user option 'TeX-complete-expert-commands'.
-- User Option: TeX-complete-expert-commands
Complete macros and environments marked as expert commands.
Possible values are nil, t, or a list of style names.
Don't complete expert commands (default).
Always complete expert commands.
(STYLES ...)
Only complete expert commands of STYLES.
* Menu:
* Equations:: Equations
* Floats:: Floats
* Itemize-like:: Itemize-like Environments
* Tabular-like:: Tabular-like Environments
* Customizing Environments:: Customizing Environments
You can close the current environment with 'C-c ]', but we suggest
that you use 'C-c C-e' to insert complete environments instead.
-- Command: LaTeX-close-environment
('C-c ]') Insert an '\end' that matches the current environment.
AUCTeX offers keyboard shortcuts for moving point to the beginning
and to the end of the current environment.
-- Command: LaTeX-find-matching-begin
('C-M-a') Move point to the '\begin' of the current environment.
If this command is called inside a comment and
'LaTeX-syntactic-comments' is enabled, try to find the environment
in commented regions with the same comment prefix.
-- Command: LaTeX-find-matching-end
('C-M-e') Move point to the '\end' of the current environment.
If this command is called inside a comment and
'LaTeX-syntactic-comments' is enabled, try to find the environment
in commented regions with the same comment prefix.

File:, Node: Equations, Next: Floats, Up: Environments
2.4.1 Equations
When inserting equation-like environments, the '\label' will have a
default prefix, which is controlled by the following variables:
-- User Option: LaTeX-equation-label
Prefix to use for 'equation' labels.
-- User Option: LaTeX-eqnarray-label
Prefix to use for 'eqnarray' labels.
-- User Option: LaTeX-amsmath-label
Prefix to use for amsmath equation labels. Amsmath equations
include 'align', 'alignat', 'xalignat', 'aligned', 'flalign' and

File:, Node: Floats, Next: Itemize-like, Prev: Equations, Up: Environments
2.4.2 Floats
Figures and tables (i.e., floats) may also be inserted using AUCTeX.
After choosing either 'figure' or 'table' in the environment list
described above, you will be prompted for a number of additional things.
This is the optional argument of float environments that controls
how they are placed in the final document. In LaTeX this is a
sequence of the letters 'htbp' as described in the LaTeX manual.
The value will default to the value of 'LaTeX-float'.
This is the caption of the float. The default is to insert the
caption at the bottom of the float. You can specify floats where
the caption should be placed at the top with
If the specified caption is greater than a specific length, then a
short caption is prompted for and it is inserted as an optional
argument to the '\caption' macro. The length that a caption needs
to be before prompting for a short version is controlled by
The label of this float. The label will have a default prefix,
which is controlled by the variables 'LaTeX-figure-label' and
Moreover, you will be asked if you want the contents of the float
environment to be horizontally centered. Upon a positive answer a
'\centering' macro will be inserted at the beginning of the float
-- User Option: LaTeX-float
Default placement for floats.
-- User Option: LaTeX-figure-label
Prefix to use for figure labels.
-- User Option: LaTeX-table-label
Prefix to use for table labels.
-- User Option: LaTeX-top-caption-list
List of float environments with top caption.
-- User Option: LaTeX-short-caption-prompt-length
Number of chars a caption should be before prompting for a short

File:, Node: Itemize-like, Next: Tabular-like, Prev: Floats, Up: Environments
2.4.3 Itemize-like Environments
In an itemize-like environment, nodes (i.e., '\item's) may be inserted
using 'C-c <LFD>'.
-- Command: LaTeX-insert-item
('C-c <LFD>') Close the current item, move to the next line and
insert an appropriate '\item' for the current environment. That
is, 'itemize' and 'enumerate' will have '\item ' inserted, while
'description' will have '\item[]' inserted.
-- User Option: TeX-arg-item-label-p
If non-nil, you will always be asked for optional label in items.
Otherwise, you will be asked only in description environments.

File:, Node: Tabular-like, Next: Customizing Environments, Prev: Itemize-like, Up: Environments
2.4.4 Tabular-like Environments
When inserting Tabular-like environments, that is, 'tabular' 'array'
etc., you will be prompted for a template for that environment. Related
-- User Option: LaTeX-default-format
Default format string for array and tabular environments.
-- User Option: LaTeX-default-width
Default width for minipage and tabular* environments.
-- User Option: LaTeX-default-position
Default position string for array and tabular environments. If
nil, act like the empty string is given, but don't prompt for a
AUCTeX calculates the number of columns from the format string and
inserts the suitable number of ampersands.
You can use 'C-c <LFD>' ('LaTeX-insert-item') to terminate rows in
these environments. It supplies line break macro '\\' and inserts the
suitable number of ampersands on the next line. AUCTeX also supports
the '*{num}{cols}' notation (which may contain another '*'-expression)
in the format string when calculating the number of ampersands. Please
note that 'num' and 'cols' must be enclosed in braces; expressions like
'*2l' are not recognized correctly by the algorithm.
-- Command: LaTeX-insert-item
('C-c <LFD>') Close the current row with '\\', move to the next
line and insert an appropriate number of ampersands for the current
Similar supports are provided for various amsmath environments such
as 'align', 'gather', 'alignat', 'matrix' etc. Try typing 'C-c <LFD>'
in these environments. It recognizes the current environment and does
the appropriate job depending on the context.

File:, Node: Customizing Environments, Prev: Tabular-like, Up: Environments
2.4.5 Customizing Environments
*Note Adding Environments::, for how to customize the list of known

File:, Node: Mathematics, Next: Completion, Prev: Environments, Up: Editing
2.5 Entering Mathematics
TeX is written by a mathematician, and has always contained good support
for formatting mathematical text. AUCTeX supports this tradition, by
offering a special minor mode for entering text with many mathematical
symbols. You can enter this mode by typing 'C-c ~'.
-- Command: LaTeX-math-mode
('C-c ~') Toggle LaTeX Math mode. This is a minor mode rebinding
the key 'LaTeX-math-abbrev-prefix' to allow easy typing of
mathematical symbols. '`' will read a character from the keyboard,
and insert the symbol as specified in 'LaTeX-math-default' and
'LaTeX-math-list'. If given a prefix argument, the symbol will be
surrounded by dollar signs.
You can use another prefix key (instead of '`') by setting the
variable 'LaTeX-math-abbrev-prefix'.
To enable LaTeX Math mode by default, add the following in your
'.emacs' file:
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
-- User Option: LaTeX-math-abbrev-prefix
A string containing the prefix of 'LaTeX-math-mode' commands; This
value defaults to '`'.
The string has to be a key or key sequence in a format understood
by the 'kbd' macro. This corresponds to the syntax usually used in
the manuals for Emacs Emacs Lisp.
The variable 'LaTeX-math-list' allows you to add your own mappings.
-- User Option: LaTeX-math-list
A list containing user-defined keys and commands to be used in
LaTeX Math mode. Each entry should be a list of two to four
First, the key to be used after 'LaTeX-math-abbrev-prefix' for
macro insertion. If it is nil, the symbol has no associated
keystroke (it is available in the menu, though).
Second, a string representing the name of the macro (without a
leading backslash.)
Third, a string representing the name of a submenu the command
should be added to. Use a list of strings in case of nested menus.
Fourth, the position of a Unicode character to be displayed in the
menu alongside the macro name. This is an integer value.
-- User Option: LaTeX-math-menu-unicode
Whether the LaTeX menu should try using Unicode for effect. Your
Emacs built must be able to display include Unicode characters in
menus for this feature.
AUCTeX's reference card 'tex-ref.tex' includes a list of all math
mode commands.
AUCTeX can help you write subscripts and superscripts in math
constructs by automatically inserting a pair of braces after typing <_>
or <^> respectively and putting point between the braces. In order to
enable this feature, set the variable 'TeX-electric-sub-and-superscript'
to a non-nil value.
-- User Option: TeX-electric-sub-and-superscript
If non-nil, insert braces after typing <^> and <_> in math mode.

File:, Node: Completion, Next: Marking, Prev: Mathematics, Up: Editing
2.6 Completion
Emacs lisp programmers probably know the 'lisp-complete-symbol' command
which was bound to 'M-<TAB>' until completion-at-point became the new
standard completion facility (see below). Users of the wonderful ispell
mode know and love the 'ispell-complete-word' command from that package.
Similarly, AUCTeX has a 'TeX-complete-symbol' command, by default bound
to 'M-<TAB>' which is equivalent to 'M-C-i'. Using
'TeX-complete-symbol' makes it easier to type and remember the names of
long LaTeX macros.
In order to use 'TeX-complete-symbol', you should write a backslash
and the start of the macro. Typing 'M-<TAB>' will now complete as much
of the macro, as it unambiguously can. For example, if you type
''\renewc'' and then 'M-<TAB>', it will expand to ''\renewcommand''.
But there's more: if point is just after '\begin{', then
'TeX-complete-symbol' will complete LaTeX environments, etc. This is
controlled by 'TeX-complete-list'.
-- Command: TeX-complete-symbol
('M-<TAB>') Complete TeX symbol before point.
-- Variable: TeX-complete-list
List of ways to complete the preceding text.
Each entry is a list with the following elements:
1. Regexp matching the preceding text or a predicate of arity 0
which returns non-nil and sets 'match-data' appropriately if
it is applicable.
2. A number indicating the subgroup in the regexp containing the
3. A function returning an alist of possible completions.
4. Text to append after a succesful completion.
Or alternatively:
1. Regexp matching the preceding text.
2. Function to do the actual completion.
More recent Emacs versions have a new completion mechanism. Modes
may define and register custom completion-at-point functions and when
the user invokes 'completion-at-point' (usually bound to 'M-<TAB>'), all
such registered functions are consulted for checking for possible
completions. Modern completion UIs like company-mode support this
completion-at-point facility.
-- Function: TeX--completion-at-point
AUCTeX's completion-at-point function which is automatically added
to 'completion-at-point-functions' in TeX and LaTeX buffers.
It offers the same completion candidates as would
'TeX-complete-symbol' (and is also controlled by
'TeX-complete-list') except that it doesn't fall back on
'ispell-complete-word' which would be awkward with completion UIs
like company-mode.
A more direct way to insert a macro is with 'TeX-insert-macro', bound
to 'C-c C-m' which is equivalent to 'C-c <RET>'. It has the advantage
over completion that it knows about the argument of most standard LaTeX
macros, and will prompt for them. It also knows about the type of the
arguments, so it will for example give completion for the argument to
'\include'. Some examples are listed below.
-- Command: TeX-insert-macro
('C-c C-m' or 'C-c <RET>') Prompt (with completion) for the name of
a TeX macro, and if AUCTeX knows the macro, prompt for each
As a default selection, AUCTeX will suggest the macro last inserted
or, as the first choice the value of the variable 'TeX-default-macro'.
-- User Option: TeX-insert-macro-default-style
Specifies whether 'TeX-insert-macro' will ask for all optional
If set to the symbol 'show-optional-args', 'TeX-insert-macro' asks
for optional arguments of TeX marcos, unless the previous optional
argument has been rejected. If set to 'show-all-optional-args',
'TeX-insert-macro' asks for all optional arguments.
'mandatory-args-only', 'TeX-insert-macro' asks only for mandatory
arguments. When 'TeX-insert-macro' is called with prefix argument
('C-u'), it's the other way round.
Note that for some macros, there are special mechanisms, e.g.
'LaTeX-includegraphics-options-alist' and 'TeX-arg-cite-note-p'.
-- User Option: TeX-default-macro
Default macro to insert when invoking 'TeX-insert-macro' first
A faster alternative is to bind the function 'TeX-electric-macro' to
'\'. This can be done by setting the variable 'TeX-electric-escape'
-- User Option: TeX-electric-escape
If this is non-nil when AUCTeX is loaded, the TeX escape character
'\' will be bound to 'TeX-electric-macro'
The difference between 'TeX-insert-macro' and 'TeX-electric-macro' is
that space will complete and exit from the minibuffer in
'TeX-electric-macro'. Use <TAB> if you merely want to complete.
-- Command: TeX-electric-macro
Prompt (with completion) for the name of a TeX macro, and if AUCTeX
knows the macro, prompt for each argument. Space will complete and
By default AUCTeX will put an empty set braces '{}' after a macro
with no arguments to stop it from eating the next whitespace. This can
be stopped by entering 'LaTeX-math-mode', *note Mathematics::, or by
setting 'TeX-insert-braces' to nil.
-- User Option: TeX-insert-braces
If non-nil, append a empty pair of braces after inserting a macro.
-- User Option: TeX-insert-braces-alist
Control the insertion of a pair of braces after a macro on a per
macro basis.
This variable is an alist. Each element is a cons cell, whose car
is the macro name, and the cdr is non-nil or nil, depending on
whether a pair of braces should be, respectively, appended or not
to the macro.
If a macro has an element in this variable, 'TeX-parse-macro' will
use its value to decided what to do, whatever the value of the
variable 'TeX-insert-braces'.
Completions work because AUCTeX can analyze TeX files, and store
symbols in Emacs Lisp files for later retrieval. *Note Automatic::, for
more information.
AUCTeX distinguishes normal and expert macros. By default, it will
offer completion only for normal commands. This behavior can be
controlled using the user option 'TeX-complete-expert-commands'.
-- User Option: TeX-complete-expert-commands
Complete macros and environments marked as expert commands.
Possible values are nil, t, or a list of style names.
Don't complete expert commands (default).
Always complete expert commands.
(STYLES ...)
Only complete expert commands of STYLES.
AUCTeX will also make completion for many macro arguments, for
example existing labels when you enter a '\ref' macro with
'TeX-insert-macro' or 'TeX-electric-macro', and BibTeX entries when you
enter a '\cite' macro. For this kind of completion to work, parsing
must be enabled as described in *note Parsing Files::. For '\cite' you
must also make sure that the BibTeX files have been saved at least once
after you enabled automatic parsing on save, and that the basename of
the BibTeX file does not conflict with the basename of one of TeX files.

File:, Node: Marking, Next: Commenting, Prev: Completion, Up: Editing
2.7 Marking Environments, Sections, or Texinfo Nodes
You can mark the current environment by typing 'C-c .', or the current
section by typing 'C-c *'.
In Texinfo documents you can type 'M-C-h' to mark the current node.
When the region is set, the point is moved to its beginning and the
mark to its end.
* Menu:
* Marking (LaTeX):: LaTeX Commands for Marking Environments and Sections
* Marking (Texinfo):: Texinfo Commands for Marking Environments, Sections, and Nodes

File:, Node: Marking (LaTeX), Next: Marking (Texinfo), Up: Marking
2.7.1 LaTeX Commands for Marking Environments and Sections
-- Command: LaTeX-mark-section
('C-c *') Set mark at end of current logical section, and point at
With a non-nil prefix argument, mark only the region from the
current section start to the next sectioning command. Thereby
subsections are not being marked. Otherwise, any included
subsections are also marked along with current section.
-- Command: LaTeX-mark-environment
('C-c .') Set mark to the end of the current environment and point
to the matching beginning.
If a prefix argument is given, mark the respective number of
enclosing environments. The command will not work properly if
there are unbalanced begin-end pairs in comments and verbatim

File:, Node: Marking (Texinfo), Prev: Marking (LaTeX), Up: Marking
2.7.2 Texinfo Commands for Marking Environments and Sections
-- Command: Texinfo-mark-section
('C-c *') Mark the current section, with inclusion of any
containing node.
The current section is detected as starting by any of the
structuring commands matched by the regular expression in the
variable 'outline-regexp' which in turn is a regular expression
matching any element of the variable 'texinfo-section-list'.
With a non-nil prefix argument, mark only the region from the
current section start to the next sectioning command. Thereby
subsections are not being marked. Otherwise, any included
subsections are also marked
Note that when the current section is starting immediately after a
node command, then the node command is also marked as part of the
-- Command: Texinfo-mark-environment
('C-c .') Set mark to the end of the current environment and point
to the matching beginning.
If a prefix argument is given, mark the respective number of
enclosing environments. The command will not work properly if
there are unbalanced begin-end pairs in comments and verbatim
-- Command: Texinfo-mark-node
('M-C-h') Mark the current node. This is the node in which point
is located. It is starting at the previous occurrence of the
keyword '@node' and ending at next occurrence of the keywords
'@node' or '@bye'.

File:, Node: Commenting, Next: Indenting, Prev: Marking, Up: Editing
2.8 Commenting
It is often necessary to comment out temporarily a region of TeX or
LaTeX code. This can be done with the commands 'C-c ;' and 'C-c %'.
'C-c ;' will comment out all lines in the current region, while 'C-c %'
will comment out the current paragraph. Type 'C-c ;' again to uncomment
all lines of a commented region, or 'C-c %' again to uncomment all
comment lines around point. These commands will insert or remove a
single '%' respectively.
-- Command: TeX-comment-or-uncomment-region
('C-c ;') Add or remove '%' from the beginning of each line in the
current region. Uncommenting works only if the region encloses
solely commented lines. If AUCTeX should not try to guess if the
region should be commented or uncommented the commands
'TeX-comment-region' and 'TeX-uncomment-region' can be used to
explicitly comment or uncomment the region in concern.
-- Command: TeX-comment-or-uncomment-paragraph
('C-c %') Add or remove '%' from the beginning of each line in the
current paragraph. When removing '%' characters the paragraph is
considered to consist of all preceding and succeeding lines
starting with a '%', until the first non-comment line.

File:, Node: Indenting, Next: Filling, Prev: Commenting, Up: Editing
2.9 Indenting
Indentation means the addition of whitespace at the beginning of lines
to reflect special syntactical constructs. This makes it easier to see
the structure of the document, and to catch errors such as a missing
closing brace. Thus, the indentation is done for precisely the same
reasons that you would indent ordinary computer programs.
Indentation is done by LaTeX environments and by TeX groups, that is
the body of an environment is indented by the value of
'LaTeX-indent-level' (default 2). Also, items of an 'itemize-like'
environment are indented by the value of 'LaTeX-item-indent', default
-2. (Items are identified with the help of 'LaTeX-item-regexp'.) If
more environments are nested, they are indented 'accumulated' just like
most programming languages usually are seen indented in nested
You can explicitely indent single lines, usually by pressing <TAB>,
or marked regions by calling 'indent-region' on it. If you have
'auto-fill-mode' enabled and a line is broken while you type it, Emacs
automatically cares about the indentation in the following line. If you
want to have a similar behavior upon typing <RET>, you can customize the
variable 'TeX-newline-function' and change the default of 'newline'
which does no indentation to 'newline-and-indent' which indents the new
line or 'reindent-then-newline-and-indent' which indents both the
current and the new line.
There are certain LaTeX environments which should be indented in a
special way, like 'tabular' or 'verbatim'. Those environments may be
specified in the variable 'LaTeX-indent-environment-list' together with
their special indentation functions. Taking the 'verbatim' environment
as an example you can see that 'current-indentation' is used as the
indentation function. This will stop AUCTeX from doing any indentation
in the environment if you hit <TAB> for example.
There are environments in 'LaTeX-indent-environment-list' which do
not bring a special indentation function with them. This is due to the
fact that first the respective functions are not implemented yet and
second that filling will be disabled for the specified environments.
This shall prevent the source code from being messed up by accidently
filling those environments with the standard filling routine. If you
think that providing special filling routines for such environments
would be an appropriate and challenging task for you, you are invited to
contribute. (*Note Filling::, for further information about the filling
The check for the indentation function may be enabled or disabled by
customizing the variable 'LaTeX-indent-environment-check'.
As a side note with regard to formatting special environments: Newer
Emacsen include 'align.el' and therefore provide some support for
formatting 'tabular' and 'tabbing' environments with the function
'align-current' which will nicely align columns in the source code.
AUCTeX is able to format commented parts of your code just as any
other part. This means LaTeX environments and TeX groups in comments
will be indented syntactically correct if the variable
'LaTeX-syntactic-comments' is set to t. If you disable it, comments
will be filled like normal text and no syntactic indentation will be
Following you will find a list of most commands and variables related
to indenting with a small summary in each case:
'LaTeX-indent-line' will indent the current line.
'newline-and-indent' inserts a new line (much like <RET>) and moves
the cursor to an appropriate position by the left margin.
Most keyboards nowadays lack a linefeed key and 'C-j' may be
tedious to type. Therefore you can customize AUCTeX to perform
indentation upon typing <RET> as well. The respective option is
called 'TeX-newline-function'.
Alias for <LFD>
-- User Option: LaTeX-indent-environment-list
List of environments with special indentation. The second element
in each entry is the function to calculate the indentation level in
The filling code currently cannot handle tabular-like environments
which will be completely messed-up if you try to format them. This
is why most of these environments are included in this
customization option without a special indentation function. This
will prevent that they get filled.
-- User Option: LaTeX-indent-level
Number of spaces to add to the indentation for each '\begin' not
matched by a '\end'.
-- User Option: LaTeX-item-indent
Number of spaces to add to the indentation for '\item''s in list
-- User Option: TeX-brace-indent-level
Number of spaces to add to the indentation for each '{' not matched
by a '}'.
-- User Option: LaTeX-syntactic-comments
If non-nil comments will be filled and indented according to LaTeX
syntax. Otherwise they will be filled like normal text.
-- User Option: TeX-newline-function
Used to specify the function which is called when <RET> is pressed.
This will normally be 'newline' which simply inserts a new line.
In case you want to have AUCTeX do indentation as well when you
press <RET>, use the built-in functions 'newline-and-indent' or
'reindent-then-newline-and-indent'. The former inserts a new line
and indents the following line, i.e. it moves the cursor to the
right position and therefore acts as if you pressed <LFD>. The
latter function additionally indents the current line. If you
choose 'Other', you can specify your own fancy function to be
called when <RET> is pressed.
AUCTeX treats by default '\[...\]' math mode as a regular environment
and indents it accordingly. If you do not like such behavior you only
need to remove '\|\[' and '\|\]' from 'LaTeX-begin-regexp' and
'LaTeX-end-regexp' variables respectively.

File:, Node: Filling, Prev: Indenting, Up: Editing
2.10 Filling
Filling deals with the insertion of line breaks to prevent lines from
becoming wider than what is specified in 'fill-column'. The linebreaks
will be inserted automatically if 'auto-fill-mode' is enabled. In this
case the source is not only filled but also indented automatically as
you write it.
'auto-fill-mode' can be enabled for AUCTeX by calling
'turn-on-auto-fill' in one of the hooks AUCTeX is running. *Note Modes
and Hooks::. As an example, if you want to enable 'auto-fill-mode' in
'LaTeX-mode', put the following into your init file:
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
You can manually fill explicitely marked regions, paragraphs,
environments, complete sections, or the whole buffer. (Note that manual
filling in AUCTeX will indent the start of the region to be filled in
contrast to many other Emacs modes.)
There are some syntactical constructs which are handled specially
with regard to filling. These are so-called code comments and paragraph
Code comments are comments preceded by code or text in the same line.
Upon filling a region, code comments themselves will not get filled.
Filling is done from the start of the region to the line with the code
comment and continues after it. In order to prevent overfull lines in
the source code, a linebreak will be inserted before the last
non-comment word by default. This can be changed by customizing
'LaTeX-fill-break-before-code-comments'. If you have overfull lines
with code comments you can fill those explicitely by calling
'LaTeX-fill-paragraph' or pressing 'M-q' with the cursor positioned on
them. This will add linebreaks in the comment and indent subsequent
comment lines to the column of the comment in the first line of the code
comment. In this special case 'M-q' only acts on the current line and
not on the whole paragraph.
Lines with '\par' are treated similarly to code comments, i.e.
'\par' will be treated as paragraph boundary which should not be
followed by other code or text. But it is not treated as a real
paragraph boundary like an empty line where filling a paragraph would
Paragraph commands like '\section' or '\noindent' (the list of
commands is defined by 'LaTeX-paragraph-commands') are often to be
placed in their own line(s). This means they should not be consecuted
with any preceding or following adjacent lines of text. AUCTeX will
prevent this from happening if you do not put any text except another
macro after the end of the last brace of the respective macro. If there
is other text after the macro, AUCTeX regards this as a sign that the
macro is part of the following paragraph.
Here are some examples:
text text text text
text text text text
If you press 'M-q' on the first line in both examples, nothing will
change. But if you write
\begin{quote} text
text text text text
and press 'M-q', you will get
\begin{quote} text text text text text
Besides code comments and paragraph commands, another speciality of
filling in AUCTeX involves commented lines. You should be aware that
these comments are treated as islands in the rest of the LaTeX code if
syntactic filling is enabled. This means, for example, if you try to
fill an environment with 'LaTeX-fill-environment' and have the cursor
placed on a commented line which does not have a surrounding environment
inside the comment, AUCTeX will report an error.
The relevant commands and variables with regard to filling are:
'C-c C-q C-p'
'LaTeX-fill-paragraph' will fill and indent the current paragraph.
Alias for 'C-c C-q C-p'
'C-c C-q C-e'
'LaTeX-fill-environment' will fill and indent the current
environment. This may e.g. be the 'document' environment, in
which case the entire document will be formatted.
'C-c C-q C-s'
'LaTeX-fill-section' will fill and indent the current logical
sectional unit.
'C-c C-q C-r'
'LaTeX-fill-region' will fill and indent the current region.
-- User Option: LaTeX-fill-break-at-separators
List of separators before or after which respectively linebreaks
will be inserted if they do not fit into one line. The separators
can be curly braces, brackets, switches for inline math ('$', '\(',
'\)') and switches for display math ('\[', '\]'). Such formatting
can be useful to make macros and math more visible or to prevent
overfull lines in the LaTeX source in case a package for displaying
formatted TeX output inside the Emacs buffer, like preview-latex,
is used.
-- User Option: LaTeX-fill-break-before-code-comments
Code comments are comments preceded by some other text in the same
line. When a paragraph containing such a comment is to be filled,
the comment start will be seen as a border after which no line
breaks will be inserted in the same line. If the option
'LaTeX-fill-break-before-code-comments' is enabled (which is the
default) and the comment does not fit into the line, a line break
will be inserted before the last non-comment word to minimize the
chance that the line becomes overfull.
-- User Option: LaTeX-fill-excluded-macros
A list of macro names (without leading backslash) for whose
arguments filling should be disabled. Typically, you will want to
add macros here which have long, multi-line arguments. An example
is '\pgfplotstabletypeset' from the pgfplotstable package which is
used as shown in the following listing:
\pgfplotstabletypeset[skip first n=4]{%
XYZ Format,
Version 1.234
Date 2010-09-01
@author Mustermann
1 2 3
4 5 6

File:, Node: Display, Next: Processing, Prev: Editing, Up: Top
3 Controlling Screen Display
It is often desirable to get visual help of what markup code in a text
actually does without having to decipher it explicitly. For this
purpose Emacs and AUCTeX provide font locking (also known as syntax
highlighting) which visually sets off markup code like macros or
environments by using different colors or fonts. For example text to be
typeset in italics can be displayed with an italic font in the editor as
well, or labels and references get their own distinct color.
While font locking helps you grasp the purpose of markup code and
separate markup from content, the markup code can still be distracting.
AUCTeX lets you hide those parts and show them again at request with its
built-in support for hiding macros and environments which we call
folding here.
Besides folding of macros and environments, AUCTeX provides support
for Emacs' outline mode which lets you narrow the buffer content to
certain sections of your text by hiding the parts not belonging to these
Moreover, you can focus in a specific portion of the code by
narrowing the buffer to the desired region. AUCTeX provides also
functions to narrow the buffer to the current group and to LaTeX
AUCTeX also provides some WYSIWYG features.
First, you can customize 'font-latex-fontify-script' to enable
special formatting of '^' superscripts and '_' subscripts (*note Font
Secondly, AUCTeX with GNU Emacs 25 or later can display certain math
macros using Unicode characters, e.g., '\alpha' as α. This is called
prettification and is lightweight and reasonable robust (*note
A more accurate approach is provided by preview-latex, a subsystem of
AUCTeX, see *note Introduction: (preview-latex)Top. This system uses
LaTeX to generate images that are then displayed in your buffer. It is
extremely accurate but can be fragile with some packages (like older pgf
Please note that you can use prettification and preview-latex
* Menu:
* Font Locking:: Font Locking
* Folding:: Folding Macros and Environments
* Outline:: Outlining the Document
* Narrowing:: Restricting display and editing to a portion of the buffer
* Prettifying:: Displaying Greek and math macros as Unicode characters

File:, Node: Font Locking, Next: Folding, Up: Display
3.1 Font Locking
Font locking is supposed to improve readability of the source code by
highlighting certain keywords with different colors or fonts. It
thereby lets you recognize the function of markup code to a certain
extent without having to read the markup command. For general
information on controlling font locking with Emacs' Font Lock mode, see
*note Font Lock Mode: (emacs)Font Lock.
-- User Option: TeX-install-font-lock
Once font locking is enabled globally or for the major modes
provided by AUCTeX, the font locking patterns and functionality of
font-latex are activated by default. You can switch to a different
font locking scheme or disable font locking in AUCTeX by
customizing the variable 'TeX-install-font-lock'.
Besides font-latex AUCTeX ships with a scheme which is derived from
Emacs' default LaTeX mode and activated by choosing
'tex-font-setup'. Be aware that this scheme is not coupled with
AUCTeX's style system and not the focus of development. Therefore
and due to font-latex being much more feature-rich the following
explanations will only cover font-latex.
In case you want to hook in your own fontification scheme, you can
choose 'other' and insert the name of the function which sets up
your font locking patterns. If you want to disable fontification
in AUCTeX completely, choose 'ignore'.
font-latex provides many options for customization which are
accessible with 'M-x customize-group RET font-latex RET'. For this
description the various options are explained in conceptional groups.
* Menu:
* Fontification of macros:: Fontification of macros
* Fontification of quotes:: Fontification of quotes
* Fontification of math:: Fontification of math constructs
* Verbatim content:: Verbatim macros and environments
* Faces:: Faces used by font-latex
* Known problems:: Known fontification problems

File:, Node: Fontification of macros, Next: Fontification of quotes, Up: Font Locking
3.1.1 Fontification of macros
Highlighting of macros can be customized by adapting keyword lists which
can be found in the customization group 'font-latex-keywords'.
Three types of macros can be handled differently with respect to
1. Commands of the form '\foo[bar]{baz}' which consist of the macro
itself, optional arguments in square brackets and mandatory
arguments in curly braces. For the command itself the face
'font-lock-keyword-face' will be used and for the optional
arguments the face 'font-lock-variable-name-face'. The face
applied to the mandatory argument depends on the macro class
represented by the respective built-in variables.
2. Declaration macros of the form '{\foo text}' which consist of the
macro which may be enclosed in a TeX group together with text to be
affected by the macro. In case a TeX group is present, the macro
will get the face 'font-lock-keyword-face' and the text will get
the face configured for the respective macro class. If no TeX
group is present, the latter face will be applied to the macro
3. Simple macros of the form '\foo' which do not have any arguments or
groupings. The respective face will be applied to the macro
Customization variables for '\foo[bar]{baz}' type macros allow both
the macro name and the sequence of arguments to be specified. The
latter is done with a string which can contain the characters
indicating the existence of a starred variant for the macro,
for optional arguments in brackets,
for mandatory arguments in braces,
for mandatory arguments consisting of a single macro and
as a prefix indicating that two alternatives are following.
For example the specifier for '\documentclass' would be '[{' because
the macro has one optional followed by one mandatory argument. The
specifier for '\newcommand' would be '*|{\[[{' because there is a
starred variant, the mandatory argument following the macro name can be
a macro or a TeX group which can be followed by two optional arguments
and the last token is a mandatory argument in braces.
Customization variables for the '{\foo text}' and '\foo' types are
simple lists of strings where each entry is a macro name (without the
leading backslash).
General macro classes
font-latex provides keyword lists for different macro classes which are
described in the following table:
Keywords for macros defining or related to functions, like
Type: '\macro[...]{...}'
Face: 'font-lock-function-name-face'
Keywords for macros defining or related to references, like '\ref'.
Type: '\macro[...]{...}'
Face: 'font-lock-constant-face'
Keywords for macros specifying textual content, like '\caption'.
Type: '\macro[...]{...}'
Face: 'font-lock-type-face'
Keywords for macros defining or related to variables, like
Type: '\macro[...]{...}'
Face: 'font-lock-variable-name-face'
Keywords for important macros, e.g. affecting line or page break,
like '\clearpage'.
Type: '\macro'
Face: 'font-latex-warning-face'
Sectioning commands
Sectioning commands are macros like '\chapter' or '\section'. For these
commands there are two fontification schemes which may be selected by
customizing the variable 'font-latex-fontify-sectioning'.
-- User Option: font-latex-fontify-sectioning
Per default sectioning commands will be shown in a larger,
proportional font, which corresponds to a number for this variable.
The font size varies with the sectioning level, e.g. '\part'
('font-latex-sectioning-0-face') has a larger font than
'\paragraph' ('font-latex-sectioning-5-face'). Typically, values
from 1.05 to 1.3 for 'font-latex-fontify-sectioning' give best
results, depending on your font setup. If you rather like to use
the base font and a different color, set the variable to the symbol
'color'. In this case the face 'font-lock-type-face' will be used
to fontify the argument of the sectioning commands.
You can make font-latex aware of your own sectioning commands be
adding them to the keyword lists:
('font-latex-sectioning-0-face') ...
Related to sectioning there is special support for slide titles which
may be fontified with the face 'font-latex-slide-title-face'. You can
add macros which should appear in this face by customizing the variable
Commands for changing fonts
LaTeX provides various macros for changing fonts or font attributes.
For example, you can select an italic font with '\textit{...}' or bold
with '\textbf{...}'. An alternative way to specify these fonts is to
use special macros in TeX groups, like '{\itshape ...}' for italics and
'{\bfseries ...}' for bold. As mentioned above, we call the former
variants commands and the latter declarations.
Besides the macros for changing fonts provided by LaTeX there is an
infinite number of other macros--either defined by yourself for logical
markup or defined by macro packages--which affect the font in the
typeset text. While LaTeX's built-in macros and macros of packages
known by AUCTeX are already handled by font-latex, different keyword
lists per type style and macro type are provided for entering your own
macros which are listed in the table below.
Keywords for commands specifying a bold type style.
Face: 'font-latex-bold-face'
Keywords for commands specifying an italic font.
Face: 'font-latex-italic-face'
Keywords for commands specifying a math font.
Face: 'font-latex-math-face'
Keywords for commands specifying a typewriter font.
Face: 'font-lock-type-face'
Keywords for declarations specifying a bold type style.
Face: 'font-latex-bold-face'
Keywords for declarations specifying an italic font.
Face: 'font-latex-italic-face'
Keywords for declarations specifying a typewriter font.
Face: 'font-latex-type-face'
Deactivating defaults of built-in keyword classes
font-latex ships with predefined lists of keywords for the classes
described above. You can disable these defaults per class by
customizing the variable 'font-latex-deactivated-keyword-classes'. This
is a list of strings for keyword classes to be deactivated. Valid
entries are "warning", "variable", "biblatexnoarg", "biblatex",
"reference", "function" , "sectioning-0", "sectioning-1",
"sectioning-2", "sectioning-3", "sectioning-4", "sectioning-5",
"slide-title", "textual", "bold-command", "italic-command",
"math-command", "type-command", "bold-declaration",
"italic-declaration", "type-declaration".
You can also get rid of certain keywords only. For example if you
want to remove highlighting of footnotes as references you can put the
following stanza into your init file:
(eval-after-load "font-latex"
(remove (TeX-assoc-string "footnote"
But note that this means fiddling with font-latex's internals and is
not guaranteed to work in future versions of font-latex.
User-defined keyword classes
In case the customization options explained above do not suffice for
your needs, you can specify your own keyword classes by customizing the
variable 'font-latex-user-keyword-classes'.
-- User Option: font-latex-user-keyword-classes
Every keyword class consists of four parts, a name, a list of
keywords, a face and a specifier for the type of macros to be
When adding new entries, you have to use unique values for the
class names, i.e. they must not clash with names of the built-in
keyword classes or other names given by you. Additionally the
names must not contain spaces.
The list of keywords defines which commands and declarations should
be covered by the keyword class. A keyword can either be a simple
command name omitting the leading backslash or a list consisting of
the command name and a string specifying the sequence of arguments
for the command.
The face argument can either be an existing face or face attributes
made by you. (The latter option is not available on XEmacs.)
There are three alternatives for the type of keywords--"Command
with arguments", "Declaration inside TeX group" and "Command
without arguments"--which correspond with the macro types explained

File:, Node: Fontification of quotes, Next: Fontification of math, Prev: Fontification of macros, Up: Font Locking
3.1.2 Fontification of quotes
Text in quotation marks is displayed with the face
'font-latex-string-face'. Besides the various forms of opening and
closing double and single quotation marks, so-called guillemets (<<, >>)
can be used for quoting. Because there are two styles of using
them--French style: << text >>; German style: >>text<<--you can
customize the variable 'font-latex-quotes' to tell font-latex which type
you are using if the correct value cannot be derived from document
-- User Option: font-latex-quotes
The default value of 'font-latex-quotes' is 'auto' which means that
font-latex will try to derive the correct type of quotation mark
matching from document properties like the language option supplied
to the babel LaTeX package.
If the automatic detection fails for you and you mostly use one
specific style you can set it to a specific language-dependent
value as well. Set the value to 'german' if you are using >>German
quotes<< and to 'french' if you are using << French quotes >>.
font-latex will recognize the different ways these quotes can be
given in your source code, i.e. ('"<', '">'), ('<<', '>>') and the
respective 8-bit variants.
If you set 'font-latex-quotes' to nil, quoted content will not be

File:, Node: Fontification of math, Next: Verbatim content, Prev: Fontification of quotes, Up: Font Locking
3.1.3 Fontification of mathematical constructs
In LaTeX mathematics can be indicated by a variety of different methods:
toggles (like dollar signs), macros and environments. Math constructs
known by font-latex are displayed with the face 'font-latex-math-face'.
Support for dollar signs and shorthands like '\(...\)' or '\[...\]' is
built-in and not customizable. Support for other math macros and
environments can be adapted by customizing the variables
'font-latex-match-math-command-keywords' and
'font-latex-math-environments' respectively.
In order to make math constructs more readable, font-latex displays
subscript and superscript parts in a smaller font and raised or lowered
respectively. This fontification feature can be controlled with the
variables 'font-latex-fontify-script' and 'font-latex-script-display'.
-- User Option: font-latex-fontify-script
If non-nil, fontify subscript and superscript strings. Concretely,
this means that the scripts are raised or lowered.
Another possiblity is setting this variable to the symbol
'multi-level'. In this case, in a formula x^{y^z}, y is raised
above and smaller than x, and z is raised above and smaller than y.
With many script levels, the text might become too small to be
readable. (See 'font-latex-fontify-script-max-level' below.)
Lastly, you can set this variable to 'invisible' whose behavior is
like 'multi-level', and in addition the super-/subscript characters
^ and _ are not displayed.
Note that this feature is not available on XEmacs, for which it is
disabled per default. In GNU Emacs raising and lowering is not
enabled for versions 21.3 and before due to it working not
-- User Option: font-latex-fontify-script-max-level
Maximum scriptification level for which script faces are applied.
The faces 'font-latex-superscript-face' and
'font-latex-subscript-face' define custom ':height' values < 1.0.
Therefore, scripts are displayed with a slightly smaller font than
normal math text. If 'font-latex-fontify-script' is 'multi-level'
or 'invisible', the font size becomes too small to be readable
after a few levels. This option allows to specify the maximum
level after which the size of the script text won’t be shrunken
For example, in the expression x^{y^{z^a_b}}, x has scriptification
level 0, y has level 1, z has level 2, and both a and b have
scriptification level 3.
If 'font-latex-fontify-script-max-level' was 2, then z, a, and b
would have the same font size. If it was 3 or more, then a and b
were smaller than z just in the same way as z is smaller than y and
y is smaller than x.
The script characters '^' and '_' themselves are also fontified with
an own face named 'font-latex-script-char-face'.
-- User Option: font-latex-script-display
Display specification for subscript and superscript content. The
car is used for subscript, the cdr is used for superscript. The
feature is implemented using so-called display properties. For
information on what exactly to specify for the values, see *note
Other Display Specifications: (elisp)Other Display Specs.

File:, Node: Verbatim content, Next: Faces, Prev: Fontification of math, Up: Font Locking
3.1.4 Verbatim macros and environments
Usually it is not desirable to have content to be typeset verbatim
highlighted according to LaTeX syntax. Therefore this content will be
fontified uniformly with the face 'font-latex-verbatim-face'.
font-latex differentiates three different types of verbatim
constructs for fontification. Macros with special characters like | as
delimiters, macros with braces, and environments. Which macros and
environments are recognized is controlled by the variables
'LaTeX-verbatim-macros-with-braces', and 'LaTeX-verbatim-environments'

File:, Node: Faces, Next: Known problems, Prev: Verbatim content, Up: Font Locking
3.1.5 Faces used by font-latex
In case you want to change the colors and fonts used by font-latex
please refer to the faces mentioned in the explanations above and use
'M-x customize-face RET <face> RET'. All faces defined by font-latex
are accessible through a customization group by typing 'M-x
customize-group RET font-latex-highlighting-faces RET'.

File:, Node: Known problems, Prev: Faces, Up: Font Locking
3.1.6 Known fontification problems
In certain cases the fontification machinery fails to interpret buffer
contents correctly. This can lead to color bleed, i.e. large parts of
a buffer get fontified with an inappropriate face. A typical situation
for this to happen is the use of a dollar sign ('$') in a verbatim macro
or environment. If font-latex is not aware of the verbatim construct,
it assumes the dollar sign to be a toggle for mathematics and fontifies
the following buffer content with the respective face until it finds a
closing dollar sign or till the end of the buffer.
As a remedy you can make the verbatim construct known to font-latex,
*note Verbatim content::. If this is not possible, you can insert a
commented dollar sign ('%$') at the next suitable end of line as a quick

File:, Node: Folding, Next: Outline, Prev: Font Locking, Up: Display
3.2 Folding Macros and Environments
A popular complaint about markup languages like TeX and LaTeX is that
there is too much clutter in the source text and that one cannot focus
well on the content. There are macros where you are only interested in
the content they are enclosing, like font specifiers where the content
might already be fontified in a special way by font locking. Or macros
the content of which you only want to see when actually editing it, like
footnotes or citations. Similarly you might find certain environments
or comments distracting when trying to concentrate on the body of your
With AUCTeX's folding functionality you can collapse those items and
replace them by a fixed string, the content of one of their arguments,
or a mixture of both. If you want to make the original text visible
again in order to view or edit it, move point sideways onto the
placeholder (also called display string) or left-click with the mouse
pointer on it. (The latter is currently only supported on Emacs.) The
macro or environment will unfold automatically, stay open as long as
point is inside of it and collapse again once you move point out of it.
(Note that folding of environments currently does not work in every
AUCTeX mode.)
In order to use this feature, you have to activate 'TeX-fold-mode'
which will activate the auto-reveal feature and the necessary commands
to hide and show macros and environments. You can activate the mode in
a certain buffer by typing the command 'M-x TeX-fold-mode RET' or using
the keyboard shortcut 'C-c C-o C-f'. If you want to use it every time
you edit a LaTeX document, add it to a hook:
(add-hook 'LaTeX-mode-hook (lambda ()
(TeX-fold-mode 1)))
If it should be activated in all AUCTeX modes, use 'TeX-mode-hook'
instead of 'LaTeX-mode-hook'.
Once the mode is active there are several commands available to hide
and show macros, environments and comments:
-- Command: TeX-fold-buffer
('C-c C-o C-b') Hide all foldable items in the current buffer
according to the setting of 'TeX-fold-type-list'.
If you want to have this done automatically every time you open a
file, add it to a hook and make sure the function is called after
font locking is set up for the buffer. The following code should
accomplish this:
(add-hook 'find-file-hook 'TeX-fold-buffer t)
The command can be used any time to refresh the whole buffer and
fold any new macros and environments which were inserted after the
last invocation of the command.
-- User Option: TeX-fold-type-list
List of symbols determining the item classes to consider for
folding. This can be macros, environments and comments. Per
default only macros and environments are folded.
-- User Option: TeX-fold-force-fontify
In order for all folded content to get the right faces, the whole
buffer has to be fontified before folding is carried out.
'TeX-fold-buffer' therefore will force fontification of unfontified
regions. As this will prolong the time folding takes, you can
prevent forced fontification by customizing the variable
-- User Option: TeX-fold-auto
By default, a macro inserted with 'TeX-insert-macro' ('C-c C-m')
will not be folded. Set this variable to a non-nil value to
aumatically fold macros as soon as they are inserted.
-- User Option: TeX-fold-preserve-comments
By default items found in comments will be folded. If your
comments often contain unfinished code this might lead to problems.
Give this variable a non-nil value and foldable items in your
comments will be left alone.
-- User Option: TeX-fold-unfold-around-mark
When this variable is non-nil and there is an active regione, text
around the mark will be kept unfolded.
-- Command: TeX-fold-region
('C-c C-o C-r') Hide all configured macros in the marked region.
-- Command: TeX-fold-paragraph
('C-c C-o C-p') Hide all configured macros in the paragraph
containing point.
-- Command: TeX-fold-macro
('C-c C-o C-m') Hide the macro on which point currently is located.
If the name of the macro is found in 'TeX-fold-macro-spec-list',
the respective display string will be shown instead. If it is not
found, the name of the macro in sqare brackets or the default
string for unspecified macros
('TeX-fold-unspec-macro-display-string') will be shown, depending
on the value of the variable 'TeX-fold-unspec-use-name'.
-- Command: TeX-fold-env
('C-c C-o C-e') Hide the environment on which point currently is
located. The behavior regarding the display string is analogous to
'TeX-fold-macro' and determined by the variables
'TeX-fold-env-spec-list' and 'TeX-fold-unspec-env-display-string'
-- Command: TeX-fold-math
Hide the math macro on which point currently is located. If the
name of the macro is found in 'TeX-fold-math-spec-list', the
respective display string will be shown instead. If it is not
found, the name of the macro in sqare brackets or the default
string for unspecified macros
('TeX-fold-unspec-macro-display-string') will be shown, depending
on the value of the variable 'TeX-fold-unspec-use-name'.
-- Command: TeX-fold-comment
('C-c C-o C-c') Hide the comment point is located on.
-- Command: TeX-fold-clearout-buffer
('C-c C-o b') Permanently unfold all macros and environments in the
current buffer.
-- Command: TeX-fold-clearout-region
('C-c C-o r') Permanently unfold all macros and environments in the
marked region.
-- Command: TeX-fold-clearout-paragraph
('C-c C-o p') Permanently unfold all macros and environments in the
paragraph containing point.
-- Command: TeX-fold-clearout-item
('C-c C-o i') Permanently show the macro or environment on which
point currently is located. In contrast to temporarily opening the
macro when point is moved sideways onto it, the macro will be
permanently unfolded and will not collapse again once point is
leaving it.
-- Command: TeX-fold-dwim
('C-c C-o C-o') Hide or show items according to the current
context. If there is folded content, unfold it. If there is a
marked region, fold all configured content in this region. If
there is no folded content but a macro or environment, fold it.
In case you want to use a different prefix than 'C-c C-o' for these
commands you can customize the variable 'TeX-fold-command-prefix'.
(Note that this will not change the key binding for activating the
The commands above will only take macros or environments into
consideration which are specified in the variables
'TeX-fold-macro-spec-list' or 'TeX-fold-env-spec-list' respectively.
-- User Option: TeX-fold-macro-spec-list
List of replacement specifiers and macros to fold. The specifier
can be a string, an integer or a function symbol.
If you specify a string, it will be used as a display replacement
for the whole macro. Numbers in braces, brackets, parens or angle
brackets will be replaced by the respective macro argument. For
example '{1}' will be replaced by the first mandatory argument of
the macro. One can also define alternatives within the specifier
which are used if an argument is not found. Alternatives are
separated by '||'. They are most useful with optional arguments.
As an example, the default specifier for '\item' is '[1]:||*' which
means that if there is an optional argument, its value is shown
followed by a colon. If there is no optional argument, only an
asterisk is used as the display string.
If you specify a number as the first element, the content of the
respective mandatory argument of a LaTeX macro will be used as the
If the first element is a function symbol, the function will be
called with all mandatory arguments of the macro and the result of
the function call will be used as a replacement for the macro.
The placeholder is made by copying the text from the buffer
together with its properties, i.e. its face as well. If
fontification has not happened when this is done (e.g. because of
lazy font locking) the intended fontification will not show up. As
a workaround you can leave Emacs idle a few seconds and wait for
stealth font locking to finish before you fold the buffer. Or you
just re-fold the buffer with 'TeX-fold-buffer' when you notice a
wrong fontification.
-- User Option: TeX-fold-env-spec-list
List of display strings or argument numbers and environments to
fold. Argument numbers refer to the '\begin' statement. That
means if you have e.g. '\begin{tabularx}{\linewidth}{XXX} ...
\end{tabularx}' and specify 3 as the argument number, the resulting
display string will be "XXX".
-- User Option: TeX-fold-math-spec-list
List of display strings and math macros to fold.
The variables 'TeX-fold-macro-spec-list', 'TeX-fold-env-spec-list',
and 'TeX-fold-math-spec-list' apply to any AUCTeX mode. If you want to
make settings which are only applied to LaTeX mode, you can use the
mode-specific variables 'LaTeX-fold-macro-spec-list',
'LaTeX-fold-env-spec-list', and 'LaTeX-fold-math-spec-list'
-- User Option: TeX-fold-unspec-macro-display-string
Default display string for macros which are not specified in
-- User Option: TeX-fold-unspec-env-display-string
Default display string for environments which are not specified in
-- User Option: TeX-fold-unspec-use-name
If non-nil the name of the macro or environment surrounded by
square brackets is used as display string, otherwise the defaults
specified in 'TeX-fold-unspec-macro-display-string' or
'TeX-fold-unspec-env-display-string' respectively.
When you hover with the mouse pointer over folded content, its
original text will be shown in a tooltip or the echo area depending on
Tooltip mode being activate. In order to avoid exorbitantly big
tooltips and to cater for the limited space in the echo area the content
will be cropped after a certain amount of characters defined by the
variable 'TeX-fold-help-echo-max-length'.
-- User Option: TeX-fold-help-echo-max-length
Maximum length of original text displayed in a tooltip or the echo
area for folded content. Set it to zero in order to disable this

File:, Node: Outline, Next: Narrowing, Prev: Folding, Up: Display
3.3 Outlining the Document
AUCTeX supports the standard outline minor mode using LaTeX/ConTeXt
sectioning commands as header lines. *Note Outline Mode: (emacs)Outline
You can add your own headings by setting the variable
-- Variable: TeX-outline-extra
List of extra TeX outline levels.
Each element is a list with two entries. The first entry is the
regular expression matching a header, and the second is the level
of the header. A '^' is automatically prepended to the regular
expressions in the list, so they must match text at the beginning
of the line.
See 'LaTeX-section-list' or 'ConTeXt-INTERFACE-section-list' for
existing header levels.
The following example add '\item' and '\bibliography' headers, with
'\bibliography' at the same outline level as '\section', and '\item'
being below '\subparagraph'.
(setq TeX-outline-extra
'(("[ \t]*\\\\\\(bib\\)?item\\b" 7)
("\\\\bibliography\\b" 2)))
You may want to check out the unbundled 'out-xtra' package for even
better outline support. It is available from your favorite emacs lisp

File:, Node: Narrowing, Next: Prettifying, Prev: Outline, Up: Display
3.4 Narrowing
Sometimes you want to focus your attention to a limited region of the
code. You can do that by restricting the text addressable by editing
commands and hiding the rest of the buffer with the narrowing functions,
*note (emacs)Narrowing::. In addition, AUCTeX provides a couple of
other commands to narrow the buffer to a group, i.e. a region enclosed
in a pair of curly braces, and to LaTeX environments.
-- Command: TeX-narrow-to-group
('C-x n g') Make text outside current group invisible.
-- Command: LaTeX-narrow-to-environment COUNT
('C-x n e') Make text outside current environment invisible. With
optional argument COUNT keep visible that number of enclosing
Like other standard narrowing functions, the above commands are
disabled. Attempting to use them asks for confirmation and gives you
the option of enabling them; if you enable the commands, confirmation
will no longer be required for them.

File:, Node: Prettifying, Prev: Narrowing, Up: Display
3.5 Prettifying
Emacs 25 is able to prettify symbols in programming language buffers,
*note (emacs)Misc for Programs::. The canonical example is to display
'(lambda () ...)' as '(λ () ...)' in Lisp buffers.
AUCTeX can use this feature in order to display certain math macros
and greek letters using their Unicode representation, too. For example,
the TeX code '\alpha \times \beta' will be displayed as 'α × β'.
When point is on one of the characters, it'll be unprettified
automatically, meaning you see the verbatim text again. For this
behaviour however you need to set 'prettify-symbols-unprettify-at-point'
to t or 'right-edge' which will unprettify the symbol when point moves
into or near it.
To enable prettification in AUCTeX, simply add
'prettify-symbols-mode' to 'TeX-mode-hook'. If you enabled
prettification globally with 'global-prettify-symbols-mode', then it's
automatically enabled in AUCTeX, too.
You can also add custom symbol unicode-character pairs for
prettification by adding to 'tex--prettify-symbols-alist'. Note that
this variable is part of Emacs' stock 'tex-mode.el' and used by that and

File:, Node: Processing, Next: Customization, Prev: Display, Up: Top
4 Starting Processors, Viewers and Other Programs
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.
* Menu:
* Commands:: Invoking external commands.
* Viewing:: Invoking external viewers.
* Debugging:: Debugging TeX and LaTeX output.
* Checking:: Checking the document.
* Control:: Controlling the processes.
* Cleaning:: Cleaning intermediate and output files.
* Documentation:: Documentation about macros and packages.

File:, Node: Commands, Next: Viewing, Up: Processing
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.
* Menu:
* Starting a Command:: Starting a Command on a Document or Region
* Selecting a Command:: Selecting and Executing a Command
* Processor Options:: Options for TeX Processors

File:, Node: Starting a Command, Next: Selecting a Command, Up: Commands
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
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
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 (*note (emacs)File Variables::).
-- 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 *note Debugging:: and *note Control:: will work on
that process, otherwise they will work on the process associated with
the current document.

File:, Node: Selecting a Command, Next: Processor Options, Prev: Starting a Command, Up: Commands
4.1.2 Selecting and Executing a Command
Once you started the command selection with 'C-c C-c', 'C-c C-r' 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
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
(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 (*note (emacs)File Variables::).
-- User Option: TeX-command-default
The default command to run in this buffer. Must be an entry in
In case you use biblatex in a document, when automatic parsing is
enabled AUCTeX checks the value of 'backend' option given to biblatex at
load time to decide whether to use BibTeX or Biber for bibliography
processing. Should AUCTeX fail to detect the right backend, you can use
the file local 'LaTeX-biblatex-use-Biber' variable.
-- Variable: LaTeX-biblatex-use-Biber
If this boolean variable is set as file local, it tells to AUCTeX
whether to use Biber with biblatex. In this case, the
autodetection of the biblatex backend will be overridden. You may
want to set locally this variable if automatic parsing is not
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
-- 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.
When performing spell checking on a document or a region (invoked
through AUCTeX's 'Spell' command or 'M-x ispell RET'), you want the
spell checking program to skip certain macro arguments and environments,
most notably the arguments of referencing macros and the contents of
verbatim environments. The skipped parts are controlled by variable
'ispell-tex-skip-alists' provided by 'ispell.el'. AUCTeX has a library
which can be added to this variable depending on the value of
'TeX-ispell-extend-skip-list' which is set to 't' by default.
-- User Option: TeX-ispell-extend-skip-list
This boolean option controls whether AUCTeX activates its extension
for skipping certain macro arguments and environments when spell
When non-'nil', AUCTeX loads the file 'tex-ispell.el' and adds its
content to 'ispell-tex-skip-alists'. This library can and will
never be complete, but the interface can be used to add selected
and private macro names within your init file or on a file local
'ispell-tex-skip-alists' has the following structure:
(defvar ispell-tex-skip-alists
'((;; First list
("\\\\addcontentsline" ispell-tex-arg-end 2)
("\\\\\\([aA]lph\\|arabic\\)" ispell-tex-arg-end)
("\\\\makebox" ispell-tex-arg-end 0)
("\\\\documentclass" . "\\\\begin{document}"))
(;; Second list
("\\(figure\\|table\\)\\*?" ispell-tex-arg-end 0)
("list" ispell-tex-arg-end 2)
("verbatim\\*?" . "\\\\end{verbatim\\*?}")))
"*Lists of regions to be skipped in TeX mode.
First list is used raw.
Second list has key placed inside \\begin{}.")
Each item is an alist and the structure of it is described in
(defvar ispell-skip-region-alist
"Alist expressing beginning and end of regions not to spell check.
The alist key must be a regular expression.
Valid forms include:
(KEY) - just skip the key.
(KEY . REGEXP) - skip to the end of REGEXP.
REGEXP may be string or symbol.
(KEY REGEXP) - skip to end of REGEXP. REGEXP must be a string.
returns end of region.")
Let's go through the first list of 'ispell-tex-skip-alists' line by
("\\\\addcontentsline" ispell-tex-arg-end 2)
'KEY' is the string '"\\\\addcontentsline"', 'FUNCTION' is
'ispell-tex-arg-end' called with 'ARGS', here '2'.
'ispell-tex-arg-end' is a function provided by 'ispell.el' which
skips as many subsequent optional arguments in square brackets as
it sees and then skips 'ARGS' number of mandatory arguments in
braces. Omitting 'ARGS' means skip '1' mandatory argument. In
practice, when you have something like this in your document:
\addcontentsline{toc}{chapter}{Some text}
The first two arguments are left out and 'Some text' will be spell
checked. For the next line
("\\\\\\([aA]lph\\|arabic\\)" ispell-tex-arg-end)
the name of the counter as argument is skipped. Next line is
("\\\\makebox" ispell-tex-arg-end 0)
where only optional arguments are skipped, the first mandatory
argument is checked, e.g.
\makebox[0pt][l]{Some text}
Finally, the next line
("\\\\documentclass" . "\\\\begin{document}"))
ensures that the entire preamble of a document is discarded.
Second list works the same; it is more convenient for environments
since 'KEY' is wrapped inside '\begin{}'.
AUCTeX provides two functions to add items to car and cdr of
'ispell-tex-arg-end', namely 'TeX-ispell-skip-setcar' and
'TeX-ispell-skip-setcdr'. The argument of these functions is
exactly as in 'ispell-tex-skip-alists'. Additions can be done via
init file, e.g.:
(eval-after-load "tex-ispell"
'(("\\\\mymacro" ispell-tex-arg-end)))
'(("myverbatim" . "\\\\end{myverbatim}")))))
Another possibility is to use file local additions at the end of
your TeX file, e.g.:
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% eval: (TeX-ispell-skip-setcar '(("\\\\mymacro" . "{[-0-9]+}")))
%%% End:
Finally, AUCTeX provides a function called 'TeX-ispell-tex-arg-end'
which sees more arguments than 'ispell-tex-arg-end'. Refer to its
doc string for more information.
AUCTeX also provides a facility to skip the argument of in-line
verbatim macros like '\Verb' from 'fancyvrb.sty' or '\mintinline' from
'minted.sty'. Characters delimiting the verbatim text are stored in
-- User Option: TeX-ispell-verb-delimiters
String with delimiters recognized for in-line verbatim macros.
This variable is initialized to '!|#~\"*/+^-'. Since this string
is used to build a character alternative inside a regular
expression, special characters '^' and '-' should come last. Other
characters like opening brace '{', asterisk '*' or at sign '@'
should be avoided as they are not recognized by 'font-latex.el'.

File:, Node: Processor Options, Prev: Selecting a Command, Up: Commands
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, and the style error messages
are printed with.
-- Command: TeX-PDF-mode
('C-c C-t C-p') This command toggles the PDF mode of AUCTeX, a
buffer-local minor mode which is enabled by default. You can
customize 'TeX-PDF-mode' to give it a different default or set it
as a file local variable on a per-document basis. 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. *Note I/O
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
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.
Sometimes you are requested, by journal rules or packages, to compile
the document into DVI output. Thus, if you want a PDF document in the
end you can either use XeTeX engine, see below for information about how
to set engines, or compile the document with 'tex' and then convert to
PDF with 'dvips'-'ps2pdf' before viewing it. In addition, current
Japanese TeX engines cannot generate PDF directly so they rely on
DVI-to-PDF converters. Usually 'dvipdfmx' command is used for this
purpose. You can use the 'TeX-PDF-from-DVI' variable to let AUCTeX know
you want to generate the final PDF by converting a DVI file.
-- User Option: TeX-PDF-from-DVI
This option controls if and how to produce a PDF file by converting
a DVI file.
When 'TeX-PDF-mode' is non-nil, if 'TeX-PDF-from-DVI' is non-nil
too the document is compiled to DVI instead of PDF. When the
document is ready, 'C-c C-c' will suggest to run the converter to
PDF or an intermediate format.
If non-nil, 'TeX-PDF-from-DVI' should be the name of the command,
as a string, used to convert the DVI file to PDF or to an
intermediate format. Values currently supported are:
* '"Dvips"': the DVI file is converted to PS with 'dvips'.
After successfully running it, 'ps2pdf' will be the default
command to convert the PS file to PDF.
* '"Dvipdfmx"': the DVI file is converted to PDF with
When the PDF file is finally ready, the next suggested command will
be to open the viewer.
This option can also be set as a file local variable, in order to
use this conversion on a per-document basis.
Recall the whole sequence of 'C-c C-c' commands can be replace by
the single 'C-c C-a'.
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
-- 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
(*note (emacs)File Variables::).
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
In some systems, Emacs cannot inherit the PATH environment variable
from the shell and thus AUCTeX may not be able to run TeX commands.
Before running them, AUCTeX checks if it able to find those commands and
will warn you in case it fails. You can skip this test by changing the
option 'TeX-check-TeX'.
-- User Option: TeX-check-TeX
If non-nil, AUCTeX will check if it is able to find a working TeX
distribution before running TeX, LaTeX, ConTeXt, etc. It actually
checks if can run 'TeX-command' command or the shell returns a
command not found error. The error code returned by the shell in
this case can be set in 'TeX-check-TeX-command-not-found' option.
Some LaTeX packages requires the document to be compiled with a
specific engine. Notable examples are fontspec and polyglossia
packages, which require LuaTeX and XeTeX engines. If you try to compile
a document which loads one of such packages and the set engine is not
one of those allowed you will be asked to select a different engine
before running the LaTeX command. If you do not want to be warned by
AUCTeX in these cases, customize the option 'TeX-check-engine'.
-- User Option: TeX-check-engine
This boolean option controls whether AUCTeX should check the
correct engine has been set before running LaTeX commands.
As shown above, AUCTeX handles in a special way most of the main
options that can be given to the TeX processors. When you need to pass
to the TeX processor arbitrary options not handled by AUCTeX, you can
use the file local variable 'TeX-command-extra-options'.
-- User Option: TeX-command-extra-options
String with the extra options to be given to the TeX processor.
For example, if you need to enable the shell escape feature to
compile a document, add the following line to the list of local
variables of the source file:
%%% TeX-command-extra-options: "-shell-escape"
By default this option is not safe as a file-local variable because
a specially crafted document compiled with shell escape enabled can
be used for malicious purposes.
You can customize AUCTeX to show the processor output as it is
-- User Option: TeX-show-compilation
If non-nil, the output of TeX compilation is shown in another
You can instruct TeX to print error messages in the form
file:line:error which is similar to the way many compilers format them.
-- User Option: TeX-file-line-error
If non-nil, TeX will produce file:line:error style error messages.
ConTeXt users can choose between Mark II and Mark IV versions. This
is controlled by 'ConTeXt-Mark-version' option.
-- User Option: ConTeXt-Mark-version
This variables specifies which version of Mark should be used.
Values currently supported are '"II"', the default, and '"IV"'. It
can be set globally using customization interface or on a per-file
basis, by specifying it as a file variable.

File:, Node: Viewing, Next: Debugging, Prev: Commands, Up: Processing
4.2 Viewing the Formatted Output
AUCTeX allows you to start external programs for previewing the
formatted output of your document.
* Menu:
* Starting Viewers:: Starting viewers
* I/O Correlation:: Forward and inverse search

File:, Node: Starting Viewers, Next: I/O Correlation, Up: Viewing
4.2.1 Starting Viewers
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'.
-- Command: 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
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.
-- User Option: TeX-view-program-selection
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
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'.
-- User Option: TeX-view-predicate-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.
-- User Option: TeX-view-program-list
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' and
'TeX-expand-list-builtin' which are expanded before the viewer is
The third element of each item is a string, or a list of strings,
with the name of the executable, or executables, needed to open the
output file in the viewer. Placeholders defined in
'TeX-expand-list' and 'TeX-expand-list-builtin' can be used here.
This element is optional and is used to check whether the viewer is
actually available on the system.
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 there is
no '%V' expander in 'TeX-expand-list'. 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.
-- User Option: TeX-output-view-style
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
-- User Option: TeX-view-style
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.

File:, Node: I/O Correlation, Prev: Starting Viewers, Up: Viewing
4.2.2 Forward and Inverse Search
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