Difference between revisions of "Command/define"

From Wiki
Jump to navigation Jump to search
(→‎Description: fine in luatex)
Line 21: Line 21:
  
 
== Description ==  
 
== Description ==  
<code>\define</code> is like the TeX primitive <code>\def</code>: it defines a new TeX macro. Unlike  
+
<code>\define</code> is like the TeX primitive <code>\def</code>: it defines a new TeX macro.  
<code>\def</code>, it will not allow you to redefine an already defined command.
+
 
 +
=== define vs def ===
 +
Unlike <code>\def</code>, 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.  
 
to your command. "text" is the result when the macro gets expanded.  
  
 +
== pitfalls ==
 
<code>\define</code> does not use <code>\long</code>, that means in MkII
 
<code>\define</code> does not use <code>\long</code>, that means in MkII
 
multiple paragraphs (e.g. through <code>\par</code> or <code>\endgraf</code>)
 
multiple paragraphs (e.g. through <code>\par</code> or <code>\endgraf</code>)
 
inside arguments will not work.
 
inside arguments will not work.
 +
 +
The name of the new command may not include numbers.
  
 
== comment ==
 
== comment ==

Revision as of 02:21, 5 December 2010

\define

Syntax

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


Description

\define is like the TeX primitive \def: it defines a new TeX macro.

define vs def

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.

pitfalls

\define does not use \long, that means in MkII multiple paragraphs (e.g. through \par or \endgraf) inside arguments will not work.

The name of the new command may not include numbers.

comment

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


Example

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

\starttext
\hello{mom}
\stoptext

See also

http://en.wikibooks.org/wiki/TeX/def