Prev Up Next
Go backward to 7.3 Symbols from other languages
Go up to 7 Carrying on
Go forward to 7.5 Theorems and such

7.4 Defining commands and environments

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.

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}{\htmlimage{badexample_bitmap.xbm}}

   \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.


Otfried Schwarzkopf, September 2, 1997

Prev Up Next