Ultra-TeX mode is a major mode for editing TeX documents. It features dynamic completion (see section Completion) of TeX commands, and a number of other handy things.
One of the key features of Ultra-TeX mode is that it uses lightning completion to complete TeX commands. When you enter Ultra-TeX mode (say, if you have followed the installation instructions (see section Installation) so that you enter Ultra-TeX whenever you open a TeX file), Emacs constructs a list of TeX commands. Then when you hit \, Emacs does lightning completion on the elements of this list.
I'll describe what lightning completion is, and I'll explain how Emacs constructs this list of commands.
Here is an example of lightning completion: suppose that the list of commands that Emacs knows about only contains the following:
\xrightarrow{}, \xleftarrow{}, \Rightarrow
If I hit \, then `\' is inserted into the buffer, and
lightning completion starts. If I then hit R, then after a delay
(of length governed by the variable ultex-complete-idle-time
)
`Rightarrow' is inserted and completion ends (this all happens
because there is only one valid completion starting `\R'). If I
hit x instead of R, then `x' gets inserted. Then I can
either hit r or l, resulting, after a delay, in either
`\xrightarrow{}' or `\xleftarrow{}'.
(The aforementioned delay was added in version 0.50 of this package. By
default, it is equal to lc-complete-idle-time-default
, a variable
documented in the Lightning Completion Manual (see section `Lightning completion' in Lightning Completion Manual). To get
the old behavior of immediate completion, set the variable
ultex-complete-idle-time
to 0.)
Using the same example, if I start by hitting \, if I hit any
printing character other than x or R, then after a delay,
Emacs beeps because there is no valid completion starting with that
character, and (depending on the value of the variable
lc-clean-up
) either that character is inserted or nothing is
inserted. I can always stop lightning completion prematurely by hitting
C-c; this is one way to insert TeX commands that Ultra-TeX
doesn't know about.
If you don't want to use lightning completion, set the variable
ultex-dont-use-completion
to t. Then Ultra-TeX will only try
to complete when you hit the TAB key.
There is more to lightning completion. See section `Lightning completion' in Lightning Completion Manual, for a full description.
As I said earlier, when Emacs enters Ultra-TeX mode, it constructs a list of TeX commands, and it uses this list for its completion table. The list is built from two pieces: first of all, the user should have a textree file, containing the TeX commands she typically uses.
Remarks:
ultex-tree-file
. See section Installation, for how to set this, if
you're not sure.
ultex-new-cs
to specify a new command sequence to be entered into
the textree file. See section Defining new commands, for more
information on this. (Alternatively, the textree file is an Emacs lisp
file, so you can edit it directly if you're comfortable with Emacs
lisp.)
ultex-delete-csname-from-tree-file
to specify a command
sequence to be deleted from the textree file. See section Defining new commands, for more information on this, too.
Now, Emacs scans the current buffer (the one which is using Ultra-TeX mode), looking for commands of the forms
\documentclass{bozo} \documentstyle{bozo} \usepackage{bozo}
When it finds any such lines, it examines the list
ultex-extra-tree-files
to see if there is an associated file of
commands for that class, style, or package, and if there is, if the main
file `textree.el' should also be loaded. It loads each one of
these files, along with the main one if appropriate.
Remarks:
ultex-extra-tree-files
.
ultex-new-cs
to add a new command, Emacs will ask
which file to add it to. Similarly, if you run
ultex-delete-csname-from-tree-file
to delete a command, if that
command appears in more than one file, Emacs will ask you which one to
delete it from.
ultex-also-load
may contain the name of a command
file to load in addition to any others which have been specified. This
is intended for use as a local variable; in other words, to use it, you
should have lines like this at the end of your TeX document:
%% Local variables: %% ultex-also-load: "~/emacs/other-ultex-commands.el" %% End:
After this has been done, Emacs scans the current buffer, looking for more commands. It finds commands in the following ways:
\newcommand{\bozo}[3]{blah blah blah}(or `\renewcommand...' or `\providecommand...') then Emacs adds the string `\bozo{}{}{}' to its list of TeX commands (there are three sets of brackets because the `3' in the square brackets tells LaTeX that `\bozo' takes 3 arguments. If you then use lightning completion to insert `\bozo{}{}{}' in the buffer, the point is placed inside the first set of brackets. Hitting the RET key moves you to the next set of brackets (see section Smart return key).
\DeclareMathOperator{\clown}{Clown}then Emacs adds `\clown' to its list.
\newenvironment{circus}(or `\renewenvironment{circus}') then Emacs adds
\begin{circus} \end{circus}to the list; when Ultra-TeX inserts this in your buffer, it puts the point on the blank line.
\newtheorem{dumb-lemma}[thm]{Lemma}then Emacs adds
\begin{dumb-lemma}\label{} \end{dumb-lemma}and it puts the point inside the argument for `\label'. If you don't want a label, just hit the RET key (see section Smart return key).
\label{ling-ling}then Emacs adds `\ref{ling-ling}', `\pageref{ling-ling}', and `\eqref{ling-ling}' to its list.
The above scanning is done by the function ultex-grab-defs
. The
following is done by ultex-grab-bibs
.
\bibitem{bib-key} Bozo the Clown, \emph{How to write bad emacs lisp code}, ...When it finds such a command, it adds `\cite{bib-key}' and `\nocite{bib-key}' to the list. If your buffer is associated to a file, `file.tex', then Emacs does exactly the same scanning on the file `file.bbl'. Lastly, if the buffer contains a command
\bibliography{bib-data-base}then Emacs looks for a file `bib-data-base.bib'; if it finds it, it adds `\cite' and `\nocite' for all of the keys in it.
Emacs does all of this scanning recursively:
\input{bozo} \include{bobo}at the start of a line, then Emacs scans the files `bozo.tex' and `bobo.tex' for their commands and labels. If these commands are not at the start of the line (they have spaces or tabs in front of them, say), then the files are not scanned.
%% -*- TeX-master: "main.tex"; -*-or lines like this at the end of the file:
%% Local variables: %% TeX-master: "main.tex" %% End:then Emacs scans the file `main.tex' for its commands and labels (and any files included or input into them, too).
A few remarks:
ultex-alist-local-flag
. If you want to change this -- if you want
Ultra-TeX to complete on commands defined in document A when you're
editing document B -- then customize the variable
ultex-alist-local-flag
(in the customization group
"ultra-tex-commands".
ultex-reset-current-alist
,
which resets the list to its default (the contents of the appropriate
textree files) in the current buffer, or in all TeX buffers if
ultex-alist-local-flag
is off.
If you want to add a command to your textree file (hence permanently
adding the command to the list of TeX commands on which Ultra-TeX
completes), you should run the command ultex-new-cs
. In
Ultra-TeX mode, this is bound to the key sequence C-c C-n.
When you do this, a new buffer, `*TeX Completions Edit*', is opened in another window, and a backslash is inserted (just to get you started). You type in your new command, including all the brackets and braces you want, put the cursor where you want the point to be when this string is inserted in your TeX document, and then hit M-C-c to exit. You will be asked if you want to use this command in math mode exclusively; if you say yes, you will get an error message if you try to use it outside of a math environment (but the command will still be inserted). If the current buffer is using more than one file of TeX commands, you will be asked in which file to store the command.
For example, if I wanted to add the command `\sqrt[]{}' to my
textree file, I would hit C-c C-n to run ultex-new-cs
, then
type sqrt[]{} in the new buffer (remember, the backslash is
already there). Then I would put the cursor inside the brackets, and
hit M-C-c.
This will add the line
("\\sqrt[]{}" -3 . ultex-math-mode)
to the appropriate textree file. The first entry here is the command, the second entry is the number of characters the point is offset from the end of the string, and the last entry says that this command should only be used in a math environment.
If your textree file has some commands you don't want, you can run the
command ultex-delete-csname-from-tree-file
. This prompts you for
a command and then deletes it from the textree file. If the command is
in more than one of the textree files associated to this buffer, you are
asked to specify the file, also.
You can also edit the command files by hand. If you have want to get rid of the command `\sqrt[]{}', open the textree file, and look for a line like
("\\sqrt[]{}" -3 . ultex-math-mode)
Once you have found it, delete it and save the file. (In case you're not familiar with emacs lisp and you want to do this: just be careful to delete a region starting with a left parenthesis and ending with its matching right parenthesis. Of course, if you're nervous about it, make a backup of your textree file, and then play around.)
If you want to disable a TeX command for this editing session (in
this buffer only, if you have made ultex-current-alist
local),
call the function ultex-delete-csname
, bound to the key sequence
C-c C-d. You are prompted for a TeX command you don't want,
and the one you select is removed, temporarily, from the master list.
When TeX sees text between two dollar signs (like `$x=y$'), it processes that text in math mode. There are a number of other ways of typesetting mathematics, such as the `equation' environment and the `eqnarray' environment. In Ultra-TeX mode, you can get at all of these things using the $ key.
Here is what $ does:
\[ \]and puts the point on the blank line.
\begin{equation}\label{} \end{equation}and puts the point in the argument of `\label'.
\begin{equation*} \end{equation*}with the point on the blank line, then
\begin{equation}\label{}\n\n\end{equation}then
\begin{equation*}\n\n\end{equation*}then
\begin{align}\label{} \end{align}then
\begin{align*} \end{align*}then
\begin{gather}\label{} \end{gather}then
\begin{gather*} \end{gather*}then
\begin{multline}\label{} \end{multline}then
\begin{multline*} \end{multline*}
\[ \]and (aside from the fact that you've skipped the first option -- a pair of dollar signs) the whole thing starts over again. If you would rather start over again with `$$' instead, then set the variable
ultex-dollar-back
to 0.
This works even if the math environment is not empty. For example, if you have
\begin{equation}\label{wiles} x^{n} + y^{n} = z^{n} \end{equation}
and you hit $, then you get
\begin{equation*} x^{n} + y^{n} = z^{n} \end{equation*}
Hitting $ again gives
\begin{align}\label{wiles} x^{n} + y^{n} = z^{n} \end{align}
If you ever just want a single dollar sign, you can either type C-q $, or hit $ and then delete one of the two dollar signs that were just inserted (using C-d or DEL, for instance).
You can change the strings that get inserted by customizing the variable
ultex-dollar-array
(customization group "ultra-tex-environments").
The RET key in Ultra-TeX mode tries to move the point forward by the "appropriate amount."
ultex-return-checks-for-new-command
.
To insert a newline, use M-RET. LFD ends a paragraph when that makes sense, and checks the paragraph to see if parentheses, etc., are properly matched.
In a typical TeX document, one might use a number of different type faces -- bold-face, italics, small caps, whatever. Ultra-TeX provides an easy way to insert the command to change type faces.
Here is a typical example: hitting M-E inserts the string `\emph{}', and puts the point inside the braces. (Note: that key sequence is META-SFT-e, not META-e). The META key, in combination with various other capital letters, produces similar effects:
These keys all call the function ultex-font
, with an appropriate
argument. This wasn't written with customization in mind, but if you
want to modify things, you can try adding lines like this to your
`.emacs' file (see section .ultex file):
(define-key ultra-tex-mode-map "\C-[D" '(lambda nil (interactive) (ultex-font "bozo")))
and see what happens when you hit M-D, both in and out of a math
environment. If things don't work the way you want, you may have to
modify the definition of the function ultex-font
.
The user's textree file (see section Making a list) stores a lot of her favorite TeX commands, and hitting the $ key (see section Dollar signs) produces some other useful commands. There is a third way to insert TeX commands -- via a Greek keyboard.
If you hit the left quote key ` followed by a, then `\alpha' is inserted into the buffer (and you get an error if you're not in a math environment). Similarly, `b gives you `\beta', etc.
Furthermore, while hitting `g gives `\gamma', hitting `G gives `\Gamma'. Once you hit the ` key, you can access the (ordinary) Greek keyboard, the Shift Greek keyboard, the Control Greek keyboard, the Meta, the Meta Shift, and the Meta Control Greek keyboards. This gives you a lot of slots for storing TeX commands.
In order to see what symbols are stored in these slots, you can use the \ key: hitting `\ opens up a little window which displays a chart with the typewriter keys and their effect in the Greek keyboard -- it might look something like this:
times amalg oplus otime odot wedge vee sqcup cap cup uplus pm circ 1 2 3 4 5 6 7 8 9 0 - = ` theta infty varep rho tau upsil xi iota omega pi subse supse q w e r t y u i o p [ ] alpha sigma delta varph gamma eta exist kappa lambd int in a s d f g h j k l ; ' zeta chi psi foral beta nu mu sum prod not z x c v b n m , . /
(Unfortunately, it only has room to display the first five characters of the TeX command.) In this example, hitting `, would produce `\sum', hitting `6 would produce `\wedge', hitting `e would produce `\varepsilon'.
Similarly, hitting `| gives you the Shift Greek keyboard, `C-\ gives the Control Greek keyboard, etc.
The bindings for the Greek keyboards are stored in a greek-keys file.
Remarks:
ultex-greek-keys-file
. See section Installation, for how to set this,
if you're not sure.
http://www.math.washington.edu/~palmieri/Emacs/LaTeX-symbols
. The variables
ultex-display-pictures
, ultex-picture-type
, and
ultex-picture-directory
are relevant here. (To find out if your
copy of XEmacs has xpm support, evaluate (featurep 'xpm)
-- t
means it has xpm support, nil means it doesn't. If you want to use
pictures in some other format, that's fine, but you'll have to convert
the xpm files included in the LaTeX symbols package to the desired
format on your own.)
There are a number of other features. I'll probably forget one or two, but here are most of them:
ultex-latex-skel-file
. A sample file is included in the package:
`skeleton.tex'. (Also, once the template is inserted, Emacs runs
ultex-skel-hook
.)
ultex-match-brackets
and ultex-match-parens
.
On the other hand, if you don't want this behavior for {, then
customize ultex-match-braces
.
ultex-array-environs
, which is a list
consisting of environments that use `&' for "tab stops". Change
this variable to change the behavior of TAB.)
itemizing-environments
, which a list consisting of
environments that use `\item'.)
http://www.math.washington.edu/~palmieri/Emacs/LaTeX-symbols
,
provides commands to open up windows with tables of symbols. The
easiest way to access these is from the Ultra-TeX menu;
alternatively, you can call these functions: latex-symbol-greek
,
latex-symbol-operators
, latex-symbol-relations
,
latex-symbol-arrows
, latex-symbol-miscellany
, and
latex-symbol-all
.
Once you have the package in front of you, you should look at the file `INSTALLATION'. That tells you how to byte-compile the Emacs lisp code and how to produce the documentation in various formats. It also has basic instructions for how to modify your `.emacs' file. Here are more details about `.emacs':
(setq load-path (cons "/home/palmieri/emacs/ultratex/lisp" load-path))
(require 'ultex-setup)
Now the next time you start Emacs, whenever you find a TeX file, you will automatically be put into Ultra-TeX mode.
When Ultra-TeX starts up, it loads the file `.ultex'. This was useful in versions of Ultra-TeX before 0.50, when one would set many options by hand and then wanted to avoid cluttering up the `.emacs' file with various Ultra-TeX settings. This is not so useful in version 0.50 (or later) of the Ultra-TeX package, since all of the features can be customized, and the customizations get stored in `.emacs' automatically.
The name of the `.ultex' file is given by the variable
ultex-init-file
, so if you'd rather give this file a different
name, like `.ultra-tex-stuff.el', then customize this variable
accordingly.
Many of the features of Ultra-TeX mode are customizable. The best way to change this is with the customization feature of Emacs: run
M-x customize-group GRP
where GRP is one of the Ultra-TeX customization groups, to each of which we devote a subsection.
To change these:
M-x customize-group ultra-tex
All of the other Ultra-TeX mode groups can be accessed from this one, also.
ultex-complete-idle-time
ultra-tex-mode-hook
To change these:
M-x customize-group ultra-tex-init
ultex-init-file
ultex-use-color
ultex-use-font-latex
font-latex
package
for colorization. This variable is only relevant if
ultex-use-color
is `on'. One version of the file
`font-latex.el' is distributed with Ultra-TeX. The most recent
version is available from
ftp://ftp.phys.ocean.dal.ca/users/rhogee/elisp/font-latex.el
ultex-use-auctex
http://sunsite.auc.dk/auctex/
.
See section ultra-tex-auctex, for options related to this one.
ultex-use-imenu
imenu
package in
Ultra-TeX mode. The `imenu' package lets you pop up a menu giving
an outline of the buffer, so that you can move around to various section
headings and theorem statements and so forth. If this option is on,
then S-mouse-3 (hold down the shift key, and hit (and release) the right
mouse button) runs the command imenu
, which pops up the
aforementioned menu.
ultex-use-bib-cite
bib-cite
package in
Ultra-TeX mode. The bib-cite
package does stuff with your
labels and citations -- highlights them, lets you jump to them, etc.
This option is not well-tested, and may yield unpredictable results.
The latest version of bib-cite
is available from
ftp://ftp.phys.ocean.dal.ca/users/rhogee/elisp/bib-cite.el
.
To change these:
M-x customize-group ultra-tex-files
ultex-tree-file
ultex-extra-tree-files
ultex-tree-file
) is
not loaded. See section Making a list.
ultex-greek-keys-file
ultex-latex-skel-file
get-latex-skel
is run.
See section Everything else.
ultex-skel-hook
get-latex-skel
is run.
See section Everything else.
To change these:
M-x customize-group ultra-tex-commands
ultex-alist-local-flag
ultex-rescan-after-new-label
ultex-return-checks-for-new-commands
ultex-append-space-to-defs
To change these:
M-x customize-group ultra-tex-parens
ultex-match-braces
ultex-match-brackets
ultex-match-parens
ultex-blink-matching-bracket
ultex-blink-matching-paren
To change these:
M-x customize-group ultra-tex-environments
ultex-array-environs
(array tabular eqnarray eqnarray* align gather alignat aligned gathered alignedat split CD matrix smallmatrix pmatrix bmatrix vmatrix Vmatrix xalignat xxalignat cases)Description: List of symbols of array environments. See section Everything else.
ultex-math-start
ultex-math-end
ultex-itemizing-environments
(list trivlist itemize description enumerate)
.
Description: List of symbols of LaTeX environments which use
`\item'. When the point is in one of these environments, hitting
\\ inserts a new line and the text `\item'.
See section Everything else.
ultex-math-cs-regexp
ultex-non-math-cs-regexp
ultex-def-regexp
ultex-dollar-array-cursor
ultex-dollar-array
.
See section Dollar signs.
ultex-dollar-array
"$|$" "\[\n|\n\]" "\begin{equation}\label{|}\n\n\end{equation}" "\begin{equation*}\n|\n\end{equation*}" "\begin{align}\label{|}\n\n\end{align}" "\begin{align*}\n|\n\end{align*}" "\begin{gather}\label{|}\n\n\end{gather}" "\begin{gather*}\n|\n\end{gather*}" "\begin{multline}\label{|}\n\n\end{multline}" "\begin{multline*}\n|\n\end{multline*}"where I have written `\n' for `newline'. Description: List of strings inserted by hitting $. The first time you hit $, the first string is inserted. Hitting it again replaces the first string with the second, etc. After inserting each string, the cursor is placed at the spot marked by the string
ultex-dollar-array-cursor
. If you do not include the string
ultex-dollar-array-cursor
anywhere, Emacs will try to guess where
to put the cursor.
(Warning: customization sets the variable
ultex-dollar-array-external
, which has the above default value.
If you want to set this directly, not via customize, then you should set
ultex-dollar-array
, which has a different syntax. Read the
documentation for that variable for help.)
See section Dollar signs.
ultex-dollar-back
ultex-dollar-array
to start over with once the elements have been
cycled through once. The elements are numbered starting with 0.
See section Dollar signs.
To change these:
M-x customize-group ultra-tex-misc
ultex-slash-dollar-is-not-math
ultex-dont-use-completion
ultex-display-pictures
ultex-picture-type
ultex-picture-directory
Except for ultex-ignore-auctex-tex.el
, the rest of these come
from AUC-TeX. To change them:
M-x customize-group ultra-tex-auctex
ultex-ignore-auctex-tex.el
load
command (rather
than require
). If the only piece of AUC-TeX you ever use is
the part that comes with Ultra-TeX, then you have nothing to worry
about. If you use other parts of the AUC-TeX distribution, then you
might want to set this variable to nil. I can't guarantee that
Ultra-TeX and AUC-TeX will interact well in that case, though.
TeX-display-help
TeX-next-error
.
TeX-debug-bad-boxes
TeX-next-error
.
These options all come from AUC-TeX. To change them:
M-x customize-group ultra-tex-auctex-files
TeX-master
TeX-one-master
TeX-file-extensions
TeX-macro-global
TeX-macro-private
TeX-check-path
TeX-macro-private
and
TeX-macro-global
, as well as the current directory. Description:
Directory path to search for dependencies.
BibTeX-file-extensions
BibTeX-style-extensions
TeX-default-extension
These options all come from AUC-TeX. To change them:
M-x customize-group ultra-tex-auctex-commands
TeX-command-BibTeX
TeX-command-list
.
TeX-command-Show
TeX-command-Print
TeX-command-Print
.
TeX-command-Queue
TeX-command-Queue
.
TeX-print-command
TeX-expand-list
.
TeX-queue-command
TeX-expand-list
.
TeX-printer-list
(("Local" "dvips -f %s | lpr" "lpq") ("lw") ("ps"))Description: List of available printers. The first element of each entry is the printer name. The second element is the command used to print to this printer. It defaults to the value of
TeX-print-command
. The third element is the command used to
examine the print queue for this printer. It defaults to the value of
TeX-queue-command
. Any occurence of `%p' in the second or
third element is expanded to the printer name given in the first
element, then ordinary expansion is performed as specified in
TeX-expand-list
.
TeX-printer-default
TeX-printer-list
, or if that is
not set, "lw". Description: Default printer to use with
TeX-command
.
TeX-view-style
(("^a5$" "xdvi %d -paper a5") ("^landscape$" "xdvi %d -paper a4r -s 4") ("." "xdvi %d"))Description: List of style options and view options. If the first element (a regular expresion) matches the name of one of the style files, any occurrence of the string `%v' in a command in
TeX-command-list
will be replaced with the second element. The
first match is used, if no match is found the `%v' is replaced with
the empty string.
TeX-expand-list
("%s" file nil t)Description: List of expansion strings for TeX command names. Each entry is a list with two or more elements. The first element is the string to be expanded. The second element is the name of a function returning the expanded string when called with the remaining elements as arguments. The special value `file' will be expanded to the name of the file being processed, with an optional extension.
TeX-command-list
("LaTeX" "%l '\\nonstopmode\\input{%t}'" TeX-run-LaTeX nil t)Description: List of commands to execute on the current document. Each element is a list of five elements, whose first element is the name of the command as it will be presented to the user. The second element is the string handed to the shell after being expanded. The expansion is done using the information found in
TeX-expand-list
. The third
element is the function which actually start the process. Several such
hooks has been defined; see the function documentation for a
description. If the fourth element is non-nil, the user will get a
chance to modify the expanded string. The fifth element is obsolete and
ignored.
These options all come from AUC-TeX. To change them:
M-x customize-group ultra-tex-auctex-latex
LaTeX-version
LaTeX-command-style
LaTeX-version
is "2e", then (("." "latex"))).
If LaTeX-version
is "2", then a longer list. Description: List
of style options and LaTeX commands.
This document was generated on 17 September 1999 using the texi2html translator version 1.51a.