Download The ltxkeys Package
Transcript
The ltxkeys package
19th December 2011
name (i. e., \hprefi@hfami@hkeyi). \parentval is always available for use as the default value of
dependant keys, but it may be lost in the callbacks of dependant keys, because a dependant key,
once defined, may be set independent of, and long after, the parent key has been executed. It is
therefore more reliable to refer to the macro \hprefi@hfami@hkeyi@value, which is recorded for
only the parent key of style keys and which holds the current user input for the parent key. The
macro \hprefi@hfami@hkeyi@value is recorded only if it appears at least once in the attributes of
dependant keys. The macro \hprefi@hfami@hkeyi@value has a more unique name than \hmpihkeyi
but they always contain the same value of a style key. As mentioned above, if hmpi is not given,
the user input for a style key will be available in the macro \stylehprefi@hfami@hkeyi, instead of
\hmpihkeyi.
Note 3.1 ‘#1’ in the callback of parent key refers to the current value of the parent key, while ‘#1’
in the callback of any dependant key refers to the current value of that dependant key. Here is an
example that defines and sets all undefined dependants on the fly:
Examples: \ltxkeys@stylekey
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
\ltxkeys@stylekey?[KV]{fam}[mp@]{keya}[{left}](%
% ‘#1’ here refers to the value of the DEPENDANT key
% at the time it is being set. Use \parentkey and \parentval
% here to access the parent key name and its current value:
ord/keyb/{right}/\def\y##1{#1##1};
% The default of keyc is the current value of parent (keya):
cmd/keyc/\parentval;
% Because \KV@fam@keya@value appears below, it will be saved
% when the parent key keya is being set, otherwise it would be
% unavailable:
bool/keyd/true/\ifmp@keyd\edef\x##1{##1\KV@fam@keya@value}\fi
){%
% ‘#1’ here refers to the value of the PARENT key at the time
% it is being set:
\def\x##1{##1xx#1xx}%
% Check the value of parent key:
\ltxkeys@checkchoice[,](\userinput\order){#1}{left,right,center}{}{%
\@latex@error{Invalid input ’#1’}\@ehd
}%
}
In this example, \userinput corresponds to #1, and \order is the numerical order of the user input
in the nominations {left | right | center}. More about the commands \ltxkeys@checkchoice
and \CheckUserInput can be found in subsection 17.2.
You can try setting keya as follows to see what happens to keys keyb, keyc and keyd:
Example: \ltxkeys@setkeys
49
\ltxkeys@setkeys[KV]{fam}{keya=right}
The following will flag an error because {right} isn’t in the list of nominations {left | right |
center}:
Example: \ltxkeys@setkeys
50
\ltxkeys@setkeys[KV]{fam}{keya={right}}
Page 8 of 66