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