% -*-latex-*-
% Document name: /u/beebe/tex/talks/ltxmode/ltxinfo.ltx
% Creator: Nelson H. F. Beebe [beebe@rios.math.utah.edu]
% Creation Date: Wed Aug 28 20:33:00 1991

%%% ====================================================================
%%%  @LaTeX-file{
%%%     author          = "Nelson H. F. Beebe",
%%%     version         = "1.10",
%%%     date            = "14 September 1993",
%%%     time            = "10:59:27 MDT",
%%%     filename        = "ltxinfo.ltx",
%%%     address         = "Center for Scientific Computing
%%%                        Department of Mathematics
%%%                        University of Utah
%%%                        Salt Lake City, UT 84112
%%%                        USA
%%%                        Tel: +1 801 581 5254
%%%                        FAX: +1 801 581 4148",
%%%     checksum        = "18101 4878 15522 136520",
%%%     email           = "beebe@magna.math.utah.edu (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "LaTeX, emacs",
%%%     supported       = "yes",
%%%     docstring       = "This document is a translation from LaTeX to
%%%                        LaTeXinfo of part of a longer one of the same
%%%                        title that will be published in the TeX Users
%%%                        Group journal, TUGboat, Volume 13, Number 1
%%%                        or 2.  The name of that file is ltxmode.ltx.
%%%
%%%                        In a small number of places, wording has been
%%%                        slightly revised to get around limitations of
%%%                        LaTeXinfo and online display of typeset
%%%                        material as printable 95-character ASCII
%%%                        data.
%%%
%%%                        The author's intent is that both documents
%%%                        will be kept strictly synchronized, and both
%%%                        will be freely available electronically.
%%%
%%%                        The LaTeXinfo version, and latex.el, will
%%%                        become the property of the Free Software
%%%                        Foundation to ensure legal protection and
%%%                        wide distribution of this work, which has
%%%                        been supported financially by taxpayers, who
%%%                        support higher education, by IBM Corporation
%%%                        through the loan of an RS/6000 workstation,
%%%                        and by the many colleagues around the world
%%%                        who have helped in the beta testing.
%%%
%%%                        The author retains responsibility for errors
%%%                        of fact, typography, or programming, and
%%%                        desires to be informed of all such errors so
%%%                        that they can be corrected in future
%%%                        revisions of this work.
%%%
%%%                        The checksum field above contains a CRC-16
%%%                        checksum as the first value, followed by the
%%%                        equivalent of the standard UNIX wc (word
%%%                        count) utility output of lines, words, and
%%%                        characters.  This is produced by Robert
%%%                        Solovay's checksum utility.",
%%%  }
%%% ====================================================================

\documentstyle[latexinfo]{book}

\pagestyle{empty}

\hbadness = 10000 % don't complain about underfull boxes
\vbadness = 10000 % don't complain about underfull boxes

\newindex{cp} \c concepts
\newindex{fn} \c functions
\newindex{ky} \c key sequences
\newindex{pg} \c control sequences
\newindex{tp} \c persons
\newindex{vr} \c variables

\c \finalout

\c \newcommand{SliTeX}{{\rm S\kern-.06em{\sc l\kern-.035emi}\kern-.06em\TeX}}

\c ===============================================
\c latexinfo-format-buffer does not handle
\c verbatim environments inside itemize or
\c enumerate environments.  I found a workaround
\c for this: code the start as \begin  {verbatim}
\c with two spaces after the \begin, and put the
\c verbatim text in separate iftex and ifinfo
\c groups.  Sigh...what a hack!
\c ===============================================

\title{
        \protect\LaTeX{} Editing Support
}

\author{
        Nelson H. F. Beebe\\
        Center for Scientific Computing\\
        Department of Mathematics\\
        University of Utah\\
        Salt Lake City, UT 84112\\
        USA\\
        Tel: +1 801 581 5254\\
        FAX: +1 801 581 4148\\
        E-mail: {\tt beebe@math.utah.edu}
}

\date{14 September 1993 \\
Version 1.10}

\c =================================================

\begin{iftex}
\c We need to allow hyphenation at - characters in
\c \tt fonts.
\global\hyphenchar\nintt = `\-
\global\hyphenchar\tentt = `\-
\global\hyphenchar\elvtt = `\-
\global\hyphenchar\twltt = `\-
\gdef\Tabrule{\hrule width \linewidth height 2pt
                      depth 2pt \relax}
\end{iftex}

\begin{document}

\maketitle

\c =================================================

\clearpage
\vspace*{0pt plus 1filll}
Copyright \copyright{} 1991 Free Software Foundation, Inc.

This file documents version 1.0 of the \LaTeX{}
editing support package for GNU Emacs, version 18
or later.\refill

Permission is granted to make and distribute
verbatim copies of this manual provided the
copyright notice and this permission notice are
preserved on all copies.\refill

Permission is granted to process this file through
\TeX{} and print the results, provided the printed
document carries copying permission notice
identical to this one except for the removal of
this paragraph (this paragraph not being relevant
to the printed manual).\refill

Permission is granted to copy and distribute
modified versions of this manual under the
conditions for verbatim copying, provided that the
entire resulting derived work is distributed under
the terms of a permission notice identical to this
one.\refill

Permission is granted to copy and distribute
translations of this manual into another language,
under the above conditions for modified versions,
except that this permission notice may be stated
in a translation approved by the Foundation.\refill

\clearpage
\pagestyle{headings}
\pagenumbering{roman}
\tableofcontents

\listoftables

\clearpage
\pagenumbering{arabic}
\bibliographystyle{plain}

\c =================================================
\c Anything before the \setfilename will not appear
\c in the .info file
\setfilename{latex-mode.info}

\node Top, Licensing Information, Variable Index, (dir)

\begin{ifinfo}
This file documents version 1.0 of the \LaTeX{}
editing support package for GNU Emacs, version 18
or later.\refill

Copyright (C) 1991 Free Software Foundation, Inc.\refill

Permission is granted to make and distribute
verbatim copies of this manual provided the
copyright notice and this permission notice are
preserved on all copies.\refill

Permission is granted to copy and distribute
modified versions of this manual under the
conditions for verbatim copying, provided that the
entire resulting derived work is distributed under
the terms of a permission notice identical to this
one.\refill

Permission is granted to copy and distribute
translations of this manual into another language,
under the above conditions for modified versions,
except that this permission notice may be stated
in a translation approved by the Foundation.\refill
\end{ifinfo}

\begin{menu}
* Licensing information::     Conditions for use
* Author and version::        Who wrote this
* LaTeX support::             Editing features for LaTeX documents
* SliTeX support::            Editing features for SliTeX documents
* Letter support::            Editing features for writing letters
* Bug reporting::             How to report bugs, comments, etc.
* Conclusion::                What more I can say
* Bibliography::              Literature references
* Concept Index::             General topic index
* Control Sequence Index::    TeX and LaTeX control sequences
* Function Index::            Lisp functions
* Key Index::                 Key bindings
* Person Index::              Individuals cited in this text
* Variable Index::            Lisp variables
\end{menu}

\c =================================================

\c ===> \node node-name, next, previous, up <===
\node Licensing information, Author and version, Top, Top

\c =============================================
\c There appears to be a bug in LaTeXinfo 1.3.5
\c \unnumberedsec{xxx} is dropped from the
\c info file.  We cannot use \section*{} in
\c LaTeX mode because tables of contents entries
\c are then lost.
\c =============================================

\begin{ifinfo}
\chapter*{Licensing Information}
\end{ifinfo}
\begin{tex}
\unnumbered{Licensing Information}
\end{tex}
\cindex{licensing information}
The program currently being distributed that
relates to \LaTeX{} is contained in the file
\file{latex.el} in the function
\code{LaTeX-mode}\c
\findex{LaTeX-mode}
and numerous other support functions.  This
program is \dfn{free}; this means that everyone is
free to use it and free to redistribute it on a
free basis.\refill

Specifically, we want to make sure that you have
the right to give away copies of the programs that
relate to \code{LaTeX-mode},\c
\findex{LaTeX-mode}
that you receive source code or else can get it if
you want it, that you can change these programs or
use pieces of them in new free programs, and that
you know you can do these things.\refill

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
the file \file{latex.el}, 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.\refill

Also, for our own protection, we must make certain
that everyone finds out that there is no warranty
for the programs that relate to \file{latex.el}.
If these programs 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.\refill

The precise conditions of the licenses for the
programs currently being distributed that relate
to \file{latex.el} are found in the General Public
Licenses that accompany them.  The programs that
are part of GNU Emacs are covered by the GNU Emacs
copying terms
(\pxref{License, , , emacs, The GNU Emacs Manual}),
and other programs are covered by licenses that
are contained in their source files.\refill

\node Author and version, LaTeX support, Licensing information, Top

\c We only include this section in the info file,
\c because the printed manual has a title page
\c with author information.
\begin{ifinfo}
The GNU Emacs Lisp file \file{latex.el}, and its
predecessor, TOPS-20 Emacs TECO file
\file{latex.emacs}, was developed by\refill
\begin{verbatim}
Nelson H. F. Beebe
Center for Scientific Computing
Department of Mathematics
University of Utah
Salt Lake City, UT 84112
USA
Tel: +1 801 581 5254
FAX: +1 801 581 4148
E-mail: beebe@math.utah.edu
\end{verbatim}

\noindent
from 1984 to 1991, and contributed to the Free
Software Foundation.\refill

This documentation corresponds to version 1.0 of
\file{latex.el}.  This should match the code
version that is stored in the Emacs variable
\code{LaTeX-mode-version}.\c
\vindex{LaTeX-mode-version}\refill
\end{ifinfo}

\node LaTeX support, SliTeX support, Author and version, Top

\chapter{\protect\LaTeX{} support}
\begin{menu}
* Preliminaries::
* Creating a new LaTeX file::
* LaTeX macros::
* LaTeX environments::
* Common commands::
* Math mode::
* Dots and commas and quotation marks::
* Font changes::
* Comments::
* Mismatched delimiters::
* Mismatched environments::
* Word abbreviations::
* Bibliographies::
* Indexing::
* Cross-references::
* French typography::
* Miscellaneous functions::
* Miscellaneous variables::
* Customizing lists::
\end{menu}

\node Preliminaries, Creating a new LaTeX file, LaTeX support, LaTeX support

\section{Preliminaries}

The material that you are now reading is
contained in the distribution as two files,
\file{ltxmode.ltx} for the TUGboat article, and
\file{ltxinfo.ltx} for \LaTeX{}info.\refill

The first job is to arrange for
\code{LaTeX-mode}\c
\findex{LaTeX-mode}
to be selected
automatically when required.\refill

Because the \file{latex.el} file of Lisp
code
\cpsubindex{Lisp}{GNU Emacs}
is not yet a standard part of the GNU Emacs
distribution, its association with particular file
extensions is unknown to Emacs.  To remedy that,
the Lisp code in
Table 1 \c\ref{fig-startup-code}
should be inserted into
the \file{.emacs} file\c
\cindex{startup file}\c
\cindex{.emacs file}
in your login directory; that file is processed
each time Emacs starts up.  The \code{load}\c
\findex{load}
command there tells where \file{latex.el} is
found; it may need adjustment for your
system.\refill

