I have a command defined as follows
\documentclass{article}
\makeatletter%
\newcommand{\@withstar}[3]{We have star #1, #2, #3}
\newcommand{\@withoutstar}[3]{We have #1, #2, #3}
\DeclareRobustCommand\mycmd{%
\@ifnextchar *%
{\@firstoftwo{\@withstar}} %
{\@withoutstar}
}%
\makeatother%
\begin{document}
\mycmd{first}{second}{and third}
\mycmd*{first}{second}{and third}
\end{document}
I want to define another command that just passes the next character to \mycmd
and sets specific arguments. Something along the lines of
\newcommand\newcmd[1]{\mycmd\nextchar{first}{,second}}
Then I can call it like
\newcmd{and third}
or
\newcmd*{and third}
I understand that I can repeat the test for next char (using @ifnextchar
) inside the definition of \newcmd
, but I would like to avoid that if possible because in my real situation \mycmd
tests for many characters, not just *.
xparse
and its\NewDocumentCommand
and argument specifier features