Defining commands and environments | Contents | Index |
Hyperlatex understands definitions of new commands with the
LaTeX-instructions \newcommand
and \newenvironment
.
\renewcommand
and \renewenvironment
are
understood as well (Hyperlatex makes no attempt to test whether a
command is actually already defined or not.) The optional parameter
of LaTeX2e is also implemented.
If you use \providecommand
, Hyperlatex checks whether the command
is already defined. The command is ignored if the command already
exists.
Note that it is not possible to redefine a Hyperlatex command that is
hard-coded in Emacs lisp inside the Hyperlatex converter. So
you could redefine the command \cite
or the verse
environment,
but you cannot redefine \T
. (But you can redefine most of the
commands understood by Hyperlatex, namely all the ones defined in
siteinit.hlx.)
Some basic examples:
\newcommand{\Html}{\textsc{Html}} \T\newcommand{\bad}{$\surd$} \W\newcommand{\bad}{\htmlimg{badexample_bitmap.xbm}{BAD}} \newenvironment{badexample}{\begin{description} \item[\bad]}{\end{description}} \newenvironment{smallexample}{\begingroup\small \begin{example}}{\end{example}\endgroup}
Command definitions made by Hyperlatex are global, their scope is not
restricted to the enclosing environment. If you need to restrict their
scope, use the \begingroup
and \endgroup
commands to create a
scope (in Hyperlatex, this scope is completely independent of the
LaTeX-environment scoping).
Note that Hyperlatex does not tokenize its input the way TeX does.
To evaluate a macro, Hyperlatex simply inserts the expansion string,
replaces occurrences of #1
to #9
by the arguments, strips one
# from strings of at least two #'s, and then reevaluates
the whole. Problems may occur when you try to use %, \T
, or
\W
in the expansion string. Better don't do that.
Defining commands and environments | Contents | Index |