SE, lately I'm playing around with expl3
and xparse
a little and I encountered following problem: I want to create a command which creates a new
command -- similar to this post. This is not as hard, as long the second command doesn't have any arguments; trying to create a command, which accepts arguments is a little more tricky.
What I got so far:
\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand\test{ m}
{
\NewDocumentCommand#1 {m}
{My name is \string#1, king of kings}
}
\begin{document}
\test{\ozymandias}
\ozymandias{\manthano}
\end{document}
This outputs My name is ozymandias, king of kings
, which gives the correct sonnet, but not what I wanted. I know where the problem is, I just don't know how to fix it atm :)
\string#1
is unclear! What do you expect this to do? – user31729 Feb 4 '16 at 23:25##1
– egreg Feb 4 '16 at 23:47\string#1
was used as an example, basically I just intended to do more complicated stuff. – manthano Feb 5 '16 at 7:04