<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% keyval2e.sty examples, version 0.0.2, August 2011

\documentclass{article}
\usepackage{keyval2e,color}
\makeatletter
\kve@definekeys[KV]{fam}[mp@]{%
  keyone/+/\ifstrcmpTF{#1}{+}{\def\userinput{#1}}{\def\userinput{not `+'}},
  keytwo/+,
  keythree/+,
  keyfour/+,
  keyfive/true/\ifmp@keyfive\def\x{keyfive is 'true'}\else
    \def\x{keyfive is 'false'}\fi,
  keysix/true
}

% \show\ifmp@keyfive

% The starred variant of \kve@definekeys gives error for the
% already defined key 'keyone':
% \kve@definekeys*[KV]{fam}[mp@]{keyone/+}

% Changing the family and macro-prefix makes 'keyone' definable again:
\kve@definekeys*[KV]{famx}[mpx@]{keyone/+}

\def\fourplus{+,+,+,+}
\newcommand*\putmany[2][*]{%
  \begingroup
  \toks@{}\@tempcnta\z@
  \loop
  \advance\@tempcnta\@ne
  \toks@\expandafter{\the\toks@#1}%
  \ifnum\@tempcnta&lt;#2\relax
  \repeat
  \expandafter\endgroup\the\toks@
}
\newcommand{\testa}[2]{%
  \kve@setafterdefaults[KV]{fam}{#2}%
  \edef\tempa{\mp@keyone,\mp@keytwo,\mp@keythree,\mp@keyfour}%
  \noindent
  \vbox{%
    \hsize\dimexpr1.1\hsize\relax\leftskip=-1.5cm
    \def\redstar{\textcolor{red}{*}}\ttfamily
    Test #1: \redstar\space\texttt{\tempa}\space\redstar\space
    \ifxTF\tempa\fourplus
      {All values are defaults\putmany[\space]{2}}%
      {At least one value is set}%
    \@spaces\textcolor{red}{||} keyone's value: \userinput
  }%
}
\newcommand{\testb}[2][]{\testa{#2}{#1}}

\begin{document}

\title{The \texttt{\color{blue}keyval2e} Package \\Examples}
\maketitle

\testa{Aa}{}\\
\testa{Ba}{keyone=+,  keythree=+}\\
\testa{Ca}{keytwo=+,  keythree=a}\\
\testa{Da}{keyone=b,  keythree=a,keyfour=+}\\

\testb{Ab}\\
\testb[keyone=+,  keythree=+]{Bb}\\
\testb[keytwo=+,  keythree=a]{Cb}\\
\testb[keyone=b,  keytwo=+,keythree=a]{Db}\\

\end{document} </pre></body></html>