[XeTeX] newcommand with optional arguments

Sven Siegmund sven.siegmund at gmail.com
Tue Mar 4 10:35:55 CET 2008


Thank you, Morten,

the problem was I did not know how the first piece with \makeatletter
relates to the actual core \newcommand* code. I thought it would be
embedded somewhere within it.

I still do not understand the individual commands, but I see the
complete code you send works well and may be universally used.

Sorry for my confusion, I'll try to read some TeX reference to find
out what those Commands, @'s nTF's and so on mean.

S.


2008/3/4, Morten Høgholm <morten.hoegholm at gmail.com>:
> On Tue, Mar 4, 2008 at 10:19 AM, Sven Siegmund <sven.siegmund at gmail.com> wrote:
>  > And I think the ultimate aolution to all this fuss may be what is written here:
>  >
>  > http://tex.loria.fr/texlive-htmldoc/eplain/eplain_6.html#SEC50
>  >
>  > But again: I do not really understand these TeX source codes...
>
>
> Sven, I have a feeling you are getting increasingly confused. Here is
>  a complete example showing how it can be done.
>
>  \documentclass{article}
>
>  \makeatletter
>
> \long\def\tlist at if@empty at nTF #1{%
>   \expandafter\ifx\expandafter\\\detokenize{#1}\\%
>    \expandafter\@firstoftwo
>   \else
>    \expandafter\@secondoftwo
>   \fi
>  }
>
>
> \newcommand*\nuu[2][]{%
>   \textit{#2}%
>   \tlist at if@empty at nTF{#1}{}{ `#1'}% only the false code executed
>  }
>  \makeatother
>  \begin{document}
>
> \nuu{this} \nuu[22]{this} \nuu[goat]{mudi}
>
> \end{document}
>
>  --
>
> Morten
>
> _______________________________________________
>  XeTeX mailing list
>  postmaster at tug.org
>  http://tug.org/mailman/listinfo/xetex
>


More information about the XeTeX mailing list