AUCTEX is an extensible package for writing and formatting TeX files in
GNU Emacs and XEmacs.
It provides the most extensive LaTeX editing support available for a
general purpose editor. Apart from the customary TeX shell
functionality, it provides syntax highlighting, smart indentation and
formatting, previews of mathematics and other stuff right in the editing
buffer (preview-latex), smart folding of syntactical elements, macro and
environment completion. It also supports the self-documenting .dtx
format from the LaTeX project. Support for other TeX-based formats
includes ConTeXt and plain TeX, but is quite more sketchy.