\begin{table}
\begin{small}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\Tabrule
\smallskip
\end{iftex}
\begin{verbatim}
;=============================================
; Add mode for .ltx files if not there already
; for most people: (load-library "latex.el")
; for my private version:
; Force tex-mode.el to be loaded so latex.el
; can override it.
(load-library "tex-mode")
(load "~/emacs/latex" t t nil)
(if (not (assoc "\\.ltx$" auto-mode-alist))
    (setq auto-mode-alist
          (cons (cons "\\.ltx$" 'LaTeX-mode)
                auto-mode-alist)))
(if (not (assoc "\\.stx$" auto-mode-alist))
    (setq auto-mode-alist
          (cons (cons "\\.stx$" 'LaTeX-mode)
                auto-mode-alist)))
(if (not (assoc "\\.sty$" auto-mode-alist))
    (setq auto-mode-alist
          (cons (cons "\\.sty$" 'LaTeX-mode)
                auto-mode-alist)))

;=============================================
; Private letter support
(load "~/emacs/letter" t t nil)
\end{verbatim}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\smallskip
\Tabrule
\end{iftex}
\end{small}
\caption{\protect\file{.emacs} file additions.}
\label{fig-startup-code}
\cindex{startup file}
\cindex{.emacs file}
\findex{LaTeX-mode}
\findex{load}
\vindex{auto-mode-alist}
\end{table}

The peculiar \code{if}\c
\findex{if}
commands attach \code{LaTeX-mode}\c
\findex{LaTeX-mode}
to the \code{auto-mode-alist}\c
\vindex{auto-mode-alist}
variable, which is a list of pairs of file
extensions and their mode names; the attachment is
omitted if the file extensions are already in the
list.\refill

Once this startup code has been executed, Emacs
will automatically select \code{LaTeX-mode}\c
\findex{LaTeX-mode}
when you visit files with extensions\c
\cindex{file extensions}
\file{.ltx}\c
\cindex{.ltx file}
(\LaTeX{} document), \file{.stx}\c
\cindex{.stx file}
(SLi\TeX{} document), or \file{.sty}\c
\cindex{.sty file}
(\LaTeX{} style).  Others can be easily added
according to taste.  File extension \file{.tex}\c
\cindex{.tex file}
is already attached to GNU Emacs \code{tex-mode}\c
\findex{tex-mode}
which comes with the system, so different
extensions are needed for different editing
modes.\refill

If you don't have these associations of file
extensions with editing modes in effect, you can
always select the mode manually with the command
\kbd{M-x LaTeX-mode}.\c
\kindex{M-x LaTeX-mode}\refill

Experienced Emacs users may wonder why the
\code{autoload}\c
\findex{autoload}
facility is not used instead of the explicit
\code{load}\c
\findex{load}
command in the startup file; the reason lies in a
conflict with the standard \code{tex-mode}.\c
\findex{tex-mode}
I expect that conflict will be removed when
\file{latex.el} becomes part of the standard GNU
Emacs distribution.  A modification of
\file{tex-mode.el} that eliminates all
\LaTeX{}-specific code has been prepared locally,
and that new version removes the incompatibility
with \file{latex.el}, allowing \code{autoload}\c
\findex{autoload}
to be used.\refill

In GNU Emacs Lisp, named functions, and variables
defined outside functions, are known globally.
There is no provision for file scoping or mode
scoping to limit name visibility.\c
\cindex{visibility of names}\c
\cindex{scope of names}
Consequently,
to avoid collision with the thousands of names
from other libraries, each library usually
includes a distinctive phrase in its global names.
Naturally enough, \samp{LaTeX} and \samp{SLiTeX}
are the phrases chosen in \file{latex.el}.  They
are almost always used as prefixes in variable names,\c
\cindex{name prefix}\c
\cindex{prefix in names}
and
usually also in function names, although a few
functions have embedded phrases for better
readability (e.g.\ \code{show-LaTeX-labels}).\c
\findex{show-LaTeX-labels}\c
\cindex{naming conventions}\c
\cindex{conventions for naming}\refill

Tables 2 \c\ref{fig-latex-mode-1}
through 4 \c\ref{fig-latex-mode-3}
show the documentation summary for
\code{LaTeX-mode},\c
\findex{LaTeX-mode}
which you can always reproduce online with the
function \code{describe-mode}\c
\findex{describe-mode}
which is normally bound to the key
\kbd{C-h m}.\c
\kindex{C-h m}\refill

Only major mode functions have such long
documentation.
Table 5 \c\ref{fig-latex-index}
shows a more typical case, the documentation of
the function \code{LaTeX-index}.\c
\findex{LaTeX-index}\c
\cindex{documentation of function}\c
\cindex{function documentation}
You could produce it online with the function
\code{describe-function}\c
\findex{describe-function}
on \kbd{C-h d}.\c
\kindex{C-h d}\refill

Tables 6 \c\ref{fig-bindings-1}
and 7 \c\ref{fig-bindings-2}
show the key bindings\c
\cindex{key binding}
in
\code{LaTeX-mode}; the listings can be produced by
the function \code{describe-bindings}\c
\findex{describe-bindings}
which is normally attached to
\kbd{C-h b}.\c
\kindex{C-h b}\refill

The name and documentation\c
\cindex{documentation of function}\c
\cindex{function documentation}
of the function
attached to any key can be obtained by invoking
the function
\code{describe-key}\c
\findex{describe-key}
attached to \kbd{C-h k}.\c
\kindex{C-h k}\refill

You can change existing key bindings,\c
\cindex{key binding}
or add new
ones, with the functions
\code{local-set-key}\c
\findex{local-set-key}
and
\code{global-set-key},\c
\findex{global-set-key}
and otherwise modify the behavior of
\code{LaTeX-mode}.\c
\findex{LaTeX-mode}
\xref{Customizing lists} for details.\refill

\begin{table}[tbph]
\begin{small}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\Tabrule
\smallskip
\end{iftex}
\begin{verbatim}
LaTeX Mode: Major editing mode for LaTeX and
SLiTeX, with tex-mode underneath.

To create a new LaTeX document, use
make-LaTeX-document (on C-c d), or
make-SLiTeX-document (on C-c s).  With an
argument, they will provide some additional
helpful comments.  The functions will prompt
for document style and options.  Type ? to see
the standard ones; you can enter them with
name completion.  You can also enter your own,
since it is possible to have private styles
and options unknown to make-LaTeX-document or
make-SLiTeX-document.

The most frequent LaTeX construct is the
\begin{}...\end{} grouping; you can generate
it by LaTeX-begin-end-block (on C-c b).  With
an argument, a helpful comment may be printed.
Type ? to see the standard environments, or
enter your own.  If you type a \begin{...}
manually, you can later generate a matching
\end{...} with the function LaTeX-end (on C-c
n).

Other common constructs are the insertion of
labels, citations, cross-references, index
entries, verbatim strings, and additional
items in a list.  The functions
        C-c .   LaTeX-add-word-to-index
        C-c C-b LaTeX-bibitem
        C-c c   LaTeX-cite
        C-c k   LaTeX-counter
        C-c f   LaTeX-footnote
        C-c x   LaTeX-index
        C-c i   LaTeX-item
        C-c l   LaTeX-label
        C-c m   LaTeX-macro
        C-c p   LaTeX-pageref-with-completion
        C-c C-p LaTeX-protect
        C-c r   LaTeX-ref-with-completion
        C-c v   LaTeX-verb
        C-c d   make-LaTeX-document
        C-c s   make-SLiTeX-document
provide for these.
\end{verbatim}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\smallskip
\Tabrule
\end{iftex}
\end{small}
\caption{Online summary of \LaTeX{} mode.}
\label{fig-latex-mode-1}\c
\findex{LaTeX-add-word-to-index}\c
\findex{LaTeX-begin-end-block}\c
\findex{LaTeX-bibitem}\c
\findex{LaTeX-end}\c
\findex{LaTeX-footnote}\c
\findex{LaTeX-index}\c
\findex{LaTeX-item}\c
\findex{LaTeX-label}\c
\findex{LaTeX-pageref-with-completion}\c
\findex{LaTeX-protect}\c
\findex{LaTeX-ref-with-completion}\c
\findex{LaTeX-uncomment}\c
\findex{LaTeX-verb}\c
\findex{make-LaTeX-document}\c
\findex{make-SLiTeX-document}\c
\pindex{\back begin}\c
\pindex{\back end}
\end{table}

\begin{table}[tbph]
\begin{small}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\Tabrule
\smallskip
\end{iftex}
\begin{verbatim}
LaTeX-tab (on C-c TAB) will indent a line to
the current \begin{}...\end{} nesting level.

Most major LaTeX macros can be entered by
LaTeX-macro (on C-c m).  This will supply the
correct set of following braces, brackets, and
parentheses, and with an argument, will insert
a short comment about the expected command
arguments.

For SLiTeX, the function renumber-slides can
be used to put a numbered comment on each
slide environment for handy reference in the
\onlynotes{...} and \onlyslides{...} commands.

You can move over \begin{} ... \end{} groups
with LaTeX-to-begin (on C-c a) and
LaTeX-to-end (on C-c e).

Insertion of paired angle brackets, braces,
square brackets, and parentheses is provided
by
        C-c <  LaTeX-angles
        C-c {  LaTeX-braces
        C-c [  LaTeX-brackets
        C-c (  LaTeX-parentheses
With an argument, the last three insert
backslash prefixes for literal braces, math
mode, and displaymath mode.

Unbalanced character pairs are found by
        C-c >  LaTeX-check-angle-balance
        C-c }  LaTeX-check-brace-balance
        C-c ]  LaTeX-check-bracket-balance
        C-c $  LaTeX-check-dollar-balance
        C-c )  LaTeX-check-parenthesis-balance

You can test for undefined labels with
check-LaTeX-labels, display the labels and
their line numbers with show-LaTeX-labels, and
fetch labels from an .aux file with
update-LaTeX-labels.
\end{verbatim}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\smallskip
\Tabrule
\end{iftex}
\end{small}
\caption{More about \LaTeX{} mode.}
\label{fig-latex-mode-2}
\cpsubindex{mail}{electronic}\c
\cindex{e-mail}\c
\findex{LaTeX-check-angle-balance}\c
\findex{LaTeX-check-brace-balance}\c
\findex{LaTeX-check-bracket-balance}\c
\findex{LaTeX-check-dollar-balance}\c
\findex{LaTeX-check-parenthesis-balance}\c
\findex{LaTeX-angles}\c
\findex{LaTeX-braces}\c
\findex{LaTeX-brackets}\c
\findex{LaTeX-parentheses}\c
\findex{LaTeX-macro}\c
\findex{LaTeX-tab}\c
\findex{LaTeX-to-begin}\c
\findex{LaTeX-to-end}\c
\findex{check-LaTeX-labels}\c
\findex{renumber-slides}\c
\findex{show-LaTeX-labels}\c
\findex{update-LaTeX-labels}\c
\pindex{\back begin}\c
\pindex{\back end}\c
\pindex{\back onlynotes}\c
\pindex{\back onlyslides}
\end{table}
\begin{table}[tbph]
\begin{small}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\Tabrule
\smallskip
\end{iftex}
\begin{verbatim}
Environment nesting errors can be caught by
check-LaTeX-nesting.

Use indent-LaTeX-begin-end-groups to get
environments nested for improved visibility.

Use LaTeX-comment (on C-c %) to comment out
the current paragraph (no arg) or region
(arg); undo with M-X undo (C-_).  LaTeX-
uncomment (on C-c u) is the inverse function.

One or more words can be set in any standard
LaTeX font using the commands

        C-c C-c b       LaTeX-font-bf
        C-c C-c e       LaTeX-font-em
        C-c C-c i       LaTeX-font-it
        C-c C-c r       LaTeX-font-rm
        C-c C-c u       LaTeX-font-sc
        C-c C-c f       LaTeX-font-sf
        C-c C-c s       LaTeX-font-sl
        C-c C-c t       LaTeX-font-tt

Please report bugs, comments, and enhancements
by e-mail to
        beebe@math.utah.edu (Internet)
LaTeX-gripe (on C-c g) makes this easier.
\end{verbatim}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\smallskip
\Tabrule
\end{iftex}
\end{small}
\caption{Even more about \LaTeX{} mode.}
\label{fig-latex-mode-3}
\cpsubindex{mail}{electronic}\c
\cindex{e-mail}\c
\findex{LaTeX-comment}\c
\findex{LaTeX-font-bf}\c
\findex{LaTeX-font-em}\c
\findex{LaTeX-font-it}\c
\findex{LaTeX-font-rm}\c
\findex{LaTeX-font-sc}\c
\findex{LaTeX-font-sf}\c
\findex{LaTeX-font-sl}\c
\findex{LaTeX-font-tt}\c
\findex{LaTeX-gripe}\c
\findex{LaTeX-uncomment}\c
\findex{check-LaTeX-nesting}\c
\findex{indent-LaTeX-begin-end-groups}\c
\findex{undo}\c
\cindex{gripe}\c
\cindex{complaint}\c
\cindex{problem report}\c
\cindex{bug report}\c
\cindex{reporting bugs}
\end{table}

\begin{table}[tbh]
\begin{small}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\Tabrule
\smallskip
\end{iftex}
\begin{verbatim}
LaTeX-index:
Insert \index{ ... } at point (on C-c x).

If a prefix argument is given, the string is
prompted for, and inserted both as text and as
an index entry, e.g. gnats and
gnus\index{gnats and gnus}.  All horizontal
space preceding \index is removed to prevent
an intervening page break causing an
off-by-one page number error.

If LaTeX-index-start-with-newline is non-nil,
insert a percent to start a comment, then put
\index at the start of a following new line.
If LaTeX-index-end-with-newline is non-nil,
follow the entry with a new line.
\end{verbatim}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\smallskip
\Tabrule
\end{iftex}
\end{small}
\caption{Online help for \protect\code{LaTeX-index}.}
\findex{LaTeX-index}
\vindex{LaTeX-index-start-with-newline}
\vindex{LaTeX-index-end-with-newline}
\pindex{\back index}
\label{fig-latex-index}
\end{table}

\begin{table}[tbph]
\begin{small}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\Tabrule
\smallskip
\end{iftex}
\begin{verbatim}
Local Bindings:
key            binding
---            -------

_              LaTeX-subscript
^              LaTeX-superscript
.              LaTeX-dot
,              LaTeX-comma
$              LaTeX-dollar
ESC            Prefix Command
LFD            newline-and-indent
C-c            Prefix Command
"              LaTeX-quote

C-c ,          LaTeX-set-indentation
C-c C-c        Prefix Command
C-c =          LaTeX-equation
C-c }          LaTeX-check-brace-balance
C-c {          LaTeX-braces
C-c x          LaTeX-index
C-c v          LaTeX-verb
C-c u          LaTeX-uncomment
C-c s          make-SLiTeX-document
C-c r          LaTeX-ref-with-completion
C-c p          LaTeX-pageref-with-completion
C-c n          LaTeX-end
C-c m          LaTeX-macro
C-c l          LaTeX-label
C-c k          LaTeX-counter
C-c i          LaTeX-item
C-c g          LaTeX-gripe
C-c f          LaTeX-footnote
C-c e          LaTeX-to-end
C-c d          make-LaTeX-document
C-c c          LaTeX-cite
C-c b          LaTeX-begin-end-block
C-c a          LaTeX-to-begin
C-c 0          renumber-slides
C-c ]          LaTeX-check-bracket-balance
C-c [          LaTeX-brackets
C-c .          LaTeX-add-word-to-index
\end{verbatim}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\smallskip
\Tabrule
\end{iftex}
\end{small}
    \caption{Local bindings in \protect\LaTeX{} mode.}
    \label{fig-bindings-1}\c
\findex{LaTeX-add-word-to-index}\c
\findex{LaTeX-begin-end-block}\c
\findex{LaTeX-check-brace-balance}\c
\findex{LaTeX-check-bracket-balance}\c
\findex{LaTeX-cite}\c
\findex{LaTeX-comma}\c
\findex{LaTeX-counter}\c
\findex{LaTeX-dollar}\c
\findex{LaTeX-dot}\c
\findex{LaTeX-end}\c
\findex{LaTeX-equation}\c
\findex{LaTeX-footnote}\c
\findex{LaTeX-gripe}\c
\findex{LaTeX-index}\c
\findex{LaTeX-braces}\c
\findex{LaTeX-brackets}\c
\findex{LaTeX-quote}\c
\findex{LaTeX-item}\c
\findex{LaTeX-label}\c
\findex{LaTeX-macro}\c
\findex{LaTeX-pageref-with-completion}\c
\findex{LaTeX-ref-with-completion}\c
\findex{LaTeX-set-indentation}\c
\findex{LaTeX-to-begin}\c
\findex{LaTeX-to-end}\c
\findex{LaTeX-uncomment}\c
\findex{LaTeX-verb}\c
\cindex{prefix command}\c
\findex{make-LaTeX-document}\c
\findex{make-SLiTeX-document}\c
\findex{newline-and-indent}\c
\findex{renumber-slides}\c
\findex{up-list}\c
\kindex{_}\c
\kindex{^}\c
\kindex{.}\c
\kindex{,}\c
\kindex{$}\c
\kindex{ESCape}\c
\kindex{LFD}\c
\kindex{"}\c
\kindex{C-c}\c
\kindex{C-c C-c}\c
\kindex{C-c =}\c
\c \kindex{C-c \{}\c
\c \kindex{C-c \}}\c
\kindex{C-c x}\c
\kindex{C-c v}\c
\kindex{C-c u}\c
\kindex{C-c s}\c
\kindex{C-c r}\c
\kindex{C-c p}\c
\kindex{C-c n}\c
\kindex{C-c m}\c
\kindex{C-c l}\c
\kindex{C-c i}\c
\kindex{C-c g}\c
\kindex{C-c f}\c
\kindex{C-c e}\c
\kindex{C-c d}\c
\kindex{C-c c}\c
\kindex{C-c b}\c
\kindex{C-c a}\c
\kindex{C-c 0}\c
\kindex{C-c [}\c
\kindex{C-c ]}\c
\kindex{C-c .}\c
\kindex{C-c (}\c
\kindex{C-c )}\c
\kindex{C-c %}\c
\kindex{C-c $}\c
\kindex{C-c >}\c
\kindex{C-c <}\c
\kindex{C-c C-n}\c
\kindex{C-c Tab}\c
\kindex{C-c C-b}\c
\kindex{C-c C-r}\c
\kindex{C-c C-p}\c
\kindex{C-c C-q}\c
\kindex{C-c C-l}\c
\kindex{C-c C-k}\c
\kindex{ESCape (}\c
\kindex{ESCape )}\c
\c \kindex{ESCape \{}\c
\c \kindex{ESCape \}}\c
\kindex{M-(}\c
\kindex{M-)}\c
\c \kindex{M-\{}\c
\c \kindex{M-\}}\c
\pindex{"}\c
\cindex{gripe}\c
\cindex{complaint}\c
\cindex{problem report}\c
\cindex{bug report}\c
\cindex{reporting bugs}\c
\cindex{key binding}
\end{table}

\begin{table}[tbph]
\begin{small}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\Tabrule
\smallskip
\end{iftex}
\begin{verbatim}
C-c )          LaTeX-check-parenthesis-balance
C-c (          LaTeX-parentheses
C-c %          LaTeX-comment
C-c $          LaTeX-check-dollar-balance
C-c >          LaTeX-check-angle-balance
C-c <          LaTeX-angles
C-c C-p        LaTeX-protect
C-c C-n        LaTeX-news
C-c TAB        LaTeX-tab
C-c C-b        LaTeX-bibitem

ESC )          forward-list
ESC (          backward-up-list

C-c C-c t      LaTeX-font-tt
C-c C-c s      LaTeX-font-sl
C-c C-c f      LaTeX-font-sf
C-c C-c u      LaTeX-font-sc
C-c C-c r      LaTeX-font-rm
C-c C-c i      LaTeX-font-it
C-c C-c e      LaTeX-font-em
C-c C-c b      LaTeX-font-bf
C-c C-c }      LaTeX-check-brace-balance
C-c C-c ]      LaTeX-check-bracket-balance
C-c C-c )      LaTeX-check-parenthesis-balance
C-c C-c $      LaTeX-check-dollar-balance
C-c C-c =      LaTeX-displaymath
\end{verbatim}
\begin{ifinfo}
----------------------------------------------------------------------
\end{ifinfo}
\begin{iftex}
\smallskip
\Tabrule
\end{iftex}
\end{small}
    \caption{More local bindings.}
    \label{fig-bindings-2}\c
\findex{backward-up-list}\c
\findex{forward-list}\c
\findex{LaTeX-bibitem}\c
\findex{LaTeX-check-angle-balance}\c
\findex{LaTeX-check-brace-balance}\c
\findex{LaTeX-check-bracket-balance}\c
\findex{LaTeX-check-dollar-balance}\c
\findex{LaTeX-check-parenthesis-balance}\c
\findex{LaTeX-comment}\c
\findex{LaTeX-displaymath}\c
\findex{LaTeX-font-bf}\c
\findex{LaTeX-font-em}\c
\findex{LaTeX-font-it}\c
\findex{LaTeX-font-rm}\c
\findex{LaTeX-font-sc}\c
\findex{LaTeX-font-sf}\c
\findex{LaTeX-font-sl}\c
\findex{LaTeX-font-tt}\c
\findex{LaTeX-angles}\c
\findex{LaTeX-parentheses}\c
\findex{LaTeX-news}\c
\findex{LaTeX-protect}\c
\findex{LaTeX-tab}\c
\kindex{C-c C-c $}\c
\kindex{C-c C-c )}\c
\kindex{C-c C-c =}\c
\kindex{C-c C-c ]}\c
\kindex{C-c C-c b}\c
\kindex{C-c C-c e}\c
\kindex{C-c C-c f}\c
\kindex{C-c C-c i}\c
\kindex{C-c C-c r}\c
\kindex{C-c C-c s}\c
\kindex{C-c C-c t}\c
\kindex{C-c C-c u}\c
\cindex{key binding}
\end{table}

\c Must force tables out manually; otherwise some
\c end up at end of chapter, 20+ pages hence, sigh...
\clearpage

\node Creating a new LaTeX file, LaTeX macros, Preliminaries, LaTeX support

\section{Creating a new \protect\LaTeX{} file}
\cindex{creating a new \protect\LaTeX{} file}
When you visit a new \LaTeX{} file, Emacs starts
up with an empty buffer.  The mode line at the
bottom of the screen will look something like\refill
\begin{verbatim}
---Emacs: foo.ltx (LaTeX Abbrev Fill)----All---
\end{verbatim}

\noindent
The first thing you want to do is get a standard
template of a \LaTeX{} file inserted; you do this
by typing \kbd{C-c d}\c
\kindex{C-c d}
(\code{make-LaTeX-document}).\c
\findex{make-LaTeX-document}
This function will first prompt you with\refill
\begin{verbatim}
Document style:
\end{verbatim}

\noindent
to which you can respond either with a complete
style file\c
\cindex{style file}
name, or with the first few
characters of a standard style, followed by a
space\c
\cindex{space}
to request Emacs to complete the name,
and a \kbd{RETurn}\c
\kindex{RETurn}
to accept the completion.\c
\cindex{completion}\c
\cindex{command completion}
If you are unsure of what to supply, just type a
query\c
\cindex{query}
(?\kindex{?}); Emacs will respond with
something like\refill
\begin{verbatim}
Possible completions are:
aaai                               amsart
amsbook                            amstex
aps                                article
book                               deproc
letter                             ltugproc
refman                             report
siam                               slides
tugboat                            ucthesis
uoftoronto                         usafmemo
uuthesis                           xxxslides
\end{verbatim}

\noindent
Completion\c
\cindex{completion}\c
\cindex{command completion}
can also be requested on partial
names: the input \samp{a?}\ in the above
command will respond with\refill
\begin{verbatim}
Possible completions are:
aaai                               amsart
amsbook                            amstex
aps                                article
\end{verbatim}

\noindent
Suppose you type \samp{article} or
\samp{ar\protect\code{<space>}}, followed by a
\kbd{RETurn}.\c
\kindex{RETurn}
Then Emacs will respond with\refill
\begin{verbatim}
Document option (RET when done):
\end{verbatim}

\noindent
to which you can then supply an option name
followed by a \kbd{RETurn}.\c
\kindex{RETurn}
As before, a query\c
\cindex{query}\c
\kindex{?}
will show you what is available:\c
\cindex{option}\refill
\begin{verbatim}
Possible completions are:
11pt                               12pt
a4                                 a4wide
acm                                acronym
agugrl                             agujgr
alltt                              amsbsy
amscd                              amsfonts
amssymb                            amssymbols
amstext                            apalike
archmemo                           array
bezier                             biihead
boxedmini                          changebar
chapterbib                         cite
clsc                               clscmemo
concrete                           cropmark
ctagsplt                           cyrillic
dblspace                           doublespace
draft                              drafthead
drop                               dvidoc
eqsecnum                           espo
fleqn                              format
fullpage                           geophysics
german                             gnuindex
ifthen                             intlim
ist21                              leqno
listing                            longtab
ltugboat                           makeidx
math                               merge
mfr                                mitthesis
moretext                           natsci
nl                                 nonamelm
nopageno                           nosumlim
openbib                            pandora
preprint                           proc
psmavg                             psmbkm
psmncs                             psmpal
psmtim                             remark
resume                             revtex
righttag                           sc21
sc21-wg1                           sfwmac
showidx                            showlabels
slem                               spacecites
supertab                           suthesis
tablisting                         tapeseal
texindex                           texnames
tgrind                             theorem
thp                                threepart
titlepage                          trademark
troffman                           troffms
twocolumn                          twoside
underline                          uofutah
vdm                                verbatim
\end{verbatim}

