I am trying to use the package options
to define a new command type option which invokes the default argument when not provided with an argument. I have tried the following MWE which defines the new option type myopttype
. It works for the example in Case I but not for the one in Case II where xxx should be typeset in italics.
I am not very familiar with the inner workings of the package options
. Could someone come to my aid?
\documentclass{article}
\usepackage{options}
\makeatletter
\options{
/handlers/new myopttype/.new handler = [\itshape]\optionsalso{%
#1/.new cmd = \option@set{#1}{##1}\optionvalue,
#1/.type = mypottype,
#1/.initial = {#2},
},
}
\options{
/mycommand/.new family,
/mycommand/myoption/.new myopttype
}
\newcommand{\mycommand}[1][]{%
\options{/mycommand,#1}%
}
\makeatother
\begin{document}
{\bfseries Testing the option:}
\vspace{1.5mm}
{\bfseries Case I:} Using \texttt{\textbackslash mycommand[myoption=\textbackslash bfseries]}
aaa {\mycommand[myoption=\bfseries] xxx}.
\vspace{1.5mm}
{\bfseries Case II:} Using \texttt{\textbackslash mycommand}
aaa {\mycommand xxx}.
\end{document}
\newcommand{\mycommand}[1][myoption=\itshape]{...}