[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 How to define new macros

The normal way to define or redefine macros is to use the builtin \define:

 
\define{name}{parameters}{expansion}

which defines name to expand to expansion.

The following example defines the macro \foo to expand to the text `Hello World.'.

 
\define\foo{}{Hello world.}
=>
\foo
=>Hello world.

parameters is used to tell how the macro accepts arguments. It consists of numbers followed by #. Each argument is referred by #-number in expansion. For example:

 
\define\bar{#1}{Good #1.}
=>
\bar{morning}
=>Good morning.

A parameter can be followed by an optional delimiters (a character). If an optional delimiters is given, text from point to the character is regarded as an argument. For example:

 
\define\baz{#1/}{#1.}
=>
\baz This is an argument/
=>This is an argument.

A macro definition can be removed with undefine:

 
\undefine{name}

which removes the macro name.



This document was generated on February, 23 2003 using texi2html