| 1 |
% This file demonstrates the use of the l3keys2e module to allow |
| 2 |
% LaTeX3 keyvals (created using l3keys) to be used as LaTeX2e |
| 3 |
% package or class options. |
| 4 |
% |
| 5 |
|
| 6 |
% First, create a class |
| 7 |
\begin{filecontents}{l3keys2e-class.cls} |
| 8 |
\LoadClass{article} |
| 9 |
\RequirePackage{l3keys2e} |
| 10 |
\ProvidesExplClass{l3keys2e-class}{0000/00/00}{0.0}{test} |
| 11 |
\keys_define:nn { test1 } { |
| 12 |
option1 .code:n = {\wlog{You~gave~`#1'~for~option1}} |
| 13 |
} |
| 14 |
\ProcessKeysOptions { test1 } |
| 15 |
\end{filecontents} |
| 16 |
|
| 17 |
% Load the class with some options. |
| 18 |
% The class itself recognizes `option1', leaving `option2' and |
| 19 |
% `option3' as global options which are not yet used. |
| 20 |
\documentclass[option1=check,option2=more stuff,option3=unused] |
| 21 |
{l3keys2e-class} |
| 22 |
|
| 23 |
%Now create a package |
| 24 |
\begin{filecontents}{l3keys2e-package.sty} |
| 25 |
\RequirePackage{l3keys2e} |
| 26 |
\ProvidesExplPackage{l3keys2e-package}{0000/00/00}{0.0}{test} |
| 27 |
\keys_define:nn { test2 } { |
| 28 |
option1 .code:n = {\wlog{You~gave~`#1'~for~option1~(again)}}, |
| 29 |
option2 .code:n = {\wlog{You~gave~`#1'~for~option2}}, |
| 30 |
option4 .code:n = {\wlog{You~gave~`#1'~for~option4}}, |
| 31 |
} |
| 32 |
\ProcessKeysOptions { test2 } |
| 33 |
\end{filecontents} |
| 34 |
|
| 35 |
% Load the package. |
| 36 |
\usepackage[option4={extra stuff},option5=undefined!] |
| 37 |
{l3keys2e-package} |
| 38 |
|
| 39 |
\begin{document} |
| 40 |
% The log should show that option3 is an unused global option, and that |
| 41 |
% option5 is not known by the l3keys2e-demo package. Everything else |
| 42 |
% should simply be listed in the log. |
| 43 |
\end{document} |