[XeTeX] newcommand with optional arguments

Sven Siegmund sven.siegmund at gmail.com
Mon Mar 3 12:25:27 CET 2008


Hi,

I need to define a command with an optional parameter. I saw a nice
description here
(http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/teTeX/latex/latex2e-html/ltx-18.html)
and defined a command like this:

\providecommand{\nuu}[1][1]{\textit{#2} `#1'} % all words of nuu write
in this style

When I write \nuu{mudi} the result shall be mudi (in italics).
When I write \nuu[goat]{mudi} the result shall be mudi (in italics
followed by) 'goat' (which is the meaning of "mudi" in the N|uu
language.)

When I try to compile the document with xelatex, it complains:

This is XeTeX, Version 3.141592-2.2-0.997 (MiKTeX 2.7)
entering extended mode
(notes.tex
LaTeX2e <2005/12/01> ...
...
...
! Illegal parameter number in definition of \\nuu.
<to be read again>
                   2
l.9 \providecommand{\nuu}[1][1]{\textit{#2} `#1'}
                                              % all words of nuu write in th...

What have I done wrong? I have tried to swap those number in the
command definition, but he complains again the same way.

S.


More information about the XeTeX mailing list