[XeTeX] command argument as macro

Morten Høgholm morten.hoegholm at latex-project.org
Thu Oct 8 14:20:20 CEST 2009


On Thu, Oct 8, 2009 at 2:13 PM, Vafa Khalighi <vafa at users.berlios.de> wrote:
>> is it possible to use a command argument as macro itself? The idea is
>>
>> something like this:
>>
>> \document{article}
>> \newcommand{\coma}{1}
>> \newcommand{\comb}{2}
>> \newcommand{\comc}{3}
>> \newcommand{\getnumber}[1]{ \#1 }
>> \begin{document}
>> \getnumber{coma}
>> \end{document}
>
>
> \def\getnumber#1{\aftergroup\#1}

Huh? This will insert the digit 1 now and a hash mark after the end of
the current group.

I believe we are looking at

\makeatletter
\newcommand*\getnumber[1]{\@nameuse{#1}}
\makeatother

Possibly with a some extra checks to see whether the command called
has been defined.
-- 
Morten


More information about the XeTeX mailing list