I am using kvoptions for a key-value syntax. However I need a switch syntax for the evaluation. Since boolexpr is problamatic (see here) I use now the other solution of this question.
However the switch is not working as expected (always results in the same value).
This is the code that I use:
\documentclass[]{scrbook}
\makeatletter
\RequirePackage{kvoptions-patch}
\RequirePackage{kvoptions} % options
\RequirePackage{pdftexcmds} % string comparison
\SetupKeyvalOptions{family=demo,prefix=demo@}
% parallel, stacked
\DeclareStringOption[stacked]{style}
\ProcessKeyvalOptions{demo}
\newcommand{\PrintDemoUsingKeys}{%
\ifnum\pdf@strcmp{\demo@style}{parallel}=0%
parallel%
\else\ifnum\pdf@strcmp{\demo@style}{stacked}=0%
stacked%
\else%
\PackageError{templatedemo}{%
\MessageBreak%
value >\tplbugs@style< unkown \MessageBreak%
}{}%
\fi\fi%
}%
% Print code and result using the key-value syntax
\newcommand{\PrintDemo}[2][]{%
% #1 is the optional keyval argument
% #2 is a mandatory argument
\begingroup%
\setkeys{demo}{#1}%
% Do stuff with #2
\PrintDemoUsingKeys%
\endgroup%
}
\makeatother
\begin{document}
\PrintDemo{style=parallel}
\PrintDemo{style=stacked}
\end{document}
\PrintDemoUsingKeyswill never see any change. – Joseph Wright Jan 20 '12 at 22:42