Skip to main content

25.11 TeX Mode

TeX is a powerful text formatter written by Donald Knuth; like GNU Emacs, it is free software. The TeX format has several variants, including LaTeX, a simplified input format for TeX; DocTeX, a special file format in which the LaTeX sources are written, combining sources with documentation; and SliTeX, an obsolete special form of LaTeX1.

Emacs provides a TeX major mode for each of these variants: Plain TeX mode, LaTeX mode, DocTeX mode, and SliTeX mode. Emacs selects the appropriate mode by looking at the contents of the buffer. (This is done by invoking the tex-mode command, which is normally called automatically when you visit a TeX-like file. See Choosing Modes.) If the contents are insufficient to determine this, Emacs chooses the mode specified by the variable tex-default-mode; its default value is latex-mode. If Emacs does not guess right, you can select the correct variant of TeX mode using the commands plain-tex-mode, latex-mode, slitex-mode, or doctex-mode.

The following sections document the features of TeX mode and its variants. There are several other TeX-related Emacs packages, which are not documented in this manual:

  • BibTeX mode is a major mode for BibTeX files, which are commonly used for keeping bibliographic references for LaTeX documents. For more information, see the documentation string for the command bibtex-mode.
  • The RefTeX package provides a minor mode which can be used with LaTeX mode to manage bibliographic references. For more information, see the RefTeX Info manual, which is distributed with Emacs.
  • The AUCTeX package provides more advanced features for editing TeX and its related formats, including the ability to preview TeX equations within Emacs buffers. Unlike BibTeX mode and the RefTeX package, AUCTeX is not distributed with Emacs by default. It can be downloaded via the Package Menu (see Packages); once installed, see the AUCTeX manual, which is included with the package.
TeX Editing  Special commands for editing in TeX mode.
LaTeX Editing  Additional commands for LaTeX input files.
TeX Print  Commands for printing part of a file with TeX.
TeX Misc  Customization of TeX mode, and related features.

  1. It has been replaced by the ‘slides’ document class, which comes with LaTeX.