[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Adding support for environments is very much like adding support for TeX macros, except that each environment normally only takes one argument, an environment hook. The example is again a short version of ‘latex.el’.
(TeX-add-style-hook "latex" (lambda () (LaTeX-add-environments '("document" LaTeX-env-document) '("enumerate" LaTeX-env-item) '("itemize" LaTeX-env-item) '("list" LaTeX-env-list)))) |
The only hook that is generally useful is LaTeX-env-item
, which is
used for environments that contain items. It is completely up to the
environment hook to insert the environment, but the function
LaTeX-insert-environment
may be of some help. The hook will be
called with the name of the environment as its first argument, and extra
arguments can be provided by adding them to a list after the hook.
For simple environments with arguments, for example defined with
‘\newenvironment’, you can make AUCTeX prompt for the arguments
by giving the prompt strings in the call to
LaTeX-add-environments
. (An optional argument can be indicated
by putting the prompt string into a vector.) For example, if you have
defined a loop
environment with the three arguments from,
to, and step, you can add support for them in a style file.
%% loop.sty \newenvironment{loop}[3]{...}{...} |
;; loop.el (TeX-add-style-hook "loop" (lambda () (LaTeX-add-environments '("loop" "From" "To" "Step")))) |
If an environment is defined multiple times, AUCTeX will chose the one with the longest definition. Thus, if you have an enumerate style file, and want it to replace the standard LaTeX enumerate hook above, you could define an ‘enumerate.el’ file as follows, and place it in the appropriate style directory.
(TeX-add-style-hook "latex" (lambda () (LaTeX-add-environments '("enumerate" LaTeX-env-enumerate foo)))) (defun LaTeX-env-enumerate (environment &optional ignore) ...) |
The symbol foo
will be passed to LaTeX-env-enumerate
as
the second argument, but since we only added it to overwrite the
definition in ‘latex.el’ it is just ignored.
Add each env to list of loaded environments.
Insert environment of type env, with optional argument extra.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated on July 21, 2009 using texi2html 1.82.