l3keys in LaTeX3
.default:n / .initial:n
请看如下一段代码:
1 |
|
在上述的例子中一个是.initial:n
, 一个是 .default:n
, 都表示设置其默认值. 在命令 \keys_set:nn
中:
- 如果没有出现
keyb
, 对应的.default
语句便不会被执行. 如果出现了keyb
, 但没有赋值,此时其对应的(默认)语句便会执行. - 无论其中是否出现
keya
, 对应的.initial
语句均会执行.
choice key
.choice:
when set key of this type:
- it accepts only one choice(belong to a set of valid choices) in a times.
1 |
|
output:
1 |
|
.choices:nn
when set key of this type:
- (B). all the choices share the same code.
1 |
|
output:
1 |
|
.multichoice:
when set key of this type:
- (A). it accepts a set of choices in a time(multiple choice).
1 |
|
output:
1 |
|
.multichoices:nn
when set key of this type:
- (A). it accepts a set of choices in a time(multiple choice), and,
- (B). all the choices share the same code.
1 |
|
output:
1 |
|
meta-元键
介绍
其实就是你传入的参数,比如{keya=valuea, keyb=valueb}
解释为键值对,然后再提取 value 给对应的 key 进行赋值. 详细的说明请参见下图:
案例
一个简单的使用案例:
1 |
|
结果输出:
1 |
|
key’s group
An simple example:
1 |
|
The output:
1 |
|
inhert
example I - intro
An simple example:
1 |
|
The output:
1 |
|
example II - add key
Other example, see: Inheritance of keys in expl3:
1 |
|
The output:
1 |
|
example III complicate inherit
The code as follows:
1 |
|
The output:
1 |
|
example IV - delete key
The code as follows:
1 |
|
the shell log is:
1 |
|
And the final output is:
1 |
|
The above results shows that pkeyA
is not in childkeyA
, then if you use:
1 |
|
the output will be:
1 |
|
temp variables
For each key processed, information of the full path of the key, the name of the key and the value of the key is available within two string and one token list variables.
\l_keys_path_str
: “full” description of the key, for example:mymodule/subset/key-a
.\l_keys_key_str
: part of the path after the last/
, by the above example, the value iskey-a
.\l_keys_value_tl
: everything after the=
.
Inside the code block for a choice generated using .choices:nn
, the variables:
\l_keys_choice_tl
: the name of the current choice,\l_keys_choice_int
: its position in the comma list.
others
usage
usage, see example:
1 |
|
the Scope of use stored in variable \l_keys_usage_<load|preamble>_prop
:
1 |
|
other command
some low level interface to handle key-value data:
\keyval_parse:nnn
,\keys_precompile:nnN
,\keys_if_exist:nnTF
,\keys_if_choice_exist:nnnTF
,- …
source code
The source code of this post:
1 |
|
the output of this source code: