[XeTeX] \newcommand and ZWNJ

Ulrike Fischer news3 at nililand.de
Thu Apr 30 10:56:22 CEST 2009


Am Thu, 30 Apr 2009 19:07:26 +1030 schrieb
vafa at live.com.au:

> Hi
> 
> If I define a new command, where the name of the command is in Persian like:
> 
> 
> 
> \newcommand\سیاه[1]{\textbf{#1}}

> Then that works fine but if a command name contains ZWNJ character
> which is common in Persian like:
 
> \newcommand\متن‌سیاه[1]{\textbf{#1}}
> Then I get error and that is
> %%%%%%%%%%%%%%%%%%%%%%
> ! LaTeX Error: Missing \begin{document}.
> 
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.3 \newcommand\متن‌س
>                            یاه[1]{\textbf{#1}}

You command name contains a symbol which is not a "letter" (that
means its catcode is not =11). You would get the same with pdflatex
if you do something like this:

\newcommand\abc]a{!}

You can change the catcode or use \csname...\endcsname to build the
command, but I general I would say it is much safer to use simple
command names. 

> But it does not happen if I use \def instead \newcommand

\def can use "delimited" argument. The non-letter symbols are not
part of the command name but part of the syntax of the argument. 

-- 
Ulrike Fischer 



More information about the XeTeX mailing list