| 1 |
\documentclass{article} |
| 2 |
\usepackage{xcolor} |
| 3 |
\usepackage{ltxkeys} |
| 4 |
\makeatletter |
| 5 |
\def\somemethod#1#2{% |
| 6 |
\begingroup |
| 7 |
\color{#1}% |
| 8 |
\ifltxkeys@novalue |
| 9 |
\ifnum\ltxkeys@listcount=\@ne |
| 10 |
\endgraf |
| 11 |
Using default value of `\ltxkeys@tkey': |
| 12 |
\fi |
| 13 |
\else |
| 14 |
\ifnum\ltxkeys@listcount=\@ne |
| 15 |
\endgraf |
| 16 |
Using user value of `\ltxkeys@tkey': |
| 17 |
\fi |
| 18 |
\fi |
| 19 |
\endgroup |
| 20 |
\endgraf |
| 21 |
Processing item no. \ltxkeys@listcount: #2% |
| 22 |
} |
| 23 |
% Use comma (,), the default list separator, as the list separator |
| 24 |
% for keya and keyb: |
| 25 |
\ltxkeys@listkey[KV]{fam}{keya,keyb}[default1,default2]{% |
| 26 |
\somemethod{blue}{#1}% |
| 27 |
% Process only four (4) items of the list/value for keya and keyb: |
| 28 |
\ifnum\ltxkeys@listcount=4\relax |
| 29 |
\stopprocessinglistkey |
| 30 |
\fi |
| 31 |
} |
| 32 |
|
| 33 |
% Use semicolon (;) as the list separator for keyc and keyd: |
| 34 |
\ltxkeys@listkey[KV]{fam}{keyc,keyd}[default1;default2]{% |
| 35 |
\listsep{;}\somemethod{red}{#1}% |
| 36 |
} |
| 37 |
|
| 38 |
\makeatother |
| 39 |
|
| 40 |
\begin{document} |
| 41 |
\parindent0pt |
| 42 |
% No values for keya and keyb; use their default values: |
| 43 |
\ltxkeysusekeys[KV]{fam}{keya,keyb} |
| 44 |
|
| 45 |
\par\bigskip |
| 46 |
\ltxkeysusekeys[KV]{fam}{% |
| 47 |
keya={item1A,item1B,item1C,item1D,item1E,item1F}, |
| 48 |
keyb={item2A,item2B,item2C,item2D,item2E,item2F} |
| 49 |
} |
| 50 |
|
| 51 |
\par\bigskip |
| 52 |
% Set keyc and keyd with their default values: |
| 53 |
\ltxkeysusekeys[KV]{fam}{keyc,keyd} |
| 54 |
|
| 55 |
\par\bigskip |
| 56 |
\ltxkeysusekeys[KV]{fam}{% |
| 57 |
keyc={item1A;item1B;item1C;item1D}, |
| 58 |
keyd={item2A;item2B;item2C;item2D} |
| 59 |
} |
| 60 |
\end{document} |
| 61 |
|