I'm trying to create a command, called \newcscommand
, that lets me define commands with values separated by commas.
Here's what I have so far
\documentclass{article}
\usepackage{xparse}
\newcommand{\newcscommand}[3]{
\NewDocumentCommand{ #1 }{ >{\SplitArgument{#2 - 1}{,}}m }{\csname aux\endcsname##1} % the auxiliary command should be named 'auxtest' instead of just aux
\newcommand{\aux}[#2]{#3} % same here
}
\newcscommand{\test}{3}{#1 is #2 a #3.}
\begin{document}
\test{This, just, test}
\end{document}
I use an auxiliary command to split the comma separated list, which should be called 'aux + the name of the command', however I couldn't get it to work so I left it as 'aux' in the MWE, which is if of course wrong because if I call newcscommand
twice I'll get an error.
I know that I have to use csname
and endcsname
somehow, but I haven't figured it out.
How can I get this to work? Is there a totally different and better way to do this that I don't know about?