\noindent
You can keep on selecting options until you
finally just type a bare \kbd{RETurn},\c
\kindex{RETurn}
at which point \code{make-LaTeX-document}\c
\findex{make-LaTeX-document}
completes, and you have a buffer that looks like
this:\refill
\begin{verbatim}
% -*-latex-*-
% Document name: /u/beebe/foo.ltx
% Creator: Nelson Beebe [beebe@math.utah.edu]
% Creation Date: Sun Jul 28 08:44:46 1991
\documentstyle[11pt,makeidx]{article}
\newcommand{\X}[1]{{#1}\index{{#1}}}
\begin{document}
<cursor>
\end{document}
\end{verbatim}
\pindex{\back documentstyle}
\pindex{\back newcommand}
\pindex{\back begin\penalty0\{document\}}
\pindex{\back end\penalty0\{document\}}

\noindent
The cursor,\c
\cindex{cursor}
represented by \code{<cursor>}, is left
positioned on the line following the
\samp{\back begin\penalty0\{document\}},\c
\pindex{\back begin\penalty0\{document\}}
ready
for text entry.\refill

The initial comment with the tag
\samp{-*-latex-*-} is a special one.  It requests
an automatic mode selection when the file is
freshly visited in Emacs, overriding any mode that
might otherwise be selected based on the file name
extension.  \code{latex-mode}\c
\findex{latex-mode}
is made equivalent to \code{LaTeX-mode}\c
\findex{LaTeX-mode}
in \file{latex.el} so that the comment tag can be
written in lower-case letters, as is conventional.\refill

The \samp{% Creator:} comment information is
obtained from Emacs' operating system interface,
which in turn fetches the user's personal name\c
\cindex{personal name}
and login name\c
\cindex{login name}
from system authorization files.  On networked
systems, the hostname\c
\cindex{hostname}
is
included as well, creating a valid electronic mail
\cpsubindex{mail}{electronic}\c
\cindex{e-mail}
address.\refill

Had you given \code{make-LaTeX-document}\c
\findex{make-LaTeX-document}
an argument, it would have been somewhat
more verbose:\refill
\begin{verbatim}
% -*-latex-*-
% Document name: /u/beebe/tex/tugboat/foo.ltx
% Creator: Nelson Beebe [beebe@math.utah.edu]
% Creation Date: Sun Jul 28 08:46:33 1991
%----------------------------------------------
% EVERYTHING TO THE RIGHT OF A  %  IS A REMARK
% TO YOU AND IS IGNORED BY LaTeX.
%
% WARNING!  DO NOT TYPE ANY OF THE FOLLOWING 10
% CHARACTERS AS NORMAL TEXT CHARACTERS:
%       &   $   #   %   _    {   }   ^   ~   \
%
% The following seven are printed by typing a
% backslash in front of them:
%       $  &  #  %  _  {  and  }.
%----------------------------------------------
\documentstyle[11pt,makeidx]{article}
\newcommand{\X}[1]{{#1}\index{{#1}}}
\begin{document}
<cursor>
\end{document}
\end{verbatim}
\pindex{\back documentstyle}
\pindex{\back newcommand}
\pindex{\back begin\penalty0\{document\}}
\pindex{\back end\penalty0\{document\}}

\noindent
The extra commentary is a useful reminder for
beginning \LaTeX{} users.  Several other commands
in \code{LaTeX-mode}\c
\findex{LaTeX-mode}
use the presence of an argument to supply
additional helpful commentary.\refill

The \samp{\back X}\c
\pindex{\back X}
command is one I have found helpful for preparing
indexes; typing \samp{\back X\{gnats and gnus\}}\c
\pindex{\back X\{gnats and gnus\}}\c
\cindex{gnats and gnus}
will put that phrase in both the document and the
index.  Further discussion is given later;
\pxref{Indexing}.\refill

The lists of standard styles and options\c
\cindex{option}
are
embedded in the \file{latex.el} code.  They cannot
be determined automatically from the file system
for several reasons:\refill
\begin{itemize}

\item
Some options (e.g.\ \samp{11pt}) do not
have a corresponding style file.\c
\cindex{style file}\refill

\item
Some style files\c
\cindex{style file}
do not represent a
valid option (e.g.\ \file{art10.sty}).\c
\cindex{art10.sty}\refill

\item
Some style files\c
\cindex{style file}
found in the normal
\code{TEXINPUTS}\c
\vindex{TEXINPUTS}
search path belong to other systems,
such as AmS\TeX{}.\refill

\item
It is impossible to distinguish from the
\file{.sty}\c
\cindex{.sty file}
file extension whether the
file represents a major document style,
or merely an option\c
\cindex{option}
that modifies a
major style.\refill
\end{itemize}
It is regrettable that these difficulties exist,
because they confuse users, as well as programmers
of code like \code{LaTeX-mode}.\c
\findex{LaTeX-mode}
It is often
difficult to tell from its contents whether a
particular file is a major style, or just a
document option.\c
\cindex{option}
It would have been wiser in the
initial \LaTeX{} design to have chosen distinctive
file extensions, and for each style and option to
be associated with a unique file.\refill

The present collection of twenty available styles
and over one hundred options is daunting for a
novice, particularly since many options can only
be used with certain styles.  Eventually I may
find a satisfactory way to deal with this,
and offer a better presentation of choices in the
completion\c
\cindex{completion}\c
\cindex{command completion}
lists.\refill

The style and option\c
\cindex{option}
lists can be easily extended.
\xref{Customizing lists} for details.\refill

\node LaTeX macros, LaTeX environments, Creating a new LaTeX file, LaTeX support

\section{\protect\LaTeX{} macros}
Every one of the 589 \LaTeX{} macros\c
\cindex{macros}
in the
index to the \emph{\LaTeX{} User's Guide and
Reference Manual}
\cite{Lamport:latex}\c
\tindex{Lamport, Leslie}
is known to the
function \code{LaTeX-macro}\c
\findex{LaTeX-macro}
(on \kbd{C-c m}),\c
\kindex{C-c m}
and as before, Emacs command completion\c
\cindex{completion}\c
\cindex{command completion}
is available with the query\c
\cindex{query}\c
\kindex{?}
(?) and space\c
\cindex{space}
(\code{<space>}) characters.  Thus, you can type\refill
\begin{itemize}

\item
\kbd{C-c m longr<space>}\c
\kindex{C-c m}
\kbd{RETurn}\c
\kindex{RETurn}
to get \samp{\back longrightarrow};\c
\pindex{\back longrightarrow}\refill

\item
\kbd{C-c m em}\c
\kindex{C-c m}
\kbd{RETurn}\c
\kindex{RETurn}
to get\refill

\samp{\{\back em <cursor>\back /\}}

\noindent
with the cursor\c
\cindex{cursor}
positioned ready for you to enter
some text;\refill

\item
\kbd{C-u}\c
\kindex{C-u}
\kbd{C-c m newcom<space>}\c
\kindex{C-c m}
\kbd{RETurn}\c
\kindex{RETurn}
to get\refill

\noindent
\begin{verbatim}
\newcommand{<cursor>}[]{} % {\cmd}[n]{def} define new 
                          % command with n arguments
\end{verbatim}

\item
\kbd{C-c m e?}\c
\kindex{C-c m}
to find the names of macros that begin with
\kbd{e}:\refill

\begin{ifinfo}
Possible completions are:
ell                            em
emptyset                       encl
end                            epsilon
equiv                          eta
evensidemargin                 exists
exp                            extracolsep
\end{ifinfo}
\begin{iftex}
\begin  {verbatim}
Possible completions are:
ell                            em
emptyset                       encl
end                            epsilon
equiv                          eta
evensidemargin                 exists
exp                            extracolsep
\end{verbatim}
\end{iftex}
\end{itemize}
\cindex{completion}\c
\cindex{command completion}
When the cursor\c
\cindex{cursor}
is left after an open brace in a
generated command, the closing brace is by default
placed at the start of the next line so that you
have a clean line to type on.  This reduces
visually-distracting screen updates, but means
that you will need to delete the end-of-line
character when you finish typing the argument.  If
you don't like this behavior, you can set the
Emacs variable
\code{LaTeX-newline-after-opening-delimiter}\c
\vindex{LaTeX-newline-after-opening-delimiter}
to a \code{nil} value, usually in your
\file{.emacs}\c
\cindex{startup file}\c
\cindex{.emacs file}
startup file:\refill
\begin{verbatim}
(setq LaTeX-mode-hook
 '(lambda ()
    (setq LaTeX-newline-after-opening-delimiter
          nil)
    )
 )
\end{verbatim}
\vindex{LaTeX-mode-hook}\c
\findex{lambda}\c
\cindex{hook}

\noindent
The variable
\code{LaTeX-newline-after-closing-delimiter}\c
\vindex{LaTeX-newline-after-closing-delimiter}
is used similarly for brace pairs inserted on
their own, or after certain macros.\refill

A \emph{mode hook}\c
\cindex{mode hook}\c
\cindex{hook}\c
\label{mode-hook}
is Lisp
\cpsubindex{Lisp}{GNU Emacs}
code to be executed whenever the corresponding
mode function is executed.  The hook is called
just before the mode function returns, so it can
override anything that the function did.  The
peculiar \samp{lambda ()}\c
\findex{lambda}
is the Lisp way of declaring a nameless function.
The single quote prefixing it means that
\code{LaTeX-mode-hook}\c
\vindex{LaTeX-mode-hook}\c
\cindex{hook}
will be assigned the
function itself, and not the value returned by the
function.\refill

In GNU Emacs,
\cpsubindex{Lisp}{GNU Emacs, executing}
you can execute Lisp code in a file through
\kbd{M-x load-file}\c
\kindex{M-x load-file}
and
\kbd{M-x load-library}\c
\kindex{M-x load-library}
commands.  Inline code must be executed in a
buffer which is in \code{emacs-lisp-mode}.\c
\findex{emacs-lisp-mode}
The minibuffer\c
\cindex{minibuffer}
always has that mode, and can
be temporarily accessed with the
\code{eval-expression}\c
\findex{eval-expression}
function bound to
\kbd{ESCape ESCape}.\c
\kindex{ESCape ESCape}\refill

If you just want to set an Emacs variable, you can
also use the command \kbd{M-x set-variable};\c
\kindex{M-x set-variable}
it supports completion\c
\cindex{completion}\c
\cindex{command completion}
on the variable name, and
prompts for the value.\refill

The availability of all of the \LaTeX{} macros
with \code{LaTeX-macro}\c
\findex{LaTeX-macro}
reduces the likelihood of spelling mistakes, and
the command completion\c
\cindex{completion}\c
\cindex{command completion}
usually means that only a few leading characters
need to be typed.  The complete macro name is
entered in the buffer:
\samp{\back abovedisplayshortskip}\c
\pindex{\back abovedisplayshortskip}
is much more
readable than a cryptic \samp{\back adss}\c
\pindex{\back adss}
that \LaTeX{}
users without such editing support might be
inclined to define as a private macro to save
typing effort.\refill

If you have frequently-used private macros,
\cpsubindex{macros}{private}
there is a convenient way to make them known to
\code{LaTeX-mode}.\c
\findex{LaTeX-mode}
\xref{Customizing lists}
for details.\refill

\node LaTeX environments, Common commands, LaTeX macros, LaTeX support

\section{\protect\LaTeX{} environments}
An important concept in \LaTeX{} is the notion of
\emph{environments},\c
\cindex{environment}
which are marked by surrounding
\samp{\back begin\penalty0\{...\}}\c
\pindex{\back begin\penalty0\{...\}}
and
\samp{\back end\penalty0\{...\}}\c
\pindex{\back end\penalty0\{...\}}
commands.  The
braced tag must be repeated, and if the tag name
is long, spelling errors are more likely.  The
function \code{LaTeX-begin-end-block}\c
\findex{LaTeX-begin-end-block}
on \kbd{C-c b}\c
\kindex{C-c b}
generates the command pair, indented
according to the current nesting level,\c
\cindex{nesting level}
and leaves the cursor\c
\cindex{cursor}
on the line between them.  The
indentation is controlled by the value of the
Emacs variable
\code{LaTeX-begin-end-indentation};\c
\vindex{LaTeX-begin-end-indentation}
the default is two spaces.\refill

If the variable
\code{LaTeX-space-after-begin-end}\c
\vindex{LaTeX-space-after-begin-end}
is
non-\code{nil}, a space will be inserted
between the keyword and the following opening
brace.  The default value is \code{nil}.  This
formatting style is discouraged, because it cannot
be applied uniformly; it must be suppressed for
the \samp{verbatim} environment.  The code in
\file{latex.el} knows about this vagary, and
always omits the space for that environment.\refill

The keystrokes
\kbd{C-c b quote}\c
\kindex{C-c b}
\kbd{RETurn}\c
\kindex{RETurn}
\kbd{C-c b ite\protect\code{<space>}}\c
\kindex{C-c b}
\kbd{RETurn}\c
\kindex{RETurn}
\kbd{C-c b verb\protect\code{<space>}}\c
\kindex{C-c b}
\kbd{RETurn}\c
\kindex{RETurn}
produce\refill
\begin{ifinfo}

  \back begin{quote}
    \back begin{itemize}
      \back item
\back begin{verbatim}
<cursor>
\back end {verbatim}
      \back item
      \back item
      \back item
    \back end{itemize}
  \back end{quote}
\end{ifinfo}
\begin{iftex}
\begin  {verbatim}
  \begin{quote}
    \begin{itemize}
      \item
\begin  {verbatim}
<cursor>
\end  {verbatim}
      \item
      \item
      \item
    \end{itemize}
  \end{quote}
\end{verbatim}
\end{iftex}
\pindex{\back begin\penalty0\{quote\}}\c
\pindex{\back end\penalty0\{quote\}}\c
\pindex{\back begin\penalty0\{itemize\}}\c
\pindex{\back end\penalty0\{itemize\}}\c
\pindex{\back begin\penalty0\{verbatim\}}\c
\pindex{\back end\penalty0\{verbatim\}}\c
\pindex{\back item}\c
\noindent
with the cursor\c
\cindex{cursor}
inside the \samp{verbatim}
environment.  Notice that the normal indentation
is automatically suppressed for that environment;
the command knows that leading spaces in front of
\samp{\back end\penalty0\{verbatim\}}\c
\pindex{\back end\penalty0\{verbatim\}}
would
otherwise generate an unwanted blank line in the
typeset output.\refill

If you have private environments,
\cpsubindex{environment}{private}
you can still use \kbd{C-c b};\c
\kindex{C-c b}
you just have to type
the complete environment name.  If you use some
private ones frequently in different documents,
it is possible to extend the list of
environments known to \code{LaTeX-mode}.\c
\findex{LaTeX-mode}
\xref{Customizing lists}
for details.\refill

In those environments that have
\samp{\back item}\c
\pindex{\back item}
commands, four are generated by default; that
number can be changed by modifying the value of the
Emacs variable \code{LaTeX-item-count}.\c
\vindex{LaTeX-item-count}
Their indentation is defined by the variable
\code{LaTeX-item-indentation};\c
\vindex{LaTeX-item-indentation}
the default is two spaces.  Additional indentation
of text under a \samp{\back item}\c
\pindex{\back item}
command is set by the variable
\code{LaTeX-item-info-indent};\c
\vindex{LaTeX-item-info-indent}
the default is
six spaces.\refill

You can generate additional \samp{\back item}\c
\pindex{\back item}
commands
as needed with the function \code{LaTeX-item}\c
\findex{LaTeX-item}
on \kbd{C-c i}.\c
\kindex{C-c i}
With an argument, it supplies the
alternate form \samp{\back item[]}\c
\pindex{\back item[]}
instead.\refill

If you forgot about the \kbd{C-c b}\c
\kindex{C-c b}
command, and
manually typed a
\samp{\back begin\penalty0\{conjecture\}},\c
\pindex{\back begin\penalty0\{conjecture\}}
you
can get the matching
\samp{\back end\penalty0\{conjecture\}}\c
\pindex{\back end\penalty0\{conjecture\}}
generated automatically by typing \kbd{C-c n}\c
\kindex{C-c n}
(\code{LaTeX-end}).\c
\findex{LaTeX-end}
That is also sometimes helpful when you have
forgotten
\cpsubindex{environment}{forgotten}
what environment you are in: you can generate the
\samp{\back end\penalty0\{...\}},\c
\pindex{\back end\penalty0\{...\}}
and then kill it.\refill

You can type \kbd{C-c a}\c
\kindex{C-c a}
(\code{LaTeX-to-begin})\c
\findex{LaTeX-to-begin}
to move backward to the enclosing
\samp{\back begin};\c
\pindex{\back begin}
with an argument, you can move backward over a
specified number of
\samp{\back begin\penalty0\{...\}}s.\c
\pindex{\back begin\penalty0\{...\}}
If the
argument is negative, you move forward over
\samp{\back end\penalty0\{...\}}s\c
\pindex{\back end\penalty0\{...\}}
instead.
Usually, you would use \kbd{C-c e}\c
\kindex{C-c e}
(\code{LaTeX-to-end})\c
\findex{LaTeX-to-end}
instead to move forward over
\samp{\back end\penalty0\{...\}}s;\c
\pindex{\back end\penalty0\{...\}}
that command handles numeric arguments too, and
reverses direction for negative arguments.\refill

These two movement commands are analogous to
the standard Emacs commands for moving backward
and forward in sentences, normally bound to
\kbd{M-a}\c
\kindex{M-a}
and \kbd{M-e}.\c
\kindex{M-e}
They also require that the \samp{\back begin}\c
\pindex{\back begin}
and \samp{\back end}\c
\pindex{\back end}
macros be
preceded on their lines only by optional
whitespace, and immediately followed by open
braces.  This helps to enforce the discipline
of keeping the
\samp{\back begin\penalty0\{...\}}\c
\pindex{\back begin\penalty0\{...\}}
\dots \samp{\back end\penalty0\{...\}}\c
\pindex{\back end\penalty0\{...\}}
grouping properly nested and
readable, and also avoids having to deal
with more complex input parsing.\refill

\node Common commands, Math mode, LaTeX environments, LaTeX support

\section{Common commands}
\cpsubindex{macros}{common}
Some \LaTeX{} macros are used so often that it
is desirable to have them bound directly to keys,
instead of having to type their first few
characters with \code{LaTeX-macro}\c
\findex{LaTeX-macro}
as described earlier.  You can find a list of
these convenience functions in the fourth
paragraph of Table \c\ref{fig-latex-mode-1}
2.\refill


For example, typing \kbd{C-c l}\c
\kindex{C-c l}
(that's the letter `l') generates\refill
\begin{verbatim}
~\label{<cursor>}
\end{verbatim}
\pindex{\back label}

\noindent
at the cursor\c
\cindex{cursor}
position, leaving the cursor after
the open brace.\refill

\node Math mode, Dots and commas and quotation marks, Common commands, LaTeX support

\section{Math mode}
\cindex{math mode}
\TeX{}'s math mode uses paired dollar signs\c
\cindex{dollar sign}
to delimit the math text.  Single dollar signs
mark inline math,\c
\cindex{inline math}
and doubled ones mark display
math.\c
\cindex{display math}
If you forget to type a closing dollar
sign, or type the wrong number of dollar signs,\c
\cindex{dollar sign}
\TeX{} will complain bitterly.\refill

The start and finish of these math regions are
indistinguishable, making it hard for simple
programs (and sometimes, readers) to distinguish
the `inside' from the `outside'.\refill

Consequently, \LaTeX{} additionally supports two
bracketing forms:\refill
\samp{\back (}
\dots \samp{\back )}\c
\pindex{\back (}
\pindex{\back )}
for \samp{$ ... $},\c
\pindex{$ ... $}
and
\samp{\back [}
\dots \samp{\back ]}\c
\pindex{\back [}
\pindex{\back ]}
for
\samp{$$ ... $$},\c
\pindex{$$ ... $$}
as well as more readable forms\refill
\begin{verbatim}
  \begin{math}
  ...
  \end{math}

  \begin{displaymath}
  ...
  \end{displaymath}
\end{verbatim}

\noindent
for the single and double dollar sign\c
\cindex{dollar sign}
pairs, respectively.  All of these have unique
opening and closing sequences.\refill

\code{LaTeX-mode}\c
\findex{LaTeX-mode}
supports all of these forms.
The variants selected are determined by the
variables \code{LaTeX-math-option}\c
\vindex{LaTeX-math-option}
and
\code{LaTeX-displaymath-option}.\c
\vindex{LaTeX-displaymath-option}
Values of 0, 1, and 2 select the dollar,
backslashed\c
\cindex{backslash}
delimiter, and
\samp{\back begin\penalty0\{...\}}\c
\pindex{\back begin\penalty0\{...\}}
\dots \samp{\back end\penalty0\{...\}} \c
\pindex{\back end\penalty0\{...\}}
environment forms respectively;
all other values are equivalent to 0.  The default
values select the single dollar\c
\cindex{dollar sign}
and \samp{displaymath}\c
\cindex{display math}
forms.\refill

Normally, when you type a dollar sign,\c
\cindex{dollar sign}
you get an inline math\c
\cindex{inline math}
environment.  If the dollar sign\c
\cindex{dollar sign}
happens to be at the beginning of a line, it
expands instead into a display math\c
\cindex{display math}
environment.  On
the other hand, if the preceding character was a
backslash,\c
\cindex{backslash}
you just get a plain dollar sign.\c
\cindex{dollar sign}\refill

Spacing around the inserted text is controlled by
two more variables. If
\code{LaTeX-newline-after-opening-delimiter}\c
\vindex{LaTeX-newline-after-opening-delimiter}
is
non-\code{nil} (the default), the opening
delimiter is followed by a newline, with the
cursor\c
\cindex{cursor}
positioned immediately after the delimiter
for the inline\c
\cindex{inline math}
case, and on a new line for the
display\c
\cindex{display math}
form.  If
\code{LaTeX-newline-after-closing-delimiter}\c
\vindex{LaTeX-newline-after-closing-delimiter}
is non-\code{nil} (the default), the closing
delimiter is followed by a newline.\refill

This pleasantness is our first example of having
an alternate function bound to a normal printing
character.  Instead of running the usual
\code{self-insert-command}\c
\findex{self-insert-command}
attached to printing characters, \samp{$} is bound
to \code{LaTeX-dollar}\c
\findex{LaTeX-dollar}
which has been programmed to deal with the three
different meanings of the dollar sign.\c
\cindex{dollar sign}
Few editors outside the Emacs family could do this;
the critical feature is that \emph{any character}
can run \emph{any function}.\refill

What if you really just wanted a single plain
dollar sign,\c
\cindex{dollar sign}
with no preceding backslash?\c
\cindex{backslash}
Well, that is easy.  In Emacs, any character can be
\emph{quoted}, which causes it to be inserted directly
into the buffer; the \code{quoted-insert}\c
\findex{quoted-insert}
function is normally bound to \kbd{C-q},\c
\kindex{C-q}
but that too can be changed.
Thus, \kbd{C-q $}\c
\kindex{C-q $}
will get you a literal\c
\cindex{literal}
dollar sign,\c
\cindex{dollar sign}
if that is
what you really want.\refill

The function \code{LaTeX-equation}\c
\findex{LaTeX-equation}
on \kbd{C-c =}\c
\kindex{C-c =}
generates\refill
\begin{verbatim}
  \begin{equation}
<cursor>
  \end{equation}
\end{verbatim}
\pindex{\back begin\penalty0\{equation\}}
\pindex{\back end\penalty0\{equation\}}

\noindent
with the cursor\c
\cindex{cursor}
between them.
\code{LaTeX-displaymath}\c
\findex{LaTeX-displaymath}
on \kbd{C-c C-c =}\c
\kindex{C-c C-c =}
inserts\refill
\begin{verbatim}
  \begin{displaymath}
<cursor>
  \end{displaymath}
\end{verbatim}
\pindex{\back begin\penalty0\{displaymath\}}
\pindex{\back end\penalty0\{displaymath\}}

All math mode environments
(\samp{array},
\samp{eqnarray*},
\samp{eqnarray},
\samp{math}, and
\samp{theorem})
can be also generated by
\code{LaTeX-begin-end-block}\c
\findex{LaTeX-begin-end-block}
on \kbd{C-c b},\c
\kindex{C-c b}
and additional ones can be easily
added;
\pxref{Customizing lists}.\refill

\begin{sloppypar}
\code{LaTeX-subscript}\c
\findex{LaTeX-subscript}
on \kbd{_}\c
\kindex{_}\c
\cindex{underscore}
(underscore) and \code{LaTeX-superscript}\c
\findex{LaTeX-superscript}
on \kbd{^}\c
\kindex{^}\c
\cindex{caret}
(caret) generate braced subscript\c
\cindex{subscript}
and superscript\c
\cindex{superscript}
sequences, leaving the cursor\c
\cindex{cursor}
between the braces
\cite{vonBechtolsheim:TQ7-195}.\c
\tindex{von Bechtolsheim, Stephan}\refill
\end{sloppypar}

\node Dots and commas and quotation marks, Font changes, Math mode, LaTeX support

\section{Dots, commas, and quotation marks}
\cindex{comma}
\cindex{quotation mark}
The dot\c
\cindex{dot}
or period\c
\cindex{period}
(full stop,\c
\cindex{full stop}
to some of you) is an overloaded character.
Normally, it just means end of sentence.\c
\cindex{end of sentence}\c
\cindex{sentence end}
Sometimes, it ends an abbreviation\c
\cindex{abbreviation}
in the middle
of a sentence.  It can also be a decimal point, as
in 3.14159.  Still other times, it appears in
ellipses,\c
\cindex{ellipsis}
as in centered dots
(\samp{\back cdots}),\c
\pindex{\back cdots}
diagonal dots
(\samp{\back ddots}),\c
\pindex{\back ddots}
ellipses
(\samp{\back ldots}),\c
\pindex{\back ldots}
and vertical dots
(\samp{\back vdots}).\c
\pindex{\back vdots}\refill

In typography, these uses are distinguished by
small changes in spacing after the dots.  That is
why \TeX{} provides control sequences for the
ellipses, and the \LaTeX{} book
\cite[p.\ 14]{Lamport:latex}\c
\tindex{Lamport, Leslie}
recommends that you type a \samp{\back <space>}\c
\pindex{\back \protect<space\protect>}
sequence
after a period that does not end a sentence.\c
\cindex{end of sentence}\c
\cindex{sentence end}\refill

\TeX{} assumes that a period following an
upper-case letter does not end a sentence\c
\cindex{end of sentence}\c
\cindex{sentence end}
(it might be someone's initial)\c
\cindex{initial}
\cite[pp. 74, 311]{Knuth:texbook},\c
\tindex{Knuth, Donald. E.}
and follows it with a smaller amount of space.
The \emph{\LaTeX{} User's Guide and Reference
Manual} recommends insertion of
\samp{\back @}\c
\pindex{\back @}
before a sentence-ending\c
\cindex{end of sentence}\c
\cindex{sentence end}
dot that follows an
upper-case letter in order to get additional
space after the dot.\refill

\code{LaTeX-mode}\c
\findex{LaTeX-mode}
handles these intricacies by
binding dot to the function \code{LaTeX-dot}.\c
\findex{LaTeX-dot}
That function examines what is immediately before
the dot in the buffer, and takes one of several
actions:\refill
\begin{itemize}

\item
If the dot ends an ellipsis,\c
\cindex{ellipsis}
the three
dots are replaced by
\samp{\back ldots\{\}}.\c
\pindex{\back ldots}\refill

\item
If the dot is preceded by an italic
correction\c
\cindex{italic correction}
at group end,
\samp{\back /\}},\c
\pindex{\back /}
the italic
correction is removed.\refill

\item
If the dot ends an abbreviation,\c
\cindex{abbreviation}
like
\emph{e.g.} or \emph{i.e.}, it inserts a
\samp{\back <space>}\c
\pindex{\back \protect<space\protect>}
command or a comma,\c
\cindex{comma}
depending
on whether the variable
\code{LaTeX-comma-after-dotted-abbreviation}\c
\vindex{LaTeX-comma-after-dotted-abbreviation}
is \code{nil} or non-\code{nil}.
Traditionally, such abbreviations\c
\cindex{abbreviation}
are
followed by a comma,\c
\cindex{comma}
but modern tendency
is to omit the comma
\cite[p.\ 84]{Shertzer:grammar},\c
\tindex{Shertzer, Margaret}
although Knuth disagrees
\cite[p.\ 74]{Knuth:texbook}.\c
\tindex{Knuth, Donald. E.}\refill

\item
If the previous characters are
abbreviations\c
\cindex{abbreviation}
like \emph{Fig.}, \emph{cf.},
\emph{vs.}, and
\emph{resp.}
\cite[p.\ 74]{Knuth:texbook}\c
\tindex{Knuth, Donald. E.}
\cite[p.\ 18]{Lamport:latex}\c
\tindex{Lamport, Leslie}
that should be tied to the following
word with a single unbreakable space,
the function inserts a tilde\c
\cindex{tilde}
to mark the\c
\cindex{tie}
tie.\refill

\item
If the dot follows two or more
upper-case letters, the dot is prefixed by
\samp{\back @}.\c
\pindex{\back @}\refill
\end{itemize}
To prevent confusion with words at end of
sentence,\c
\cindex{end of sentence}\c
\cindex{sentence end}
abbreviations\c
\cindex{abbreviation}
are not recognized if they
are immediately preceded by a letter in the
editing buffer.\refill

The abbreviations\c
\cindex{abbreviation}
known to \code{LaTeX-dot}\c
\findex{LaTeX-dot}
are defined by the variable
\code{LaTeX-standard-dotted-abbreviations}.\c
\vindex{LaTeX-standard-dotted-abbreviations}
More can be added by a suitable definition of the
variable
\code{LaTeX-extra-dotted-abbreviations},\c
\vindex{LaTeX-extra-dotted-abbreviations}
such as this example:\refill
\begin{verbatim}
(setq LaTeX-extra-dotted-abbreviations
      '(
        ("ad. lib.")
        ("cwt.")
        ("q.e.d.")
        )
      )
\end{verbatim}

\noindent
\xref{Customizing lists}
for more details.\refill

The abbreviations\c
\cindex{abbreviation}
for which ties\c
\cindex{tie}
are supplied are similarly defined by the
variables
\code{LaTeX-standard-tied-abbreviations}\c
\vindex{LaTeX-standard-tied-abbreviations}
and
\code{LaTeX-extra-tied-abbreviations}.\c
\vindex{LaTeX-extra-tied-abbreviations}\refill

\code{LaTeX-dot}\c
\findex{LaTeX-dot}
cannot tell whether a dot
following an upper-case letter is a
sentence-ending\c
\cindex{end of sentence}\c
\cindex{sentence end}
one or not, so it only inserts
\samp{\back @}\c
\pindex{\back @}
before a dot if there are \emph{two or more}
preceding upper-case letters.  It is up to the
user to remember to insert
\samp{\back @}\c
\pindex{\back @}
in the exceptional case of a single final
upper-case letter.\refill

What about a dot after a macro that expands to a
word ending in an upper-case letter, like \TeX{}
itself?  No
\samp{\back @}\c
\pindex{\back @}
is necessary there, because \TeX{} treats that dot
as a normal end of sentence.\c
\cindex{end of sentence}\c
\cindex{sentence end}\refill

These actions cover most of the common cases, but
of course, for abbreviations,\c
\cindex{abbreviation}
cannot be
omniscient.  Dictionaries that I consulted listed
over a thousand abbreviations\c
\cindex{abbreviation}
in use in English.
Fewer than a dozen of the commonest ones are
included in
\code{LaTeX-standard-dotted-abbreviations},\c
\vindex{LaTeX-standard-dotted-abbreviations}
but customization of
\code{LaTeX-extra-dotted-abbreviations}\c
\vindex{LaTeX-extra-dotted-abbreviations}
provides a way to add new ones.\refill

Emacs' \code{quoted-insert}\c
\findex{quoted-insert}
function saves the day when you want to suppress
all of this wizardry; just type \kbd{C-q .}\c
\kindex{C-q .}
to get a literal\c
\cindex{literal}
dot inserted.\refill

\begin{sloppypar}
\code{LaTeX-comma}\c
\findex{LaTeX-comma}
bound to comma\c
\cindex{comma}
removes any immediately preceding italic
correction,\c
\cindex{italic correction}
and then inserts a comma.\refill
\end{sloppypar}

Italic corrections\c
\cindex{italic correction}
are somewhat of a nuisance, since you are supposed
to have them after italicized text, \emph{except}
a period or a comma,\c
\cindex{comma}
which are so low that it
doesn't matter if the character to their immediate
left leans over them.  Those two exceptions make
it hard to write a \TeX{} macro to determine
whether the correction is needed or not.  I'd
rather let Emacs remember for me, so I programmed
it to do so.\refill

Good typography uses different opening and closing
quotation marks;
\cindex{quotation mark}
in \TeX{}, you get ``quoted text'' by typing
\samp{``quoted text''}.
Because many people are accustomed to using the
double quotation mark character, \samp{"}, found
on computer keyboards and typewriters, the
function \code{LaTeX-quote}\c
\findex{LaTeX-quote}
is bound to
that character.  It generates the correct paired
opening grave accents,\c
\cindex{opening apostrophe}\c
\cindex{grave accent}
\samp{``}, or closing apostrophes,\c
\cindex{closing apostrophe}\c
\cindex{apostrophe}
\samp{''}, as appropriate: the input
\samp{"quoted text"} expands to \samp{``quoted
text''} in the edit buffer. With an argument,
the function inserts a bare double quotation mark;
you can get the same effect from
\code{quoted-insert}\c
\findex{quoted-insert}
by typing \kbd{C-q "}.\c
\kindex{C-q "}\refill

\node Font changes, Comments, Dots and commas and quotation marks, LaTeX support

\section{Font changes}
\cindex{font change}
The \code{LaTeX-macro}\c
\findex{LaTeX-macro}
function on \kbd{C-c m}\c
\kindex{C-c m}
lets you easily generate font changes to any of
\LaTeX{}'s eight standard styles, including
supplying the italic correction\c
\cindex{italic correction}
in the three
leaning font styles (\samp{\back em},\c
\pindex{\back em}
\samp{\back it},\c
\pindex{\back it}
and
\samp{\back sl}).\c
\pindex{\back sl}\refill

But what if you are revising a document, and
decide to add a font change?  Well, you could use
\kbd{C-c m}\c
\kindex{C-c m}
to do it, but then you'd have to move
the closing brace, and any preceding italic
correction.\refill
\cindex{italic correction}

\code{LaTeX-mode}\c
\findex{LaTeX-mode}
provides a better solution:
customized functions \emph{wrap} a font
change\c
\cindex{font change}
around the current word, or if a numeric
argument is given, around that many words starting
from the current one.  These functions are listed
in Table 7.  \c\ref{fig-bindings-2}.
They are almost the only functions that require a
second prefix character; \kbd{C-c C-c e}\c
\kindex{C-c C-c e}
(\code{LaTeX-font-em})\c
\findex{LaTeX-font-em}
is easy to type, and retains mnemonic
significance.  These functions handle the italic
correction\c
\cindex{italic correction}
properly; leaning
fonts get it unless the character following the
last word is a period or a comma.\c
\cindex{comma}\refill

\node Comments, Mismatched delimiters, Font changes, LaTeX support

\section{Comments}
\TeX{} provides an inline comment\c
\cindex{inline comment}\c
\cindex{comment}
mechanism with the percent sign.  It discards text
from that character to the end of the line, plus
\emph{all leading space on the next line up to,
but not including, its end-of-line
character}.\refill

Sometimes, however, you want to temporarily
suppress typesetting of a part of a document
without actually removing it from the file.  One
way is to insert leading percents on each line of
the region to be suppressed, but that is tedious
to do manually.  A second way is to use \LaTeX{}'s
\file{ifthen} style option\c
\cindex{option}
which added loops and
conditionals, but appeared after the \emph{\LaTeX{}
User's Guide and Reference Manual} was written,
and so is not widely known.  A third way is to
define a \LaTeX{} macro like\refill
\begin{verbatim}
\newcommand{\comment}[1]{}
\end{verbatim}
\pindex{\back newcommand}

\noindent
However, that won't work if the argument contains
paragraph breaks.  You could drop down to
low-level \TeX{} and write\refill
\begin{verbatim}
\long\def\comment#1{}
\end{verbatim}
\pindex{\back long}\c
\pindex{\back def}\c
\pindex{\back comment}

\noindent
but \LaTeX{} users are not supposed to do that,
except in style files.\c
\cindex{style file}
Also, both of these macros
risk overflowing \TeX{}'s input buffer,\c
\cindex{overflow of buffer}\c
\cindex{buffer overflow}
since the complete argument might be rather long,
even if it is subsequently discarded.\refill

I often wish that \LaTeX{} had provided a standard
\samp{comment} environment to do this; it could be
implemented much like \samp{verbatim}, except that
it must support properly nested \samp{comment}
environments.  Rainer Sch\"opf
has implemented a version of a \samp{comment}
environment in a new \samp{verbatim}
implementation for \LaTeX{}
\cite{Schoepf:TB11-2-284-296},\c
\tindex{Schoepf, Rainer}
although nested comments are not yet supported.\refill

The solution provided by \code{LaTeX-mode}\c
\findex{LaTeX-mode}
is the function \code{LaTeX-comment}\c
\findex{LaTeX-comment}
on \kbd{C-c %}\c
\kindex{C-c %}
which implements the first choice
above.  By default, it comments out the current
paragraph, or with an argument, the current
region.  The comment prefix inserted at the
beginning of each line is defined by the variable
\code{LaTeX-comment-prefix};\c
\vindex{LaTeX-comment-prefix}
its default value
is \samp{%%:<space>}.  A unique prefix is desirable to
distinguish such lines from ordinary comments.
You should avoid using any regular-expression\c
\cindex{regular expression}
matching characters in it.\refill

You can remove the comments inserted by
\code{LaTeX-comment}\c
\findex{LaTeX-comment}
by using the function
\code{LaTeX-uncomment}\c
\findex{LaTeX-uncomment}
on \kbd{C-c u}.\c
\kindex{C-c u}
It should normally be used with an argument to act
on a region, instead of a paragraph.  The reason
for this is that paragraphs are recognized
according to the regular expression\c
\cindex{regular expression}
in the Emacs
variable \code{paragraph-separate};\c
\vindex{paragraph-separate}
the default setting is such that a line containing
only a comment ends a paragraph.  Consequently,
\code{LaTeX-uncomment}\c
\findex{LaTeX-uncomment}
will do nothing because
its `paragraph' is always empty.  Invoking it with
an argument to process a marked region solves the
problem.\refill

\node Mismatched delimiters, Mismatched environments, Comments, LaTeX support

\section{Mismatched delimiters}
\cpsubindex{mismatch}{of delimiter}\c
\cindex{delimiter mismatch}
\TeX{} gets very unhappy when it finds mismatched
braces, and in complex documents, it can sometimes
be difficult to find them.  The job is not made
easier on low-resolution screen displays where
braces and parentheses are virtually
indistinguishable.  Finding such mismatches is a
job for a computer, not a human, and
\code{LaTeX-mode}\c
\findex{LaTeX-mode}
offers you help.\refill

Braces are not the only things you might want
assistance with.  Checking for mismatched
parentheses, square brackets, and angle brackets
is also supported.  These normally insert
themselves when you type them, but
\code{LaTeX-mode}\c
\findex{LaTeX-mode}
has commands that insert pairs: typing
\kbd{C-c \{} \c cannot index this because of latexinfo bug
gets you a pair of open and close
braces, and similarly for
\kbd{C-c [}, \c ] match
\kindex{C-c [}\c ] match
\kbd{C-c (}, \c ) match
\kindex{C-c (}\c ) match
and
\kbd{C-c <}. \c > match
\kindex{C-c <}\c > match
These are the default bindings\c
\cindex{key binding}
of the functions
\code{LaTeX-braces},\c
\findex{LaTeX-braces}
\code{LaTeX-brackets},\c
\findex{LaTeX-brackets}
\code{LaTeX-parentheses},\c
\findex{LaTeX-parentheses}
and
\code{LaTeX-angles}.\c
\findex{LaTeX-angles}\refill

If you get in the habit of using these instead of
typing the delimiter pair yourself, you will
rarely have mismatch problems.  Emacs itself has
native delimiter matching support: as you type a
close delimiter, the cursor flashes
\cindex{cursor flash}
briefly to the matching open delimiter.\refill

But what if you didn't follow my advice, typed a
lot of braces yourself, and then when \TeX{}
complained about unbalanced braces, you couldn't
find the errors?  Well, the function
\code{LaTeX-check-brace-balance}\c
\findex{LaTeX-check-brace-balance}
bound to
\kbd{C-c \}} \c cannot index this because of latexinfo bug
will scan the buffer from the current point to the
end, checking for unbalanced braces, and brace
pairs separated by unusually long strings, but
ignoring backslashed\c
\cindex{backslash}
braces.  It complains if it
finds a paragraph break between braces, unless you
give it an argument.
If mismatches are detected, you are so informed,
and the positions of the mismatches are remembered
on Emacs' stack of marks,\c
\cindex{mark stack}
so you can easily get to them.\refill

\begin{sloppypar}
Similar functions
\code{LaTeX-check-angle-balance},\c
\findex{LaTeX-check-angle-balance}
\code{LaTeX-check-bracket-balance},\c
\findex{LaTeX-check-bracket-balance}
and
\code{LaTeX-check-parenthesis-balance}\c
\findex{LaTeX-check-parenthesis-balance}
are provided on
\c << match
\kbd{C-c >},\c
\kindex{C-c >}
\c [[ match
\kbd{C-c ]},\c
\kindex{C-c ]}
and
\c (( match
\kbd{C-c )},\c
\kindex{C-c )}
for checking those delimiter balances.  Note the
key binding symmetry:\c
\cindex{key binding}
\kbd{C-c open-delimiter}
inserts the pair, and \kbd{C-c close-delimiter}
checks the balance.\refill
\end{sloppypar}

The characters \samp{<} and \samp{>} are likely to
be used in math mode,\c
\cindex{math mode}
and not require balancing.
However, you might also have used them for other
purposes.  In such a case, you can just add
matching delimiters inside comments in your math mode
uses, and then \kbd{C-c >}\c
\kindex{C-c >}
will work satisfactorily.\refill

There is also
\code{LaTeX-check-dollar-balance}\c
\findex{LaTeX-check-dollar-balance}
on \kbd{C-c $}.\c
\kindex{C-c $}
It looks for dollar\c
\cindex{dollar sign}
pairs separated by long
strings, ignoring backslashed\c
\cindex{backslash}
dollars.\c
\cindex{dollar sign}
It also
complains about paragraph breaks between dollar\c
\cindex{dollar sign}
pairs, unless it is given an argument.  There is
no way for a computer program that is much less
complex than \TeX{} to tell the inside of math
mode from the outside, so you can confuse this
function by starting it inside math mode.\refill

\begin{sloppypar}
The Emacs variables
\code{LaTeX-angle-interval},\c
\vindex{LaTeX-angle-interval}
\code{LaTeX-brace-interval},\penalty0\c
\vindex{LaTeX-brace-interval}
\code{LaTeX-bracket-interval},\c
\vindex{LaTeX-bracket-interval}
\code{LaTeX-dollar-interval},\c
\vindex{LaTeX-dollar-interval}
and
\code{LaTeX-parenthesis-interval}\c
\vindex{LaTeX-parenthesis-interval}
set the limiting between-delimiter string length
before a warning is raised; their default values
are each set to 500 characters.\refill
\end{sloppypar}

\node Mismatched environments, Word abbreviations, Mismatched delimiters, LaTeX support

\section{Mismatched environments}
\cpsubindex{mismatch}{of environment}\c
\cpsubindex{environment}{mismatch}
\begin{sloppypar}
If you have a complex document where
\samp{\back begin\penalty0\{...\}}\c
\pindex{\back begin\penalty0\{...\}}
\dots \samp{\back end\penalty0\{...\}}\c
\pindex{\back end\penalty0\{...\}}
groups have been typed manually, you can also
end up with mismatched environments that are
hard to find.\refill
\end{sloppypar}

The command \kbd{M-x check-LaTeX-nesting}\c
\kindex{M-x check-LaTeX-nesting}\c
\cindex{nesting check}
scans the buffer to ensure the correctness of
\samp{\back begin\penalty0\{...\}}\c
\pindex{\back begin\penalty0\{...\}}
\dots \samp{\back end\penalty0\{...\}}\c
\pindex{\back end\penalty0\{...\}}
nesting.  If, for example, your buffer contains a
nesting error\c
\cindex{nesting error}
like this\refill
\begin{verbatim}
  \begin{verse}
...
    \begin{quote}
...
  \end{verse}
...
    \end{quote}
\end{verbatim}
\pindex{\back begin\penalty0\{verse\}}
\pindex{\back end\penalty0\{verse\}}\c
\pindex{\back begin\penalty0\{quote\}}\c
\pindex{\back end\penalty0\{quote\}}

\noindent
the command will terminate with the cursor\c
\cindex{cursor}
in front of the \samp{\back end\penalty0\{verse\}}\c
\pindex{\back end\penalty0\{verse\}}
with the error message\refill
\begin{verbatim}
This \end{verse} is matched by preceding \begin{quote} 
at mark.
\end{verbatim}
\noindent
The Emacs function
\code{exchange-point-and-mark}\c
\findex{exchange-point-and-mark}
on \kbd{C-x C-x}\c
\kindex{C-x C-x}
will move the cursor\c
\cindex{cursor}
to the mismatching
\samp{\back begin\penalty0\{quote\}}.\c
\pindex{\back begin\penalty0\{quote\}}
After fixing the error, you can rerun the nesting
check\c
\cindex{nesting check}
by typing \kbd{C-x ESCape}\c
\kindex{C-x ESCape}
(\code{repeat-complex-command})\c
\findex{repeat-complex-command}
until it finally reports\refill
\begin{verbatim}
[done] -- all \begin{}-end{}s balance.
\end{verbatim}

The command
\kbd{M-x indent-LaTeX-begin-end-groups}\c
\kindex{M-x indent-LaTeX-begin-end-groups}
indents
\samp{\back begin\penalty0\{...\}}\c
\pindex{\back begin\penalty0\{...\}}
\dots \samp{\back end\penalty0\{...\}}\c
\pindex{\back end\penalty0\{...\}}
groups according to their nesting level,\c
\cindex{nesting level}
which helps to make the input file more
readable.\refill

You don't need these commands very often, so
they do not have default key bindings.\c
\cindex{key binding}\refill

\node Word abbreviations, Bibliographies, Mismatched environments, LaTeX support

\section{Word abbreviations}
Emacs provides a convenient word abbreviation\c
\cindex{word abbreviation}\c
\cindex{abbreviation}
facility
that permits the automatic expansion of a
string of letters when the following space\c
\cindex{space}
or punctuation\c
\cindex{punctuation}
is typed.  \code{LaTeX-mode}\c
\findex{LaTeX-mode}
provides this by default with a set of
abbreviations\c
\cindex{abbreviation}
in a table that can be customized
for personal use.\refill

You can find the complete set of abbreviations by
examining the value of the variable
\code{LaTeX-mode-abbrev-table},\c
\cindex{word abbreviation}\c
\cindex{abbreviation}\c
\vindex{LaTeX-mode-abbrev-table}
or by invoking
the function \code{list-abbrevs}.\c
\findex{list-abbrevs}
You can make changes most easily with
\kbd{M-x edit-abbrevs}.\c
\kindex{M-x edit-abbrevs}\c
\cindex{edit-abbrevs}\refill

The commonest abbreviations recognized in
\code{LaTeX-mode}\c
\findex{LaTeX-mode}
are for macro names that are awkward to type: the
input
\samp{latex } expands to \samp{\back LaTeX\{\} },\c
\pindex{latex to \back LaTeX\{\} }
\samp{tex } to \samp{\back TeX\{\} },\c
\pindex{tex to \back TeX\{\}}
and so on.\refill

\begin{sloppypar}
Note particularly that the expansion here is to
\samp{\back TeX\{\}},
and \emph{not}
\samp{\back TeX\back<space>}!\c
\pindex{\back TeX\{\} vs.\ \back TeX\back }
\c ????????????????????????????????????????
\c \cindex{tex vs. tex@\samp{\back TeX\{\}} vs.
\c \samp{\back TeX\protect\back\protect<space\protect>}}
\c ????????????????????????????????????????
There are good reasons for this:\refill
\end{sloppypar}
\begin{itemize}

\item
If you terminate macro names with
\samp{\back <space>}\c
\pindex{\back \protect<space\protect>}
instead of with
\samp{\{\}},
you have to remember to do that only
where a space would really be
permitted; in particular, you don't
want the \samp{\back <space>}\c
\pindex{\back \protect<space\protect>}
before
punctuation. You can use \samp{\{\}}
consistently in both cases.\refill

\item
If the \samp{\back <space>}\c
\pindex{\back \protect<space\protect>}
appears at
the end of a line, and trailing
spaces\c
\cpsubindex{space}{trailing}
are subsequently stripped, you
now have a new macro equivalent to
\samp{\back ^^M},\c
\pindex{\back ^^M}
which might have a
different meaning.  Although both
\file{plain.tex}\c
\cindex{plain.tex}
and
\file{lplain.tex}\c
\cindex{lplain.tex}
make the two macros
equivalent, that might not always be
the case.\refill

You should never count on end-of-line
blanks being preserved; some e-mail
\cpsubindex{mail}{electronic}\c
\cindex{e-mail}
systems, and some editors, may delete
them.  Text filling and justification
as commonly used in Emacs can also
remove them.\refill

\item
In composite words, like
\samp{\back TeX\{\}book},\c
\cindex{\back TeX\{\}book}
the braces keep
the parts together for text fill
operations, word counting, spell
checking and so forth, while the form
\samp{\back TeX book}\c
\cindex{\back TeX book}
will not.\refill
\end{itemize}
The form \samp{\{\back TeX\}}\c
\pindex{\{\back TeX\}}
has the almost same
advantages over
\samp{\back TeX\back <space>}\c
\pindex{\back TeX\back \protect<space\protect>}
as
\samp{\back TeX\{\}}\c
\pindex{\back TeX\{\}}
does, but has one drawback: if you need to
\samp{\back protect}\c
\pindex{\back protect}
it, then you must do so inside the
braces.  Use of a final empty brace pair therefore
seems the best choice.\refill

By Emacs convention, word abbreviation\c
\cindex{abbreviation}\c
\cindex{word abbreviation}
mode is
never turned on automatically; you must explicitly
toggle it on a case-by-case basis by executing the
command \kbd{M-x abbrev-mode}.\c
\kindex{M-x abbrev-mode}
If you always want
it selected in \code{LaTeX-mode},\c
\findex{LaTeX-mode}
add it to your \file{.emacs}\c
\cindex{startup file}\c
\cindex{.emacs file}
file in a
mode hook:\c
\cindex{mode hook}\c
\cindex{hook}\refill
\begin{verbatim}
(setq LaTeX-mode-hook
      '(lambda ()
         (abbrev-mode 1)
         )
      )
\end{verbatim}
\vindex{LaTeX-mode-hook}\c
\findex{lambda}

\noindent
If you have other things to set in that mode hook,\c
\cindex{hook}
they should go on the lines immediately before or
after the \samp{(abbrev-mode 1)} line, since there
can be only one mode hook for each editing mode.\refill

\node Bibliographies, Indexing, Word abbreviations, LaTeX support

\section{Bibliographies}
\cindex{bibliography}
Literature citations are conveniently provided for
on \kbd{C-c c}\c
\kindex{C-c c}
(\code{LaTeX-cite}),\c
\findex{LaTeX-cite}
which generates a \samp{\back cite\{\}}\c
\pindex{\back cite\{\}}
command with the cursor\c
\cindex{cursor}
after the open brace.  With
an argument, it produces \samp{\back cite[]\{\}}\c
\pindex{\back cite[]\{\}}
instead, with the cursor\c
\cindex{cursor}
between the square brackets.\refill

There is another function,
\code{LaTeX-bibitem},\c
\findex{LaTeX-bibitem}
on \kbd{C-c C-b},\c
\kindex{C-c C-b}
which generates a
\samp{\back bibitem\{\}}\c
\pindex{\back bibitem\{\}}
for you;
with an argument, it produces
\samp{\back bibitem[]\{\}}.\c
\pindex{\back bibitem[]\{\}}
Normally, you should be using a program like
Bib\TeX{}
\cite[Appendix B]{Lamport:latex}\c
\tindex{Lamport, Leslie}\c
\cindex{Bib\TeX{}}
or \file{Tib}\c
\cindex{Tib}
\cite{Alexander:TB7-3-138,Alexander:TB8-2-102}\c
\tindex{Alexander, James}
for preparation of bibliographies from a data base
and the citations recorded in the \LaTeX{}
\file{.aux}\c
\cindex{.aux file}
file.   If you find yourself using
this command, you are doing the job the hard and
inflexible way.\refill

\code{LaTeX-mode}\c
\findex{LaTeX-mode}
automatically invokes the function
\code{update-LaTeX-bibtags}\c
\findex{update-LaTeX-bibtags}
to extract the list of bibliography files
from the \samp{\back bibdata}\c
\pindex{\back bibdata}
command in the \file{.aux}\c
\cindex{.aux file}
file, or the \samp{\back bibliography}\c
\pindex{\back bibliography}
command in the \LaTeX{} file.
Each such file is then located in the
\code{BIBINPUTS}\c
\vindex{BIBINPUTS}
search path, and scanned to extract citation
tags which are stored as an association list
in the variable
\code{LaTeX-bibtags}\c
\vindex{LaTeX-bibtags}.
Each list entry contains a citation tag and the
name of the file in which the tag was found.\refill

If the \code{BIBINPUTS}\c
\vindex{BIBINPUTS}
environment variable is not set, then the Emacs
variable
\code{LaTeX-BIBINPUTS}\c
\vindex{LaTeX-BIBINPUTS}
is used instead to get a suitable search
path.\refill

You can view the citation tag list by invoking
the function \code{show-LaTeX-bibtags}.\c
\findex{show-LaTeX-bibtags}\refill

You can request completion on a citation tag
inside a \samp{\back cite}\c
\pindex{\back cite}
command by using the function
\code{LaTeX-bibtag-with-completion}\c
\findex{LaTeX-bibtag-with-completion}
normally bound to \kbd{C-c C}.\c
\kindex{C-c C}\refill

If you are visiting a subfile in a multi-file
document, or have just modified the list of
bibliography files in the
\samp{\back bibliography}\c
\pindex{\back bibliography}
command, you should manually run
\code{update-LaTeX-bibtags}\c
\findex{update-LaTeX-bibtags}
to update the variable
\code{LaTeX-bibtags}.\c
\vindex{LaTeX-bibtags}\refill

\node Indexing, Cross-references, Bibliographies, LaTeX support

\section{Indexing}
\label{indexing}\c
\cindex{indexing}
Index preparation is a tedious job that cannot be
entirely automated
\cite{Aurbach:TQ3-1,Bentley:EPODD-1-1-3,Chen:UCB-TR-87-347,Chen:SPE-19-9-897,Lamport:makeindex}.\c
\tindex{Aurbach, R. L.}\c
\tindex{Bentley, J. L.}\c
\tindex{Kernighan, B. W.}\c
\tindex{Lamport, Leslie}\c
\tindex{Chen, Pehong}\c
\tindex{Harrison, Michael A.}
Nevertheless, technical documents can benefit
significantly from a good index, and support tools
like \file{makeindex}\c
\cindex{makeindex utility}
or \file{texindex}\c
\cindex{texindex utility}
can handle much of the drudge work of sorting and
formatting the index entries.\refill

\code{LaTeX-mode}\c
\findex{LaTeX-mode}
provides two functions to support generation of
index entries in the \LaTeX{} file.\refill

\code{LaTeX-add-word-to-index}\c
\findex{LaTeX-add-word-to-index}
on \kbd{C-c .}\c
\kindex{C-c .}
wraps an index entry around the word at the cursor\c
\cindex{cursor}
position, either using a private indexing macro
like \samp{\back X}\c
\pindex{\back X}
described earlier
(\pxref{Creating a new LaTeX file}),
or by duplicating the word inside a standard
\LaTeX{} \samp{\back index}{}\c
\pindex{\back index}
command.  The choice
between the two is determined by the Emacs
variable
\code{LaTeX-index-macro};\c
\vindex{LaTeX-index-macro}
a non-\code{nil} value supplies the indexing macro
name.  With a numeric argument, multiple words can
be selected for indexing.\refill

\code{LaTeX-index}\c
\findex{LaTeX-index}
on \kbd{C-c x}\c
\kindex{C-c x}
generates\refill

\noindent
\samp{\back index\{<cursor>\}}\c
\pindex{\back index}

\noindent
so you can type an explicit index entry that will
not appear at that point in the text.\refill

For use in the X Window System\c
\cindex{X Window System}
on workstations and
personal computers acting as X clients,
\file{latex.el} provides additional functions,
\code{x-LaTeX-index-start}\c
\findex{x-LaTeX-index-start}
and
\code{x-LaTeX-index-end}\c
\findex{x-LaTeX-index-end}
that are bound to mouse\c
\cindex{mouse}
actions; they cannot
usefully be invoked from the keyboard.\refill

To index a phrase in the document like
\emph{gnats and gnus}, simply hold down the shift
key and click the right mouse\c
\cindex{mouse}
button at the start of the first word, and then
holding the button down, sweep the mouse\c
\cindex{mouse}
across
the entire phrase, lifting the button anywhere in
the last word.  Bingo: the buffer now contains
\samp{\back X\{gnats and gnus\}}!\c
\cindex{gnats and gnus}\refill

I find it useful to sit down with a typeset copy
of a document, and use a colored highlighter
pen\c
\cindex{highlighter pen}
to mark phrases to be indexed.  With the
marked-up copy, it is then straightforward to use
the mouse\c
\cindex{mouse}
to add the marked phrases to the index.
For documents like this one, with lots of
technical terms to be indexed, it pays to think
about matters before you start writing.  Define
suitable macros that will typeset those terms in a
particular font, and also automatically create an
index entry for them.  For example, I typeset and
index an Emacs function using a private
\samp{\back FUNCTION\{\}}\c
\pindex{\back FUNCTION\{\}}
macro.\refill
\cpsubindex{macros}{private}

The Emacs variable
\code{LaTeX-index-start-with-newline}\c
\vindex{LaTeX-index-start-with-newline}
can be set to a non-\code{nil} value if you prefer
to have the inserted index entry start a new line.
The variable
\code{LaTeX-index-end-with-newline}\c
\vindex{LaTeX-index-end-with-newline}
can be set to a non-\code{nil} value to have a
newline generated after the inserted index entry.
The default for both is \code{nil}, so that no
additional lines are generated.\refill

\node Cross-references, French typography, Indexing, LaTeX support

\section{Cross-references}
\LaTeX{}'s \samp{\back label},\c
\pindex{\back label}
\samp{\back pageref},\c
\pindex{\back pageref}
and
\samp{\back ref}\c
\pindex{\back ref}
commands provide a convenient way to
generate cross-references\c
\cindex{cross-references}
to equations,
figures, pages, sections, and tables.  In
\code{LaTeX-mode},\c
\findex{LaTeX-mode}
they are readily available
on the keys \kbd{C-c l}\c
\kindex{C-c l}
(that's the letter `l'),
\kbd{C-c p},\c
\kindex{C-c p}
and \kbd{C-c r}.\c
\kindex{C-c r}\refill

Since definitions with \samp{\back label}\c
\pindex{\back label}
tend to be
separated from their references, you may often
find yourself unable to remember the exact name of
the label you want.  If you type the label name
incorrectly, you won't discover the error until
you have run \LaTeX{} twice.  To avoid this delay,
two functions provide additional support:\refill
\begin{itemize}

\item
\code{show-LaTeX-labels}\c
\findex{show-LaTeX-labels}
finds all labels\c
\cpsubindex{labels}{in use}
in the buffer and displays them
with their line numbers; I ran that
function while I was writing a companion
article, and got the output\refill

\begin{ifinfo}
LaTeX labels for buffer ltxmode.ltx (in alphabetical order). Mouse-2 or C-c C-c goes to label.
1862: "X-command"
3793: "customizing-lists"
1324: "fig-bindings-1"
1455: "fig-bindings-2"
1258: "fig-latex-index"
1099: "fig-latex-mode-1"
1188: "fig-latex-mode-2"
4083: "fig-letter"
1554: "fig-startup-code"
748: "gnu-emacs-size"
3159: "indexing"
1487: "latex-support"
2030: "mode-hook"
2629: "quote"
2976: "word-abbreviations"
\end{ifinfo}
\begin{iftex}
\begin  {verbatim}
LaTeX labels for buffer ltxmode.ltx (in alphabetical \
order).  Mouse-2 or C-c C-c goes to label.
1862: "X-command"
3793: "customizing-lists"
1324: "fig-bindings-1"
1455: "fig-bindings-2"
1258: "fig-latex-index"
1099: "fig-latex-mode-1"
1188: "fig-latex-mode-2"
4083: "fig-letter"
1554: "fig-startup-code"
748: "gnu-emacs-size"
3159: "indexing"
1487: "latex-support"
2030: "mode-hook"
2629: "quote"
2976: "word-abbreviations"
\end{verbatim}
\end{iftex}
\noindent
showing the labels in alphabetical order.
With an argument, the labels are shown
instead in line number order.\refill

The labels are displayed a buffer in Emacs
\code{occur-mode}.  You can position to any
one of them, and then type \kbd{C-c}\kbd{C-c} to jump
to the location in the \LaTeX{} buffer where the
label is defined.  With Emacs version 19 or later,
you can also click the middle mouse button on an
entry in the label buffer: the cursor in the
\LaTeX{} buffer will move to the point of
definition and the label will be highlighted.\refill

\item
\code{check-LaTeX-labels}\c
\findex{check-LaTeX-labels}\c
\cpsubindex{labels}{checking validity of}
scans the entire buffer, looking for
labels that are referenced, but
undefined.  At each such label found, a
recursive edit\c
\cindex{recursive edit}
is entered to allow
you to supply the missing
label;\c
\cpsubindex{labels}{missing}
when you exit the recursive edit, the
search for undefined labels continues
from where it left off.\refill
\end{itemize}
These functions locate label references by
searching for the string defined by the variable
\code{LaTeX-label-reference};\c
\vindex{LaTeX-label-reference}
it contains a
regular expression\c
\cindex{regular expression}
that normally matches both
\samp{\back pageref}\c
\pindex{\back pageref}
and \samp{\back ref}.\c
\pindex{\back ref}
If you have
defined private macros
\cpsubindex{macros}{private}
that also receive labels
as arguments, you may wish to extend it.  For
example, the companion document has
\samp{\back FIGREF}\c
\pindex{\back FIGREF}
and
\samp{\back PAGEREF}\c
\pindex{\back PAGEREF}
macros that simplify
cross-referencing.\refill

Similarly, these functions locate label
definitions by searching for the string defined by
the variable \code{LaTeX-label-definition},\c
\vindex{LaTeX-label-definition}
another regular expression that normally matches
\samp{\back label}.\c
\pindex{\back label}
You may wish to customize it if
private macros
\cpsubindex{macros}{private}
also generate labels.\refill

Multi-file documents
\cpsubindex{labels}{in multi-file documents}
pose a challenge: labels
defined in one file may be referenced in another
file, and it would be helpful to be able to show a
list of all currently-defined labels when one is
needed for a cross-reference.\refill

It is not feasible for the code in \file{latex.el}
to attempt to figure out what files are used for a
particular document, nor is it acceptable to ask
the user to provide those file names.  Yet we
somehow need to scan those files to find all of
the labels.\refill

The solution is that \LaTeX{} can do part of this
job for us: \LaTeX{} processing of the master file
produces in the corresponding \file{.aux}\c
\cindex{.aux file}
file all defined labels embedded in \samp{\back
newlabel}\c
\pindex{\back newlabel}
commands.  The function
\code{update-LaTeX-labels}\c
\findex{update-LaTeX-labels}
\cpsubindex{labels}{in multi-file documents}
does the remainder of the job: it prompts for the
name of the master \file{.aux}\c
\cindex{.aux file}
file, and then
scans it to extract a list of labels from the
\samp{\back newlabel}\c
\pindex{\back newlabel}
commands.  This list is then
\emph{appended} to the current contents of the
variable \code{LaTeX-aux-file-label-tags}.\c
\vindex{LaTeX-aux-file-label-tags}
Augmentation, rather than replacement, permits
selective construction of list subsets by
multiple invocations of
\code{update-LaTeX-labels}\c
\findex{update-LaTeX-labels}
on different files.  \code{check-LaTeX-labels}\c
\findex{check-LaTeX-labels}
\cpsubindex{labels}{checking validity of}
includes the values from
\code{LaTeX-aux-file-label-tags}\c
\vindex{LaTeX-aux-file-label-tags}
in its list of defined labels.\refill

For convenience, whenever \code{LaTeX-mode}\c
\findex{LaTeX-mode}
is run (normally when a file is first visited), it
will search the buffer for the first \TeX{} macro
which is preceded only by optional whitespace on
its line.  If that macro is
\samp{\back documentstyle},\c
\pindex{\back documentstyle}
then the file must be the
master file for the document, so
\code{LaTeX-aux-file-label-tags}\c
\vindex{LaTeX-aux-file-label-tags}
is set to
\code{nil}, and \code{update-LaTeX-labels}\c
\findex{update-LaTeX-labels}
is automatically called on the corresponding
\file{.aux}\c
\cindex{.aux file}
file.  This means that manual
invocation of \code{update-LaTeX-labels}\c
\findex{update-LaTeX-labels}
is needed only when you visit a sub-file without
first visiting the master file.\refill

In recent versions of \file{latex.el},
\code{LaTeX-pageref}\c
\findex{LaTeX-pageref}
and \code{LaTeX-ref}\c
\findex{LaTeX-ref}
have been augmented by
\code{LaTeX-pageref-with-completion}\c
\findex{LaTeX-pageref-with-completion}
and
\code{LaTeX-ref-with-completion}.\c
\findex{LaTeX-ref-with-completion}
The new functions are bound to \kbd{C-c p}\c
\kindex{C-c p}
and \kbd{C-c r},\c
\kindex{C-c r}
replacing the bindings\c
\cindex{key binding}
to the older functions.  The new ones use an
internal function to dynamically scan the buffer
for \samp{\back label\{\}}\c
\pindex{\back label}
definitions, add the contents of
\code{LaTeX-aux-file-label-tags}\c
\vindex{LaTeX-aux-file-label-tags}
to the labels collected, and construct a list that
can be used for command completion.\c
\cindex{completion}\c
\cindex{command completion}
They then prompt for a label, and if you type a
query,\c
\cindex{query}\c
\kindex{?}
they will display the current list of labels.
\cpsubindex{labels}{in use}
You can use completion\c
\cindex{completion}\c
\cindex{command completion}
to select any one of them,
or you can enter an arbitrary label that is not in
the completion list.\refill

Here is what the completion list looks like for
this document:\refill
\begin{verbatim}
Possible completions are:
X-command                    customizing-lists
fig-bindings-1               fig-bindings-2
fig-latex-index              fig-latex-mode-1
fig-latex-mode-2             fig-letter
fig-startup-code             gnu-emacs-size
indexing                     latex-support
mode-hook                    word-abbreviations
\end{verbatim}
\cindex{completion}\c
\cindex{command completion}

Because the dynamic label scan that happens each
time these functions are executed may be slow in
large documents, the old functions remain
available for rebinding to keys.\c
\cindex{key binding}\refill

The Emacs variable
\code{LaTeX-label-start-with-newline}\c
\vindex{LaTeX-label-start-with-newline}
can be
set to a non-\code{nil} value if you prefer to
have the inserted label entry start a new line.
The variable
\code{LaTeX-label-end-with-newline}\c
\vindex{LaTeX-label-end-with-newline}
can be set
to a non-\code{nil} value to have a newline
generated after the inserted label entry.  The
default for both is \code{nil}, so that no
additional lines are generated.\refill

\node French typography, Miscellaneous functions, Cross-references, LaTeX support

\section{French typography}
\cindex{French typography}
English typographical\c
\cindex{English typography}\c
\cpsubindex{typography}{English}
conventions for spacing around punctuation are at
odds with good French typography.\c
\cpsubindex{typography}{French}
\TeX{}'s \samp{\back frenchspacing}\c
\pindex{\back frenchspacing}
macro \cite[p.\ 74]{Knuth:texbook}\c
\tindex{Knuth, Donald. E.}
\cite[p.\ 154]{Lamport:latex}\c
\tindex{Lamport, Leslie}
does not entirely satisfy French conventions: it
only makes spaces after punctuation the same as
interword spaces.\refill

In French typography,\c
\cindex{French typography}\c
\cpsubindex{typography}{French}
the punctuation characters
\samp{: ; ? !} are \emph{preceded} by an
unbreakable interword space (in \TeX{} language, a
\emph{tie}).\c
\cindex{tie}
Em-dashes\c
\cindex{em-dash (---)}
(---) are always surrounded
by spaces; in English typography, such spacing is
a matter of personal style.  Quotations are made
with guillemets\c
\cindex{guillemet}
as \samp{<<\ ...\ >>},\c
\cindex{<<\ \dots\ >>}
instead
of as ``\dots''; the open guillemet is followed
by a space, and the close one is preceded by a space.\refill

The GUTenberg\c
\cindex{GUTenberg}
organization has developed a standard \TeX{} and
\LaTeX{} style file,\c
\cindex{style file}
\file{french.sty},\c
\cindex{french.sty}
to provide
suitable definitions of the guillemets as the
control sequences
\samp{"<}\c
\kindex{"<}\c
\pindex{"<}
(or \samp{\back flqq})\c
\pindex{\back flqq}
and \samp{">}\c
\kindex{">}\c
\pindex{">}
(or \samp{\back frqq}),\c
\pindex{\back frqq}
as well as more
convenient accent primitives.\refill

It is tedious to remember to type the \TeX{} tie\c
\cindex{tie}
command everywhere that special French punctuation
spacing is required, so the minor mode function
\code{French-LaTeX-mode}\c
\findex{French-LaTeX-mode}
is provided in
\file{latex.el}.  Each time it is invoked, it
toggles between French and non-French conventions.
It can be used in either \TeX{} or \LaTeX{} files.\refill

\begin{sloppypar}
When French mode is selected, the Emacs mode
line\c
\cindex{mode line}
contains the string \samp{French}, and new
functions
\code{LaTeX-French-colon},\c
\findex{LaTeX-French-colon}
\code{LaTeX-French-exclamation},\c
\findex{LaTeX-French-exclamation}
\code{LaTeX-French-langle},\c
\findex{LaTeX-French-langle}
\code{LaTeX-French-minus},\c
\findex{LaTeX-French-minus}
\code{LaTeX-French-query},\c
\findex{LaTeX-French-query}
\code{LaTeX-French-rangle}, and\c
\findex{LaTeX-French-rangle}
\code{LaTeX-French-semicolon}\c
\findex{LaTeX-French-semicolon}
are bound to the appropriate keys.  The quotation
mark is rebound to
\code{self-insert-command}\c
\findex{self-insert-command}
so that the special handling normally provided by
\code{LaTeX-quote}\c
\findex{LaTeX-quote}
(\pxref{Dots and commas and quotation marks})
is suppressed.\refill
\end{sloppypar}

The French angle bracket\c
\cindex{angle bracket}
functions insert an angle bracket, expand
\samp{<<} to \samp{"<},\c
\kindex{"<}\c
\pindex{"<}\c
\kindex{<<}
and
\samp{>>} to \samp{">},\c
\kindex{">}\c
\pindex{">}\c
\kindex{>>}
and then supply the necessary ties.\c
\cindex{tie}
Isolated angle brackets are inserted without
further modification.  Guillemets can thus be
inserted either by typing their named control
sequences, or
by \samp{"<} or \samp{<<}, and \samp{">} or
\samp{>>}.\refill

\code{LaTeX-French-minus}\c
\findex{LaTeX-French-minus}
inserts a minus sign, and if it is the end of an
em-dash,\c
\cindex{em-dash (---)}
supplies surrounding spaces (\emph{not} ties).\refill

While it would be possible to have \TeX{} provide
for the French spacing requirements by suitable
macro definitions of active characters, such
redefinitions risk interfering with other macros.
It seems best to provide for the spacing
requirements in the input file itself, letting
Emacs remember the necessary rules.\refill

French mode can be customized by defining a
suitable value of the
\code{French-LaTeX-mode-hook}\c
\vindex{French-LaTeX-mode-hook}\c
\cindex{hook}
variable;
\pxref{LaTeX macros}.\refill

\node Miscellaneous functions, Miscellaneous variables, French typography, LaTeX support

\section{Miscellaneous functions}
\code{LaTeX-counter}\c
\findex{LaTeX-counter}
on \kbd{C-c k}\c
\kindex{C-c k}
generates a counter name\c
\cindex{counter name}
with completion,\c
\cindex{completion}\c
\cindex{command completion}
using the names stored in the variable
\code{LaTeX-standard-counters}.\c
\vindex{LaTeX-standard-counters}\refill

\begin{sloppypar}
\code{LaTeX-footnote}\c
\cindex{footnote}
\findex{LaTeX-footnote}
on \kbd{C-c f}\c
\kindex{C-c f}
generates a
\samp{\back footnote\{\}}.\c
\pindex{\back footnote\{\}}
Not only does this save typing, but it also
prevents my fingers from producing \samp{\back
bootnote\{\}},\c
\pindex{\back bootnote\{\}}
which looks reasonable enough, but makes \TeX{}
unhappy.  Non-\code{nil} values of the variables
\code{LaTeX-footnote-end-with-newline}\c
\vindex{LaTeX-footnote-end-with-newline}
and
\code{LaTeX-footnote-start-with-newline}\c
\vindex{LaTeX-footnote-start-with-newline}
request that newlines be generated before and
after the footnote; the default values are
\code{nil}.\refill
\end{sloppypar}

\code{LaTeX-news}\c
\findex{LaTeX-news}\c
\cindex{news}
on \kbd{C-c C-n}\c
\kindex{C-c C-n}
views the
\file{latex.el} file to show the
revision history\c
\cindex{history of revisions}\c
\cindex{revision history}
recorded in it.\refill

\code{LaTeX-tab}\c
\findex{LaTeX-tab}
on \kbd{C-c Tab}\c
\kindex{C-c Tab}
indents to the current
\samp{\back begin\penalty0\{...\}}\c
\pindex{\back begin\penalty0\{...\}}
\dots \samp{\back end\penalty0\{...\}}\c
\pindex{\back end\penalty0\{...\}}
nesting level.\c
\cindex{nesting level}\refill

\code{LaTeX-protect}\c
\findex{LaTeX-protect}\c
\cindex{protecting arguments}
on \kbd{C-c C-p}\c
\kindex{C-c C-p}
inserts a \samp{\back protect}\c
\pindex{\back protect}
macro at the current
point.  It is needed whenever fragile commands\c
\cindex{fragile command}
(e.g.\ any \LaTeX{} command that has a star form
\cite[p.\ 27]{Lamport:latex})\c
\tindex{Lamport, Leslie}
are present in a moving argument
\cite[p.\ 151]{Lamport:latex}.\c
\tindex{Lamport, Leslie}
In particular, all macros in
\samp{\back index\{\}}\c
\pindex{\back index}
entries should be
preceded by \samp{\back protect}.\c
\pindex{\back protect}
Otherwise, you can
get long macro expansions that cause
buffer-overflow\c
\cindex{overflow of buffer}\c
\cindex{buffer overflow}
problems for indexing programs,
and make the index file hard to read.  Also, macro
expansions can introduce special characters which
cause problems for indexing programs like
\file{makeindex}.\c
\cindex{makeindex utility}\refill

\code{LaTeX-set-indentation}\c
\findex{LaTeX-set-indentation}
on \kbd{C-c ,}\c
\kindex{C-c ,}
sets the current indentation column to the value
of its argument, or to the cursor column\c
\cindex{cursor column}
if there is no argument.  It is only rarely
necessary to use this function, because the
indentation is reset by several other
functions.\refill

\begin{sloppypar}
\code{LaTeX-verb}\c
\findex{LaTeX-verb}
on \kbd{C-c v}\c
\kindex{C-c v}
generates a
\samp{\back verb|...|}\c
\pindex{\back verb|...|}
command with the cursor\c
\cindex{cursor}
after
the first vertical bar.\c
\cindex{vertical bar}
With an argument, it
creates the
\samp{\back verb*|...|}\c
\pindex{\back verb*|...|}
form, which makes
spaces visible.
\cpsubindex{space}{visible}
The delimiter character can be changed from a
vertical bar\c
\cindex{vertical bar}
by reassigning the Emacs variable
\code{LaTeX-verb-delimiter}.\c
\vindex{LaTeX-verb-delimiter}
For example, to set it to a plus sign\c
\cindex{plus sign}
instead of a
vertical bar:\refill
\end{sloppypar}
\begin{verbatim}
(setq LaTeX-verb-delimiter ?\+)
\end{verbatim}

\noindent
The funny \samp{?\back} prefix is one of Lisp's
\cpsubindex{Lisp}{GNU Emacs}
\cpsubindex{Lisp}{character quote}
character quotes.  As shown elsewhere
(\pxref{LaTeX macros}),
this assignment should normally be placed inside a
mode hook.\c
\cindex{mode hook}\c
\cindex{hook}
It can also be executed dynamically inside the
Emacs minibuffer.\c
\cindex{minibuffer}
Alternatively, you can use
\kbd{M-x set-variable};\c
\kindex{M-x set-variable}
\cindex{set-variable}
it will prompt for the variable name and value.\refill

There are several other functions in
\file{latex.el} that I shall not document here;
they are intended for internal use only, and are
subject to change without warning.  They all begin
with the reserved prefix \code{internal-}.\refill
\cindex{internal functions}\c
\findex{internal- (reserved prefix)}\c
\cindex{naming conventions}\c
\cindex{conventions for naming}\c
\cindex{name prefix}\c
\cindex{prefix in names}

\node Miscellaneous variables, Customizing lists, Miscellaneous functions, LaTeX support

\section{Miscellaneous variables}
\cindex{variables}
There are a number of variables that we have not
yet described.  You should not have to modify any
of them, but you occasionally might want to know
what they are.\refill

\code{LaTeX-current-indentation}\c
\vindex{LaTeX-current-indentation}
tracks the
current environment indentation as the number of
spaces from the left margin.  It is updated
dynamically by many functions.\refill

\code{LaTeX-mode-map}\c
\vindex{LaTeX-mode-map}
holds the map\c
\cindex{map of keys}\c
\cindex{key map}
that associates keys with
functions.\refill

\code{LaTeX-mode-version}\c
\vindex{LaTeX-mode-version}
is a string
containing the version number\c
\cindex{version number}
and date of the last
revision\c
\cindex{revision date}\c
\cindex{date of revision}
to the code.  You should cite its value
when reporting bugs; \code{LaTeX-gripe}\c
\findex{LaTeX-gripe}\c
\cindex{gripe}\c
\cindex{complaint}\c
\cindex{problem report}\c
\cindex{bug report}\c
\cindex{reporting bugs}
puts it in the e-mail subject line.
\cpsubindex{mail}{electronic}\c
\cindex{e-mail}\refill

\code{LaTeX-standard-environments}\c
\vindex{LaTeX-standard-environments}
contains
the list of environment names used by
\code{LaTeX-begin-end-block}.\c
\findex{LaTeX-begin-end-block}\refill

\code{LaTeX-standard-fonts}\c
\vindex{LaTeX-standard-fonts}
holds a list of
font names and sizes.\refill

\code{LaTeX-standard-italic-fonts}\c
\vindex{LaTeX-standard-italic-fonts}
is a list
of the \LaTeX{} control sequences for fonts that
require italic corrections.\refill

\code{LaTeX-standard-list-environments}\c
\vindex{LaTeX-standard-list-environments}
is a
list of \LaTeX{} environments which can have
\samp{\back item}\c
\pindex{\back item}
entries.\refill

\code{LaTeX-standard-options}\c
\vindex{LaTeX-standard-options}
is a list of
options\c
\cindex{option}
that can go in the square
brackets of the
\samp{\back documentstyle}\c
\pindex{\back documentstyle}
command.
It is used
by \code{make-LaTeX-document}\c
\findex{make-LaTeX-document}
and
\code{make-SLiTeX-document}.\c
\findex{make-SLiTeX-document}\refill

\code{LaTeX-standard-styles}\c
\vindex{LaTeX-standard-styles}
is a list of
styles that can go in the braces
of the \samp{\back documentstyle}\c
\pindex{\back documentstyle}
command.  It is used
by \code{make-LaTeX-document}.\c
\findex{make-LaTeX-document}\refill

\code{LaTeX-standard-unindented-environments}\c
\vindex{LaTeX-standard-unindented-environments}
is a list of environments that must not be
indented.\refill

Variables beginning with the reserved prefix
\code{internal-}
\cindex{internal variables}\c
\vindex{internal- (reserved prefix)}\c
\cindex{naming conventions}\c
\cindex{conventions for naming}\c
\cindex{name prefix}\c
\cindex{prefix in names}
are for internal use only; they
are subject to change without warning, and will
not be documented here.\refill

\node Customizing lists, LaTeX support, Miscellaneous variables, LaTeX support

\section{Customizing lists}
\label{customizing-lists}\c
\cindex{customization}
It is undesirable for users to have to duplicate
the long initializations of standard fonts,
macros, environments, and so on, when all they
want to do is add a few more items to the lists.\refill

\begin{sloppypar}
\emergencystretch=3pt
Therefore, for each variable
\code{LaTeX-standard-xxx},\c
\vindex{LaTeX-standard-xxx}
there is a corresponding variable
\code{LaTeX-extra-xxx}\c
\vindex{LaTeX-extra-xxx}
that is intended for user customization.  The
extra values are appended to the standard ones to
make new lists that are used for command
completion.\c
\cindex{completion}\c
\cindex{command completion}
Here are the names of these
customization variables:
\code{LaTeX-extra-counters},\c
\vindex{LaTeX-extra-counters}
\code{LaTeX-extra-dotted-abbreviations},\c
\vindex{LaTeX-extra-dotted-abbreviations}
\code{LaTeX-extra-environments},\c
\vindex{LaTeX-extra-environments}
\code{LaTeX-extra-fonts},\c
\vindex{LaTeX-extra-fonts}
\code{LaTeX-extra-italic-fonts},\c
\vindex{LaTeX-extra-italic-fonts}
\code{LaTeX-extra-list-environments},\c
\vindex{LaTeX-extra-list-environments}
\code{LaTeX-extra-macros},\c
\vindex{LaTeX-extra-macros}
\code{LaTeX-extra-options},\c
\vindex{LaTeX-extra-options}
\code{LaTeX-extra-styles},\c
\vindex{LaTeX-extra-styles}
\code{LaTeX-extra-tied-abbreviations},\c
\vindex{LaTeX-extra-tied-abbreviations}
and
\code{LaTeX-extra-unindented-environments}.\c
\vindex{LaTeX-extra-unindented-environments}\refill
\end{sloppypar}

Suppose for example that you want to add new
environments named \samp{conjecture},
\samp{postulate}, and \samp{wildguess} to the
standard list used by
\code{LaTeX-begin-end-block}.\c
\findex{LaTeX-begin-end-block}
In the \code{LaTeX-mode-hook}\c
\vindex{LaTeX-mode-hook}\c
\cindex{hook}
in your \file{.emacs}\c
\cindex{startup file}\c
\cindex{.emacs file}
file, add this assignment:\refill
\begin{verbatim}
(setq LaTeX-extra-environments
      '(
        ("conjecture")
        ("postulate")
        ("wildguess")
        )
      )
\end{verbatim}

\noindent
When you subsequently type \kbd{C-c b},\c
\kindex{C-c b}
these three new names will appear in the
environment name completion\c
\cindex{completion}\c
\cindex{command completion}
list.  Such lists are
automatically alphabetized during the completion
process, so the names can be given in any order in
the assignment.\refill

There is no provision for deleting names from the
standard lists; after all, they are
\emph{standard}!  Also, remember that the new
additions are made known only to Emacs; you still
have to teach \LaTeX{} how to typeset them.\refill

\begin{sloppypar}
You may have wondered in the example above why I
wrote \samp{("conjecture")} instead of just
\samp{"conjecture"} in the assignment of
\code{LaTeX-extra-environments}.\c
\vindex{LaTeX-extra-environments}
The extra
parentheses make a list out of each element in the
variable.  In \file{latex.el}, all variables that
hold multiple strings store them as \emph{lists of
lists} of strings, rather than as simpler lists
of strings.  This choice was intentional, because
it facilitates adding additional related strings
in the form of Lisp \emph{association
lists}.\refill
\cindex{association list}
\end{sloppypar}

\begin{sloppypar}
The variables
\code{LaTeX-extra-environments},\c
\vindex{LaTeX-extra-environments}
\code{LaTeX-extra-macros},\c
\vindex{LaTeX-extra-macros}
\code{LaTeX-standard-environments},\c
\vindex{LaTeX-standard-environments}
and
\code{LaTeX-standard-macros}\c
\vindex{LaTeX-standard-macros}
already use association lists to hold trailing
braces and brackets, and descriptive
comments.\refill
\end{sloppypar}

\node SliTeX support, Letter support, LaTeX support, Top

\chapter{Sli\protect\TeX{} support}
SLi\TeX{}\c
\cindex{SLi\TeX{}}
works much like \LaTeX{}, so little
additional support is required.  All of the
commands in the preceding sections can be used,
and the editing mode is still called
\code{LaTeX-mode}.\c
\findex{LaTeX-mode}\refill

When you select a new SLi\TeX{} file to edit, you
can create an initial template with
\code{make-SLiTeX-document}\c
\findex{make-SLiTeX-document}
on \kbd{C-c s}.\c
\kindex{C-c s}
It prompts only for document style options,\c
\cindex{option}
since
the major style is fixed at \samp{slides}, and
produces something like this:\refill
\begin{verbatim}
% -*-latex-*-
% Document name: /u/beebe/tex/tugboat/foo.stx
% Creator: Nelson Beebe [beebe@math.utah.edu]
% Creation Date: Mon Jul 29 08:15:15 1991
\documentstyle[]{slides}
\begin{document}
  \onlyslides{1-9999}
  \onlynotes{1-9999}
% \colors{} % {red,green,blue,etc.} colors
% \colorslides{} % input file
  \blackandwhite{<cursor>} % input file
\end{document}
\end{verbatim}
\pindex{\back documentstyle}\c
\pindex{\back newcommand}\c
\pindex{\back begin\penalty0\{document\}}\c
\pindex{\back end\penalty0\{document\}}\c
\pindex{\back onlynotes}\c
\pindex{\back onlyslides}\c
\pindex{\back colors}\c
\pindex{\back colorslides}

\noindent
The cursor\c
\cindex{cursor}
is left positioned in the brace pair of
the \samp{\back blackandwhite\{\}}\c
\pindex{\back blackandwhite\{\}}
macro,
where you can type the name of another file that
you can create in \code{LaTeX-mode},\c
\findex{LaTeX-mode}
using \samp{slide}\c
\cindex{slide environment}
environments generated by
\kbd{C-c b sli<space>}\c
\kindex{C-c b}
\kbd{RETurn}.\c
\kindex{RETurn}\refill

It is convenient to number each slide with a
comment, so that you have the numbers available if
you need them for the
\samp{\back onlynotes}\c
\pindex{\back onlynotes}
and
\samp{\back onlyslides}\c
\pindex{\back onlyslides}
commands.  The function
\code{renumber-slides}\c
\findex{renumber-slides}
on \kbd{C-c 0}\c
\kindex{C-c 0}
modifies relevant\c
\pindex{\back begin}
commands in the buffer to read
something like this:\refill
\begin{verbatim}
  \begin{slide}{} % slide number 1
...
  \begin{slide}{} % slide number 2
...
  \begin{overlay}{red} % overlay number 2-a
...
  \begin{overlay}{green} % overlay number 2-b
...
  \begin{note} % note number 2-1
...
  \begin{slide}{} % slide number 3
...
  \begin{note} % note number 3-1
...
  \begin{note} % note number 3-2
\end{verbatim}
\pindex{\back begin\penalty0\{slide\}\{\}}

\noindent
Any existing comments on the\c
\pindex{\back begin}
commands
are discarded.  Notice the special handling
accorded the SLi\TeX{}
\samp{note}\c
\cindex{note environment}
and
\samp{overlay}\c
\cindex{overlay environment}
environments; they receive a major number equal to
that of the closest preceding slide, followed by a
hyphen and a minor number or letter
\cite[pp. 136--137]{Lamport:latex}.\c
\tindex{Lamport, Leslie}\refill

The Emacs variable \code{SLiTeX-begin-slide}\c
\vindex{SLiTeX-begin-slide}
defines the regular expression\c
\cindex{regular expression}
used to find
the start of the \samp{note}, \samp{overlay}, and
\samp{slide} environments.\refill

\node Letter support, Bug reporting, SliTeX support, Top

\chapter{Letter support}
\cindex{letter}
\LaTeX{} \cite[pp. 66ff]{Lamport:latex}\c
\tindex{Lamport, Leslie}
provides a \samp{letter} document style,
but there is a fair amount of constant
`boilerplate'\c
\cindex{boilerplate}
that has to be typed each time you
use it.  This suggests that the best approach is
to have private template files\c
\cindex{template file}
that already have a
letter outline in them, and then arrange to start
each letter with a copy of the template already
inserted into the buffer.  Emacs' programmability
makes this straightforward.\refill

The startup file code in
Table 1 \c\ref{fig-startup-code}
loads a small Lisp
\cpsubindex{Lisp}{GNU Emacs}
file, \file{letter.el}.  It defines a
\code{letter-mode}\c
\findex{letter-mode}
function, and
associates it with files with extension\c
\cindex{file extensions}
\file{.ltr}.\c
\cindex{.ltr file}
If I then visit a new file
\file{rb-jones.ltr}, I immediately get the
buffer shown in
Table 8, \c\ref{fig-letter},
with the cursor\c
\cindex{cursor}
positioned in the empty brace pair in
\samp{\back begin\penalty0\{letter\}\{\}},\c
\pindex{\back begin\penalty0\{letter\}\{\}}
ready for entry of the address.  The query\c
\cindex{query}\c
\kindex{?}
in
\samp{\back opening\{Dear ?\}}\c
\pindex{\back opening\{Dear ?\}}
is a reminder to enter
something there, and then the body of the letter
can be typed in following the
\samp{\back opening}\c
\pindex{\back opening}
line.\refill

\begin{ifinfo}
\begin{table}[tbph]
----------------------------------------------------------------------

% -*-LaTeX-*-
% Document name: /u/beebe/rb-jones.ltr
% Creator: Nelson Beebe [beebe@math.utah.edu]
% Creation Date: Mon Jul 29 20:06:18 1991

%---------------------------------------------
% EVERYTHING TO THE RIGHT OF A  %  IS A REMARK
% TO YOU AND IS IGNORED BY LaTeX.
%
% WARNING!  DO NOT TYPE ANY OF THE FOLLOWING
% 10 CHARACTERS AS NORMAL TEXT CHARACTERS:
%       &   $   #   %   _    {   }   ^   ~   \back
%
% The following seven are printed by typing a
% backslash in front of them:
%       $  &  #  %  _  {  and  }.
%---------------------------------------------

\back documentstyle[nhfb-letter]{letter}
\back begin{document}
\back begin{letter}{<cursor>}

\back opening{Dear ?}

\back closing{Sincerely,}
\back ps{{$\back cal NHFB$}/\back LaTeX}
\back end{letter}
\back end{document}

----------------------------------------------------------------------
\caption{Letter template.}
\label{fig-letter}

\end{table}
\end{ifinfo}

\begin{iftex}
  \begin{table}[tbph]
\Tabrule
\smallskip
  \begin{verbatim}
% -*-LaTeX-*-
% Document name: /u/beebe/rb-jones.ltr
% Creator: Nelson Beebe [beebe@math.utah.edu]
% Creation Date: Mon Jul 29 20:06:18 1991

%---------------------------------------------
% EVERYTHING TO THE RIGHT OF A  %  IS A REMARK
% TO YOU AND IS IGNORED BY LaTeX.
%
% WARNING!  DO NOT TYPE ANY OF THE FOLLOWING
% 10 CHARACTERS AS NORMAL TEXT CHARACTERS:
%       &   $   #   %   _    {   }   ^   ~   \
%
% The following seven are printed by typing a
% backslash in front of them:
%       $  &  #  %  _  {  and  }.
%---------------------------------------------

\documentstyle[nhfb-letter]{letter}
\begin{document}
\setfilename{foo.info}
\begin{letter}{<cursor>}

\opening{Dear ?}

\closing{Sincerely,}
\ps{{$\cal NHFB$}/\LaTeX}
\end{letter}
\end{document}
\end{verbatim}
\smallskip
\Tabrule
    \caption{Letter template.}
    \label{fig-letter}
  \end{table}
\end{iftex}
\pindex{\back documentstyle}
\pindex{\back newcommand}
\pindex{\back begin\penalty0\{document\}}
\pindex{\back end\penalty0\{document\}}
\pindex{\back begin\penalty0\{letter\}\{\}}
\pindex{\back end\penalty0\{letter\}}
\pindex{\back opening}
\pindex{\back closing}
\pindex{\back ps}
\pindex{\back cal}
My personal style option\c
\cindex{option}
\samp{nhfb-letter}
provides for a University and Department
letterhead\c
\cindex{letterhead}
on the first page, and defines a
few private macros
\cpsubindex{macros}{private}
that I often need in my
correspondence.\refill

Once the letter file has been saved, I suspend
Emacs, or switch to another workstation
window, and then process the letter by typing\refill
\begin{verbatim}
make LET=rb-jones
\end{verbatim}

\noindent
The UNIX \file{make}\c
\cindex{make utility}
utility is a wonderful
tool; here it directs the execution of commands
to expand tabs to blanks, changes the file
protection to remove access to all but its
owner, runs \LaTeX{}, and then runs a
PostScript\c
\cindex{PostScript}
DVI driver, sending the output to a
nearby printer.  Then it sends the output
PostScript through a shell filter that modifies
the \samp{showpage}\c
\cindex{showpage}
command to print the string
\emph{File Copy}\c
\cindex{file copy}
in outline letters\c
\cindex{outline letters}
diagonally across each page, and queues that to
the printer as well.  On those occasions where I
require multiple copies of the original letter, I
just type something like\refill
\begin{verbatim}
make LET=rb-jones C=3
\end{verbatim}

\noindent
This gives me one file copy, and three
originals for signing and mailing.\refill

With this support, preparation of typeset
letters is just as easy as typewritten ones,
and the result looks much better.  And I can
use mathematics and a variety of fonts too!\refill

\node Bug reporting, Conclusion, Letter support, Top

\chapter{Bug reporting}
\cindex{bug reporting}
\code{LaTeX-gripe}\c
\findex{LaTeX-gripe}\c
\cindex{gripe}\c
\cindex{complaint}\c
\cindex{problem report}\c
\cindex{bug report}\c
\cindex{reporting bugs}
on \kbd{C-c g}\c
\kindex{C-c g}
makes it easy
to complain about \code{LaTeX-mode};\c
\findex{LaTeX-mode}
it puts you in an e-mail\c
\cindex{e-mail}
\cpsubindex{mail}{electronic}
buffer with a mail header something like this:\refill
\begin{small}
\begin{verbatim}
To: beebe@math.utah.edu
Subject: LaTeX-mode gripe report {beta test 0.23 [08-May-1991]}
\end{verbatim}
\end{small}

\noindent
The standardized subject field makes it easy
for the author to identify such messages in his
voluminous e-mail correspondence, and
also automatically identifies the code version.\c
\cindex{revision date}\c
\cindex{date of revision}\c
\cindex{code version}\c
\cindex{version of code}\refill

If you don't have an electronic mail
\cpsubindex{mail}{electronic}\c
\cindex{e-mail}
connection yet, you probably soon will.  For now,
just send me your comments in postal mail.
Machine-readable submissions can be sent on IBM PC\c
\cindex{IBM PC}\c
\cindex{PC}
or Apple Macintosh\c
\cindex{Apple Macintosh}\c
\cindex{Macintosh}
floppy disks.\c
\cindex{floppy disk}\refill

\node Conclusion, Bibliography, Bug reporting, Top

\chapter{Conclusion}
\code{LaTeX-mode}\c
\findex{LaTeX-mode}
editing support in GNU Emacs provides a very
powerful, and pleasant, way to prepare \LaTeX{}
and SLi\TeX{} input.\refill

The original TOPS-20\c
\cindex{TOPS-20}
version written in TECO\c
\cindex{TECO}
was begun in October 1984, and used
extensively at Utah until our DEC-20/60\c
\cindex{DEC-20}
retired on October 31, 1990.\c
\cindex{Halloween}
It consists of about
1000 lines of code defining 24 functions.\refill

The power of Lisp
\cpsubindex{Lisp}{GNU Emacs}
over TECO made it possible to
be much more ambitious in the functionality of
the GNU Emacs version, and I consequently
suspended further development of the TECO code
in January 1988 when I began the Lisp coding.
The current Lisp version is more than 4 times the
size of the TECO one, both in lines of code,
and in editing functions.\c
\cindex{code size}
Despite the increase in size, it is \emph{much}
easier to maintain.\refill

The GNU Emacs implementation was released for
beta testing in March, 1988.  About 70 sites
have participated in the beta test\c
\cindex{beta test}
of
\file{latex.el}.  I thank these many people for
their contributions of comments, and sometimes,
even code.\refill

Is it bug free?  No computer program for a
realistic problem ever is; there are simply too
many details for humans ever to get completely
right. The \file{latex.el} revision history\c
\cindex{history of revisions}\c
\cindex{revision history}
shows
mostly additions of new functionality, and code
changes for better performance.  The virtue of the
Emacs editing environment is that new functions
can be written, debugged, and tested in the editor
itself, providing immediate feedback and
confidence in the correctness of operation.\refill

Much of the code is in small functions that are
independent of the others, following the Lisp
\cpsubindex{Lisp}{programming tradition}
programming tradition.  After removal of comments
and empty lines, and ignoring the initializations
of large tables, the average is about 22 lines of
code and documentation per function.\c
\cindex{documentation of function}\c
\cindex{function documentation}
This is
close to the 20-line average for all of GNU Emacs.
Documentation contributions are included here
because Emacs functions, and some variables, carry
their own documentation with them, even after
compilation.  That documentation is readily
available for viewing in the editor.\refill

I believe that this code could serve as a model
for other Emacs-like editors that have an
extension language in which new functions can be
written.  I had planned to write an EEL\c
\cindex{EEL}
version for the \file{epsilon} editor\c
\cindex{epsilon editor}
on PC DOS,\c
\cindex{PC DOS}\c
\cindex{IBM PC}\c
\cindex{PC}
but alas, have not found the time to do so.  This
is not a small job, but it should be
straightforward for someone familiar with both
Lisp
\cpsubindex{Lisp}{GNU Emacs}
and EEL\.\c
\cindex{EEL}
The \file{latex.el} file is over 4200 lines long,
with about 155KB of text; Emacs compiles it into
about 100KB of byte codes.  The latter figure
should give some idea of the memory requirements
for implementations in other editors.  I hope some
reader will prepare such a translation and make it
freely available, as \file{latex.el} is.  A large
portion of the \TeX{} community uses personal
computers that are inadequate for GNU Emacs, but
have smaller Emacs-like editors available, and
such editing support would be a great boon for
them.\refill

If you plan to undertake such a translation
effort, check with the author of \file{latex.el}
first to find out if anyone else is already
working on one.\refill

Some other work in the \TeX{} community for
editing support has been reported in the \TeX{}
User Group \TeX{}niques series
\cite{McPherson:TQ1-1,Muller:TQ7-235,vonBechtolsheim:TQ7-195}\c
\tindex{McPherson, Kent}\c
\tindex{Muller, Paul M.}\c
\tindex{von Bechtolsheim, Stephan}
and in TUGboat\c
\cindex{TUGboat}
\cite{Clark:TB10-1-14-15,Eijkhout:TB11-4-605,Hoenig:TB7-1-51,Hoover:TB10-4-549-559,Hornbach:TB7-2-99,Kleine:TB7-2-111,Williams:TB11-3-421-424}.\c
\tindex{Clark, Adrian}\c
\tindex{Eijkhout, Victor}\c
\tindex{Hall, Linda}\c
\tindex{Hoenig, Alan}\c
\tindex{Hoover, Anita}\c
\tindex{Hornbach, Kathy}\c
\tindex{Kleine, Karl}\c
\tindex{Pfeffer, M.}\c
\tindex{Williams, Linda}
I believe that \file{latex.el} is much more
powerful, however.\refill

Those who use UNIX\c
\cindex{UNIX}
workstations or VMS\c
\cindex{VMS}
systems where GNU Emacs is already available
should eventually find \file{latex.el} in the
\file{emacs/lisp} directory, and until then, can
obtain it directly from the author, provided they
have Internet electronic mail
\cpsubindex{mail}{electronic}\c
\cindex{e-mail}
or \file{ftp} access.\refill

If you have a UNIX or VMS\c
\cindex{VMS}
system, but do not yet have GNU Emacs,
\cpsubindex{GNU Emacs}{getting}
you can get Emacs from any site that already has it,
or better, you can get the latest version directly
from the Free Software Foundation.\c
\cindex{Free Software Foundation}
The latter
is accessible either via Internet anonymous
\file{ftp} to the machine
\file{prep.\penalty0ai.\penalty0mit.\penalty0edu},
or through postal mail to\refill
\begin{iftex}
\begin{verse}
Free Software Foundation, Inc.\\
675 Massachusetts Ave\\
Cambridge, MA 02139\\
USA
\end{verse}
\end{iftex}
\begin{ifinfo}
\begin{example}
Free Software Foundation, Inc.
675 Massachusetts Ave
Cambridge, MA 02139
USA
\end{example}
\end{ifinfo}
The postal mail
\cpsubindex{mail}{postal}
approach carries some shipping and documentation
charges, but the software itself is free.\refill

\node Bibliography, Concept Index, Conclusion, Top

\begin{ifinfo}
\chapter*{Bibliography}
\cindex{bibliography}
\cindex{literature}
\cindex{references}
\begin{description}
\item[Alexander:TB7-3-138]
James Alexander.
\code{Tib}: a reference setting package for \TeX.
\emph{TUGBoat}, 7(3):138, October 1986.\refill

\item[Alexander:TB8-2-102]
James Alexander.
\code{Tib}: a reference setting package, update.
\emph{TUGBoat}, 8(2):102, July 1987.\refill

\item[Aurbach:TQ3-1]
R. L. Aurbach.
User's guide to the Idx\TeX{} program.
\emph{TeXniques, Publications for the TeX community},
(3):i, 1--14, 1987.\refill

\item[Bentley:EPODD-1-1-3]
J. L. Bentley and B. W. Kernighan.
Tools for printing indexes.
\emph{Electronic Publishing---Origination, Dissemination, and Design},
1(1):3--18, April 1988.\refill

\item[Chen:UCB-TR-87-347]
Pehong Chen and Michael A. Harrison.
Automating index preparation.
Technical Report 87/347, Computer Science Division, University of
California, Berkeley, CA, USA, March 1987.
This is an expanded version of \cite{Chen:SPE-19-9-897}.\refill

\item[Chen:SPE-19-9-897]
Pehong Chen and Michael A. Harrison.
Index preparation and processing.
\emph{Software---Practice and Experience}, 19(9):897--915,
September 1988.
The \LaTeX{} text of this paper is included in the
\code{makeindex}\c
\cindex{makeindex utility}
software distribution.\refill

\item[Clark:TB10-1-14-15]
Adrian Clark.
An enhanced \TeX-editor interface for VMS.
\emph{TUGBoat}, 10(1):14--15, April 1989.\refill

\item[Eijkhout:TB11-4-605]
Victor Eijkhout.
A new editor.
\emph{TUGBoat}, 11(4):605, November 1990.\refill

\item[Hoenig:TB7-1-51]
A. Hoenig and M. Pfeffer.
\TeX{} text editors for the IBM PC.
\emph{TUGBoat}, 7(1):51, March 1986.\refill

\item[Hoover:TB10-4-549-559]
Anita Z. Hoover.
Using WordPerfect 5.0 to Create \TeX{} and \LaTeX{} Documents.
\emph{TUGBoat}, 10(4):549--559, December 1989.\refill

\item[Hornbach:TB7-2-99]
Kathy Hornbach.
\VAX{} Language Sensitive Editor Templates and Guide for use with
\LaTeX.
\emph{TUGBoat}, 7(2):99, June 1986.\refill

\item[Kleine:TB7-2-111]
Karl Kleine.
Customized editors for \TeX.
\emph{TUGBoat}, 7(2):111, June 1986.\refill

\item[Knuth:texbook]
Donald E. Knuth.
\emph{The TeXbook}.
Addison-Wesley 1984.\refill

\item[Lamport:latex]
Leslie Lamport.
\emph{LaTeX---A Document Preparation System---User's Guide and
Reference Manual}.
Addison-Wesley 1985.\refill

\item[Lamport:makeindex]
Leslie Lamport.
\emph{MakeIndex: An Index Processor For LaTeX}, 17 February
1987.
The \LaTeX{} text of this paper is included in the
\code{makeindex}\c
\cindex{makeindex utility}
software distribution.\refill

\item[McPherson:TQ1-1]
Kent McPherson.
VAX Language-Sensitive Editor (LSEDIT) Quick Reference Guide.
\emph{TeXniques, Publications for the TeX community},
(1):ii, 1--9, 1988.\refill

\item[Muller:TQ7-235]
Paul M. Muller.
FAS\TeX{}: A PC text editor and front-end for \TeX{}.
\emph{TeXniques, Publications for the TeX community},
(7):235--254, 1988.\refill

\item[Schoepf:TB11-2-284-296]
Rainer Schoepf.
A new implementation of the \LaTeX{} \code{verbatim} and
\code{verbatim*} environments.
\emph{TUGBoat}, 11(2):284--296, June 1990.\refill

\item[Shertzer:grammar]
Margaret Shertzer.
\emph{The Elements of Grammar}.
Collier Books, Macmillan Publishing Company, 1986.\refill

\item[vonBechtolsheim:TQ7-195]
Stephan von Bechtolsheim.
Using the Emacs editor to safely edit \TeX{} sources.
\emph{TeXniques, Publications for the TeX community},
(7):195--202, 1988.\refill

\item[Williams:TB11-3-421-424]
Linda Williams and Linda Hall.
Increased efficiency using advanced EDT editing features.
\emph{TUGBoat}, 11(3):421--424, September 1990.\refill
\end{description}

\end{ifinfo}

\begin{iftex}
\def\VAX{\leavevmode\hbox{V\kern-.12em A\kern-.1em X}}
\bibliography{ltxinfo}
\end{iftex}

\twocolumn
\node Concept Index, Control Sequence Index, Bibliography, Top

\begin{ifinfo}
\chapter*{Concept Index}
\end{ifinfo}
\begin{iftex}
\unnumbered{Concept Index}
\end{iftex}
\cindex{concept index}
\cpsubindex{index}{concept}
\printindex{cp}

\twocolumn
\node Control Sequence Index, Function Index, Concept Index, Top

\begin{ifinfo}
\chapter*{Control Sequence Index}
\end{ifinfo}
\begin{iftex}
\unnumbered{Control Sequence Index}
\end{iftex}
\cindex{control sequence index}
\cpsubindex{index}{control sequence}
\printindex{pg}

\onecolumn
\node Function Index, Key Index, Control Sequence Index, Top

\begin{ifinfo}
\chapter*{Function Index}
\end{ifinfo}
\begin{iftex}
\unnumbered{Function Index}
\end{iftex}
\cindex{function index}
\cpsubindex{index}{function}
\printindex{fn}

\twocolumn
\node Key Index, Person Index, Function Index, Top

\begin{ifinfo}
\chapter*{Key Index}
\end{ifinfo}
\begin{iftex}
\unnumbered{Key Index}
\end{iftex}
\cindex{key index}
\cpsubindex{index}{key}
\printindex{ky}

\onecolumn
\node Person Index, Variable Index, Key Index, Top

\begin{ifinfo}
\chapter*{Person Index}
\end{ifinfo}
\begin{iftex}
\unnumbered{Person Index}
\end{iftex}
\cindex{person index}
\cpsubindex{index}{person}
\printindex{tp}

\onecolumn
\node Variable Index, Top , Person Index, Top

\begin{ifinfo}
\chapter*{Variable Index}
\end{ifinfo}
\begin{iftex}
\unnumbered{Variable Index}
\end{iftex}
\cindex{variable index}
\cpsubindex{index}{variable}
\printindex{vr}

\end{document}
%%% This is for GNU Emacs file-specific customization:
%%% Local Variables:
%%% fill-column: 50
%%% End:
