[-*- Text -*-]					1:33pm  Friday, 25 July 1980

This file contains documentation on the TeX library for Emacs.
Library created and maintained by KMP@MIT-MC.

The TeX Library is for editting files which contain formatting information
for Knuth's TeX (Tau Epsilon Chi) text formatting system. This node will
assume the reader is already familiar with TeX.

The Emacs syntax table is set up in a useful way for editting TeX code.

{ ... }	Typing a close-brace will flash the brace which it matches. Control
	of this flashing is done via the variables ^[Display Matching Paren^[
	and ^[Permit UnMatched Paren^[ in the same way as for other languages.
	By default, Emacs will beep if you try to type a "}" without closing
	a mathmode context (unfortunately, display mathmode cannot be cheaply
	checked for, so you may not get a warning beep if a display math mode
	context is unbalanced inside braces you are closing).

\	Backslash will `quote' the syntax of the character which follows
	it. As a result, Emacs will be able to recognize that objects like
	{...\{...} are balanced, and the Control-Meta- commands normally used
	for handling Lisp lists will work. Eg, C-M-F should go forward over
	balanced TeX braces. C-M-B should go backward, etc.

$	Typing a dollarsign runs a macro which scans backward and tries to
	determine if the $ begins or ends a TeX math mode field. If more than
	two $'s appear together, Emacs will beep at you. If the $ typed begins
	a field, there is no effect. If, however, the $ is the end of a math
	mode field, TeX mode will move the cursor to flash the $ or $$ which
	begins the field. See Dollar.

Tab	Typing tab will indent you using indentation relative to the line
	above (see documentation on ^R Indent Relative)

%	% is the comment character used by TeX mode. Comment commands (such as
	M-N, M-;, M-P, C-M-;, and so on) will recognize and use % for this
	purpose.

TeX mode offers ``flashing'' dollarsigns (like the flashing parens available
for Lisp Mode).

It may be the case that TeX mode's dollarsigns are very slow at times in
long files. This is because every time you type a dollarsign, it must scan
outward looking for the first preceding { or for the beginning of the file if
not in a {. Once having scanned back for that point, it moves forward, counting
$'s and $$'s to see if you are entering or exitting a mathmode field. Hence, if
you have typed { ... $  it won't have to scan back far to find the { and so
will be quite fast. If you type a $ at toplevel, you may have to wait a long
time for it to return. Typing C-Q $ is one way to locally get around this
problem, or C-G may be typed if you realize that you're hanging waiting for
it to return from the backward scan of a long file. However, the recommended
approach is to type C-M-$ (C-M-dollarsign) at intervals in the file where
you *know* the dollarsigns should be balanced. This inserts a special marker
at the end of the line you type it on (the marker looks like "% {]" -- why
it must look like this will be obvious to those familiar with ITS Teco, but
suffice to say it is a very efficient way of delimiting the backward context
scan). This marker says to TeX mode, ``You may assume that all $'s prior to
this point are correctly balanced.'' Experience has shown that flashing
$'s, in conjunction with judicious use of the markers inserted by C-M-$
can make TeX's hard-to-read syntax quite livable.

Although flashing dollarsigns are on by default, they can be disabled if
they are found undesirable. To do so, put the command string

	1 m.v Inhibit TeX Dollarsign^[

in your Emacs init file or by executing that string in a minibuffer before
you run enter TeX mode. If you are already in TeX Mode, you should exit TeX
mode into some other mode and then re-enter it to get the appropriate effect.

Users of TeX are encouraged to use ``...'' rather than "..." to delimit
quoted text -- it makes the output look far nicer. There exists a macro
which the user can put on the " key to make it expand into either `` or ''
as appropriate from context. Just typing `` and '' is not really hard, but
especially as a novice, it's easy to forget to do. This feature is not
on by default, but can be turned on by doing

	@:i*| m.m^R TeX "^[m.q^R"^[ !''! | m.v TeX Mode Hook^[

in an init file. (Note: That's m.m<UpArrow>R TeX "^[ but later m.q<Control-R>"^[
in the line you see above. The ^['s are altmodes.)

This node offers descriptions of the extended commands which come with the
TeX library, in addition to M-X TeX Mode^[ ...

M-X Setup Indented TeX Display^[

  This macro will take a normally indented expression in a variable
  width region and set it up so that it will be output aligned similarly
  by TeX. *Only* the beginnings of lines will line up right. Example:
  The region must be placed around the area that is to be set up.
  This macro is primarily for setting up indented Lisp code in a variable
  width font. Requires a \noflash macro to be defined
  (see M-X Insert TeXmac Aux Macros^[ below)

M-X UnSetup Indented TeX Display^[

  This macro will convert a region of the buffer which has had
  M-X Setup Indented TeX Display^[ run across it and turn it back into
  normally indented text. The cursor may be placed generally anywhere
  touching the \vbox{...} which is to be converted back.

M-X Insert TeXmac Aux Macros^[

  Inserts macro definition for \noflash macro used by the output of
  M-X Setup Indented TeX Display^[. If the \noflash macro is found to be
  of general use to the TeX community, it may be moved into one of the
  TeX libraries, but for now you'll have to manually include its definition
  by running this macro at the top of your file.