There are several packages for defining a key=value syntax. I'll show keyval
as it's part pf the basic latex distribution, and I know something about it.
If you LaTeX the following:
\makeatletter % not needed in a .sty file
\RequirePackage{keyval}
\define@key{test}{key}{%
\count@=#1\relax}
\define@key{test}{color}{%
\def\thiscolor{#1}}
\newcommand{\mycommand}[1]{%
\count@=0 % default
\def\thiscolor{}% default
\setkeys{test}{#1}%
\ifodd\count@
\typeout{key=\the\count@: Odd!}%
\else
\typeout{key=\the\count@: Even!}%
\fi
\typeout{the color is \thiscolor}}
\typeout{======}
\mycommand{key=1,color=red]}
\stop
You will see both keys have been processed and the following typeouts are made
======
key=1: Odd!
the color is red]
)
No pages of output.
The way this works is the package handles the splitting up of the comma separated settings , but for each key "key" and "color" here you have to define a command that does something with the value. Here the key is a number to be saved in \count@
and the colour is treated as text stored in \thiscolor
, then after processing the keys these values can be used as normal TeX code.
\mycommand
have to distinguish between differentkey
s? For example, do you allow inputs like\mycommand[house=1]
,\mycommand[tree=2]
,\mycommand[house=4,tree=1]
?\coursecontent[yes]
or since there are only two values have no argument at all and just\coursecontent
and\coursecontent*
(which you can code easily by using\def\coursecontent{\@ifstar{code for * version}{code for other version}}