From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Mon, 2 Sep 2019 13:46:59 +0900
Subject: Initial commit

---
 .../latex/contrib/keyval2e/keyval2e-examples.tex   | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 macros/latex/contrib/keyval2e/keyval2e-examples.tex

(limited to 'macros/latex/contrib/keyval2e/keyval2e-examples.tex')

diff --git a/macros/latex/contrib/keyval2e/keyval2e-examples.tex b/macros/latex/contrib/keyval2e/keyval2e-examples.tex
new file mode 100644
index 0000000000..a13274b3e2
--- /dev/null
+++ b/macros/latex/contrib/keyval2e/keyval2e-examples.tex
@@ -0,0 +1,67 @@
+% 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<#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} 
\ No newline at end of file
-- 
cgit v1.2.3

