Quantcast
Channel: Active questions tagged starred-version - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 63

Using Starred Version as Optional Argument

$
0
0

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)}}

Viewing all articles
Browse latest Browse all 63

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>