# commandx optional arguments

I have a custom command for the package todonotes

\newcommandx{\custom}[3][1=]{\todo[#1,author=#2]{#3}}


which is supposed to be used like:

\custom[inline]{author1,some comments}


E: main.tex:124 Package xkeyval Error: some comments' undefined in families todonotes'

• You are only specifying two parameters, it should probably read \custom[inline]{author1}{some comments}. In your case, you are using \todo[inline,author=author1,some comments] where some comments is an invalid key for the todonotes package. – epR8GaYuh Feb 20 '18 at 14:23
• Rather than xargs, I'd use xparse and \NewDocumentCommand{\custom}{O{}mm}{\todo[#1,author=#2]{#3}} with a call such as \custom[inline]{author1}{whatever}. More robust. – egreg Feb 20 '18 at 14:51