Difference between revisions of "Command/define"

From Wiki
Jump to navigation Jump to search
Line 21: Line 21:
  
 
== Description ==  
 
== Description ==  
<pre>
+
<tt>\define</tt> is like the TeX primitive <tt>\def</tt>: it defines a new TeX macro. Unlike  
\define is like the TeX primitive \def: it defines a new TeX macro. Unlike  
+
<tt>\def</tt>, it will not allow you to redefine an already defined command.
\def, it will not allow you to redefine an already defined command.
 
  
 
The optional (bracketed) argument denotes the number of parameters you can give  
 
The optional (bracketed) argument denotes the number of parameters you can give  
to your command. text is the result when the macro gets expanded. \define is
+
to your command. text is the result when the macro gets expanded. <tt>\define</tt> is
not \long, that means you cannot use \par inside the arguments.
+
not <tt>\long</tt>, that means you cannot use <tt>\par</tt> inside the arguments.
  
</pre>
 
 
== comment ==
 
== comment ==
 
<pre>
 
<pre>

Revision as of 19:03, 18 April 2010

\define

Syntax

\define[...]\command{...}
[...] number
{...} text


Description

\define is like the TeX primitive \def: it defines a new TeX macro. Unlike \def, it will not allow you to redefine an already defined command.

The optional (bracketed) argument denotes the number of parameters you can give to your command. text is the result when the macro gets expanded. \define is not \long, that means you cannot use \par inside the arguments.

comment

is there any bonus when I use \define instead of \def? -PG


Example

\define[1]\hello{Good morning, #1}

\starttext
\hello{mom} % Good morning mom
\stoptext


See also