Index
Go backward to Mathematical formulas
Go up to Carrying on
Go forward to Theorems and such

Defining commands and environments

Hyperlatex understands command definitions with \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.)

Note that it is not possible to redefine a Hyperlatex command that is hard-coded into the Hyperlatex converter. So you could redefine the command \cite or the verse environment, but you cannot redefine \T. (Currently, the only way to determine whether a command is hard-coded is to try or to look at the Hyperlatex source file.)

When a command definition appears in the preamble, it must start at the beginning of a line, with only whitespace before it (the macro definitions may be prepended with \W as well).

Some examples:

   \newcommand{\Html}{\textsc{Html}}

   \T\newcommand{\bad}{$\surd$}
   \W\newcommand{\bad}{\htmlimage{badexample_bitmap.xbm}}

   \newenvironment{badexample}{\begin{description}
                   \item[\bad]}{\end{description}}

   \W \newenvironment{smallexample}{\begin{example}}{\end{example}}
   \T \newenvironment{smallexample}{\begingroup\small
               \begin{example}}{\end{example}\endgroup}
The \bad command and the smallexample environments are good examples for conditional compilation. The smallexample environment is equal to example in HTML, but is typeset in a smaller font in the LaTeX document.

Command definitions made by Hyperlatex are global, their scope is not restricted to the enclosing environment.

Note that Hyperlatex does not tokenize its input the way TeX does. To evaluate your macros, 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. Since the white space after a command is already removed when the command is parsed, the following code will not work in Hyperlatex:

   \newcommand{\smallit}{\small\it}
     ...
   And now some \smallit text in smaller italics.
Hyperlatex will complain with the error message "Command \ittext undefined." To avoid this, you should always leave a final space in the expansion string, if it ends with a macro invocation. So the right way is to write:
   \newcommand{\smallit}{\small\it }
     ...
   And now some \smallit text in smaller italics.
And everything will work fine.

Problems also occur when you try to use %, \T, or \W in the expansion string. Don't do that.


otfried@postech.vision.ac.kr

Prev Up Next