Efficient editing of TeX and LaTeX in Emacs

B. Narasimhan

Friday, October 25, 12:00, in Room 450 (Seminar room)

Introduction

Emacs comes with a package for editing TeX and LaTeX files. You might have encountered it when you loaded any file with the extension .tex into Emacs. However, this package is extremely limited in its functionality. A far better package called AUC TeX exists that can help you write your papers efficiently. On RGMiller, this enhanced package is the default and I am certain you will like it. On Playfair or Tukey it is not the default, but you can make AUC TeX the default quite easily.

Overview

AUC TeX is a comprehensive customizable integrated environment for writing input files for LaTeXusing Emacs.

AUC TeX lets you run TeX, LaTeX, and other LaTeX-related tools, such as a output filters or post processor from inside Emacs. Running LaTeXis especially interesting as AUC TeX lets you browse through the errors TeX reported, while it moves the cursor directly to the reported error, and displays some documentation for that particular error. This will even work when the document is spread over several files.

AUC TeX automatically indents your LaTeX source, not only as you write it--you can also let it indent and format an entire document. It has a special outline feature, which can greatly help you get an overview of a document.

Apart from these special features, AUC TeX provides an large range of handy Emacs macros, which in several different ways can help you write your LaTeX documents fast and painless.

All features of AUC TeX are documented using the Emacs online documentation system. That is, documentation for any command is just a key click away!

Indentation and Formatting

AUC TeX may automatically indent your document as you write it. By pressing LFD instead of RET at the end of a line, the current line is indented by two spaces according to the current environment level, and the cursor is moved down one line. By pressing TAB, the current line is indented, and the cursor stays where it is. The well-known Emacs feature format-paragraph (M-q) is reimplemented especially for AUC TeX to follow the indentation. A special command LaTeX-fill-buffer lets you indent an entire document.

Completion

By studying your \documentstyle command (in the top of your document), and consulting a precompiled list of TeX, LaTeX symbols from a large number of TeX and LaTeX files, AUC TeX is aware of the LaTeX commands you should able to use in this particular document. This knowledge is used for two purposes.

Editing your document

A number of more or less intelligent keyboard macros have been defined to aid you editing your document. The most important are listed here below.

Font changes can be easily accomplished via C-c C-f C-r, or C-c C-f C-i, or C-c C-f C-b which inserts one of {\rm }, {\it }, {\bf }, etc.

A number of additional functions are available. Refer to the online documentation for further information.

Running LaTeX

Invoking TeX-command-master (C-c C-c) or TeX-command-region (C-c C-r) runs LaTeX on either the entire current document or a given region. The Emacs view is split in two, and the output of TeX is printed in the second half of the screen, as you may simultaneously continue editing you document. In case TeX found any errors when processing your input you can call the function TeX-next-error (C-c `) which will move the cursor to the first given error, and display a short explanatory text along with the message TeX gave. This procedure may be repeated until all errors have been displayed. By pressing C-c C-w (TeX-toggle-debug-boxes) you can toggle whether the browser also should notify over-full/under-full boxes or not.

Once you've successfully formatted your document, you may preview, ghostview or print it by invoking TeX-command-master again.

Outlines

Along with AUC TeX comes support for outline mode for Emacs, which lets you browse the sectioning structure of your document, while you will still be able to use the full power of the rest of the AUC TeX functionality.