I have been reading this page on defining commands with *-options. I have got completely stuck, though. I'd like the following.
A command with an optional argument and a star option.
Optional Argument:
\cmd{b}
-->N_b
and\cmd[a]{b}
-->N_b(a)
Starred Argument:
\cmd*{b}
-->N^*_b
and\cmd*[a]{b}
-->N^*_b(a)
I'm not sure if one can use the star argument as well as an optional argument, though.
These are my attempts, but they don't work.
\makeatletter\newcommand{\cmd}[2]{% \@ifstar {% \ifthenelse{\equal{}{#1}}% {\NN^*_{#2}}% {\NN^*_{#2}(#1)}% }% {% \ifthenelse{\equal{}{#1}}% {\NN_{#2}}% {\NN_{#2}(#1)}% }}\makeatother---------------\makeatletter\newcommand{\cmd}[2]{% \@ifstar \cmdStar[#1]{#2}% \cmdNoStar[#1]{#2}% \makeatother}\newcommand{\cmdStar}[2]{% \ifthenelse{\equal{}{#1}} {\NN_{#2}} {\NN_{#2}(#1)}}\newcommand{\cmdNoStar}[2]{% \ifthenelse{\equal{}{#1}} {\NN^*_{#2}} {\NN^*_{#2}(#1)}}