Interface 3
Interface 3
Interface 3
Abstract
This is the reference documentation for the expl3 programming environment; see the
matching source3 PDF for the typeset sources. The expl3 modules set up a naming
scheme for LATEX commands, which allow the LATEX programmer to systematically
name functions and variables, and specify the argument types of functions.
The TEX and ε-TEX primitives are all given a new name according to these con-
ventions. However, in the main direct use of the primitives is not required or en-
couraged: the expl3 modules define an independent low-level LATEX3 programming
language.
The expl3 modules are designed to be loaded on top of LATEX 2ε . With an up-to-
date LATEX 2ε kernel, this material is loaded as part of the format. The fundamental
programming code can also be loaded with other TEX formats, subject to restrictions
on the full range of functionality.
∗ E-mail: [email protected]
i
Contents
I Introduction 1
1 Introduction to expl3 and this document 2
1.1 Naming functions and variables . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 Scratch variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.2 Terminological inexactitude . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Formal language conventions which apply generally . . . . . . . . . . . . 7
1.4 TEX concepts not supported by LATEX3 . . . . . . . . . . . . . . . . . . . 7
II Bootstrapping 8
2 The l3bootstrap package: Bootstrap code 9
2.1 Using the LATEX3 modules . . . . . . . . . . . . . . . . . . . . . . . . . . 9
ii
5 The l3expan package: Argument expansion 31
5.1 Defining new variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2 Methods for defining variants . . . . . . . . . . . . . . . . . . . . . . . . 32
5.3 Introducing the variants . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4 Manipulating the first argument . . . . . . . . . . . . . . . . . . . . . . . 35
5.5 Manipulating two arguments . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.6 Manipulating three arguments . . . . . . . . . . . . . . . . . . . . . . . . 37
5.7 Unbraced expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.8 Preventing expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.9 Controlled expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.10 Internal functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
iii
10 The l3sys package: System/runtime functions 75
10.1 The name of the job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
10.2 Date and time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
10.3 Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
10.4 Output format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
10.5 Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
10.6 Random numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
10.7 Access to the shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
10.8 Loading configuration data . . . . . . . . . . . . . . . . . . . . . . . . . . 79
10.8.1 Final settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
iv
15.5.2 Head and tail of token lists . . . . . . . . . . . . . . . . . . . . . . 120
15.5.3 Items and ranges in token lists . . . . . . . . . . . . . . . . . . . . 122
15.5.4 Sorting token lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
15.6 Manipulating tokens in token lists . . . . . . . . . . . . . . . . . . . . . . 124
15.6.1 Replacing tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
15.6.2 Reassigning category codes . . . . . . . . . . . . . . . . . . . . . . 125
15.7 Constant token lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
15.8 Scratch token lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
v
20 The l3seq package: Sequences and stacks 151
20.1 Creating and initialising sequences . . . . . . . . . . . . . . . . . . . . . 151
20.2 Appending data to sequences . . . . . . . . . . . . . . . . . . . . . . . . 153
20.3 Recovering items from sequences . . . . . . . . . . . . . . . . . . . . . . . 153
20.4 Recovering values from sequences with branching . . . . . . . . . . . . . 155
20.5 Modifying sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
20.6 Sequence conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
20.7 Mapping over sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
20.8 Using the content of sequences directly . . . . . . . . . . . . . . . . . . . 160
20.9 Sequences as stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
20.10 Sequences as sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
20.11 Constant and scratch sequences . . . . . . . . . . . . . . . . . . . . . . . 163
20.12 Viewing sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
vi
24 The l3token package: Token manipulation 194
24.1 Creating character tokens . . . . . . . . . . . . . . . . . . . . . . . . . . 195
24.2 Manipulating and interrogating character tokens . . . . . . . . . . . . . . 196
24.3 Generic tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
24.4 Converting tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
24.5 Token conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
24.6 Peeking ahead at the next token . . . . . . . . . . . . . . . . . . . . . . . 204
24.7 Description of all possible tokens . . . . . . . . . . . . . . . . . . . . . . 209
24.8 Deprecated functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
vii
27 The l3keys package: Key–value interfaces 237
27.1 Creating keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
27.2 Sub-dividing keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
27.3 Choice and multiple choice keys . . . . . . . . . . . . . . . . . . . . . . . 244
27.4 Key usage scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
27.5 Setting keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
27.6 Handling of unknown keys . . . . . . . . . . . . . . . . . . . . . . . . . . 247
27.7 Selective key setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
27.8 Digesting keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
27.9 Utility functions for keys . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
27.10 Low-level interface for parsing key–val lists . . . . . . . . . . . . . . . . . 250
viii
33 The l3text package: Text processing 288
33.1 Expanding text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
33.2 Case changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
33.3 Removing formatting from text . . . . . . . . . . . . . . . . . . . . . . . 291
33.4 Control variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
33.5 Mapping to graphemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
VI Typesetting 293
34 The l3box package: Boxes 294
34.1 Creating and initialising boxes . . . . . . . . . . . . . . . . . . . . . . . . 294
34.2 Using boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
34.3 Measuring and setting box dimensions . . . . . . . . . . . . . . . . . . . 296
34.4 Box conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
34.5 The last box inserted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
34.6 Constant boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
34.7 Scratch boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
34.8 Viewing box contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
34.9 Boxes and color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
34.10 Horizontal mode boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
34.11 Vertical mode boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
34.12 Using boxes efficiently . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
34.13 Affine transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
34.14 Viewing part of a box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
34.15 Primitive box conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . 306
ix
37 The l3pdf package: Core PDF support 321
37.1 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
37.2 Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
37.3 Page (media) size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
37.4 Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
37.5 Destinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Index 328
x
Part I
Introduction
1
Chapter 1
This document is intended to act as a comprehensive reference manual for the expl3
language. A general guide to the LATEX3 programming language is found in expl3.pdf.
c This means csname, and indicates that the argument will be turned into a csname
before being used. So \foo:c {ArgumentOne} will act in the same way as \foo:N
\ArgumentOne. All macros that appear in the argument are expanded. An internal
error will occur if the result of expansion inside a c-type argument is not a series
of character tokens.
V and v These mean value of variable. The V and v specifiers are used to get the con-
tent of a variable without needing to worry about the underlying TEX structure
containing the data. A V argument will be a single token (similar to N), for example
2
\foo:V \MyVariable; on the other hand, using v a csname is constructed first, and
then the value is recovered, for example \foo:v {MyVariable}.
o This means expansion once. In general, the V and v specifiers are favoured over o
for recovering stored information. However, o is useful for correctly processing
information with delimited arguments.
x The x specifier stands for exhaustive expansion: every token in the argument is fully
expanded until only unexpandable ones remain. The TEX \edef primitive carries
out this type of expansion. Functions which feature an x-type argument are not
expandable.
e The e specifier is in many respects identical to x, but uses \expanded primitive. Para-
meter character (usually #) in the argument need not be doubled. Functions which
feature an e-type argument may be expandable.
f The f specifier stands for full expansion, and in contrast to x stops at the first non-
expandable token (reading the argument from left to right) without trying to expand
it. If this token is a ⟨space token ⟩, it is gobbled, and thus won’t be part of the
resulting argument. For example, when setting a token list variable (a macro used
for storage), the sequence
\tl_set:Nn \l_mya_tl { A }
\tl_set:Nn \l_myb_tl { B }
\tl_set:Nf \l_mya_tl { \l_mya_tl \l_myb_tl }
will leave \l_mya_tl with the content A\l_myb_tl, as A cannot be expanded and
so terminates expansion before \l_myb_tl is considered.
T and F For logic tests, there are the branch specifiers T (true) and F (false). Both
specifiers treat the input in the same way as n (no change), but make the logic
much easier to see.
p The letter p indicates TEX parameters. Normally this will be used for delimited func-
tions as expl3 provides better methods for creating simple sequential arguments.
w Finally, there is the w specifier for weird arguments. This covers everything else, but
mainly applies to delimited values (where the argument must be terminated by
some specified string).
D The D stands for Do not use. All of the TEX primitives are initially \let to a D name,
and some are then given a second name. These functions have no standardized
syntax, they are engine dependent and their name can change without warning,
thus their use is strongly discouraged in package code: programmers should instead
use the interfaces documented in interface3.pdf1 .
Notice that the argument specifier describes how the argument is processed prior to being
passed to the underlying function. For example, \foo:c will take its argument, convert
it to a control sequence and pass it to \foo:N.
Variables are named in a similar manner to functions, but begin with a single letter
to define the type of variable:
1 If a primitive offers a functionality not yet in the kernel, programmers and users are encouraged
3
c Constant: global parameters whose value should not be changed.
g Parameters whose value should only be set globally.
ior/iow An input or output stream, for reading from or writing to, respectively.
prop Property list: analogue of dictionary or associative arrays in other languages.
regex Regular expression.
2 The module names are not used in case of generic scratch registers defined in the data type modules,
e.g., the int module contains some scratch variables called \l_tmpa_int, \l_tmpb_int, and so on. In
such a case adding the module name up front to denote the module and in the back to indicate the type,
as in \l_int_tmpa_int would be very unreadable.
4
1.1.1 Scratch variables
Modules focussed on variable usage typically provide four scratch variables, two local
and two global, with names of the form \⟨scope ⟩_tmpa_⟨type ⟩/\⟨scope ⟩_tmpb_⟨type ⟩.
These are never used by the core code. The nature of TEX grouping means that as
with any other scratch variable, these should only be set and used with no intervening
third-party code.
5
\seq_new:N \seq_new:N ⟨sequence ⟩
\seq_new:c
When a number of variants are described, the arguments are usually illustrated only for
the base function. Here, ⟨sequence ⟩ indicates that \seq_new:N expects the name of a
sequence. From the argument specifier, \seq_new:c also expects a sequence name, but
as a name rather than as a control sequence. Each argument given in the illustration
should be described in the following text.
Fully expandable functions Some functions are fully expandable, which allows them
to be used within an x-type or e-type argument (in plain TEX terms, inside an \edef or
\expanded), as well as within an f-type argument. These fully expandable functions are
indicated in the documentation by a star:
Restricted expandable functions A few functions are fully expandable but cannot
be fully expanded within an f-type argument. In this case a hollow star is used to indicate
this:
Conditional functions Conditional (if) functions are normally defined in three vari-
ants, with T, F and TF argument specifiers. This allows them to be used for different
“true”/“false” branches, depending on which outcome the conditional is being used to
test. To indicate this without repetition, this information is given in a shortened form:
• \sys_if_engine_xetex:TF
Usually, the illustration will use the TF variant, and so both ⟨true code ⟩ and ⟨false
code ⟩ will be shown. The two variant forms T and F take only ⟨true code ⟩ and ⟨false
code ⟩, respectively. Here, the star also shows that this function is expandable. With
some minor exceptions, all conditional functions in the expl3 modules should be defined
in this way.
Variables, constants and so on are described in a similar manner:
\l_tmpa_tl A short piece of text will describe the variable: there is no syntax illustration in this case.
In some cases, the function is similar to one in LATEX 2ε or plain TEX. In these cases,
the text will include an extra “TEXhackers note” section:
6
\token_to_str:N ⋆ \token_to_str:N ⟨token ⟩
The normal description text.
TEXhackers note: Detail for the experienced TEX or LATEX 2ε programmer. In this case,
it would point out that this function is the TEX primitive \string.
Changes to behaviour When new functions are added to expl3, the date of first
inclusion is given in the documentation. Where the documented behaviour of a function
changes after it is first introduced, the date of the update will also be given. This means
that the programmer can be sure that any release of expl3 after the date given will contain
the function of interest with expected behaviour as described. Note that changes to code
internals, including bug fixes, are not recorded in this way unless they impact on the
expected behaviour.
7
Part II
Bootstrapping
8
Chapter 2
TEXhackers note: Spaces introduced by ~ behave much in the same way as normal space
characters in the standard category code regime: they are ignored after a control word or at
the start of a line, and multiple consecutive ~ are equivalent to a single one. However, ~ is not
ignored at the end of a line.
9
\GetIdInfo \GetIdInfo $Id: ⟨SVN info field ⟩ $ {⟨description ⟩}
Updated: 2012-06-04 Extracts all information from a SVN field. Spaces are not ignored in these fields. The in-
formation pieces are stored in separate control sequences with \ExplFileName for the part
of the file name leading up to the period, \ExplFileDate for date, \ExplFileVersion
for version and \ExplFileDescription for the description.
To summarize: Every single package using this syntax should identify itself using
one of the above methods. Special care is taken so that every package or class file loaded
with \RequirePackage or similar are loaded with usual LATEX 2ε category codes and the
LATEX3 category code scheme is reloaded when needed afterwards. See implementation
for details. If you use the \GetIdInfo command you can use the information when
loading a package with
\ProvidesExplPackage{\ExplFileName}
{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
10
Chapter 3
11
Part III
Programming Flow
12
Chapter 4
As the name suggest this package holds some basic definitions which are needed by most
or all other packages in this set.
Here we describe those functions that are used all over the place. With that we mean
functions dealing with the construction and testing of control sequences. Furthermore
the basic parts of conditional processing are covered; conditional processing dealing with
specific data types is described in the modules specific for the respective data types.
\prg_do_nothing: ⋆ \prg_do_nothing:
An expandable function which does nothing at all: leaves nothing in the input stream
after a single expansion.
\scan_stop: \scan_stop:
A non-expandable function which does nothing. Does not vanish on expansion but pro-
duces no typeset output.
\group_begin: \group_begin:
\group_end: \group_end:
These functions begin and end a group for definition purposes. Assignments are local
to groups unless carried out in a global manner. (A small number of exceptions to this
rule will be noted as necessary elsewhere in this document.) Each \group_begin: must
be matched by a \group_end:, although this does not have to occur within the same
function. Indeed, it is often necessary to start a group within one function and finish it
within another, for example when seeking to use non-standard category codes.
13
\group_insert_after:N \group_insert_after:N ⟨token ⟩
Adds ⟨token ⟩ to the list of ⟨tokens ⟩ to be inserted when the current group level ends.
The list of ⟨tokens ⟩ to be inserted is empty at the beginning of a group: multiple appli-
cations of \group_insert_after:N may be used to build the inserted list one ⟨token ⟩
at a time. The current group level may be closed by a \group_end: function or by a
token with category code 2 (close-group), namely a } if standard category codes apply.
\group_show_list: \group_show_list:
\group_log_list: \group_log_list:
New: 2021-05-11 Display (to the terminal or log file) a list of the groups that are currently opened. This
is intended for tracking down problems.
14
Within each set of scope there are different ways to define a function. The differences
depend on restrictions on the actual parameters and the expandability of the resulting
function.
nopar Create a new function with the nopar restriction, such as \cs_set_nopar:Npn.
The parameter may not contain \par tokens.
protected Create a new function with the protected restriction, such as \cs_set_-
protected:Npn. The parameter may contain \par tokens but the function will not
expand within an e-type or x-type expansion.
Finally, the functions in Subsections 4.3.2 and 4.3.3 are primarily meant to define
base functions only. Base functions can only have the following argument specifiers:
N and n No manipulation.
T and F Functionally equivalent to n (you are actually encouraged to use the family of
\prg_new_conditional: functions described in Section 9.1).
p and w These are special cases.
The \cs_new: functions below (and friends) do not stop you from using other argu-
ment specifiers in your function names, but they do not handle expansion for you. You
should define the base function and then use \cs_generate_variant:Nn to generate
custom variants as described in Section 5.2.
15
\cs_new_protected_nopar:Npn \cs_new_protected_nopar:Npn ⟨function ⟩ ⟨parameters ⟩ {⟨code ⟩}
\cs_new_protected_nopar:cpn
\cs_new_protected_nopar:Npe
\cs_new_protected_nopar:cpe
\cs_new_protected_nopar:Npx
\cs_new_protected_nopar:cpx
Creates ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. When
the ⟨function ⟩ is used the ⟨parameters ⟩ absorbed cannot contain \par tokens. The
⟨function ⟩ will not expand within an e-type or x-type argument. The definition is
global and an error results if the ⟨function ⟩ is already defined.
Sets ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. When
the ⟨function ⟩ is used the ⟨parameters ⟩ absorbed cannot contain \par tokens. The
assignment of a meaning to the ⟨function ⟩ is restricted to the current TEX group level.
The ⟨function ⟩ will not expand within an e-type or x-type argument.
16
\cs_gset:Npn \cs_gset:Npn ⟨function ⟩ ⟨parameters ⟩ {⟨code ⟩}
\cs_gset:cpn
Globally sets ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩,
\cs_gset:Npe
\cs_gset:cpe the ⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. The
\cs_gset:Npx assignment of a meaning to the ⟨function ⟩ is not restricted to the current TEX group
\cs_gset:cpx level: the assignment is global.
Globally sets ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩,
the ⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function.
When the ⟨function ⟩ is used the ⟨parameters ⟩ absorbed cannot contain \par tokens.
The assignment of a meaning to the ⟨function ⟩ is not restricted to the current TEX
group level: the assignment is global. The ⟨function ⟩ will not expand within an e-type
or x-type argument.
17
\cs_new_protected:Nn \cs_new_protected:Nn ⟨function ⟩ {⟨code ⟩}
\cs_new_protected:(cn|Ne|ce)
Creates ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
number of ⟨parameters ⟩ is detected automatically from the function signature. These
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. The
⟨function ⟩ will not expand within an e-type or x-type argument. The definition is global
and an error results if the ⟨function ⟩ is already defined.
Creates ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
number of ⟨parameters ⟩ is detected automatically from the function signature. These
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. When
the ⟨function ⟩ is used the ⟨parameters ⟩ absorbed cannot contain \par tokens. The
⟨function ⟩ will not expand within an e-type or x-type argument. The definition is
global and an error results if the ⟨function ⟩ is already defined.
Sets ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
number of ⟨parameters ⟩ is detected automatically from the function signature. These
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. When
the ⟨function ⟩ is used the ⟨parameters ⟩ absorbed cannot contain \par tokens. The
⟨function ⟩ will not expand within an e-type or x-type argument. The assignment of a
meaning to the ⟨function ⟩ is restricted to the current TEX group level.
18
\cs_gset:Nn \cs_gset:Nn ⟨function ⟩ {⟨code ⟩}
\cs_gset:(cn|Ne|ce)
Sets ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
number of ⟨parameters ⟩ is detected automatically from the function signature. These
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. The
assignment of a meaning to the ⟨function ⟩ is global.
Sets ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
number of ⟨parameters ⟩ is detected automatically from the function signature. These
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. The
⟨function ⟩ will not expand within an e-type or x-type argument. The assignment of a
meaning to the ⟨function ⟩ is global.
Sets ⟨function ⟩ to expand to ⟨code ⟩ as replacement text. Within the ⟨code ⟩, the
number of ⟨parameters ⟩ is detected automatically from the function signature. These
⟨parameters ⟩ (#1, #2, etc.) will be replaced by those absorbed by the function. When
the ⟨function ⟩ is used the ⟨parameters ⟩ absorbed cannot contain \par tokens. The
⟨function ⟩ will not expand within an e-type or x-type argument. The assignment of a
meaning to the ⟨function ⟩ is global.
Uses the ⟨creator ⟩ function (which should have signature Npn, for example \cs_-
new:Npn) to define a ⟨function ⟩ which takes ⟨number ⟩ arguments and has ⟨code ⟩ as
replacement text. The ⟨number ⟩ of arguments is an integer expression, evaluated as
detailed for \int_eval:n.
19
\cs_new_eq:NN \cs_new_eq:NN ⟨cs1 ⟩ ⟨cs2 ⟩
\cs_new_eq:(Nc|cN|cc) \cs_new_eq:NN ⟨cs1 ⟩ ⟨token ⟩
Globally creates ⟨control sequence1 ⟩ and sets it to have the same meaning as ⟨control
sequence2 ⟩ or ⟨token ⟩. The second control sequence may subsequently be altered with-
out affecting the copy.
TEXhackers note: This is the TEX primitive \meaning. For tokens that are not control
sequences, it is more logical to use \token_to_meaning:N. The c variant correctly reports
undefined arguments.
20
\cs_log:N \cs_log:N ⟨control sequence ⟩
\cs_log:c
Writes the definition of the ⟨control sequence ⟩ in the log file. See also \cs_show:N
New: 2014-08-22 which displays the result in the terminal.
Updated: 2017-02-14
TEXhackers note: These are the TEX primitives \csname and \endcsname.
21
\tl_new:N \l_my_tl
\tl_set:Nn \l_my_tl { a b c }
\cs:w \tl_use:N \l_my_tl \cs_end:
would be equivalent to
\abc
after one expansion of \cs:w.
TEXhackers note: The prefix can be empty, \long, \protected or \protected\long with
backslash replaced by the current escape character.
22
\cs_parameter_spec:N ⋆ \cs_parameter_spec:N ⟨token ⟩
New: 2022-06-24 If the ⟨token ⟩ is a macro, this function leaves the primitive TEX parameter specification
in input stream as a string of character tokens of category code 12 (with spaces having
category code 10). Thus for example
TEXhackers note: If the parameter specification contains the string ->, then the function
produces incorrect results.
TEXhackers note: If the parameter specification contains the string ->, then the function
produces incorrect results.
23
\use:n ⋆ \use:n {⟨group1 ⟩}
\use:nn ⋆ \use:nn {⟨group1 ⟩} {⟨group2 ⟩}
\use:nnn ⋆ \use:nnn {⟨group1 ⟩} {⟨group2 ⟩} {⟨group3 ⟩}
\use:nnnn ⋆ \use:nnnn {⟨group1 ⟩} {⟨group2 ⟩} {⟨group3 ⟩} {⟨group4 ⟩}
As illustrated, these functions absorb between one and four arguments, as indicated by
the argument specifier. The braces surrounding each argument are removed and the
remaining tokens are left in the input stream. The category code of these tokens is also
fixed by this process (if it has not already been by some other absorption). All of these
functions require only a single expansion to operate, so that one expansion of
\use:nn { abc } { { def } }
results in the input stream containing
abc { def }
24
\use_i:nn ⋆ \use_i:nn {⟨arg1 ⟩} {⟨arg2 ⟩}
\use_ii:nn ⋆ \use_i:nnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩}
\use_i:nnn ⋆ \use_i:nnnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩} {⟨arg4 ⟩}
\use_ii:nnn ⋆ \use_i:nnnnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩} {⟨arg4 ⟩} {⟨arg5 ⟩}
\use_iii:nnn ⋆ \use_i:nnnnnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩} {⟨arg4 ⟩} {⟨arg5 ⟩} {⟨arg6 ⟩}
\use_i_ii:nnn ⋆ \use_i:nnnnnnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩} {⟨arg4 ⟩} {⟨arg5 ⟩} {⟨arg6 ⟩} {⟨arg7 ⟩}
\use_i:nnnn ⋆ \use_i:nnnnnnnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩} {⟨arg4 ⟩} {⟨arg5 ⟩} {⟨arg6 ⟩} {⟨arg7 ⟩}
\use_ii:nnnn ⋆ {⟨arg8 ⟩}
\use_iii:nnnn ⋆ \use_i:nnnnnnnnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩} {⟨arg4 ⟩} {⟨arg5 ⟩} {⟨arg6 ⟩} {⟨arg7 ⟩}
\use_iv:nnnn ⋆ {⟨arg8 ⟩} {⟨arg9 ⟩}
\use_i:nnnnn ⋆
These functions absorb a number (n) arguments from the input stream. They then
\use_ii:nnnnn ⋆
discard all arguments other than that indicated by the roman numeral, which is left in
\use_iii:nnnnn ⋆
\use_iv:nnnnn ⋆ the input stream. For example, \use_i:nn discards the second argument, and leaves the
\use_v:nnnnn ⋆ content of the first argument in the input stream. The category code of these tokens is
\use_i:nnnnnn ⋆ also fixed (if it has not already been by some other absorption). A single expansion is
\use_ii:nnnnnn ⋆ needed for the functions to take effect.
\use_iii:nnnnnn ⋆
\use_iv:nnnnnn ⋆
\use_v:nnnnnn ⋆
\use_vi:nnnnnn ⋆
\use_i:nnnnnnn ⋆
\use_ii:nnnnnnn ⋆
\use_iii:nnnnnnn ⋆
\use_iv:nnnnnnn ⋆
\use_v:nnnnnnn ⋆
\use_vi:nnnnnnn ⋆
\use_vii:nnnnnnn ⋆
\use_i:nnnnnnnn ⋆
\use_ii:nnnnnnnn ⋆
\use_iii:nnnnnnnn ⋆
\use_iv:nnnnnnnn ⋆
\use_v:nnnnnnnn ⋆
\use_vi:nnnnnnnn ⋆
\use_vii:nnnnnnnn ⋆
\use_vii:nnnnnnnn ⋆
\use_i:nnnnnnnnn ⋆
\use_ii:nnnnnnnnn ⋆
\use_iii:nnnnnnnnn ⋆
\use_iv:nnnnnnnnn ⋆
\use_v:nnnnnnnnn ⋆
\use_vi:nnnnnnnnn ⋆
\use_vii:nnnnnnnnn ⋆
\use_viii:nnnnnnnnn ⋆
\use_ix:nnnnnnnnn ⋆
25
\use_i_ii:nnn ⋆ \use_i_ii:nnn {⟨arg1 ⟩} {⟨arg2 ⟩} {⟨arg3 ⟩}
This function absorbs three arguments and leaves the content of the first and second in
the input stream. The category code of these tokens is also fixed (if it has not already
been by some other absorption). A single expansion is needed for the function to take
effect. An example:
\use_i_ii:nnn { abc } { { def } } { ghi }
results in the input stream containing
abc { def }
i.e. the outer braces are removed and the third group is removed.
TEXhackers note: \use:e is a wrapper around the primitive \expanded. It requires two
expansions to complete its action.
26
\use_i_delimit_by_q_nil:nw ⋆ \use_i_delimit_by_q_nil:nw {⟨inserted tokens ⟩} ⟨balanced text ⟩
\use_i_delimit_by_q_stop:nw ⋆ \q_nil
\use_i_delimit_by_q_recursion_stop:nw ⋆ \use_i_delimit_by_q_stop:nw {⟨inserted tokens ⟩} ⟨balanced
text ⟩ \q_stop
\use_i_delimit_by_q_recursion_stop:nw {⟨inserted tokens ⟩}
⟨balanced text ⟩ \q_recursion_stop
Absorb the ⟨balanced text ⟩ from the input stream delimited by the marker given in the
function name, leaving ⟨inserted tokens ⟩ in the input stream for further processing.
\bool_if:nTF {
\cs_if_free_p:N \l_tmpz_tl || \cs_if_free_p:N \g_tmpz_tl
} {⟨true code ⟩} {⟨false code ⟩}
For each predicate defined, a “branching conditional” also exists that behaves like
a conditional described above.
27
Primitive conditionals There is a third variety of conditional, which is the original
concept used in plain TEX and LATEX 2ε . Their use is discouraged in expl3 (although
still used in low-level definitions) because they are more fragile and in many cases
require more expansion control (hence more code) than the two types of conditionals
described above.
TEXhackers note: \if_true: and \if_false: are equivalent to their corresponding TEX
primitive conditionals \iftrue and \iffalse; \else: and \fi: are the TEX primitives \else
and \fi; \reverse_if:N is the ε-TEX primitive \unless.
28
\if_meaning:w ⋆ \if_meaning:w ⟨arg1 ⟩ ⟨arg2 ⟩ ⟨true code ⟩ \else: ⟨false code ⟩ \fi:
\if_meaning:w executes ⟨true code ⟩ when ⟨arg1 ⟩ and ⟨arg2 ⟩ are the same, otherwise
it executes ⟨false code ⟩. ⟨arg1 ⟩ and ⟨arg2 ⟩ could be functions, variables, tokens; in all
cases the unexpanded definitions are compared.
\if:w ⋆ \if:w ⟨token1 ⟩ ⟨token2 ⟩ ⟨true code ⟩ \else: ⟨false code ⟩ \fi:
\if_charcode:w ⋆ \if_catcode:w ⟨token1 ⟩ ⟨token2 ⟩ ⟨true code ⟩ \else: ⟨false code ⟩ \fi:
\if_catcode:w ⋆ These conditionals expand any following tokens until two unexpandable tokens are left.
If you wish to prevent this expansion, prefix the token in question with \exp_not:N.
\if_catcode:w tests if the category codes of the two tokens are the same whereas \if:w
tests if the character codes are identical. \if_charcode:w is an alternative name for
\if:w.
TEXhackers note: \if:w and \if_charcode:w are both the TEX primitive \if. \if_-
catcode:w is the TEX primitive \ifcat.
TEXhackers note: These are the TEX primitives \ifdefined and \ifcsname.
\mode_leave_vertical: \mode_leave_vertical:
New: 2017-07-04 Ensures that TEX is not in vertical (inter-paragraph) mode. In horizontal or math mode
this command has no effect, in vertical mode it switches to horizontal mode, and inserts
a box of width \parindent, followed by the \everypar token list.
TEXhackers note: This results in the contents of the \everypar token register being
inserted, after \mode_leave_vertical: is complete. Notice that in contrast to the LATEX 2ε
\leavevmode approach, no box is used by the method implemented here.
29
4.8 Debugging support
• check-declarations that checks all expl3 variables used were previously declared
and that local/global variables (based on their name or on their first assignment)
are only locally/globally assigned;
• check-expressions that checks integer, dimension, skip, and muskip expressions
are not terminated prematurely;
Providing these as switches rather than options allows testing code even if it relies on
other packages: load all other packages, call \debug_on:n, and load the code that one is
interested in testing.
30
Chapter 5
This module provides generic methods for expanding TEX arguments in a systematic
manner. The functions in this module all have prefix exp.
Not all possible variations are implemented for every base function. Instead only
those that are used within the LATEX3 kernel or otherwise seem to be of general interest
are implemented. Consult the module description to find out which functions are actually
defined. The next section explains how to define missing variants.
\cs_generate_variant:Nn \seq_gpush:Nn { No }
results in the definition of \seq_gpush:No
31
\cs_new:Npn \seq_gpush:No { \exp_args:NNo \seq_gpush:Nn }
Providing variants in this way in style files is safe as the \cs_generate_variant:Nn
function will only create new definitions if there is not already one available. Therefore
adding such definition to later releases of the kernel will not make such style files obsolete.
The steps above may be automated by using the function \cs_generate_-
variant:Nn, described next.
32
\cs_generate_variant:Nn \cs_generate_variant:Nn ⟨parent control sequence ⟩ {⟨variant argument specifiers ⟩}
\cs_generate_variant:cn
This function is used to define argument-specifier variants of the ⟨parent control
Updated: 2017-11-28 sequence ⟩ for LATEX3 code-level macros. The ⟨parent control sequence ⟩ is first
separated into the ⟨base name ⟩ and ⟨original argument specifier ⟩. The comma-
separated list of ⟨variant argument specifiers ⟩ is then used to define variants of the
⟨original argument specifier ⟩ if these are not already defined; entries which corre-
spond to existing functions are silently ingored. For each ⟨variant ⟩ given, a function is
created that expands its arguments as detailed and passes them to the ⟨parent control
sequence ⟩. So for example
generates the functions \foo:NV and \foo:cV in the same way. The \cs_generate_-
variant:Nn function should only be applied if the ⟨parent control sequence ⟩ is al-
ready defined. (This is only enforced if debugging support check-declarations is en-
abled.) If the ⟨parent control sequence ⟩ is protected or if the ⟨variant ⟩ involves any
x argument, then the ⟨variant control sequence ⟩ is also protected. The ⟨variant ⟩
is created globally, as is any \exp_args:N⟨variant ⟩ function needed to carry out the
expansion. There is no need to re-apply \cs_generate_variant:Nn after changing the
definition of the parent function: the variant will always use the current definition of
the parent. Providing variants repeatedly is safe as \cs_generate_variant:Nn will only
create new definitions if there is not already one available.
Only n and N arguments can be changed to other types. The only allowed changes
are
• c variant of an N parent;
• o, V, v, f, e, or x variant of an n parent;
• N, n, T, F, or p argument unchanged.
This means the ⟨parent ⟩ of a ⟨variant ⟩ form is always unambiguous, even in cases
where both an n-type parent and an N-type parent exist, such as for \tl_count:n and
\tl_count:N.
When creating variants for conditional functions, \prg_generate_conditional_-
variant:Nnn provides a convenient way of handling the related function set.
For backward compatibility it is currently possible to make n, o, V, v, f, e, or x-type
variants of an N-type argument or N or c-type variants of an n-type argument. Both
are deprecated. The first because passing more than one token to an N-type argument
will typically break the parent function’s code. The second because programmers who
use that most often want to access the value of a variable given its name, hence should
use a V-type or v-type variant instead of c-type. In those cases, using the lower-level
\exp_args:No or \exp_args:Nc functions explicitly is preferred to defining confusing
variants.
33
\exp_args_generate:n \exp_args_generate:n {⟨variant argument specifiers ⟩}
New: 2018-04-04 Defines \exp_args:N⟨variant ⟩ functions for each ⟨variant ⟩ given in the comma list
Updated: 2019-02-08 {⟨variant argument specifiers ⟩}. Each ⟨variant ⟩ should consist of the letters N, c,
n, V, v, o, f, e, x, p and the resulting function is protected if the letter x appears in
the ⟨variant ⟩. This is only useful for cases where \cs_generate_variant:Nn is not
applicable.
34
at the cost of being protected for x-type. If you use f type expansion in conditional
processing then you should stick to using TF type functions only as the expansion does
not finish any \if... \fi: itself!
It is important to note that both f- and o-type expansion are concerned with the
expansion of tokens from left to right in their arguments. In particular, o-type expansion
applies to the first token in the argument it receives: it is conceptually similar to
\exp_after:wN <base function> \exp_after:wN { <argument> }
At the same time, f-type expansion stops at the first non-expandable token. This means
for example that both
\tl_set:No \l_tmpa_tl { { \g_tmpb_tl } }
and
• Finally f expansion only expands the front of the token list, stopping at the first
non-expandable token. This may fail to fully expand the argument.
When speed is essential (for functions that do very little work and whose variants are
used numerous times in a document) the following considerations apply because internal
functions for argument expansion come in two flavours, some faster than others.
• Arguments that might need expansion should come first in the list of arguments.
• Arguments that should consist of single tokens N, c, V, or v should come first among
these.
• Arguments that appear after the first multi-token argument n, f, e, or o require
slightly slower special processing to be expanded. Therefore it is best to use the
optimized functions, namely those that contain only N, c, V, and v, and, in the last
position, o, f, e, with possible trailing N or n or T or F, which are not expanded.
Any x-type argument causes slightly slower processing.
35
\exp_args:Nc ⋆ \exp_args:Nc ⟨function ⟩ {⟨tokens ⟩}
\exp_args:cc ⋆
This function absorbs two arguments (the ⟨function ⟩ name and the ⟨tokens ⟩). The
⟨tokens ⟩ are expanded until only characters remain, and are then turned into a control
sequence. The result is inserted into the input stream after reinsertion of the ⟨function ⟩.
Thus the ⟨function ⟩ may take more than one argument: all others are left unchanged.
The :cc variant constructs the ⟨function ⟩ name in the same manner as described
for the ⟨tokens ⟩.
36
5.5 Manipulating two arguments
37
\exp_args:NNcf ⋆ \exp_args:NNoo ⟨token1 ⟩ ⟨token2 ⟩ {⟨token3 ⟩} {⟨tokens ⟩}
\exp_args:NNno ⋆
These functions absorb four arguments and expand the second, third and fourth as de-
\exp_args:NNnV ⋆
\exp_args:NNoo ⋆
tailed by their argument specifier. The first argument of the function is then the next
\exp_args:NNVV ⋆ item on the input stream, followed by the expansion of the second argument, etc. These
\exp_args:Ncno ⋆ functions need slower processing.
\exp_args:NcnV ⋆
\exp_args:Ncoo ⋆
\exp_args:NcVV ⋆
\exp_args:Nnnc ⋆
\exp_args:Nnno ⋆
\exp_args:Nnnf ⋆
\exp_args:Nnff ⋆
\exp_args:Nooo ⋆
\exp_args:Noof ⋆
\exp_args:Nffo ⋆
\exp_args:Neee ⋆
38
\exp_last_unbraced:Nx \exp_last_unbraced:Nx ⟨function ⟩ {⟨tokens ⟩}
This function fully expands the ⟨tokens ⟩ and leaves the result in the input stream after
reinsertion of the ⟨function ⟩. This function is not expandable.
This function absorbs three arguments and expands the second and third once. The first
argument of the function is then the next item on the input stream, followed by the
expansion of the second and third arguments, which are not wrapped in braces. This
function needs special (slower) processing.
TEXhackers note: This is the TEX primitive \noexpand. It only prevents expansion. At
the beginning of an f-type argument, a space ⟨token ⟩ is removed even if it appears as \exp_not:N
\c_space_token. In an e-expanding definition (\cs_new:Npe), a macro parameter introduces
an argument even if it appears as \exp_not:N # 1. This differs from \exp_not:n.
39
\exp_not:n ⋆ \exp_not:n {⟨tokens ⟩}
Prevents expansion of the ⟨tokens ⟩ in an e-type or x-type argument. In all other cases
the ⟨tokens ⟩ continue to be expanded, for example in the input stream or in other types
of arguments such as c, f, v. The argument of \exp_not:n must be surrounded by
braces.
40
5.9 Controlled expansion
The expl3 language makes all efforts to hide the complexity of TEX expansion from the
programmer by providing concepts that evaluate/expand arguments of functions prior to
calling the “base” functions. Thus, instead of using many \expandafter calls and other
trickery it is usually a matter of choosing the right variant of a function to achieve a
desired result.
Of course, deep down TEX is using expansion as always and there are cases where
a programmer needs to control that expansion directly; typical situations are basic data
manipulation tools. This section documents the functions for that level. These commands
are used throughout the kernel code, but we hope that outside the kernel there will be
little need to resort to them. Instead the argument manipulation methods document
above should usually be sufficient.
While \exp_after:wN expands one token (out of order) it is sometimes necessary to
expand several tokens in one go. The next set of commands provide this functionality.
Be aware that it is absolutely required that the programmer has full control over the
tokens to be expanded, i.e., it is not possible to use these functions to expand unknown
input as part of ⟨expandable-tokens ⟩ as that will break badly if unexpandable tokens
are encountered in that place!
where somewhere during the expansion of \@@_case:NnTF the \exp_end: gets generated.
TEXhackers note: The current implementation uses \romannumeral hence ignores space
tokens and explicit signs + and - in the expansion of the ⟨expandable tokens ⟩, but this should
not be relied upon.
4 Due to the implementation you might get the character in position 0 in the current font (typically
41
\exp:w ⋆ \exp:w ⟨expandable-tokens ⟩ \exp_end_continue_f:w ⟨further-tokens ⟩
\exp_end_continue_f:w ⋆
Expands ⟨expandable-tokens ⟩ until reaching \exp_end_continue_f:w at which point
New: 2015-08-23 expansion continues as an f-type expansion expanding ⟨further-tokens ⟩ until an un-
expandable token is encountered (or the f-type expansion is explicitly terminated by
\exp_stop_f:). As with all f-type expansions a space ending the expansion gets re-
moved.
The full expansion of ⟨expandable-tokens ⟩ has to be empty. If any token in
⟨expandable-tokens ⟩ or any token generated by expanding the tokens therein is not
expandable the expansion will end prematurely and as a result \exp_end_continue_f:w
will be misinterpreted later on.5
In typical use cases ⟨expandable-tokens ⟩ contains no tokens at all, e.g., you will
see code such as
\exp_after:wN { \exp:w \exp_end_continue_f:w #2 }
where the \exp_after:wN triggers an f-expansion of the tokens in #2. For technical
reasons this has to happen using two tokens (if they would be hidden inside another
command \exp_after:wN would only expand the command but not trigger any additional
f-expansion).
You might wonder why there are two different approaches available, after all the
effect of
42
5.10 Internal functions
43
Chapter 6
\clist_set:Nn \l_foo_clist { 3 , 01 , -2 , 5 , +1 }
\clist_sort:Nn \l_foo_clist
{
\int_compare:nNnTF { #1 } > { #2 }
{ \sort_return_swapped: }
{ \sort_return_same: }
}
results in \l_foo_clist holding the values { -2 , 01 , +1 , 3 , 5 } sorted in non-
decreasing order.
The code defining the comparison should call \sort_return_swapped: if the two
items given as #1 and #2 are not in the correct order, and otherwise it should call \sort_-
return_same: to indicate that the order of this pair of items should not be changed.
For instance, a ⟨comparison code ⟩ consisting only of \sort_return_same: with no
test yields a trivial sort: the final order is identical to the original order. Conversely,
using a ⟨comparison code ⟩ consisting only of \sort_return_swapped: reverses the list
(in a fairly inefficient way).
TEXhackers note: The current implementation is limited to sorting approximately 20000
items (40000 in LuaTEX), depending on what other packages are loaded.
Internally, the code from l3sort stores items in \toks registers allocated locally. Thus,
the ⟨comparison code ⟩ should not call \newtoks or other commands that allocate new \toks
registers. On the other hand, altering the value of a previously allocated \toks register is not a
problem.
44
\sort_return_same: \seq_sort:Nn ⟨seq var ⟩
\sort_return_swapped: { ... \sort_return_same: or \sort_return_swapped: ... }
New: 2017-02-06 Indicates whether to keep the order or swap the order of two items that are compared
in the sorting code. Only one of the \sort_return_... functions should be used by the
code, according to the results of some tests on the items #1 and #2 to be compared.
45
Chapter 7
This module provides functions that are particularly useful in the l3regex module for
mapping through a token list one ⟨token ⟩ at a time (including begin-group/end-group
tokens). For \tl_analysis_map_inline:Nn or \tl_analysis_map_inline:nn, the to-
ken list is given as an argument; the analogous function \peek_analysis_map_inline:n
documented in l3token finds tokens in the input stream instead. In both cases the user
provides ⟨inline code ⟩ that receives three arguments for each ⟨token ⟩:
• ⟨tokens ⟩, which both o-expand and e/x-expand to the ⟨token ⟩. The detailed form
of ⟨tokens ⟩ may change in later releases.
• ⟨char code ⟩, a decimal representation of the character code of the ⟨token ⟩, −1 if
it is a control sequence.
• ⟨catcode ⟩, a capital hexadecimal digit which denotes the category code of the
⟨token ⟩ (0: control sequence, 1: begin-group, 2: end-group, 3: math shift, 4: align-
ment tab, 6: parameter, 7: superscript, 8: subscript, A: space, B: letter, C: other,
D: active). This can be converted to an integer by writing "⟨catcode ⟩.
46
Chapter 8
The l3regex package provides regular expression testing, extraction of submatches, split-
ting, and replacement, all acting on token lists. The syntax of regular expressions is
mostly a subset of the pcre syntax (and very close to posix), with some additions due
to the fact that TEX manipulates tokens rather than characters. For performance rea-
sons, only a limited set of features are implemented. Notably, back-references are not
supported.
Let us give a few examples. After
\tl_set:Nn \l_my_tl { That~cat. }
\regex_replace_once:nnN { at } { is } \l_my_tl
the token list variable \l_my_tl holds the text “This cat.”, where the first occurrence
of “at” was replaced by “is”. A more complicated example is a pattern to emphasize
each word and add a comma after it:
\regex_replace_all:nnN { \w+ } { \c{emph}\cB\{ \0 \cE\} , } \l_my_tl
The \w sequence represents any “word” character, and + indicates that the \w sequence
should be repeated as many times as possible (at least once), hence matching a word in
the input token list. In the replacement text, \0 denotes the full match (here, a word).
The command \emph is inserted using \c{emph}, and its argument \0 is put between
braces \cB\{ and \cE\}.
If a regular expression is to be used several times, it can be compiled once, and
stored in a regex variable using \regex_set:Nn. For example,
\regex_new:N \l_foo_regex
\regex_set:Nn \l_foo_regex { \c{begin} \cB. (\c[^BE].*) \cE. }
stores in \l_foo_regex a regular expression which matches the starting marker for an
environment: \begin, followed by a begin-group token (\cB.), then any number of tokens
which are neither begin-group nor end-group character tokens (\c[^BE].*), ending with
an end-group token (\cE.). As explained in the next section, the parentheses “capture”
the result of \c[^BE].*, giving us access to the name of the environment when doing
replacements.
47
8.1 Syntax of regular expressions
8.1.1 Regular expression examples
We start with a few examples, and encourage the reader to apply \regex_show:n to
these regular expressions.
• Cat matches the word “Cat” capitalized in this way, but also matches the beginning
of the word “Cattle”: use \bCat\b to match a complete word only.
• [abc] matches one letter among “a”, “b”, “c”; the pattern (a|b|c) matches the
same three possible letters (but see the discussion of submatches below).
• [A-Za-z]* matches any number (due to the quantifier *) of Latin letters (not
accented).
• \G.*?\K at the beginning of a regular expression matches and discards (due to \K)
everything between the end of the previous match (\G) and what is matched by
the rest of the regular expression; this is useful in \regex_replace_all:nnN when
the goal is to extract matches or submatches in a finer way than with \regex_-
extract_all:nnN.
48
8.1.2 Characters in regular expressions
Most characters match exactly themselves, with an arbitrary category code. Some charac-
ters are special and must be escaped with a backslash (e.g., \* matches a star character).
Some escape sequences of the form backslash–letter also have a special meaning (for
instance \d matches any digit). As a rule,
• every alphanumeric character (A–Z, a–z, 0–9) matches exactly itself, and should
not be escaped, because \A, \B, . . . have special meanings;
49
\v Any vertical space character, equivalent to [\^^J\^^K\^^L\^^M]. Note that \^^K
is a vertical space, but not a space, for compatibility with Perl.
\w Any word character, i.e., alphanumerics and underscore, equivalent to the explicit
class [A-Za-z0-9\_].
\D Any token not matched by \d.
\H Any token not matched by \h.
\N Any token other than the \n character (hex 0A).
\S Any token not matched by \s.
\V Any token not matched by \v.
\W Any token not matched by \w.
Of those, ., \D, \H, \N, \S, \V, and \W match arbitrary control sequences.
Character classes match exactly one token in the subject.
[...] Positive character class. Matches any of the specified tokens.
[^...] Negative character class. Matches any token other than the specified characters.
x-y Within a character class, this denotes a range (can be used with escaped characters).
[:⟨name ⟩:] Within a character class (one more set of brackets), this denotes the posix character
class ⟨name ⟩, which can be alnum, alpha, ascii, blank, cntrl, digit, graph,
lower, print, punct, space, upper, word, or xdigit.
[:^⟨name ⟩:] Negative posix character class.
For instance, [a-oq-z\cC.] matches any lowercase latin letter except p, as well as control
sequences (see below for a description of \c).
In character classes, only [, ^, -, ], \ and spaces are special, and should be escaped.
Other non-alphanumeric characters can still be escaped without harm. Any escape se-
quence which matches a single character (\d, \D, etc.) is supported in character classes.
If the first character is ^, then the meaning of the character class is inverted; ^ appear-
ing anywhere else in the range is not special. If the first character (possibly following a
leading ^) is ] then it does not need to be escaped since ending the range there would
make it empty. Ranges of characters can be expressed using -, for instance, [\D 0-5]
and [^6-9] are equivalent.
50
+? 1 or more, lazy.
{n} Exactly n.
results in \l_foo_seq containing the items {1} and {a}: the true matches are {a1} and
{aa}, but they are trimmed by the use of \K. The \K command does not affect capturing
groups: for instance,
\regex_extract_once:nnN { (. \K c)+ \d } { acbc3 } \l_foo_seq
results in \l_foo_seq containing the items {c3} and {bc}: the true match is {acbc3},
with first submatch {bc}, but \K resets the beginning of the match to the last position
where it appears.
51
• M for math shift;
• T for alignment tab tokens;
• S for spaces;
• L for letters;
• O for others; and
• A for active characters.
The category code tests can be used inside classes; for instance, [\cO\d \c[LO][A-F]]
matches what TEX considers as hexadecimal digits, namely digits with category other,
or uppercase letters from A to F with category either letter or other. Within a group
affected by a category code test, the outer test can be overridden by a nested test: for
instance, \cL(ab\cO\*cd) matches ab*cd where all characters are of category letter,
except * which has category other.
The \u escape sequence allows to insert the contents of a token list directly into
a regular expression or a replacement, avoiding the need to escape special characters.
Namely, \u{⟨var name ⟩} matches the exact contents (both character codes and cate-
gory codes) of the variable \⟨var name ⟩, which are obtained by applying \exp_not:v
{⟨var name ⟩} at the time the regular expression is compiled. Within a \c{...} control
sequence matching, the \u escape sequence only expands its argument once, in effect
performing \tl_to_str:v. Quantifiers are supported.
The \ur escape sequence allows to insert the contents of a regex variable into a
larger regular expression. For instance, A\ur{l_tmpa_regex}D matches the tokens A and
6 This last example also captures “abc” as a regex group; to avoid this use a non-capturing group
\cO(?:abc).
52
D separated by something that matches the regular expression \l_tmpa_regex. This
behaves as if a non-capturing group were surrounding \l_tmpa_regex, and any group
contained in \l_tmpa_regex is converted to a non-capturing group. Quantifiers are
supported.
For instance, if \l_tmpa_regex has value B|C, then A\ur{l_tmpa_regex}D is equiv-
alent to A(?:B|C)D (matching ABD or ACD) and not to AB|CD (matching AB or CD). To
get the latter effect, it is simplest to use TEX’s expansion machinery directly: if \l_-
mymodule_BC_tl contains B|C then the following two lines show the same result:
\regex_show:n { A \u{l_mymodule_BC_tl} D }
\regex_show:n { A B | C D }
8.1.6 Miscellaneous
Anchors and simple assertions.
\b Word boundary: either the previous token is matched by \w and the next by \W,
or the opposite. For this purpose, the ends of the token list are considered as \W.
\B Not a word boundary: between two \w tokens or two \W tokens (including the
boundary).
The option (?i) makes the match case insensitive (treating A–Z and a–z as equiv-
alent, with no support yet for Unicode case changing). This applies until the end of
the group in which it appears, and can be reverted using (?-i). For instance, in
(?i)(a(?-i)b|c)d, the letters a and d are affected by the i option. Characters within
ranges and classes are affected individually: (?i)[\?-B] is equivalent to [\?@ABab]
(and differs from the much larger class [\?-b]), and (?i)[^aeiou] matches any char-
acter which is not a vowel. The i option has no effect on \c{...}, on \u{...},
on character properties, or on character classes, for instance it has no effect at all in
(?i)\u{l_foo_tl}\d\d[[:lower:]].
• \1 is the submatch that was matched by the first (capturing) group (...); similarly
for \2, . . . , \9 and \g{⟨number ⟩};
• \␣ inserts a space (spaces are ignored when not escaped);
53
• \a, \e, \f, \n, \r, \t, \xhh, \x{hhh} correspond to single characters as in regular
expressions;
• space characters (with character code 32) inserted with \␣ or \x20 or \x{20} have
category code 10 regardless of the prevailing category code regime;
• if the category code would be 0 (escape), 5 (newline), 9 (ignore), 14 (comment) or
15 (invalid), it is replaced by 12 (other) instead.
The escape sequence \c allows to insert characters with arbitrary category codes, as well
as control sequences.
\cX(...) Produces the characters “. . . ” with category X, which must be one of CBEMTPUDSLOA
as in regular expressions. Parentheses are optional for a single character (which
can be an escape sequence). When nested, the innermost category code applies, for
instance \cL(Hello\cS\ world)! gives this text with standard category codes.
\c{⟨text ⟩} Produces the control sequence with csname ⟨text ⟩. The ⟨text ⟩ may contain ref-
erences to the submatches \0, \1, and so on, as in the example for \u below.
The escape sequence \u{⟨var name ⟩} allows to insert the contents of the variable
with name ⟨var name ⟩ directly into the replacement, giving an easier control of cate-
gory codes. When nested in \c{. . . } and \u{. . . } constructions, the \u and \c escape
sequences perform \tl_to_str:v, namely extract the value of the control sequence and
turn it into a string. Matches can also be used within the arguments of \c and \u. For
instance,
54
\tl_set:Nn \l_my_one_tl { first }
\tl_set:Nn \l_my_two_tl { \emph{second} }
\tl_set:Nn \l_my_tl { one , two , one , one }
\regex_replace_all:nnN { [^,]+ } { \u{l_my_\0_tl} } \l_my_tl
results in \l_my_tl holding first,\emph{second},first,first.
Regex replacement is also a convenient way to produce token lists with arbitrary
category codes. For instance
\tl_clear:N \l_tmpa_tl
\regex_replace_all:nnN { } { \cU\% \cA\~ } \l_tmpa_tl
results in \l_tmpa_tl containing the percent character with category code 7 (superscript)
and an active tilde character.
55
\regex_show:N \regex_show:n {⟨regex ⟩}
\regex_show:n \regex_log:n {⟨regex ⟩}
\regex_log:N
Displays in the terminal or writes in the log file (respectively) how l3regex interprets the
\regex_log:n
⟨regex ⟩. For instance, \regex_show:n {\A X|Y} shows
New: 2021-04-26
Updated: 2021-04-29 +-branch
anchor at start (\A)
char code 88 (X)
+-branch
char code 89 (Y)
indicating that the anchor \A only applies to the first branch: the second branch is not
anchored to the beginning of the match.
8.4 Matching
All regular expression functions are available in both :n and :N variants. The former
require a “standard” regular expression, while the later require a compiled expression as
generated by \regex_set:Nn.
56
\regex_match_case:nn \regex_match_case:nnTF
\regex_match_case:nnTF {
{⟨regex1 ⟩} {⟨code case1 ⟩}
New: 2022-01-10
{⟨regex2 ⟩} {⟨code case2 ⟩}
...
{⟨regexn ⟩} {⟨code casen ⟩}
} {⟨token list ⟩}
{⟨true code ⟩} {⟨false code ⟩}
Determines which of the ⟨regular expressions ⟩ matches at the earliest point in the
⟨token list ⟩, and leaves the corresponding ⟨codei ⟩ followed by the ⟨true code ⟩ in the
input stream. If several ⟨regex ⟩ match starting at the same point, then the first one
in the list is selected and the others are discarded. If none of the ⟨regex ⟩ match, the
⟨false code ⟩ is left in the input stream. Each ⟨regex ⟩ can either be given as a regex
variable or as an explicit regular expression.
In detail, for each starting position in the ⟨token list ⟩, each of the ⟨regex ⟩ is
searched in turn. If one of them matches then the corresponding ⟨code ⟩ is used and
everything else is discarded, while if none of the ⟨regex ⟩ match at a given position then
the next starting position is attempted. If none of the ⟨regex ⟩ match anywhere in the
⟨token list ⟩ then nothing is left in the input stream. Note that this differs from nested
\regex_match:nnTF statements since all ⟨regex ⟩ are attempted at each position rather
than attempting to match ⟨regex1 ⟩ at every position before moving on to ⟨regex2 ⟩.
57
\regex_extract_all:nnN \regex_extract_all:nnN {⟨regex ⟩} {⟨token list ⟩} ⟨seq var ⟩
\regex_extract_all:nVN \regex_extract_all:nnNTF {⟨regex ⟩} {⟨token list ⟩} ⟨seq var ⟩ {⟨true code ⟩} {⟨false
\regex_extract_all:nnNTF code ⟩}
\regex_extract_all:nVN
Finds all matches of the ⟨regular expression ⟩ in the ⟨token list ⟩, and stores all
\regex_extract_all:NnN
the submatch information in a single sequence (concatenating the results of multiple
\regex_extract_all:NVN
\regex_extract_all:NnNTF \regex_extract_once:nnN calls). The ⟨seq var ⟩ is assigned locally. If there is no
\regex_extract_all:NVN match, the ⟨seq var ⟩ is cleared. The testing versions insert the ⟨true code ⟩ into the
input stream if a match was found, and the ⟨false code ⟩ otherwise. For instance,
New: 2017-05-26
assume that you type
\regex_extract_all:nnNTF { \w+ } { Hello,~world! } \l_foo_seq
{ true } { false }
Then the regular expression matches twice, the resulting sequence contains the two items
{Hello} and {world}, and the true branch is left in the input stream.
\seq_new:N \l_path_seq
\regex_split:nnNTF { / } { the/path/for/this/file.tex } \l_path_seq
{ true } { false }
the sequence \l_path_seq contains the items {the}, {path}, {for}, {this}, and
{file.tex}, and the true branch is left in the input stream.
8.6 Replacement
58
\regex_replace_all:nnN \regex_replace_all:nnN {⟨regular expression ⟩} {⟨replacement ⟩} ⟨tl var ⟩
\regex_replace_all:nVN \regex_replace_all:nnNTF {⟨regular expression ⟩} {⟨replacement ⟩} ⟨tl var ⟩ {⟨true
\regex_replace_all:nnNTF code ⟩} {⟨false code ⟩}
\regex_replace_all:nVN
Replaces all occurrences of the ⟨regular expression ⟩ in the contents of the ⟨tl var ⟩
\regex_replace_all:NnN
by the ⟨replacement ⟩, where \0 represents the full match, \1 represent the contents of
\regex_replace_all:NVN
\regex_replace_all:NnNTF the first capturing group, \2 of the second, etc. Every match is treated independently,
\regex_replace_all:NVN and matches cannot overlap. The result is assigned locally to ⟨tl var ⟩.
New: 2017-05-26
\regex_replace_case_once:nN \regex_replace_case_once:nNTF
\regex_replace_case_once:nNTF {
{⟨regex1 ⟩} {⟨replacement1 ⟩}
New: 2022-01-10
{⟨regex2 ⟩} {⟨replacement2 ⟩}
...
{⟨regexn ⟩} {⟨replacementn ⟩}
} ⟨tl var ⟩
{⟨true code ⟩} {⟨false code ⟩}
Replaces the earliest match of the regular expression (?|⟨regex1 ⟩|. . . |⟨regexn ⟩) in
the ⟨token list variable ⟩ by the ⟨replacement ⟩ corresponding to which ⟨regexi ⟩
matched, then leaves the ⟨true code ⟩ in the input stream. If none of the ⟨regex ⟩
match, then the ⟨tl var ⟩ is not modified, and the ⟨false code ⟩ is left in the input
stream. Each ⟨regex ⟩ can either be given as a regex variable or as an explicit regular
expression.
In detail, for each starting position in the ⟨token list ⟩, each of the ⟨regex ⟩ is
searched in turn. If one of them matches then it is replaced by the corresponding
⟨replacement ⟩ as described for \regex_replace_once:nnN. This is equivalent to check-
ing with \regex_match_case:nn which ⟨regex ⟩ matches, then performing the replace-
ment with \regex_replace_once:nnN.
59
\regex_replace_case_all:nN \regex_replace_case_all:nNTF
\regex_replace_case_all:nNTF {
{⟨regex1 ⟩} {⟨replacement1 ⟩}
New: 2022-01-10
{⟨regex2 ⟩} {⟨replacement2 ⟩}
...
{⟨regexn ⟩} {⟨replacementn ⟩}
} ⟨tl var ⟩
{⟨true code ⟩} {⟨false code ⟩}
Replaces all occurrences of all ⟨regex ⟩ in the ⟨token list ⟩ by the corresponding
⟨replacement ⟩. Every match is treated independently, and matches cannot overlap.
The result is assigned locally to ⟨tl var ⟩, and the ⟨true code ⟩ or ⟨false code ⟩ is left
in the input stream depending on whether any replacement was made or not.
In detail, for each starting position in the ⟨token list ⟩, each of the ⟨regex ⟩ is
searched in turn. If one of them matches then it is replaced by the corresponding
⟨replacement ⟩, and the search resumes at the position that follows this match (and
replacement). For instance
\tl_set:Nn \l_tmpa_tl { Hello,~world! }
\regex_replace_case_all:nN
{
{ [A-Za-z]+ } { ‘‘\0’’ }
{ \b } { --- }
{ . } { [\0] }
} \l_tmpa_tl
results in \l_tmpa_tl having the contents ‘‘Hello’’---[,][␣]‘‘world’’---[!]. Note
in particular that the word-boundary assertion \b did not match at the start of words
because the case [A-Za-z]+ matched at these positions. To change this, one could simply
swap the order of the two cases in the argument of \regex_replace_case_all:nN.
\l_tmpa_regex Scratch regex for local assignment. These are never used by the kernel code, and so are
\l_tmpb_regex safe for use with any LAT X3-defined function. However, they may be overwritten by
E
New: 2017-12-11 other non-kernel code and so should only be used for short-term storage.
\g_tmpa_regex Scratch regex for global assignment. These are never used by the kernel code, and so
\g_tmpb_regex are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
New: 2017-12-11 other non-kernel code and so should only be used for short-term storage.
60
• Rewrite the documentation in a more ordered way, perhaps add a bnf?
Additional error-checking to come.
• Clean up the use of messages.
• Cleaner error reporting in the replacement phase.
• Add tracing information.
• Detect attempts to use back-references and other non-implemented syntax.
• Test for the maximum register \c_max_register_int.
• Find out whether the fact that \W and friends match the end-marker leads to bugs.
Possibly update \__regex_item_reverse:n.
• The empty cs should be matched by \c{}, not by \c{csname.?endcsname\s?}.
Code improvements to come.
• Shift arrays so that the useful information starts at position 1.
• Only build \c{...} once.
• Use arrays for the left and right state stacks when compiling a regex.
• Should \__regex_action_free_group:n only be used for greedy {n,} quantifier?
(I think not.)
• Quantifiers for \u and assertions.
• When matching, keep track of an explicit stack of curr_state and curr_-
submatches.
• If possible, when a state is reused by the same thread, kill other subthreads.
• Use an array rather than \g__regex_balance_tl to build the function \__regex_-
replacement_balance_one_match:n.
• Reduce the number of epsilon-transitions in alternatives.
• Optimize simple strings: use less states (abcade should give two states, for abc and
ade). [Does that really make sense?]
• Optimize groups with no alternative.
• Optimize states with a single \__regex_action_free:n.
• Optimize the use of \__regex_action_success: by inserting it in state 2 directly
instead of having an extra transition.
• Optimize the use of \int_step_... functions.
• Groups don’t capture within regexes for csnames; optimize and document.
• Better “show” for anchors, properties, and catcode tests.
• Does \K really need a new state for itself?
61
• When compiling, use a boolean in_cs and less magic numbers.
• Instead of checking whether the character is special or alphanumeric using its char-
acter code, check if it is special in regexes with \cs_if_exist tests.
The following features are likely to be implemented at some point in the future.
• General look-ahead/behind assertions.
• Regex matching on external files.
• Newline conventions are not done. In particular, we should have an option for . not
to match newlines. Also, \A should differ from ^, and \Z, \z and $ should differ.
• Unicode properties: \p{..} and \P{..}; \X which should match any “extended”
Unicode sequence. This requires to manipulate a lot of data, probably using tree-
boxes.
• Named subpatterns: TEX programmers have lived so far without any need for
named macro parameters.
The following features of pcre or Perl will definitely not be implemented.
• Back-references: non-regular feature, this requires backtracking, which is pro-
hibitively slow.
• Recursion: this is a non-regular feature.
• Atomic grouping, possessive quantifiers: those tools, mostly meant to fix catastrophic
backtracking, are unnecessary in a non-backtracking algorithm, and difficult to im-
plement.
62
• \ddd, matching the character with octal code ddd: we already have \x{...} and
the syntax is confusingly close to what we could have used for backreferences (\1,
\2, . . . ), making it harder to produce useful error message.
• \C single byte in UTF-8 mode: XETEX and LuaTEX serve us characters directly,
and splitting those into bytes is tricky, encoding dependent, and most likely not
useful anyways.
63
Chapter 9
TEXhackers note: The arguments are executed after exiting the underlying \if...\fi:
structure.
64
\prg_new_protected_conditional:Npnn \prg_new_protected_conditional:Npnn \⟨name ⟩:⟨arg spec ⟩
\prg_set_protected_conditional:Npnn ⟨parameters ⟩ {⟨conditions ⟩} {⟨code ⟩}
\prg_gset_protected_conditional:Npnn \prg_new_protected_conditional:Nnn \⟨name ⟩:⟨arg spec ⟩
\prg_new_protected_conditional:Nnn {⟨conditions ⟩} {⟨code ⟩}
\prg_set_protected_conditional:Nnn
\prg_gset_protected_conditional:Nnn
Updated: 2012-02-06
These functions create a family of protected conditionals using the same {⟨code ⟩} to
perform the test created. The ⟨code ⟩ does not need to be expandable. The new version
check for existing definitions and perform assignments globally (cf. \cs_new:Npn) whereas
the set version do not (cf. \cs_set:Npn). The conditionals created are depended on the
comma-separated list of ⟨conditions ⟩, which should be one or more of T, F and TF (not
p).
The conditionals are defined by \prg_new_conditional:Npnn and friends as:
• \⟨name ⟩_p:⟨arg spec ⟩ — a predicate function which will supply either a logical
true or logical false. This function is intended for use in cases where one or more
logical tests are combined to lead to a final outcome. This function cannot be
defined for protected conditionals.
• \⟨name ⟩:⟨arg spec ⟩T — a function with one more argument than the original ⟨arg
spec ⟩ demands. The ⟨true branch ⟩ code in this additional argument will be left
on the input stream only if the test is true.
• \⟨name ⟩:⟨arg spec ⟩F — a function with one more argument than the original ⟨arg
spec ⟩ demands. The ⟨false branch ⟩ code in this additional argument will be left
on the input stream only if the test is false.
• \⟨name ⟩:⟨arg spec ⟩TF — a function with two more argument than the original
⟨arg spec ⟩ demands. The ⟨true branch ⟩ code in the first additional argument
will be left on the input stream if the test is true, while the ⟨false branch ⟩ code
in the second argument will be left on the input stream if the test is false.
The ⟨code ⟩ of the test may use ⟨parameters ⟩ as specified by the second argument to
\prg_set_conditional:Npnn: this should match the ⟨argument specification ⟩ but
this is not enforced. The Nnn versions infer the number of arguments from the argument
specification given (cf. \cs_new:Nn, etc.). Within the ⟨code ⟩, the functions \prg_-
return_true: and \prg_return_false: are used to indicate the logical outcomes of the
test.
An example can easily clarify matters here:
\prg_set_conditional:Npnn \foo_if_bar:NN #1#2 { p , T , TF }
{
\if_meaning:w \l_tmpa_tl #1
\prg_return_true:
\else:
\if_meaning:w \l_tmpa_tl #2
\prg_return_true:
\else:
\prg_return_false:
\fi:
65
\fi:
}
These functions copy a family of conditionals. The new version checks for existing defin-
itions (cf. \cs_new_eq:NN) whereas the set version does not (cf. \cs_set_eq:NN). The
conditionals copied are depended on the comma-separated list of ⟨conditions ⟩, which
should be one or more of p, T, F and TF.
\prg_return_true: ⋆ \prg_return_true:
\prg_return_false: ⋆ \prg_return_false:
These “return” functions define the logical state of a conditional statement. They appear
within the code for a conditional function generated by \prg_set_conditional:Npnn,
etc, to indicate when a true or false branch should be taken. While they may appear
multiple times each within the code of such conditionals, the execution of the conditional
must result in the expansion of one of these two functions exactly once.
The return functions trigger what is internally an f-expansion process to com-
plete the evaluation of the conditional. Therefore, after \prg_return_true: or \prg_-
return_false: there must be no non-expandable material in the input stream for the
remainder of the expansion of the conditional code. This includes other instances of
either of these functions.
66
two canonical booleans: \c_true_bool or \c_false_bool. Besides preventing problems
as described above, it also allows us to implement a simple boolean parser supporting
the logical operations And, Or, Not, etc. which can then be used on both the boolean
type and predicate functions.
All conditional \bool_ functions except assignments are expandable and expect the
input to also be fully expandable (which generally means being constructed from predicate
functions and booleans, possibly nested).
TEXhackers note: The bool data type is not implemented using the \iffalse/\iftrue
primitives, in contrast to \newif, etc., in plain TEX, LATEX 2ε and so on. Programmers should
not base use of bool switches on any particular expectation of the implementation.
Updated: 2017-07-15
67
\bool_if_p:N ⋆ \bool_if_p:N ⟨boolean ⟩
\bool_if_p:c ⋆ \bool_if:NTF ⟨boolean ⟩ {⟨true code ⟩} {⟨false code ⟩}
\bool_if:NTF ⋆
Tests the current truth of ⟨boolean ⟩, and continues expansion based on this result.
\bool_if:c ⋆
Updated: 2017-07-15
\c_true_bool Constants that represent true and false, respectively. Used to implement predicates.
\c_false_bool
\l_tmpa_bool A scratch boolean for local assignment. It is never used by the kernel code, and so is
\l_tmpb_bool safe for use with any LAT X3-defined function. However, it may be overwritten by other
E
non-kernel code and so should only be used for short-term storage.
68
\g_tmpa_bool A scratch boolean for global assignment. It is never used by the kernel code, and so is
\g_tmpb_bool safe for use with any LAT X3-defined function. However, it may be overwritten by other
E
non-kernel code and so should only be used for short-term storage.
69
the line marked with skipped is not expanded because the result of \bool_lazy_any_-
p:n is known once the second boolean expression is found to be logically true. On the
other hand, the last line is expanded because its logical value is needed to determine the
result of \bool_lazy_and_p:nn.
70
\bool_xor_p:nn ⋆ \bool_xor_p:nn {⟨boolexpr1 ⟩} {⟨boolexpr2 ⟩}
\bool_xor:nnTF ⋆ \bool_xor:nnTF {⟨boolexpr1 ⟩} {⟨boolexpr2 ⟩} {⟨true code ⟩} {⟨false code ⟩}
New: 2018-05-09 Implements an “exclusive or” operation between two boolean expressions. There is no
infix operation for this logical operation.
71
\bool_while_do:nn ✩ \bool_while_do:nn {⟨boolean expression ⟩} {⟨code ⟩}
Updated: 2017-07-15 This function first checks the logical value of the ⟨boolean expression ⟩ (as described for
\bool_if:nTF). If it is true the ⟨code ⟩ is placed in the input stream and expanded. After
the completion of the ⟨code ⟩ the truth of the ⟨boolean expression ⟩ is re-evaluated. The
process then loops until the ⟨boolean expression ⟩ is false.
\bool_case:n ⋆ \bool_case:nTF
\bool_case:nTF ⋆ {
{⟨boolexpr case1 ⟩} {⟨code case1 ⟩}
New: 2023-05-03
{⟨boolexpr case2 ⟩} {⟨code case2 ⟩}
...
{⟨boolexpr casen ⟩} {⟨code casen ⟩}
}
{⟨true code ⟩}
{⟨false code ⟩}
Evaluates in turn each of the ⟨boolean expression cases ⟩ until the first one that
evaluates to true. The ⟨code ⟩ associated to this first case is left in the input stream,
followed by the ⟨true code ⟩, and other cases are discarded. If none of the cases match
then only the ⟨false code ⟩ is inserted. The function \bool_case:n, which does nothing
if there is no match, is also available. For example
\bool_case:nF
{
{ \dim_compare_p:n { \l__mypkg_wd_dim <= 10pt } }
{ Fits }
{ \int_compare_p:n { \l__mypkg_total_int >= 10 } }
{ Many }
{ \l__mypkg_special_bool }
{ Special }
}
{ No idea! }
leaves “Fits” or “Many” or “Special” or “No idea!” in the input stream, in a way
similar to some other language’s “if . . . elseif . . . elseif . . . else . . . ”.
\mode_if_horizontal_p: ⋆ \mode_if_horizontal_p:
\mode_if_horizontal:TF ⋆ \mode_if_horizontal:TF {⟨true code ⟩} {⟨false code ⟩}
Detects if TEX is currently in horizontal mode.
72
\mode_if_inner_p: ⋆ \mode_if_inner_p:
\mode_if_inner:TF ⋆ \mode_if_inner:TF {⟨true code ⟩} {⟨false code ⟩}
Detects if TEX is currently in inner mode.
\mode_if_math_p: ⋆ \mode_if_math_p:
\mode_if_math:TF ⋆ \mode_if_math:TF {⟨true code ⟩} {⟨false code ⟩}
Updated: 2011-09-05 Detects if TEX is currently in maths mode.
\mode_if_vertical_p: ⋆ \mode_if_vertical_p:
\mode_if_vertical:TF ⋆ \mode_if_vertical:TF {⟨true code ⟩} {⟨false code ⟩}
Detects if TEX is currently in vertical mode.
73
\prg_map_break:Nn ⋆ \prg_map_break:Nn \⟨type ⟩_map_break: {⟨user code ⟩}
...
New: 2018-03-26
\prg_break_point:Nn \⟨type ⟩_map_break: {⟨ending code ⟩}
Breaks a recursion in mapping contexts, inserting in the input stream the ⟨user code ⟩
after the ⟨ending code ⟩ for the loop. The function breaks loops, inserting their ⟨ending
code ⟩, until reaching a loop with the same ⟨type ⟩ as its first argument. This \⟨type ⟩_-
map_break: argument must be defined; it is simply used as a recognizable marker for the
⟨type ⟩.
For types with mappings defined in the kernel, \⟨type ⟩_map_break: and \⟨type ⟩_-
map_break:n are defined as \prg_map_break:Nn \⟨type ⟩_map_break: {} and the same
with {} omitted.
\prg_break_point: ⋆ This copy of \prg_do_nothing: is used to mark the end of a fast short-term recursion:
New: 2018-03-27 the function \prg_break:n uses this to break out of the loop.
\group_align_safe_begin: ⋆ \group_align_safe_begin:
\group_align_safe_end: ⋆ ...
\group_align_safe_end:
Updated: 2011-08-11
These functions are used to enclose material in a TEX alignment environment within a
specially-constructed group. This group is designed in such a way that it does not add
brace groups to the output but does act as a group for the & token inside \halign. This
is necessary to allow grabbing of tokens for testing purposes, as TEX uses group level
to determine the effect of alignment tokens. Without the special grouping, the use of a
function such as \peek_after:Nw would result in a forbidden comparison of the internal
\endtemplate token, yielding a fatal error. Each \group_align_safe_begin: must be
matched by a \group_align_safe_end:, although this does not have to occur within
the same function.
74
Chapter 10
\c_sys_jobname_str Constant that gets the “job name” assigned when TEX starts.
New: 2015-09-19
TEXhackers note: This is the TEX primitive \jobname. For technical reasons, the string
Updated: 2019-10-27
here is not of the same internal form as other, but may be manipulated using normal string
functions.
\c_sys_minute_int The date and time at which the current job was started: these are all reported as integers.
\c_sys_hour_int
\c_sys_day_int TEXhackers note: Whilst the underlying TEX primitives \time, \day, \month, and \year
\c_sys_month_int can be altered by the user, this interface to the time and date is intended to be the “real” values.
\c_sys_year_int
New: 2015-09-22
\c_sys_timestamp_str The timestamp for the current job: the format is as described for \file_timestamp:n.
New: 2023-08-27
75
10.3 Engine
\sys_if_engine_luatex_p: ⋆ \sys_if_engine_pdftex_p:
\sys_if_engine_luatex:TF ⋆ \sys_if_engine_pdftex:TF {⟨true code ⟩} {⟨false code ⟩}
\sys_if_engine_pdftex_p: ⋆ Conditionals which allow engine-specific code to be used. The names follow naturally
\sys_if_engine_pdftex:TF ⋆
from those of the engine binaries: note that the (u)ptex tests are for ε-pTEX and ε-upTEX
\sys_if_engine_ptex_p: ⋆
\sys_if_engine_ptex:TF ⋆
as expl3 requires the ε-TEX extensions. Each conditional is true for exactly one supported
\sys_if_engine_uptex_p: ⋆ engine. In particular, \sys_if_engine_ptex_p: is true for ε-pTEX but false for ε-upTEX.
\sys_if_engine_uptex:TF ⋆
\sys_if_engine_xetex_p: ⋆
\sys_if_engine_xetex:TF ⋆
New: 2015-09-07
\c_sys_engine_str The current engine given as a lower case string: one of luatex, pdftex, ptex, uptex or
New: 2015-09-19 xetex.
\c_sys_engine_exec_str The name of the standard executable for the current TEX engine given as a lower case
New: 2020-08-20 string: one of luatex, luahbtex, pdftex, eptex, euptex or xetex.
\c_sys_engine_format_str The name of the preloaded format for the current TEX run given as a lower case string:
New: 2020-08-20 one of lualatex (or dvilualatex), pdflatex (or latex), platex, uplatex or xelatex
for LATEX, similar names for plain TEX (except pdfTEX in DVI mode yields etex), and
cont-en for ConTEXt (i.e. the \fmtname).
\c_sys_engine_version_str The version string of the current engine, in the same form as given in the banner issued
New: 2018-05-02 when running a job. For pdfTEX and LuaTEX this is of the form
⟨major ⟩.⟨minor ⟩.⟨revision ⟩
\sys_timer: ⋆ \sys_timer:
New: 2021-05-12 Expands to the current value of the engine’s timer clock, a non-negative integer. This
function is only defined for engines with timer support. This command measures not
just CPU time but real time (including time waiting for user input). The unit are scaled
seconds (2−16 seconds).
76
\sys_if_timer_exist_p: ⋆ \sys_if_timer_exist_p:
\sys_if_timer_exist:TF ⋆ \sys_if_timer_exist:TF {⟨true code ⟩} {⟨false code ⟩}
New: 2021-05-12 Tests whether current engine has timer support.
\sys_if_output_dvi_p: ⋆ \sys_if_output_dvi_p:
\sys_if_output_dvi:TF ⋆ \sys_if_output_dvi:TF {⟨true code ⟩} {⟨false code ⟩}
\sys_if_output_pdf_p: ⋆ Conditionals which give the current output mode the T X run is operating in. This is
\sys_if_output_pdf:TF ⋆
E
always one of two outcomes, DVI mode or PDF mode. The two sets of conditionals are
New: 2015-09-19 thus complementary and are both provided to allow the programmer to emphasise the
most appropriate case.
\c_sys_output_str The current output mode given as a lower case string: one of dvi or pdf.
New: 2015-09-19
10.5 Platform
\sys_if_platform_unix_p: ⋆ \sys_if_platform_unix_p:
\sys_if_platform_unix:TF ⋆ \sys_if_platform_unix:TF {⟨true code ⟩} {⟨false code ⟩}
\sys_if_platform_windows_p: ⋆
\sys_if_platform_windows:TF ⋆
New: 2018-07-27
Conditionals which allow platform-specific code to be used. The names follow the Lua
os.type() function, i.e. all Unix-like systems are unix (including Linux and MacOS).
\c_sys_platform_str The current platform given as a lower case string: one of unix, windows or unknown.
New: 2018-07-27
\sys_rand_seed: ⋆ \sys_rand_seed:
New: 2017-05-27 Expands to the current value of the engine’s random seed, a non-negative integer. In
engines without random number support this expands to 0.
77
\sys_gset_rand_seed:n \sys_gset_rand_seed:n {⟨int expr ⟩}
New: 2017-05-27 Globally sets the seed for the engine’s pseudo-random number generator to the ⟨integer
expression ⟩. This random seed affects all \..._rand functions (such as \int_rand:nn
or \clist_rand_item:n) as well as other packages relying on the engine’s random num-
ber generator. In engines without random number support this produces an error.
TEXhackers note: While a 32-bit (signed) integer can be given as a seed, only the absolute
value is used and any number beyond 228 is divided by an appropriate power of 2. We recommend
using an integer in [0, 228 − 1].
\c_sys_shell_escape_int This variable exposes the internal triple of the shell escape status. The possible values
New: 2017-05-27 are
0 Shell escape is disabled
1 Unrestricted shell escape is enabled
\sys_if_shell_p: ⋆ \sys_if_shell_p:
\sys_if_shell:TF ⋆ \sys_if_shell:TF {⟨true code ⟩} {⟨false code ⟩}
New: 2017-05-27 Performs a check for whether shell escape is enabled. This returns true if either of
restricted or unrestricted shell escape is enabled.
\sys_if_shell_unrestricted_p: ⋆ \sys_if_shell_unrestricted_p:
\sys_if_shell_unrestricted:TF ⋆ \sys_if_shell_unrestricted:TF {⟨true code ⟩} {⟨false code ⟩}
New: 2017-05-27
78
\sys_if_shell_restricted_p: ⋆ \sys_if_shell_restricted_p:
\sys_if_shell_restricted:TF ⋆ \sys_if_shell_restricted:TF {⟨true code ⟩} {⟨false code ⟩}
New: 2017-05-27
Performs a check for whether restricted shell escape is enabled. This returns false if
unrestricted shell escape is enabled. Unrestricted shell escape is not considered a superset
of restricted shell escape in this case. To find whether any shell escape is enabled use
\sys_if_shell:TF.
\sys_ensure_backend: \sys_ensure_backend:
New: 2022-07-29 Ensures that a backend has been loaded by calling \sys_load_backend:n if required.
\c_sys_backend_str Set to the name of the backend in use by \sys_load_backend:n when issued. Possible
values are
• pdftex
• luatex
• xetex
• dvips
• dvipdfmx
• dvisvgm
\sys_load_debug: \sys_load_debug:
New: 2019-09-12 Load the additional configuration file for debugging support.
79
10.8.1 Final settings
\sys_finalise: \sys_finalise:
New: 2019-10-06 Finalises all system-dependent functionality: required before loading a backend.
80
Chapter 11
Messages need to be passed to the user by modules, either when errors occur or to indicate
how the code is proceeding. The l3msg module provides a consistent method for doing
this (as opposed to writing directly to the terminal or log).
The system used by l3msg to create messages divides the process into two distinct
parts. Named messages are created in the first part of the process; at this stage, no
decision is made about the type of output that the message will produce. The second
part of the process is actually producing a message. At this stage a choice of message
class has to be made, for example error, warning or info.
By separating out the creation and use of messages, several benefits are available.
First, the messages can be altered later without needing details of where they are used
in the code. This makes it possible to alter the language used, the detail level and so
on. Secondly, the output which results from a given message can be altered. This can be
done on a message class, module or message name basis. In this way, message behaviour
can be altered and messages can be entirely suppressed.
81
\char_set_catcode_space:n { ‘\ }
\msg_new:nnn { foo } { bar }
{Some message text using ’#1’ and usual message shorthands \{ \ \ \}.}
\char_set_catcode_ignore:n { ‘\ }
although in general this may be confusing; simply writing the messages using ~ characters
is the method favored by the team.
\g_msg_module_name_prop Provides a mapping between the module name used for messages, and that for documen-
New: 2018-10-10 tation.
\g_msg_module_type_prop Provides a mapping between the module name used for messages, and that type of
New: 2018-10-10 module. For example, for LATEX3 core messages, an empty entry is set here meaning that
they are not described using the standard Package text.
82
11.3 Contextual information for messages
\msg_line_context: ✩ \msg_line_context:
Prints the current line number when a message is given, and thus suitable for giving
context to messages. The number itself is proceeded by the text on line.
\msg_line_number: ⋆ \msg_line_number:
Prints the current line number when a message is given.
This function can be redefined to alter the language in which the message is given, using
#1 as the name of the ⟨module ⟩ to be included.
83
\msg_see_documentation_text:n ⋆ \msg_see_documentation_text:n {⟨module ⟩}
Updated: 2018-09-30
• warning, written to terminal and log file, for important messages that may require
corrections by the user;
• note (less common than info) for important information messages written to the
terminal and log file;
• info for normal information messages written to the log file only;
• term and log for un-decorated messages written to the terminal and log file, or to
the log file only;
• none for suppressed messages.
84
\msg_fatal:nnnnnn \msg_fatal:nnnnnn {⟨module ⟩} {⟨message ⟩} {⟨arg one ⟩} {⟨arg two ⟩}
\msg_fatal:nneeee {⟨arg three ⟩} {⟨arg four ⟩}
\msg_fatal:nnnnn
\msg_fatal:(nneee|nnnee)
\msg_fatal:nnnn
\msg_fatal:(nnVV|nnVn|nnnV|nnee|nnne)
\msg_fatal:nnn
\msg_fatal:(nnV|nne)
\msg_fatal:nn
Updated: 2012-08-11
Issues ⟨module ⟩ error ⟨message ⟩, passing ⟨arg one ⟩ to ⟨arg four ⟩ to the text-creating
functions. After issuing a fatal error the TEX run halts. No PDF file will be produced in
this case (DVI mode runs may produce a truncated DVI file).
Issues ⟨module ⟩ error ⟨message ⟩, passing ⟨arg one ⟩ to ⟨arg four ⟩ to the text-creating
functions. After issuing a critical error, TEX stops reading the current input file. This
may halt the TEX run (if the current file is the main file) or may abort reading a sub-file.
TEXhackers note: The TEX \endinput primitive is used to exit the file. In particular,
the rest of the current line remains in the input stream.
Issues ⟨module ⟩ error ⟨message ⟩, passing ⟨arg one ⟩ to ⟨arg four ⟩ to the text-creating
functions. The error interrupts processing and issues the text at the terminal. After user
input, the run continues.
85
\msg_warning:nnnnnn \msg_warning:nnnnnn {⟨module ⟩} {⟨message ⟩} {⟨arg one ⟩} {⟨arg
\msg_warning:nneeee two ⟩} {⟨arg three ⟩} {⟨arg four ⟩}
\msg_warning:nnnnn
\msg_warning:(nneee|nnnee)
\msg_warning:nnnn
\msg_warning:(nnVV|nnVn|nnnV|nnee|nnne)
\msg_warning:nnn
\msg_warning:(nnV|nne)
\msg_warning:nn
Updated: 2012-08-11
Issues ⟨module ⟩ warning ⟨message ⟩, passing ⟨arg one ⟩ to ⟨arg four ⟩ to the text-
creating functions. The warning text is added to the log file and the terminal, but
the TEX run is not interrupted.
Issues ⟨module ⟩ information ⟨message ⟩, passing ⟨arg one ⟩ to ⟨arg four ⟩ to the text-
creating functions. For the more common \msg_info:nnnnnn, the information text is
added to the log file only, while \msg_note:nnnnnn adds the info text to both the log file
and the terminal. The TEX run is not interrupted.
86
\msg_term:nnnnnn \msg_term:nnnnnn {⟨module ⟩} {⟨message ⟩} {⟨arg one ⟩} {⟨arg two ⟩} {⟨arg
\msg_term:nneeee three ⟩} {⟨arg four ⟩}
\msg_term:nnnnn \msg_log:nnnnnn {⟨module ⟩} {⟨message ⟩} {⟨arg one ⟩} {⟨arg two ⟩} {⟨arg
\msg_term:(nneee|nnnee) three ⟩} {⟨arg four ⟩}
\msg_term:nnnn
\msg_term:(nnVV|nnVn|nnnV|nnee|nnne)
\msg_term:nnn
\msg_term:(nnV|nne)
\msg_term:nn
\msg_log:nnnnnn
\msg_log:nneeee
\msg_log:nnnnn
\msg_log:(nneee|nnnee)
\msg_log:nnnn
\msg_log:(nnVV|nnVn|nnnV|nnee|nnne)
\msg_log:nnn
\msg_log:(nnV|nne)
\msg_log:nn
Updated: 2012-08-11
Issues ⟨module ⟩ information ⟨message ⟩, passing ⟨arg one ⟩ to ⟨arg four ⟩ to the text-
creating functions. The output is briefer than \msg_info:nnnnnn, omitting for in-
stance the module name. It is added to the log file by \msg_log:nnnnnn while \msg_-
term:nnnnnn also prints it on the terminal.
Does nothing: used as a message class to prevent any output at all (see the discussion of
message redirection).
87
11.4.1 Messages for showing material
Issues ⟨module ⟩ information ⟨message ⟩, passing ⟨arg one ⟩ to ⟨arg four ⟩ to the text-
creating functions. The information text is shown on the terminal and the TEX run is
interrupted in a manner similar to \tl_show:n. This is used in conjunction with \msg_-
show_item:n and similar functions to print complex variable contents completely. If the
formatted text does not contain >~ at the start of a line, an additional line >~. will be
put at the end. In addition, a final period is added if not present.
Used in the text of messages for \msg_show:nnnnnn to show or log a list of items or
key–value pairs. The output of \msg_show_item:n produces a newline, the prefix >,
two spaces, then the braced string representation of its argument. The two-argument
versions separates the key and value using ␣␣=>␣␣, and the unbraced versions don’t
print the surrounding braces.
These functions are suitable for usage with iterator functions like \seq_map_-
function:NN, \prop_map_function:NN, etc. For example, with a sequence \l_tmpa_seq
containing a, {b} and \c,
\seq_map_function:NN \l_tmpa_seq \msg_show_item:n
88
to print to the terminal or the log file are expandable. As a result, short-hands such as
\{ or \\ do not work, and messages must be very short (with default settings, they are
truncated after approximately 50 characters). It is advisable to ensure that the message
is understandable even when truncated, by putting the most important information up
front. Another particularity of expandable messages is that they cannot be redirected or
turned off by the user.
Issues an “Undefined error” message from TEX itself using the undefined control sequence
\::error then prints “! ⟨module ⟩: ”⟨error message ⟩, which should be short. With
default settings, anything beyond approximately 60 characters long (or bytes in some
engines) is cropped. A leading space might be removed as well.
89
immediately. Infinite loops are prevented by eliminating the redirection starting from
the target of the redirection that caused the loop to appear. Namely, if redirections are
requested as A → B, B → C and C → A in this order, then the A → B redirection is
cancelled.
90
Chapter 12
This module provides functions for working with external files. Some of these functions
apply to an entire file, and have prefix \file_..., while others are used to work with
files on a line by line basis and have prefix \ior_... (reading) or \iow_... (writing).
It is important to remember that when reading external files TEX attempts to locate
them using both the operating system path and entries in the TEX file database (most
TEX systems use such a database). Thus the “current path” for TEX is somewhat broader
than that for other programs.
For functions which expect a ⟨file name ⟩ argument, this argument may contain
both literal items and expandable content, which should on full expansion be the desired
file name. Active characters (as declared in \l_char_active_seq) are not expanded,
allowing the direct use of these in file names. Quote tokens (") are not permitted in file
names as they are reserved for internal use by some TEX primitives.
Spaces are trimmed at the beginning and end of the file name: this reflects the
fact that some file systems do not allow or interact unpredictably with spaces in these
positions. When no extension is given, this will trim spaces from the start of the name
only.
91
\ior_new:N \ior_new:N ⟨stream ⟩
\ior_new:c \iow_new:N ⟨stream ⟩
\iow_new:N
Globally reserves the name of the ⟨stream ⟩, either for reading or for writing as appropri-
\iow_new:c
ate. The ⟨stream ⟩ is not opened until the appropriate \..._open:Nn function is used.
New: 2011-09-26 Attempting to use a ⟨stream ⟩ which has not been opened is an error, and the ⟨stream ⟩
Updated: 2011-12-27 will behave as the corresponding \c_term_....
92
\ior_close:N \ior_close:N ⟨stream ⟩
\ior_close:c \iow_close:N ⟨stream ⟩
\iow_close:N
Closes the ⟨stream ⟩. Streams should always be closed when they are finished with as
\iow_close:c
this ensures that they remain available to other programmers.
Updated: 2012-07-31
\ior_show_list: \ior_show_list:
\ior_log_list: \ior_log_list:
\iow_show_list: \iow_show_list:
\iow_log_list: \iow_log_list:
New: 2017-06-27 Display (to the terminal or log file) a list of the file names associated with each open
(read or write) stream. This is intended for tracking down problems.
93
\ior_get:NN \ior_get:NN ⟨stream ⟩ ⟨token list variable ⟩
\ior_get:NNTF \ior_get:NNTF ⟨stream ⟩ ⟨token list variable ⟩ ⟨true code ⟩ ⟨false code ⟩
New: 2012-06-24 Function that reads one or more lines (until an equal number of left and right braces are
Updated: 2019-03-23 found) from the file input ⟨stream ⟩ and stores the result locally in the ⟨token list ⟩
variable. The material read from the ⟨stream ⟩ is tokenized by TEX according to the
category codes and \endlinechar in force when the function is used. Assuming normal
settings, any lines which do not end in a comment character % have the line ending
converted to a space, so for example input
a b c
results in a token list a␣b␣c␣. Any blank line is converted to the token \par. Therefore,
blank lines can be skipped by using a test such as
Also notice that if multiple lines are read to match braces then the resulting token list
can contain \par tokens. In the non-branching version, where the ⟨stream ⟩ is not open
the ⟨tl var ⟩ is set to \q_no_value.
TEXhackers note: This protected macro is a wrapper around the TEX primitive \read.
Regardless of settings, TEX replaces trailing space and tab characters (character codes 32 and 9)
in each line by an end-of-line character (character code \endlinechar, omitted if \endlinechar
is negative or too large) before turning characters into tokens according to current category
codes. With default settings, spaces appearing at the beginning of lines are also ignored.
TEXhackers note: This protected macro is a wrapper around the ε-TEX primitive
\readline. Regardless of settings, TEX removes trailing space and tab characters (character
codes 32 and 9). However, the end-line character normally added by this primitive is not in-
cluded in the result of \ior_str_get:NN.
All mappings are done at the current group level, i.e. any local assignments made
94
by the ⟨function ⟩ or ⟨code ⟩ discussed below remain in effect after the loop.
95
\ior_map_break: \ior_map_break:
New: 2012-06-29 Used to terminate a \ior_map_... function before all lines from the ⟨stream ⟩ have been
processed. This normally takes place within a conditional statement, for example
\ior_map_inline:Nn \l_my_ior
{
\str_if_eq:nnTF { #1 } { bingo }
{ \ior_map_break: }
{
% Do something useful
}
}
Use outside of a \ior_map_... scenario leads to low level TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
further items are taken from the input stream. This depends on the design of the mapping
function.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
the ⟨code ⟩ is inserted into the input stream. This depends on the design of the mapping function.
96
12.1.2 Reading from the terminal
prompt=
TEXhackers note: When using expl3 with a format other than LATEX, new line char-
acters inserted using \iow_newline: or using the line-wrapping code \iow_wrap:nnnN are not
recognized in the argument of \iow_shipout:Nn. This may lead to the insertion of additional
unwanted line-breaks.
97
\iow_shipout_e:Nn \iow_shipout_e:Nn ⟨stream ⟩ {⟨tokens ⟩}
\iow_shipout_e:(Ne|cn|ce)
This function writes ⟨tokens ⟩ to the specified ⟨stream ⟩ when the current page is finalised
Updated: 2023-09-17 (i.e. at shipout). The ⟨tokens ⟩ are expanded at the time of writing in addition to any
expansion when the function is used. This makes these functions suitable for including
material finalised during the page building process (such as the page number integer).
TEXhackers note: This is a wrapper around the TEX primitive \write. When using expl3
with a format other than LATEX, new line characters inserted using \iow_newline: or using the
line-wrapping code \iow_wrap:nnnN are not recognized in the argument of \iow_shipout:Nn.
This may lead to the insertion of additional unwanted line-breaks.
The function has no effect if writing is taking place without expansion (e.g. in the second
argument of \iow_now:Nn).
\iow_newline: ⋆ \iow_newline:
Function to add a new line within the ⟨tokens ⟩ written to a file. The function has
no effect if writing is taking place without expansion (e.g. in the second argument of
\iow_now:Nn).
TEXhackers note: When using expl3 with a format other than LATEX, the character in-
serted by \iow_newline: is not recognized by TEX, which may lead to the insertion of additional
unwanted line-breaks. This issue only affects \iow_shipout:Nn, \iow_shipout_e:Nn and direct
uses of primitive operations.
98
12.1.4 Wrapping lines in output
Additional functions may be added to the wrapping by using the ⟨set up ⟩, which is
executed before the wrapping takes place: this may include overriding the substitutions
listed.
Any expandable material in the ⟨text ⟩ which is not to be expanded on wrapping
should be converted to a string using \token_to_str:N, \tl_to_str:n, \tl_to_str:N,
etc.
The result of the wrapping operation is passed as a braced argument to the
⟨function ⟩, which is typically a wrapper around a write operation. The output of
\iow_wrap:nnnN (i.e. the argument passed to the ⟨function ⟩) consists of characters of
category “other” (category code 12), with the exception of spaces which have category
“space” (category code 10). This means that the output does not expand further when
written to a file.
\iow_wrap_allow_break: \iow_wrap_allow_break:
New: 2023-04-25 In the first argument of \iow_wrap:nnnN (for instance in messages), inserts a break-point
that allows a line break. If no break occurs, this function adds nothing to the output.
99
\l_iow_line_count_int The maximum number of characters in a line to be written by the \iow_wrap:nnnN
New: 2012-06-24 function. This value depends on the TEX system in use: the standard value is 78, which
is typically correct for unmodified TEX Live and MiKTEX systems.
\g_tmpa_ior Scratch input stream for global use. These are never used by the kernel code, and so
\g_tmpb_ior are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
New: 2017-12-11 other non-kernel code and so should only be used for short-term storage.
\c_log_iow Constant output streams for writing to the log and to the terminal (plus the log), respec-
\c_term_iow tively.
\g_tmpa_iow Scratch output stream for global use. These are never used by the kernel code, and so
\g_tmpb_iow are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
New: 2017-12-11 other non-kernel code and so should only be used for short-term storage.
\g_file_curr_dir_str Contain the directory, name and extension of the current file. The directory is empty
\g_file_curr_name_str if the file was loaded without an explicit path (i.e. if it is in the T X search path), and
E
\g_file_curr_ext_str does not end in / other than the case that it is exactly equal to the root directory. The
New: 2017-06-21 ⟨name ⟩ and ⟨ext ⟩ parts together make up the file name, thus the ⟨name ⟩ part may be
thought of as the “job name” for the current file.
Note that TEX does not provide information on the ⟨dir ⟩ and ⟨ext ⟩ part for the
main (top level) file and that this file always has empty ⟨dir ⟩ and ⟨ext ⟩ components.
Also, the ⟨name ⟩ here will be equal to \c_sys_jobname_str, which may be different from
the real file name (if set using --jobname, for example).
100
\l_file_search_path_seq Each entry is the path to a directory which should be searched when seeking a file. Each
New: 2017-06-18 path can be relative or absolute, and need not include the trailing slash. Spaces need not
Updated: 2023-06-15 be quoted.
101
\file_parse_full_name:nNNN \file_parse_full_name:nNNN {⟨full name ⟩} ⟨dir ⟩ ⟨name ⟩ ⟨ext ⟩
\file_parse_full_name:VNNN
Parses the ⟨full name ⟩ and splits it into three parts, each of which is returned by setting
New: 2017-06-23 the appropriate local string variable:
Updated: 2020-06-24
• The ⟨dir ⟩: everything up to the last / (path separator) in the ⟨file path ⟩. As
with system PATH variables and related functions, the ⟨dir ⟩ does not include the
trailing / unless it points to the root directory. If there is no path (only a file
name), ⟨dir ⟩ is empty.
• The ⟨name ⟩: everything after the last / up to the last ., where both of those
characters are optional. The ⟨name ⟩ may contain multiple . characters. It is empty
if ⟨full name ⟩ consists only of a directory name.
• The ⟨ext ⟩: everything after the last . (including the dot). The ⟨ext ⟩ is empty if
there is no . after the last /.
Before parsing, the ⟨full name ⟩ is expanded until only non-expandable tokens re-
main, except that active characters are also not expanded. Quotes (") are invalid in file
names and are discarded from the input.
102
\file_get_hex_dump:nN \file_get_hex_dump:nN {⟨file name ⟩} ⟨tl var ⟩
\file_get_hex_dump:VN \file_get_hex_dump:nnnN {⟨file name ⟩} {⟨start index ⟩} {⟨end index ⟩} ⟨tl var ⟩
\file_get_hex_dump:nNTF
Sets the ⟨tl var ⟩ to the result of applying \file_hex_dump:n/\file_hex_dump:nnn to
\file_get_hex_dump:VN
the ⟨file ⟩. If the file is not found, the ⟨tl var ⟩ will be set to \q_no_value.
\file_get_hex_dump:nnnN
\file_get_hex_dump:VnnN
\file_get_hex_dump:nnnNTF
\file_get_hex_dump:VnnN
New: 2019-11-19
New: 2017-07-11
Updated: 2019-02-16
103
\file_get_timestamp:nN \file_get_timestamp:nN {⟨file name ⟩} ⟨tl var ⟩
\file_get_timestamp:VN
Sets the ⟨tl var ⟩ to the result of applying \file_timestamp:n to the ⟨file ⟩. If the
\file_get_timestamp:nNTF
\file_get_timestamp:VN file is not found, the ⟨tl var ⟩ will be set to \q_no_value. This is not available in older
versions of XETEX.
New: 2017-07-09
Updated: 2019-02-16
Compares the file stamps on the two ⟨files ⟩ as indicated by the ⟨comparator ⟩, and
inserts either the ⟨true code ⟩ or ⟨false case ⟩ as required. A file which is not found is
treated as older than any file which is found. This allows for example the construct
\file_compare_timestamp:nNnT { source-file } > { derived-file }
{
% Code to regenerate derived file
}
to work when the derived file is entirely absent. The timestamp of two absent files is
regarded as different. This is not available in older versions of XETEX.
TEXhackers note: This function is intended only for contexts where files must be read
purely by expansion, for example at the start of a table cell in an \halign.
104
\file_input_stop: \file_input_stop:
New: 2017-07-07 Ends the reading of a file started by \file_input:n or similar before the end of the
file is reached. Where the file reading is being terminated due to an error, \msg_-
critical:nn(nn) should be preferred.
TEXhackers note: This function must be used on a line on its own: TEX reads files
line-by-line and so any additional tokens in the “current” line will still be read.
This is also true if the function is hidden inside another function (which will be the normal
case), i.e., all tokens on the same line in the source file are still processed. Putting it on a line
by itself in the definition doesn’t help as it is the line where it is used that counts!
\file_show_list: \file_show_list:
\file_log_list: \file_log_list:
These functions list all files loaded by LATEX 2ε commands that populate \@filelist or
by \file_input:n. While \file_show_list: displays the list in the terminal, \file_-
log_list: outputs it to the log file only.
105
Chapter 13
The LuaTEX engine provides access to the Lua programming language, and with it access
to the “internals” of TEX. In order to use this within the framework provided here, a
family of functions is available. When used with pdfTEX, pTEX, upTEX or XETEX these
raise an error: use \sys_if_engine_luatex:T to avoid this. Details on using Lua with
the LuaTEX engine are given in the LuaTEX manual.
106
\lua_escape:n ⋆ \lua_escape:n {⟨token list ⟩}
\lua_escape:e ⋆
Converts the ⟨token list ⟩ such that it can safely be passed to Lua: embedded back-
New: 2015-06-29 slashes, double and single quotes, and newlines and carriage returns are escaped. This is
done by prepending an extra token consisting of a backslash with category code 12, and
for the line endings, converting them to \n and \r, respectively.
TEXhackers note: This is a wrapper around the Lua call require ’⟨module ⟩’.
ltx.utils Most public interfaces provided by the module are stored within the ltx.utils table.
where the latter may be Z (UTC) or ⟨plus-minus ⟩⟨hours ⟩’⟨minutes ⟩’. If the ⟨file ⟩
is not found, nothing is returned with no error raised.
107
ltx.utils.filesize size = ltx.utils.filesize(⟨file ⟩)
Returns the size of the ⟨file ⟩ in bytes. If the ⟨file ⟩ is not found, nothing is returned
with no error raised.
108
Chapter 14
There are a small number of TEX or LATEX 2ε concepts which are not used in expl3 code
but which need to be manipulated when working as a LATEX 2ε package. To allow these
to be integrated cleanly into expl3 code, a set of legacy interfaces are provided here.
109
Part IV
Data types
110
Chapter 15
TEX works with tokens, and LATEX3 therefore provides a number of functions to deal with
lists of tokens. Token lists may be present directly in the argument to a function:
\foo:n { a collection of \tokens }
or may be stored in a so-called “token list variable”, which have the suffix tl: a token
list variable can also be used as the argument to a function, for example
\foo:N \l_some_tl
In both cases, functions are available to test and manipulate the lists of tokens, and these
have the module prefix tl. In many cases, functions which can be applied to token list
variables are paired with similar functions for application to explicit lists of tokens: the
two “views” of a token list are therefore collected together here.
A token list (explicit, or stored in a variable) can be seen either as a list of “items”,
or a list of “tokens”. An item is whatever \use:n would grab as its argument: a single
non-space token or a brace group, with optional leading explicit space characters (each
item is thus itself a token list). A token is either a normal N argument, or ␣, {, or }
(assuming normal TEX category codes). Thus for example
{ Hello } ~ world
contains six items (Hello, w, o, r, l and d), but thirteen tokens ({, H, e, l, l, o, }, ␣, w,
o, r, l and d). Functions which act on items are often faster than their analogue acting
directly on tokens.
111
\tl_const:Nn \tl_const:Nn ⟨tl var ⟩ {⟨token list ⟩}
\tl_const:(Ne|cn|ce)
Creates a new constant ⟨tl var ⟩ or raises an error if the name is already taken. The
value of the ⟨tl var ⟩ is set globally to the ⟨token list ⟩.
Sets ⟨tl var ⟩ to contain ⟨tokens ⟩, removing any previous content from the variable.
Appends ⟨tokens ⟩ to the left side of the current content of ⟨tl var ⟩.
112
\tl_put_right:Nn \tl_put_right:Nn ⟨tl var ⟩ {⟨tokens ⟩}
\tl_put_right:(NV|Nv|Ne|No|cn|cV|cv|ce|co)
\tl_gput_right:Nn
\tl_gput_right:(NV|Nv|Ne|No|cn|cV|cv|ce|co)
Appends ⟨tokens ⟩ to the right side of the current content of ⟨tl var ⟩.
yields false. See also \str_if_eq:nnTF for a comparison that ignores category codes.
\tl_if_eq:NnTF \tl_if_eq:NnTF ⟨tl var1 ⟩ {⟨token list2 ⟩} {⟨true code ⟩} {⟨false code ⟩}
\tl_if_eq:cn
Tests if the ⟨token list variable1 ⟩ and the ⟨token list2 ⟩ contain the same list of
New: 2020-07-14 tokens, both in respect of character codes and category codes. This conditional is not
expandable: see \tl_if_eq:NNTF for an expandable version when both token lists are
stored in variables, or \str_if_eq:nnTF if category codes are not important.
113
\tl_if_eq:nnTF \tl_if_eq:nnTF {⟨token list1 ⟩} {⟨token list2 ⟩} {⟨true code ⟩} {⟨false code ⟩}
\tl_if_eq:(nV|ne|Vn|en|ee)TF
Tests if ⟨token list1 ⟩ and ⟨token list2 ⟩ contain the same list of tokens, both in respect
of character codes and category codes. This conditional is not expandable: see \tl_if_-
eq:NNTF for an expandable version when token lists are stored in variables, or \str_-
if_eq:nnTF if category codes are not important.
\tl_if_in:NnTF \tl_if_in:NnTF ⟨tl var ⟩ {⟨token list ⟩} {⟨true code ⟩} {⟨false code ⟩}
\tl_if_in:(NV|cn|cV)TF
Tests if the ⟨token list ⟩ is found in the content of the ⟨tl var ⟩. The ⟨token list ⟩
cannot contain the tokens {, } or # (more precisely, explicit character tokens with category
code 1 (begin-group) or 2 (end-group), and tokens with category code 6).
\tl_if_in:nnTF \tl_if_in:nnTF {⟨token list1 ⟩} {⟨token list2 ⟩} {⟨true code ⟩} {⟨false code ⟩}
\tl_if_in:(Vn|nV|on|no)TF
Tests if ⟨token list2 ⟩ is found inside ⟨token list1 ⟩. The ⟨token list2 ⟩ cannot con-
tain the tokens {, } or # (more precisely, explicit character tokens with category code 1
(begin-group) or 2 (end-group), and tokens with category code 6). The search does not
enter brace (category code 1/2) groups.
114
15.3.1 Testing the first token
Tests if the first ⟨token ⟩ in the ⟨token list ⟩ has the same category code as the ⟨test
token ⟩. In the case where the ⟨token list ⟩ is empty, the test is always false.
Tests if the first ⟨token ⟩ in the ⟨token list ⟩ has the same character code as the ⟨test
token ⟩. In the case where the ⟨token list ⟩ is empty, the test is always false.
Tests if the first ⟨token ⟩ in the ⟨token list ⟩ has the same meaning as the ⟨test token ⟩.
In the case where ⟨token list ⟩ is empty, the test is always false.
Tests if the first ⟨token ⟩ in the ⟨token list ⟩ is a normal N-type argument. In other
words, it is neither an explicit space character (explicit token with character code 32 and
category code 10) nor an explicit begin-group character (with category code 1 and any
character code). An empty argument yields false, as it does not have a normal first
token. This function is useful to implement actions on token lists on a token by token
basis.
115
\tl_if_head_is_space_p:n ⋆ \tl_if_head_is_space_p:n {⟨token list ⟩}
\tl_if_head_is_space:nTF ⋆ \tl_if_head_is_space:nTF {⟨token list ⟩} {⟨true code ⟩} {⟨false code ⟩}
Updated: 2012-07-08 Tests if the first ⟨token ⟩ in the ⟨token list ⟩ is an explicit space character (explicit
token with character code 32 and category code 10). In particular, the test is false
if the ⟨token list ⟩ starts with an implicit token such as \c_space_token, or if it is
empty. This function is useful to implement actions on token lists on a token by token
basis.
116
15.4.2 Counting and reversing token lists
TEXhackers note: The result is returned within \unexpanded, which means that the
token list does not expand further when appearing in an e-type or x-type argument expansion.
TEXhackers note: The result is returned within \unexpanded, which means that the
token list does not expand further when appearing in an e-type or x-type argument expansion.
117
\tl_trim_spaces:n ⋆ \tl_trim_spaces:n {⟨token list ⟩}
\tl_trim_spaces:(V|v|e|o) ⋆
Removes any leading and trailing explicit space characters (explicit tokens with character
New: 2011-07-09 code 32 and category code 10) from the ⟨token list ⟩ and leaves the result in the input
Updated: 2012-06-25 stream.
TEXhackers note: The result is returned within \unexpanded, which means that the
token list does not expand further when appearing in an e-type or x-type argument expansion.
118
15.5 Manipulating items in token lists
15.5.1 Mapping over token lists
All mappings are done at the current group level, i.e. any local assignments made by the
⟨function ⟩ or ⟨code ⟩ discussed below remain in effect after the loop.
expands to twice each ⟨item ⟩ in the ⟨tl var ⟩: for each ⟨item ⟩ in \l_my_tl the function
\prg_replicate:nn receives 2 and ⟨item ⟩ as its two arguments. The function \tl_-
map_inline:Nn is typically faster but is not expandable.
119
\tl_map_variable:nNn \tl_map_variable:nNn {⟨token list ⟩} ⟨variable ⟩ {⟨code ⟩}
Updated: 2012-06-29 Stores each ⟨item ⟩ of the ⟨token list ⟩ in turn in the (token list) ⟨variable ⟩ and applies
the ⟨code ⟩. The ⟨code ⟩ will usually make use of the ⟨variable ⟩, but this is not enforced.
The assignments to the ⟨variable ⟩ are local. Its value after the loop is the last ⟨item ⟩ in
the ⟨tl var ⟩, or its original value if the ⟨tl var ⟩ is blank. See also \tl_map_inline:nn.
\tl_map_break: ✩ \tl_map_break:
Updated: 2012-06-29 Used to terminate a \tl_map_... function before all entries in the ⟨token list
variable ⟩ have been processed. This normally takes place within a conditional state-
ment, for example
\tl_map_inline:Nn \l_my_tl
{
\str_if_eq:nnT { #1 } { bingo } { \tl_map_break: }
% Do something useful
}
See also \tl_map_break:n. Use outside of a \tl_map_... scenario leads to low level
TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
the ⟨tokens ⟩ are inserted into the input stream. This depends on the design of the mapping
function.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
the ⟨code ⟩ is inserted into the input stream. This depends on the design of the mapping function.
120
\tl_head:N ⋆ \tl_head:n {⟨token list ⟩}
\tl_head:n ⋆
Leaves in the input stream the first ⟨item ⟩ in the ⟨token list ⟩, discarding the rest of
\tl_head:(V|v|f) ⋆
the ⟨token list ⟩. All leading explicit space characters (explicit tokens with character
Updated: 2012-09-09 code 32 and category code 10) are discarded; for example
\tl_head:n { abc }
and
\tl_head:n { ~ abc }
both leave a in the input stream. If the “head” is a brace group, rather than a single
token, the braces are removed, and so
\tl_head:n { ~ { ~ ab } c }
yields ␣ab. A blank ⟨token list ⟩ (see \tl_if_blank:nTF) results in \tl_head:n leav-
ing nothing in the input stream.
TEXhackers note: The result is returned within \exp_not:n, which means that the token
list does not expand further when appearing in an e-type or x-type argument expansion.
\tl_tail:n { a ~ {bc} d }
and
\tl_tail:n { ~ a ~ {bc} d }
both leave ␣{bc}d in the input stream. A blank ⟨token list ⟩ (see \tl_if_blank:nTF)
results in \tl_tail:n leaving nothing in the input stream.
TEXhackers note: The result is returned within \exp_not:n, which means that the token
list does not expand further when appearing in an e-type or x-type argument expansion.
If you wish to handle token lists where the first token may be a space, and this
121
needs to be treated as the head/tail, this can be accomplished using \tl_if_head_is_-
space:nTF, for example
\exp_last_unbraced:NNo
\cs_new:Npn \__mypkg_gobble_space:w \c_space_tl { }
\cs_new:Npn \mypkg_tl_head_keep_space:n #1
{
\tl_if_head_is_space:nTF {#1}
{ ~ }
{ \tl_head:n {#1} }
}
\cs_new:Npn \mypkg_tl_tail_keep_space:n #1
{
\tl_if_head_is_space:nTF {#1}
{ \exp_not:o { \__mypkg_gobble_space:w #1 } }
{ \tl_tail:n {#1} }
}
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨item ⟩ does not expand further when appearing in an e-type or x-type
argument expansion.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨item ⟩ does not expand further when appearing in an e-type or x-type
argument expansion.
122
\tl_range:Nnn ⋆ \tl_range:Nnn ⟨tl var ⟩ {⟨start index ⟩} {⟨end index ⟩}
\tl_range:nnn ⋆ \tl_range:nnn {⟨token list ⟩} {⟨start index ⟩} {⟨end index ⟩}
New: 2017-02-17 Leaves in the input stream the items from the ⟨start index ⟩ to the ⟨end index ⟩ inclu-
Updated: 2017-07-15 sive. Spaces and braces are preserved between the items returned (but never at either end
of the list). Here ⟨start index ⟩ and ⟨end index ⟩ should be ⟨integer expressions ⟩.
For describing in detail the functions’ behavior, let m and n be the start and end index
respectively. If either is 0, the result is empty. A positive index means ‘start counting
from the left end’, and a negative index means ‘from the right end’. Let l be the count
of the token list.
The actual start point is determined as M = m if m > 0 and as M = l + m + 1
if m < 0. Similarly the actual end point is N = n if n > 0 and N = l + n + 1 if n < 0.
If M > N , the result is empty. Otherwise it consists of all items from position M to
position N inclusive; for the purpose of this rule, we can imagine that the token list
extends at infinity on either side, with void items at positions s for s ≤ 0 or s > l.
Spaces in between items in the actual range are preserved. Spaces at either end
of the token list will be removed anyway (think to the token list being passed to
\tl_trim_spaces:n to begin with.
Thus, with l = 7 as in the examples below, all of the following are equivalent and
result in the whole token list
\tl_range:nnn { abcd~{e{}}fg } { 1 } { 7 }
\tl_range:nnn { abcd~{e{}}fg } { 1 } { 12 }
\tl_range:nnn { abcd~{e{}}fg } { -7 } { 7 }
\tl_range:nnn { abcd~{e{}}fg } { -12 } { 7 }
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨item ⟩ does not expand further when appearing in an e-type or x-type
argument expansion.
123
15.5.4 Sorting token lists
TEXhackers note: The result is returned within \exp_not:n, which means that the token
list does not expand further when appearing in an e-type or x-type argument expansion.
Replaces the first (leftmost) occurrence of ⟨old tokens ⟩ in the ⟨tl var ⟩ with ⟨new
tokens ⟩. ⟨Old tokens ⟩ cannot contain {, } or # (more precisely, explicit character
tokens with category code 1 (begin-group) or 2 (end-group), and tokens with category
code 6).
124
\tl_replace_all:Nnn \tl_replace_all:Nnn ⟨tl var ⟩ {⟨old tokens ⟩} {⟨new
\tl_replace_all:(NVn|NnV|Nen|Nne|Nee|cnn|cVn|cnV|cen| tokens ⟩}
cne|cee)
\tl_greplace_all:Nnn
\tl_greplace_all:(NVn|NnV|Nen|Nne|Nee|cnn|cVn|cnV|cen|
cne|cee)
Updated: 2011-08-11
Replaces all occurrences of ⟨old tokens ⟩ in the ⟨tl var ⟩ with ⟨new tokens ⟩. ⟨Old
tokens ⟩ cannot contain {, } or # (more precisely, explicit character tokens with category
code 1 (begin-group) or 2 (end-group), and tokens with category code 6). As this function
operates from left to right, the pattern ⟨old tokens ⟩ may remain after the replacement
(see \tl_remove_all:Nn for an example).
Removes the first (leftmost) occurrence of ⟨tokens ⟩ from the ⟨tl var ⟩. ⟨Tokens ⟩ cannot
contain {, } or # (more precisely, explicit character tokens with category code 1 (begin-
group) or 2 (end-group), and tokens with category code 6).
Removes all occurrences of ⟨tokens ⟩ from the ⟨tl var ⟩. ⟨Tokens ⟩ cannot contain {, }
or # (more precisely, explicit character tokens with category code 1 (begin-group) or 2
(end-group), and tokens with category code 6). As this function operates from left to
right, the pattern ⟨tokens ⟩ may remain after the removal, for instance,
\tl_set:Nn \l_tmpa_tl {abbccd} \tl_remove_all:Nn \l_tmpa_tl {bc}
results in \l_tmpa_tl containing abcd.
125
\tl_set_rescan:Nnn \tl_set_rescan:Nnn ⟨tl var ⟩ {⟨setup ⟩} {⟨tokens ⟩}
\tl_set_rescan:(NnV|Nne|Nno|cnn|cnV|cne|cno)
\tl_gset_rescan:Nnn
\tl_gset_rescan:(NnV|Nne|Nno|cnn|cnV|cne|cno)
Updated: 2015-08-11
Sets ⟨tl var ⟩ to contain ⟨tokens ⟩, applying the category code régime specified in the
⟨setup ⟩ before carrying out the assignment. (Category codes applied to tokens not
explicitly covered by the ⟨setup ⟩ are those in force at the point of use of \tl_set_-
rescan:Nnn.) This allows the ⟨tl var ⟩ to contain material with category codes other
than those that apply when ⟨tokens ⟩ are absorbed. The ⟨setup ⟩ is run within a group
and may contain any valid input, although only changes in category codes, such as uses
of \cctab_select:N, are relevant. See also \tl_rescan:nn.
TEXhackers note: The ⟨tokens ⟩ are first turned into a string (using \tl_to_str:n).
If the string contains one or more characters with character code \newlinechar (set equal to
\endlinechar unless that is equal to 32, before the user ⟨setup ⟩), then it is split into lines at
these characters, then read as if reading multiple lines from a file, ignoring spaces (catcode 10) at
the beginning and spaces and tabs (character code 32 or 9) at the end of every line. Otherwise,
spaces (and tabs) are retained at both ends of the single-line string, as if it appeared in the
middle of a line read from a file.
126
\c_novalue_tl A marker for the absence of an argument. This constant tl can safely be typeset (cf. \q_-
New: 2017-11-14 nil), with the result being -NoValue-. It is important to note that \c_novalue_tl is
constructed such that it will not match the simple text input -NoValue-, i.e. that
\tl_if_eq:NnTF \c_novalue_tl { -NoValue- }
is logically false. The \c_novalue_tl marker is intended for use in creating document-
level interfaces, where it serves as an indicator that an (optional) argument was omitted.
In particular, it is distinct from a simple empty tl.
\c_space_tl An explicit space character contained in a token list (compare this with \c_space_token).
For use where an explicit space is required.
\l_tmpa_tl Scratch token lists for local assignment. These are never used by the kernel code, and so
\l_tmpb_tl are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
\g_tmpa_tl Scratch token lists for global assignment. These are never used by the kernel code, and
\g_tmpb_tl so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
by other non-kernel code and so should only be used for short-term storage.
127
Chapter 16
128
Chapter 17
TEX associates each character with a category code: as such, there is no concept of
a “string” as commonly understood in many other programming languages. However,
there are places where we wish to manipulate token lists while in some sense “ignoring”
category codes: this is done by treating token lists as strings in a TEX sense.
A TEX string (and thus an expl3 string) is a series of characters which have category
code 12 (“other”) with the exception of space characters which have category code 10
(“space”). Thus at a technical level, a TEX string is a token list with the appropriate
category codes. In this documentation, these are simply referred to as strings.
String variables are simply specialised token lists, but by convention should be named
with the suffix ...str. Such variables should contain characters with category code 12
(other), except spaces, which have category code 10 (blank space). All the functions in
this module which accept a token list argument first convert it to a string using \tl_to_-
str:n for internal processing, and do not treat a token list or the corresponding string
representation differently.
As a string is a subset of the more general token list, it is sometimes unclear when
one should be used over the other. Use a string variable for data that isn’t primarily
intended for typesetting and for which a level of protection from unwanted expansion is
suitable. This data type simplifies comparison of variables since there are no concerns
about expansion of their contents.
The functions \cs_to_str:N, \tl_to_str:n, \tl_to_str:N and \token_to_str:N
(and variants) generate strings from the appropriate input: these are documented in
l3basics, l3tl and l3token, respectively.
Most expandable functions in this module come in three flavours:
• \str_...:N, which expect a token list or string variable as their argument;
• \str_...:n, taking any token list (or string) as an argument;
129
17.1 Creating and initialising string variables
130
17.2 Adding data to string variables
Converts the ⟨token list ⟩ to a ⟨string ⟩, and prepends the result to ⟨str var ⟩. The
current contents of the ⟨str var ⟩ are not automatically converted to a string.
Converts the ⟨token list ⟩ to a ⟨string ⟩, and appends the result to ⟨str var ⟩. The
current contents of the ⟨str var ⟩ are not automatically converted to a string.
131
\str_if_eq_p:nn ⋆ \str_if_eq_p:nn {⟨tl1 ⟩} {⟨tl2 ⟩}
\str_if_eq_p:(Vn|on|no|nV|VV|vn|nv|ee) ⋆ \str_if_eq:nnTF {⟨tl1 ⟩} {⟨tl2 ⟩} {⟨true code ⟩} {⟨false code ⟩}
\str_if_eq:nnTF ⋆
\str_if_eq:(Vn|on|no|nV|VV|vn|nv|ee)TF ⋆
Updated: 2018-06-18
Compares the two ⟨token lists ⟩ on a character by character basis (namely after con-
verting them to strings), and is true if the two ⟨strings ⟩ contain the same characters
in the same order. Thus for example
\str_if_eq_p:no { abc } { \tl_to_str:n { abc } }
is logically true. See \tl_if_eq:nnTF to compare tokens (including their category codes)
rather than characters.
\str_if_in:NnTF \str_if_in:NnTF ⟨str var ⟩ {⟨token list ⟩} {⟨true code ⟩} {⟨false code ⟩}
\str_if_in:cn
Converts the ⟨token list ⟩ to a ⟨string ⟩ and tests if that ⟨string ⟩ is found in the
New: 2017-10-08 content of the ⟨str var ⟩.
132
\str_case_e:nn ⋆ \str_case_e:nnTF {⟨test string ⟩}
\str_case_e:en ⋆ {
\str_case_e:nnTF ⋆ {⟨string case1 ⟩} {⟨code case1 ⟩}
\str_case_e:en ⋆ {⟨string case2 ⟩} {⟨code case2 ⟩}
...
New: 2018-06-19
{⟨string casen ⟩} {⟨code casen ⟩}
}
{⟨true code ⟩}
{⟨false code ⟩}
Compares the full expansion of the ⟨test string ⟩ in turn with the full expansion of
the ⟨string case ⟩s (all token lists are converted to strings). If the two full expansions
are equal (as described for \str_if_eq:eeTF) then the associated ⟨code ⟩ is left in the
input stream and other cases are discarded. If any of the cases are matched, the ⟨true
code ⟩ is also inserted into the input stream (after the code for the appropriate case),
while if none match then the ⟨false code ⟩ is inserted. The function \str_case_e:nn,
which does nothing if there is no match, is also available. In \str_case_e:nn(TF), the
⟨test string ⟩ is expanded in each comparison, and must always yield the same result:
for example, random numbers must not be used within this string.
TEXhackers note: This is a wrapper around the TEX primitive \(pdf)strcmp. It is meant for
programming and not for sorting textual contents, as it simply considers character codes and
not more elaborate considerations of grapheme clusters, locale, etc.
133
\str_map_inline:nn \str_map_inline:nn {⟨token list ⟩} {⟨inline function ⟩}
\str_map_inline:Nn \str_map_inline:Nn ⟨str var ⟩ {⟨inline function ⟩}
\str_map_inline:cn
Converts the ⟨token list ⟩ to a ⟨string ⟩ then applies the ⟨inline function ⟩ to every
New: 2017-11-14 ⟨character ⟩ in the ⟨str var ⟩ including spaces. The ⟨inline function ⟩ should consist
of code which receives the ⟨character ⟩ as #1.
\str_map_break: ✩ \str_map_break:
New: 2017-10-08 Used to terminate a \str_map_... function before all characters in the ⟨string ⟩ have
been processed. This normally takes place within a conditional statement, for example
\str_map_inline:Nn \l_my_str
{
\str_if_eq:nnT { #1 } { bingo } { \str_map_break: }
% Do something useful
}
See also \str_map_break:n. Use outside of a \str_map_... scenario leads to low level
TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
continuing with the code that follows the loop. This depends on the design of the mapping
function.
134
\str_map_break:n ✩ \str_map_break:n {⟨code ⟩}
New: 2017-10-08 Used to terminate a \str_map_... function before all characters in the ⟨string ⟩ have
been processed, inserting the ⟨code ⟩ after the mapping has ended. This normally takes
place within a conditional statement, for example
\str_map_inline:Nn \l_my_str
{
\str_if_eq:nnT { #1 } { bingo }
{ \str_map_break:n { <code> } }
% Do something useful
}
Use outside of a \str_map_... scenario leads to low level TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
the ⟨code ⟩ is inserted into the input stream. This depends on the design of the mapping function.
Leaves in the input stream the number of characters in the string representation of ⟨token
list ⟩, as an integer denotation. The functions differ in their treatment of spaces. In the
case of \str_count:N and \str_count:n, all characters including spaces are counted.
The \str_count_ignore_spaces:n function leaves the number of non-space characters
in the input stream.
135
\str_head:N ⋆ \str_head:n {⟨token list ⟩}
\str_head:c ⋆
\str_head:n ⋆
\str_head_ignore_spaces:n ⋆
New: 2015-09-18
Converts the ⟨token list ⟩ into a ⟨string ⟩. The first character in the ⟨string ⟩ is
then left in the input stream, with category code “other”. The functions differ if the
first character is a space: \str_head:N and \str_head:n return a space token with
category code 10 (blank space), while the \str_head_ignore_spaces:n function ignores
this space character and leaves the first non-space character in the input stream. If the
⟨string ⟩ is empty (or only contains spaces in the case of the _ignore_spaces function),
then nothing is left on the input stream.
Converts the ⟨token list ⟩ to a ⟨string ⟩, removes the first character, and leaves the
remaining characters (if any) in the input stream, with category codes 12 and 10 (for
spaces). The functions differ in the case where the first character is a space: \str_tail:N
and \str_tail:n only trim that space, while \str_tail_ignore_spaces:n removes the
first non-space character and any space before it. If the ⟨token list ⟩ is empty (or blank
in the case of the _ignore_spaces variant), then nothing is left on the input stream.
Converts the ⟨token list ⟩ to a ⟨string ⟩, and leaves in the input stream the char-
acter in position ⟨integer expression ⟩ of the ⟨string ⟩, starting at 1 for the first
(left-most) character. In the case of \str_item:Nn and \str_item:nn, all characters
including spaces are taken into account. The \str_item_ignore_spaces:nn function
skips spaces when counting characters. If the ⟨integer expression ⟩ is negative, char-
acters are counted from the end of the ⟨string ⟩. Hence, −1 is the right-most character,
etc.
136
\str_range:Nnn ⋆ \str_range:nnn {⟨token list ⟩} {⟨start index ⟩} {⟨end index ⟩}
\str_range:cnn ⋆
\str_range:nnn ⋆
\str_range_ignore_spaces:nnn ⋆
New: 2015-09-18
Converts the ⟨token list ⟩ to a ⟨string ⟩, and leaves in the input stream the characters
from the ⟨start index ⟩ to the ⟨end index ⟩ inclusive. Spaces are preserved and counted
as items (contrast this with \tl_range:nnn where spaces are not counted as items and
are possibly discarded from the output).
Here ⟨start index ⟩ and ⟨end index ⟩ should be integer denotations. For describing
in detail the functions’ behavior, let m and n be the start and end index respectively.
If either is 0, the result is empty. A positive index means ‘start counting from the left
end’, a negative index means ‘start counting from the right end’. Let l be the count of
the token list.
The actual start point is determined as M = m if m > 0 and as M = l + m + 1
if m < 0. Similarly the actual end point is N = n if n > 0 and N = l + n + 1 if n < 0.
If M > N , the result is empty. Otherwise it consists of all items from position M to
position N inclusive; for the purpose of this rule, we can imagine that the token list
extends at infinity on either side, with void items at positions s for s ≤ 0 or s > l. For
instance,
\iow_term:e { \str_range:nnn { abcdef } { 2 } { 5 } }
\iow_term:e { \str_range:nnn { abcdef } { -4 } { -1 } }
\iow_term:e { \str_range:nnn { abcdef } { -2 } { -1 } }
\iow_term:e { \str_range:nnn { abcdef } { 0 } { -1 } }
prints bcde, cdef, ef, and an empty line to the terminal. The ⟨start index ⟩ must
always be smaller than or equal to the ⟨end index ⟩: if this is not the case then no
output is generated. Thus
137
\iow_term:e { \str_range_ignore_spaces:nnn { abcd~efg } { 2 } { 5 } }
\iow_term:e { \str_range_ignore_spaces:nnn { abcd~efg } { 2 } { -3 } }
\iow_term:e { \str_range_ignore_spaces:nnn { abcd~efg } { -6 } { 5 } }
\iow_term:e { \str_range_ignore_spaces:nnn { abcd~efg } { -6 } { -3 } }
will print four instances of bcde, four instances of bc e and eight instances of bcde.
New: 2017-10-08
138
17.7 String manipulation
139
\str_casefold:n ⋆ \str_casefold:n {⟨tokens ⟩}
\str_casefold:V ⋆
Converts the input ⟨tokens ⟩ to their string representation, as described for \tl_to_-
New: 2022-10-16 str:n, and then folds the case of the resulting ⟨string ⟩ to remove case information. The
result of this process is left in the input stream.
String folding is a process used for material such as identifiers rather than for “text”.
The folding provided by \str_casefold:n follows the mappings provided by the Unicode
Consortium, who state:
Case folding is primarily used for caseless comparison of text, such as iden-
tifiers in a computer program, rather than actual text transformation. Case
folding in Unicode is based on the lowercase mapping, but includes additional
changes to the source text to help make it language-insensitive and consistent.
As a result, case-folded text should be used solely for internal processing and
generally should not be stored or displayed to the end user.
The folding approach implemented by \str_casefold:n follows the “full” scheme defined
by the Unicode Consortium (e.g. SSfolds to SS). As case-folding is a language-insensitive
process, there is no special treatment of Turkic input (i.e. I always folds to i and not to
ı).
140
17.9 Constant strings
\c_ampersand_str Constant strings, containing a single character token, with category code 12.
\c_atsign_str
\c_backslash_str
\c_left_brace_str
\c_right_brace_str
\c_circumflex_str
\c_colon_str
\c_dollar_str
\c_hash_str
\c_percent_str
\c_tilde_str
\c_underscore_str
\c_zero_str
New: 2015-09-19
Updated: 2020-12-22
\l_tmpa_str Scratch strings for local assignment. These are never used by the kernel code, and so
\l_tmpb_str are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
\g_tmpa_str Scratch strings for global assignment. These are never used by the kernel code, and so
\g_tmpb_str are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
141
Chapter 18
• Bytes are translated to TEX tokens through a given “escaping”. Those are defined
for the most part by the pdf file format. See Table 2 for a list of escaping methods
supported.7
142
Table 1: Supported encodings. Non-alphanumeric characters are ignored, and capital
letters are lower-cased before searching for the encoding in this list.
⟨Encoding ⟩ description
utf8 utf-8
utf16 utf-16, with byte-order mark
utf16be utf-16, big-endian
utf16le utf-16, little-endian
utf32 utf-32, with byte-order mark
utf32be utf-32, big-endian
utf32le utf-32, little-endian
iso88591, latin1 iso 8859-1
iso88592, latin2 iso 8859-2
iso88593, latin3 iso 8859-3
iso88594, latin4 iso 8859-4
iso88595 iso 8859-5
iso88596 iso 8859-6
iso88597 iso 8859-7
iso88598 iso 8859-8
iso88599, latin5 iso 8859-9
iso885910, latin6 iso 8859-10
iso885911 iso 8859-11
iso885913, latin7 iso 8859-13
iso885914, latin8 iso 8859-14
iso885915, latin9 iso 8859-15
iso885916, latin10 iso 8859-16
clist comma-list of integers
⟨empty ⟩ native (Unicode) string
default like utf8 with 8-bit engines, and like native with unicode-engines
143
18.2 Conversion functions
\str_set_convert:NnnnTF \str_set_convert:NnnnTF ⟨str var ⟩ {⟨string ⟩} {⟨name 1⟩} {⟨name 2⟩} {⟨true code ⟩}
\str_gset_convert:NnnnTF {⟨false code ⟩}
As \str_set_convert:Nnnn, converts the ⟨string ⟩ from the encoding given by ⟨name 1⟩
to the encoding given by ⟨name 2⟩, and assigns the result to ⟨str var ⟩. Contrarily
to \str_set_convert:Nnnn, the conditional variant does not raise errors in case the
⟨string ⟩ is not valid according to the ⟨name 1⟩ encoding, or cannot be expressed in the
⟨name 2⟩ encoding. Instead, the ⟨false code ⟩ is performed.
144
• In XETEX/LuaTEX, would it be better to use the ^^^^.... approach to build
a string from a given list of character codes? Namely, within a group, assign
0-9a-f and all characters we want to category “other”, then assign ^ the category
superscript, and use \scantokens.
• Change \str_set_convert:Nnnn to expand its last two arguments.
• Describe the internal format in the code comments. Refuse code points in
["D800, "DFFF] in the internal representation?
• Add documentation about each encoding and escaping method, and add examples.
• The hex unescaping should raise an error for odd-token count strings.
• Decide what bytes should be escaped in the url escaping. Perhaps the characters
!’()*-./0123456789_ are safe, and all other characters should be escaped?
145
Chapter 19
Two special types of constants in LATEX3 are “quarks” and “scan marks”. By convention
all constants of type quark start out with \q_, and scan marks start with \s_.
19.1 Quarks
Quarks are control sequences (and in fact, token lists) that expand to themselves and
should therefore never be executed directly in the code. This would result in an endless
loop!
They are meant to be used as delimiter in weird functions, the most common use
case being the ‘stop token’ (i.e. \q_stop). For example, when writing a macro to parse
a user-defined date
\date_parse:n {19/June/1981}
one might write a command such as
\cs_new:Npn \date_parse:n #1 { \date_parse_aux:w #1 \q_stop }
\cs_new:Npn \date_parse_aux:w #1 / #2 / #3 \q_stop
{ <do something with the date> }
Quarks are sometimes also used as error return values for functions that receive
erroneous input. For example, in the function \prop_get:NnN to retrieve a value stored
in some key of a property list, if the key does not exist then the return value is the quark
\q_no_value. As mentioned above, such quarks are extremely fragile and it is imperative
when using such functions that code is carefully written to check for pathological cases
to avoid leakage of a quark into an uncontrolled environment.
Quarks also permit the following ingenious trick when parsing tokens: when you
pick up a token in a temporary variable and you want to know whether you have picked
up a particular quark, all you have to do is compare the temporary variable to the quark
using \tl_if_eq:NNTF. A set of special quark testing functions is set up below. All the
quark testing functions are expandable although the ones testing only single tokens are
much faster.
146
19.2 Defining quarks
\q_mark Used as a marker for delimited arguments when \q_stop is already in use.
\q_nil Quark to mark a null value in structured variables or functions. Used as an end delimiter
when this may itself need to be tested (in contrast to \q_stop, which is only ever used
as a delimiter).
\q_no_value A canonical value for a missing value, when one is requested from a data structure. This
is therefore used as a “return” value by functions such as \prop_get:NnN if there is no
data to return.
147
19.4 Recursion
This module provides a uniform interface to intercepting and terminating loops as when
one is doing tail recursion. The building blocks follow below and an example is shown in
Section 19.4.1.
\q_recursion_tail This quark is appended to the data structure in question and appears as a real element
there. This means it gets any list separators around it.
\q_recursion_stop This quark is added after the data structure. Its purpose is to make it possible to
terminate the recursion at any point easily.
Tests if ⟨token ⟩ contains only the marker \q_recursion_tail, and if so uses \use_-
none_delimit_by_q_recursion_stop:w to terminate the recursion that this belongs
to. The recursion input must include the marker tokens \q_recursion_tail and \q_-
recursion_stop as the last two items.
Tests if the ⟨token list ⟩ contains only \q_recursion_tail, and if so uses \use_-
none_delimit_by_q_recursion_stop:w to terminate the recursion that this belongs
to. The recursion input must include the marker tokens \q_recursion_tail and \q_-
recursion_stop as the last two items.
Tests if ⟨token ⟩ contains only the marker \q_recursion_tail, and if so uses \use_-
i_delimit_by_q_recursion_stop:w to terminate the recursion that this belongs to.
The recursion input must include the marker tokens \q_recursion_tail and \q_-
recursion_stop as the last two items. The ⟨insertion ⟩ code is then added to the
input stream after the recursion has ended.
Tests if the ⟨token list ⟩ contains only \q_recursion_tail, and if so uses \use_-
i_delimit_by_q_recursion_stop:w to terminate the recursion that this belongs to.
The recursion input must include the marker tokens \q_recursion_tail and \q_-
recursion_stop as the last two items. The ⟨insertion ⟩ code is then added to the
input stream after the recursion has ended.
148
\quark_if_recursion_tail_break:NN ⋆ \quark_if_recursion_tail_break:nN {⟨token list ⟩}
\quark_if_recursion_tail_break:nN ⋆ \⟨type ⟩_map_break:
New: 2018-04-10
Tests if ⟨token list ⟩ contains only \q_recursion_tail, and if so terminates the recur-
sion using \⟨type ⟩_map_break:. The recursion end should be marked by \prg_break_-
point:Nn \⟨type ⟩_map_break:.
\cs_new:Nn \__my_map_dbl:nn
{
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop:n {#2}
\__my_map_dbl_fn:nn {#1} {#2}
Finally, recurse:
\__my_map_dbl:nn
}
Note that contrarily to LATEX3 built-in mapping functions, this mapping function cannot
be nested, since the second map would overwrite the definition of \__my_map_dbl_fn:nn.
149
19.5 Scan marks
Scan marks are control sequences set equal to \scan_stop:, hence never expand in an
expansion context and are (largely) invisible if they are encountered in a typesetting
context.
Like quarks, they can be used as delimiters in weird functions and are often safer to
use for this purpose. Since they are harmless when executed by TEX in non-expandable
contexts, they can be used to mark the end of a set of instructions. This allows to skip
to that point if the end of the instructions should not be performed (see l3regex).
\s_stop Used at the end of a set of instructions, as a marker that can be jumped to using \use_-
New: 2018-04-01 none_delimit_by_s_stop:w.
Removes the ⟨tokens ⟩ and \s_stop from the input stream. This leads to a low-level
TEX error if \s_stop is absent.
150
Chapter 20
LATEX3 implements a “sequence” data type, which contain an ordered list of entries which
may contain any ⟨balanced text ⟩. It is possible to map functions to sequences such that
the function is applied to every item in the sequence.
Sequences are also used to implement stack functions in LATEX3. This is achieved
using a number of dedicated stack functions.
151
\seq_set_from_clist:NN \seq_set_from_clist:NN ⟨seq var ⟩ ⟨comma-list ⟩
\seq_set_from_clist:(cN|Nc|cc)
\seq_set_from_clist:Nn
\seq_set_from_clist:cn
\seq_gset_from_clist:NN
\seq_gset_from_clist:(cN|Nc|cc)
\seq_gset_from_clist:Nn
\seq_gset_from_clist:cn
New: 2014-07-17
Converts the data in the ⟨comma list ⟩ into a ⟨seq var ⟩: the original ⟨comma list ⟩ is
unchanged.
Splits the ⟨token list ⟩ into ⟨items ⟩ separated by ⟨delimiter ⟩, and assigns the result
to the ⟨seq var ⟩. Spaces on both sides of each ⟨item ⟩ are ignored, then one set of outer
braces is removed (if any); this space trimming behaviour is identical to that of l3clist
functions. Empty ⟨items ⟩ are preserved by \seq_set_split:Nnn, and can be removed
afterwards using \seq_remove_all:Nn ⟨seq var ⟩ {}. The ⟨delimiter ⟩ may not contain
{, } or # (assuming TEX’s normal category code régime). If the ⟨delimiter ⟩ is empty,
the ⟨token list ⟩ is split into ⟨items ⟩ as a ⟨token list ⟩. See also \seq_set_split_-
keep_spaces:Nnn, which omits space stripping.
Splits the ⟨token list ⟩ into ⟨items ⟩ separated by ⟨delimiter ⟩, and assigns the result
to the ⟨seq var ⟩. One set of outer braces is removed (if any) but any surrounding spaces
are retained: any braces inside one or more spaces are therefore kept. Empty ⟨items ⟩
are preserved by \seq_set_split_keep_spaces:Nnn, and can be removed afterwards
using \seq_remove_all:Nn ⟨seq var ⟩ {}. The ⟨delimiter ⟩ may not contain {, } or #
(assuming TEX’s normal category code régime). If the ⟨delimiter ⟩ is empty, the ⟨token
list ⟩ is split into ⟨items ⟩ as a ⟨token list ⟩. See also \seq_set_split:Nnn, which
removes spaces around the delimiters.
152
\seq_concat:NNN \seq_concat:NNN ⟨seq var1 ⟩ ⟨seq var2 ⟩ ⟨seq var3 ⟩
\seq_concat:ccc
Concatenates the content of ⟨seq var2 ⟩ and ⟨seq var3 ⟩ together and saves the result in
\seq_gconcat:NNN
\seq_gconcat:ccc ⟨seq var1 ⟩. The items in ⟨seq var2 ⟩ are placed at the left side of the new sequence.
153
\seq_pop_left:NN \seq_pop_left:NN ⟨seq var ⟩ ⟨token list variable ⟩
\seq_pop_left:cN
Pops the left-most item from a ⟨seq var ⟩ into the ⟨token list variable ⟩, i.e. removes
Updated: 2012-05-14 the item from the sequence and stores it in the ⟨token list variable ⟩. Both of the
variables are assigned locally. If ⟨seq var ⟩ is empty the ⟨token list variable ⟩ is set
to the special marker \q_no_value.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨item ⟩ does not expand further when appearing in an e-type or x-type
argument expansion.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨item ⟩ does not expand further when appearing in an e-type or x-type
argument expansion.
154
20.4 Recovering values from sequences with branch-
ing
The functions in this section combine tests for non-empty sequences with recovery of an
item from the sequence. They offer increased readability and performance over separate
testing and recovery phases.
\seq_get_left:NNTF \seq_get_left:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_get_left:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-14 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If
Updated: 2012-05-19 the ⟨seq var ⟩ is non-empty, stores the left-most item from the ⟨seq var ⟩ in the ⟨token
list variable ⟩ without removing it from the ⟨seq var ⟩, then leaves the ⟨true code ⟩
in the input stream. The ⟨token list variable ⟩ is assigned locally.
\seq_get_right:NNTF \seq_get_right:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_get_right:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of the
New: 2012-05-19 ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If the
⟨seq var ⟩ is non-empty, stores the right-most item from the ⟨seq var ⟩ in the ⟨token
list variable ⟩ without removing it from the ⟨seq var ⟩, then leaves the ⟨true code ⟩
in the input stream. The ⟨token list variable ⟩ is assigned locally.
\seq_pop_left:NNTF \seq_pop_left:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_pop_left:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-14 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If
Updated: 2012-05-19 the ⟨seq var ⟩ is non-empty, pops the left-most item from the ⟨seq var ⟩ in the ⟨token
list variable ⟩, i.e. removes the item from the ⟨seq var ⟩, then leaves the ⟨true code ⟩
in the input stream. Both the ⟨seq var ⟩ and the ⟨token list variable ⟩ are assigned
locally.
\seq_gpop_left:NNTF \seq_gpop_left:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_gpop_left:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of the
New: 2012-05-14 ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If the
Updated: 2012-05-19 ⟨seq var ⟩ is non-empty, pops the left-most item from the ⟨seq var ⟩ in the ⟨token list
variable ⟩, i.e. removes the item from the ⟨seq var ⟩, then leaves the ⟨true code ⟩ in the
input stream. The ⟨seq var ⟩ is modified globally, while the ⟨token list variable ⟩ is
assigned locally.
\seq_pop_right:NNTF \seq_pop_right:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_pop_right:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-19 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If
the ⟨seq var ⟩ is non-empty, pops the right-most item from the ⟨seq var ⟩ in the ⟨token
list variable ⟩, i.e. removes the item from the ⟨seq var ⟩, then leaves the ⟨true code ⟩
in the input stream. Both the ⟨seq var ⟩ and the ⟨token list variable ⟩ are assigned
locally.
155
\seq_gpop_right:NNTF \seq_gpop_right:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_gpop_right:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-19 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon.
If the ⟨seq var ⟩ is non-empty, pops the right-most item from the ⟨seq var ⟩ in the
⟨token list variable ⟩, i.e. removes the item from the ⟨seq var ⟩, then leaves the
⟨true code ⟩ in the input stream. The ⟨seq var ⟩ is modified globally, while the ⟨token
list variable ⟩ is assigned locally.
TEXhackers note: This function iterates through every item in the ⟨seq var ⟩ and does a
comparison with the ⟨items ⟩ already checked. It is therefore relatively slow with large sequences.
Removes every occurrence of ⟨item ⟩ from the ⟨seq var ⟩. The ⟨item ⟩ comparison takes
place on a token basis, as for \tl_if_eq:nnTF.
156
\seq_sort:Nn \seq_sort:Nn ⟨seq var ⟩ {⟨comparison code ⟩}
\seq_sort:cn
Sorts the items in the ⟨seq var ⟩ according to the ⟨comparison code ⟩, and assigns the
\seq_gsort:Nn
\seq_gsort:cn result to ⟨seq var ⟩. The details of sorting comparison are described in Section 6.1.
New: 2017-02-06
157
\seq_map_tokens:Nn ✩ \seq_map_tokens:Nn ⟨seq var ⟩ {⟨code ⟩}
\seq_map_tokens:cn ✩
Analogue of \seq_map_function:NN which maps several tokens instead of a single func-
New: 2019-08-30 tion. The ⟨code ⟩ receives each item in the ⟨seq var ⟩ as a trailing brace group. For
instance,
\seq_map_tokens:Nn \l_my_seq { \prg_replicate:nn { 2 } }
expands to twice each item in the ⟨seq var ⟩: for each item in \l_my_seq the function
\prg_replicate:nn receives 2 and ⟨item ⟩ as its two arguments. The function \seq_-
map_inline:Nn is typically faster but it is not expandable.
Stores each ⟨item ⟩ of the ⟨seq var ⟩ in turn in the (token list) ⟨variable ⟩ and applies
the ⟨code ⟩. The ⟨code ⟩ will usually make use of the ⟨variable ⟩, but this is not enforced.
The assignments to the ⟨variable ⟩ are local. Its value after the loop is the last ⟨item ⟩ in
the ⟨seq var ⟩, or its original value if the ⟨seq var ⟩ is empty. The ⟨items ⟩ are returned
from left to right.
Applies ⟨function ⟩ to every entry in the ⟨sequence variable ⟩. The ⟨function ⟩ should
have signature :nn. It receives two arguments for each iteration: the ⟨index ⟩ (namely 1
for the first entry, then 2 and so on) and the ⟨item ⟩.
Applies ⟨function ⟩ to every pair of items ⟨seq1 -item ⟩–⟨seq2 -item ⟩ from the two se-
quences, returning items from both sequences from left to right. The ⟨function ⟩ receives
two n-type arguments for each iteration. The mapping terminates when the end of ei-
ther sequence is reached (i.e. whichever sequence has fewer items determines how many
iterations occur).
158
\seq_map_break: ✩ \seq_map_break:
Updated: 2012-06-29 Used to terminate a \seq_map_... function before all entries in the ⟨seq var ⟩ have been
processed. This normally takes place within a conditional statement, for example
\seq_map_inline:Nn \l_my_seq
{
\str_if_eq:nnTF { #1 } { bingo }
{ \seq_map_break: }
{
% Do something useful
}
}
Use outside of a \seq_map_... scenario leads to low level TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
further items are taken from the input stream. This depends on the design of the mapping
function.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
the ⟨code ⟩ is inserted into the input stream. This depends on the design of the mapping function.
159
\seq_set_map_e:NNn \seq_set_map_e:NNn ⟨seq var1 ⟩ ⟨seq var2 ⟩ {⟨inline function ⟩}
\seq_gset_map_e:NNn
Applies ⟨inline function ⟩ to every ⟨item ⟩ stored within the ⟨seq var2 ⟩. The ⟨inline
New: 2020-07-16 function ⟩ should consist of code which will receive the ⟨item ⟩ as #1. The sequence
Updated: 2023-10-26 resulting from e-expanding ⟨inline function ⟩ applied to each ⟨item ⟩ is assigned to
⟨seq var1 ⟩. As such, the code in ⟨inline function ⟩ should be expandable.
inserts “a, b, c, de, and f” in the input stream. The first separator argument is not
used in this case because the sequence has more than 2 items.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨items ⟩ do not expand further when appearing in an e-type or x-type
argument expansion.
160
\seq_use:Nn ⋆ \seq_use:Nn ⟨seq var ⟩ {⟨separator ⟩}
\seq_use:cn ⋆
Places the contents of the ⟨seq var ⟩ in the input stream, with the ⟨separator ⟩ between
New: 2013-05-26 the items. If the sequence has a single item, it is placed in the input stream with no
⟨separator ⟩, and an empty sequence produces no output. An error is raised if the
variable does not exist or if it is invalid.
For example,
\seq_set_split:Nnn \l_tmpa_seq { | } { a | b | c | {de} | f }
\seq_use:Nn \l_tmpa_seq { ~and~ }
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨items ⟩ do not expand further when appearing in an e-type or x-type
argument expansion.
\seq_get:NNTF \seq_get:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_get:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-14 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If
Updated: 2012-05-19 the ⟨seq var ⟩ is non-empty, stores the top item from a ⟨seq var ⟩ in the ⟨token list
variable ⟩ without removing it from the ⟨seq var ⟩. The ⟨token list variable ⟩ is
assigned locally.
161
\seq_pop:NNTF \seq_pop:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_pop:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-14 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon.
Updated: 2012-05-19 If the ⟨seq var ⟩ is non-empty, pops the top item from the ⟨seq var ⟩ in the ⟨token
list variable ⟩, i.e. removes the item from the ⟨seq var ⟩. Both the ⟨seq var ⟩ and
the ⟨token list variable ⟩ are assigned locally.
\seq_gpop:NNTF \seq_gpop:NNTF ⟨seq var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\seq_gpop:cN
If the ⟨seq var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-14 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon.
Updated: 2012-05-19 If the ⟨seq var ⟩ is non-empty, pops the top item from the ⟨seq var ⟩ in the ⟨token
list variable ⟩, i.e. removes the item from the ⟨seq var ⟩. The ⟨seq var ⟩ is modified
globally, while the ⟨token list variable ⟩ is assigned locally.
The intersection of two sets ⟨seq var1 ⟩ and ⟨seq var2 ⟩ can be stored into
⟨seq var3 ⟩ by collecting items of ⟨seq var1 ⟩ which are in ⟨seq var2 ⟩.
162
\seq_clear:N ⟨seq var3 ⟩
\seq_map_inline:Nn ⟨seq var1 ⟩
{
\seq_if_in:NnT ⟨seq var2 ⟩ {#1}
{ \seq_put_right:Nn ⟨seq var3 ⟩ {#1} }
}
The code as written here only works if ⟨seq var3 ⟩ is different from the other two se-
quence variables. To cover all cases, items should first be collected in a sequence
\l__⟨pkg ⟩_internal_seq, then ⟨seq var3 ⟩ should be set equal to this internal sequence.
The same remark applies to other set functions.
The union of two sets ⟨seq var1 ⟩ and ⟨seq var2 ⟩ can be stored into ⟨seq var3 ⟩
through
\seq_concat:NNN ⟨seq var3 ⟩ ⟨seq var1 ⟩ ⟨seq var2 ⟩
\seq_remove_duplicates:N ⟨seq var3 ⟩
or by adding items to (a copy of) ⟨seq var1 ⟩ one by one
\seq_set_eq:NN ⟨seq var3 ⟩ ⟨seq var1 ⟩
\seq_map_inline:Nn ⟨seq var2 ⟩
{
\seq_if_in:NnF ⟨seq var3 ⟩ {#1}
{ \seq_put_right:Nn ⟨seq var3 ⟩ {#1} }
}
The second approach is faster than the first when the ⟨seq var2 ⟩ is short compared to
⟨seq var1 ⟩.
The difference of two sets ⟨seq var1 ⟩ and ⟨seq var2 ⟩ can be stored into ⟨seq var3 ⟩
by removing items of the ⟨seq var2 ⟩ from (a copy of) the ⟨seq var1 ⟩ one by one.
\seq_set_eq:NN ⟨seq var3 ⟩ ⟨seq var1 ⟩
\seq_map_inline:Nn ⟨seq var2 ⟩
{ \seq_remove_all:Nn ⟨seq var3 ⟩ {#1} }
The symmetric difference of two sets ⟨seq var1 ⟩ and ⟨seq var2 ⟩ can be stored into
⟨seq var3 ⟩ by computing the difference between ⟨seq var1 ⟩ and ⟨seq var2 ⟩ and stor-
ing the result as \l__⟨pkg ⟩_internal_seq, then the difference between ⟨seq var2 ⟩ and
⟨seq var1 ⟩, and finally concatenating the two differences to get the symmetric differ-
ences.
\seq_set_eq:NN \l__⟨pkg ⟩_internal_seq ⟨seq var1 ⟩
\seq_map_inline:Nn ⟨seq var2 ⟩
{ \seq_remove_all:Nn \l__⟨pkg ⟩_internal_seq {#1} }
\seq_set_eq:NN ⟨seq var3 ⟩ ⟨seq var2 ⟩
\seq_map_inline:Nn ⟨seq var1 ⟩
{ \seq_remove_all:Nn ⟨seq var3 ⟩ {#1} }
\seq_concat:NNN ⟨seq var3 ⟩ ⟨seq var3 ⟩ \l__⟨pkg ⟩_internal_seq
163
\l_tmpa_seq Scratch sequences for local assignment. These are never used by the kernel code, and so
\l_tmpb_seq are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
New: 2012-04-26 other non-kernel code and so should only be used for short-term storage.
\g_tmpa_seq Scratch sequences for global assignment. These are never used by the kernel code, and
\g_tmpb_seq so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
New: 2012-04-26 by other non-kernel code and so should only be used for short-term storage.
164
Chapter 21
Calculation and comparison of integer values can be carried out using literal numbers, int
registers, constants and integers stored in token list variables. The standard operators +,
-, / and * and parentheses can be used within such expressions to carry arithmetic oper-
ations. This module carries out these functions on integer expressions (“⟨int expr ⟩”).
• / denotes division rounded to the closest integer with ties rounded away from zero;
• there is an error and the overall expression evaluates to zero whenever the absolute
value of any intermediate result exceeds 231 − 1, except in the case of scaling oper-
ations a*b/c, for which a*b may be arbitrarily large (but the operands a, b, c are
still constrained to an absolute value at most 231 − 1);
\int_show:n { 5 + 4 * 3 - ( 3 + 4 * 5 ) }
and
\tl_new:N \l_my_tl
\tl_set:Nn \l_my_tl { 5 }
\int_new:N \l_my_int
\int_set:Nn \l_my_int { 4 }
\int_show:n { \l_my_tl + \l_my_int * 3 - ( 3 + 4 * 5 ) }
165
show the same result −6 because \l_my_tl expands to the integer denotation 5 while
the integer variable \l_my_int takes the value 4. As the ⟨integer expression ⟩ is fully
expanded from left to right during evaluation, fully expandable and restricted-expandable
functions can both be used, and \exp_not:n and its variants have no effect while \exp_-
not:N may incorrectly interrupt the expression.
TEXhackers note: Exactly two expansions are needed to evaluate \int_eval:n. The
result is not an ⟨internal integer ⟩, and therefore should be terminated by a space if used in
\int_value:w or in a TEX-style integer assignment.
As all TEX integers, integer operands can also be: \value{⟨LATEX 2ε counter ⟩}; dimension
or skip variables, converted to integers in sp; the character code of some character given as
‘⟨char ⟩ or ‘\⟨char ⟩; octal numbers given as ’ followed by digits from 0 to 7; or hexadecimal
numbers given as " followed by digits and upper case letters from A to F.
166
\int_eval:n ⋆ \int_eval:n {⟨int expr ⟩}
Evaluates the ⟨int expr ⟩ and leaves the result in the input stream as an integer deno-
tation: for positive results an explicit sequence of decimal digits not starting with 0, for
negative results - followed by such a sequence, and 0 for zero. The ⟨int expr ⟩ should
consist, after expansion, of +, -, *, /, (, ) and of course integer operands. The result is
calculated by applying standard mathematical rules with the following peculiarities:
• / denotes division rounded to the closest integer with ties rounded away from zero;
• there is an error and the overall expression evaluates to zero whenever the ab-
solute value of any intermediate result exceeds 231 − 1, except in the case of scaling
operations a*b/c, for which a*b may be arbitrarily large;
• parentheses may not appear after unary + or -, namely placing +( or -( at the
start of an expression or after +, -, *, / or ( leads to an error.
Each integer operand can be either an integer variable (with no need for \int_use:N) or
an integer denotation. For example both
\int_eval:n { 5 + 4 * 3 - ( 3 + 4 * 5 ) }
and
\tl_new:N \l_my_tl
\tl_set:Nn \l_my_tl { 5 }
\int_new:N \l_my_int
\int_set:Nn \l_my_int { 4 }
\int_eval:n { \l_my_tl + \l_my_int * 3 - ( 3 + 4 * 5 ) }
evaluate to −6 because \l_my_tl expands to the integer denotation 5. As the ⟨int expr ⟩
is fully expanded from left to right during evaluation, fully expandable and restricted-
expandable functions can both be used, and \exp_not:n and its variants have no effect
while \exp_not:N may incorrectly interrupt the expression.
TEXhackers note: Exactly two expansions are needed to evaluate \int_eval:n. The
result is not an ⟨internal integer ⟩, and therefore requires suitable termination if used in a
TEX-style integer assignment.
As all TEX integers, integer operands can also be dimension or skip variables, converted to
integers in sp, or octal numbers given as ’ followed by digits other than 8 and 9, or hexadecimal
numbers given as " followed by digits or upper case letters from A to F, or the character code of
some character or one-character control sequence, given as ‘⟨char ⟩.
167
\int_sign:n ⋆ \int_sign:n {⟨int expr ⟩}
New: 2018-11-03 Evaluates the ⟨int expr ⟩ then leaves 1 or 0 or −1 in the input stream according to the
sign of the result.
168
\int_zero:N \int_zero:N ⟨integer ⟩
\int_zero:c
Sets ⟨integer ⟩ to 0.
\int_gzero:N
\int_gzero:c
New: 2011-12-13
Updated: 2011-10-22
169
\int_sub:Nn \int_sub:Nn ⟨integer ⟩ {⟨int expr ⟩}
\int_sub:cn
Subtracts the result of the ⟨int expr ⟩ from the current content of the ⟨integer ⟩.
\int_gsub:Nn
\int_gsub:cn
Updated: 2011-10-22
TEXhackers note: \int_use:N is the TEX primitive \the: this is one of several LATEX3
names for this primitive.
170
\int_compare_p:n ⋆ \int_compare_p:n
\int_compare:nTF ⋆ {
⟨int expr1 ⟩ ⟨relation1 ⟩
Updated: 2013-01-13
...
⟨int exprN ⟩ ⟨relationN ⟩
⟨int exprN +1 ⟩
}
\int_compare:nTF
{
⟨int expr1 ⟩ ⟨relation1 ⟩
...
⟨int exprN ⟩ ⟨relationN ⟩
⟨int exprN +1 ⟩
}
{⟨true code ⟩} {⟨false code ⟩}
This function evaluates the ⟨int expr ⟩s as described for \int_eval:n and compares
consecutive result using the corresponding ⟨relation ⟩, namely it compares ⟨int expr1 ⟩
and ⟨int expr2 ⟩ using the ⟨relation1 ⟩, then ⟨int expr2 ⟩ and ⟨int expr3 ⟩ using
the ⟨relation2 ⟩, until finally comparing ⟨int exprN ⟩ and ⟨int exprN +1 ⟩ using the
⟨relationN ⟩. The test yields true if all comparisons are true. Each ⟨int expr ⟩ is
evaluated only once, and the evaluation is lazy, in the sense that if one comparison is
false, then no other ⟨integer expression ⟩ is evaluated and no other comparison is
performed. The ⟨relations ⟩ can be any of the following:
Equal = or ==
Greater than or equal to >=
Greater than >
Less than or equal to <=
Less than <
Not equal !=
This function is more flexible than \int_compare:nNnTF but around 5 times slower.
171
\int_case:nn ⋆ \int_case:nnTF {⟨test int expr ⟩}
\int_case:nnTF ⋆ {
{⟨int expr case1 ⟩} {⟨code case1 ⟩}
New: 2013-07-24
{⟨int expr case2 ⟩} {⟨code case2 ⟩}
...
{⟨int expr casen ⟩} {⟨code casen ⟩}
}
{⟨true code ⟩}
{⟨false code ⟩}
This function evaluates the ⟨test int expr ⟩ and compares this in turn to each of the
⟨int expr cases ⟩. If the two are equal then the associated ⟨code ⟩ is left in the input
stream and other cases are discarded. If any of the cases are matched, the ⟨true code ⟩
is also inserted into the input stream (after the code for the appropriate case), while if
none match then the ⟨false code ⟩ is inserted. The function \int_case:nn, which does
nothing if there is no match, is also available. For example
\int_case:nnF
{ 2 * 5 }
{
{ 5 } { Small }
{ 4 + 6 } { Medium }
{ -2 * 10 } { Negative }
}
{ No idea! }
leaves “Medium” in the input stream.
172
\int_do_while:nNnn ✩ \int_do_while:nNnn {⟨int expr1 ⟩} ⟨relation ⟩ {⟨int expr2 ⟩} {⟨code ⟩}
Places the ⟨code ⟩ in the input stream for TEX to process, and then evaluates the rela-
tionship between the two ⟨int expr ⟩s as described for \int_compare:nNnTF. If the test
is true then the ⟨code ⟩ is inserted into the input stream again and a loop occurs until
the ⟨relation ⟩ is false.
173
21.7 Integer step functions
174
21.8 Formatting integers
Integers can be placed into the output stream with formatting. These conversions apply
to any integer expressions.
\int_to_symbols:nnn ⋆ \int_to_symbols:nnn
{⟨int expr ⟩} {⟨total symbols ⟩}
Updated: 2011-09-17
{⟨value to symbol mapping ⟩}
This is the low-level function for conversion of an ⟨int expr ⟩ into a symbolic form (often
letters). The ⟨total symbols ⟩ available should be given as an integer expression. Values
are actually converted to symbols according to the ⟨value to symbol mapping ⟩. This
should be given as ⟨total symbols ⟩ pairs of entries, a number and the appropriate
symbol. Thus the \int_to_alph:n function is defined as
\cs_new:Npn \int_to_alph:n #1
{
\int_to_symbols:nnn {#1} { 26 }
{
{ 1 } { a }
{ 2 } { b }
...
{ 26 } { z }
}
}
175
\int_to_bin:n ⋆ \int_to_bin:n {⟨int expr ⟩}
New: 2014-02-11 Calculates the value of the ⟨int expr ⟩ and places the binary representation of the result
in the input stream.
176
\int_from_hex:n ⋆ \int_from_hex:n {⟨hexadecimal number ⟩}
New: 2014-02-11 Converts the ⟨hexadecimal number ⟩ into the integer (base 10) representation and leaves
Updated: 2014-08-25 this in the input stream. Digits greater than 9 may be represented in the ⟨hexadecimal
number ⟩ by upper or lower case letters. The ⟨hexadecimal number ⟩ is first converted to
a string, with no expansion. The function also accepts a leading sign, made of + and -.
This is the inverse function of \int_to_hex:n and \int_to_Hex:n.
177
\int_show:n \int_show:n {⟨int expr ⟩}
New: 2011-11-22 Displays the result of evaluating the ⟨int expr ⟩ on the terminal.
Updated: 2015-08-07
\c_zero_int Integer values used with primitive tests and assignments: their self-terminating nature
\c_one_int makes these more convenient and faster than literal numbers.
New: 2018-05-07
\l_tmpa_int Scratch integer for local assignment. These are never used by the kernel code, and so
\l_tmpb_int are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
\g_tmpa_int Scratch integer for global assignment. These are never used by the kernel code, and so
\g_tmpb_int are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
178
21.14 Direct number expansion
In this last case expansion stops once a non-digit is found; if that is a space it is removed
as in f-expansion, and so \exp_stop_f: may be employed as an end marker. Note that
protected functions are expanded by this process.
This function requires exactly one expansion to produce a value, and so is suitable
for use in cases where a number is required “directly”. In general, \int_eval:n is the
preferred approach to generating numbers.
TEXhackers note: These are the TEX primitives \ifcase and \or.
179
\if_int_odd:w ⋆ \if_int_odd:w ⟨tokens ⟩ ⟨optional space ⟩
⟨true code ⟩
\else:
⟨true code ⟩
\fi:
Expands ⟨tokens ⟩ until a non-numeric token or a space is found, and tests whether
the resulting ⟨integer ⟩ is odd. If so, ⟨true code ⟩ is executed. The \else: branch is
optional.
180
Chapter 22
Flags are the only data-type that can be modified in expansion-only contexts. This
module is meant mostly for kernel use: in almost all cases, booleans or integers should
be preferred to flags because they are very significantly faster.
A flag can hold any non-negative value, which we call its ⟨height ⟩. In expansion-only
contexts, a flag can only be “raised”: this increases the ⟨height ⟩ by 1. The ⟨height ⟩
can also be queried expandably. However, decreasing it, or setting it to zero requires
non-expandable assignments.
Flag variables are always local. They are referenced by a ⟨flag name ⟩ such as str_-
missing. The ⟨flag name ⟩ is used as part of \use:c constructions hence is expanded
at point of use. It must expand to character tokens only, with no spaces.
A typical use case of flags would be to keep track of whether an exceptional condition
has occurred during expandable processing, and produce a meaningful (non-expandable)
message after the end of the expandable processing. This is exemplified by l3str-convert,
which for performance reasons performs conversions of individual characters expandably
and for readability reasons produces a single error message describing incorrect inputs
that were encountered.
Flags should not be used without carefully considering the fact that raising a flag
takes a time and memory proportional to its height. Flags should not be used unless
unavoidable.
181
\flag_clear_new:n \flag_clear_new:n {⟨flag name ⟩}
Ensures that the ⟨flag ⟩ exists globally by applying \flag_new:n if necessary, then ap-
plies \flag_clear:n, setting the height to zero locally.
182
Chapter 23
Comma lists (in short, clist) contain ordered data where items can be added to the
left or right end of the list. This data type allows basic list manipulations such as
adding/removing items, applying a function to every item, removing duplicate items,
extracting a given item, using the comma list with specified separators, and so on. Se-
quences (defined in l3seq) are safer, faster, and provide more features, so they should
often be preferred to comma lists. Comma lists are mostly useful when interfacing with
LATEX 2ε or other code that expects or provides items separated by commas.
Several items can be added at once. To ease input of comma lists from data provided
by a user outside an \ExplSyntaxOn . . . \ExplSyntaxOff block, spaces are removed
from both sides of each comma-delimited argument upon input. Blank arguments are
ignored, to allow for trailing commas or repeated commas (which may otherwise arise
when concatenating comma lists “by hand”). In addition, a set of braces is removed if
the result of space-trimming is braced: this allows the storage of any item in a comma
list. For instance,
\clist_new:N \l_my_clist
\clist_put_left:Nn \l_my_clist { ~a~ , ~{b}~ , c~\d }
\clist_put_right:Nn \l_my_clist { ~{e~} , , {{f}} , }
results in \l_my_clist containing a,b,c~\d,{e~},{{f}} namely the five items a, b,
c~\d, e~ and {f}. Comma lists normally do not contain empty or blank items so the
following gives an empty comma list:
\clist_clear_new:N \l_my_clist
\clist_set:Nn \l_my_clist { , ~ , , }
\clist_if_empty:NTF \l_my_clist { true } { false }
and it leaves true in the input stream. To include an “unsafe” item (empty, or one that
contains a comma, or starts or ends with a space, or is a single brace group), surround
it with braces.
Any n-type token list is a valid comma list input for l3clist functions, which will
split the token list at every comma and process the items as described above. On the
other hand, N-type functions expect comma list variables, which are particular token
list variables in which this processing of items (and removal of blank items) has already
183
occurred. Because comma list variables are token list variables, expanding them once
yields their items separated by commas, and l3tl functions such as \tl_show:N can be
applied to them. (These functions often have l3clist analogues, which should be preferred.)
Almost all operations on comma lists are noticeably slower than those on sequences
so converting the data to sequences using \seq_set_from_clist:Nn (see l3seq) may be
advisable if speed is important. The exception is that \clist_if_in:NnTF and \clist_-
remove_duplicates:N may be faster than their sequence analogues for large lists. How-
ever, these functions work slowly for “unsafe” items that must be braced, and may pro-
duce errors when their argument contains {, } or # (assuming the usual TEX category
codes apply). The sequence data type should thus certainly be preferred to comma lists
to store such items.
Converts the data in the ⟨sequence ⟩ into a ⟨clist var ⟩: the original ⟨sequence ⟩ is
unchanged. Items which contain either spaces or commas are surrounded by braces.
184
\clist_concat:NNN \clist_concat:NNN ⟨comma list1 ⟩ ⟨comma list2 ⟩ ⟨comma list3 ⟩
\clist_concat:ccc
Concatenates the content of ⟨comma list2 ⟩ and ⟨comma list3 ⟩ together and saves the
\clist_gconcat:NNN
\clist_gconcat:ccc result in ⟨comma list1 ⟩. The items in ⟨comma list2 ⟩ are placed at the left side of the
new comma list.
Sets ⟨clist var ⟩ to contain the ⟨items ⟩, removing any previous content from the vari-
able. Blank items are omitted, spaces are removed from both sides of each item, then
a set of braces is removed if the resulting space-trimmed item is braced. To store some
⟨tokens ⟩ as a single ⟨item ⟩ even if the ⟨tokens ⟩ contain commas or spaces, add a set of
braces: \clist_set:Nn ⟨clist var ⟩ { {⟨tokens ⟩} }.
Appends the ⟨items ⟩ to the left of the ⟨clist var ⟩. Blank items are omitted, spaces are
removed from both sides of each item, then a set of braces is removed if the resulting space-
trimmed item is braced. To append some ⟨tokens ⟩ as a single ⟨item ⟩ even if the ⟨tokens ⟩
contain commas or spaces, add a set of braces: \clist_put_left:Nn ⟨clist var ⟩ {
{⟨tokens ⟩} }.
Appends the ⟨items ⟩ to the right of the ⟨clist var ⟩. Blank items are omitted, spaces
are removed from both sides of each item, then a set of braces is removed if the resulting
space-trimmed item is braced. To append some ⟨tokens ⟩ as a single ⟨item ⟩ even if
the ⟨tokens ⟩ contain commas or spaces, add a set of braces: \clist_put_right:Nn
⟨clist var ⟩ { {⟨tokens ⟩} }.
185
23.3 Modifying comma lists
While comma lists are normally used as ordered lists, it may be necessary to modify the
content. The functions here may be used to update comma lists, while retaining the
order of the unaffected entries.
Removes duplicate items from the ⟨clist var ⟩, leaving the left most copy of each item
in the ⟨clist var ⟩. The ⟨item ⟩ comparison takes place on a token basis, as for \tl_-
if_eq:nnTF.
TEXhackers note: This function iterates through every item in the ⟨clist var ⟩ and
does a comparison with the ⟨items ⟩ already checked. It is therefore relatively slow with large
comma lists. Furthermore, it may fail if any of the items in the ⟨clist var ⟩ contains {, }, or #
(assuming the usual TEX category codes apply).
Removes every occurrence of ⟨item ⟩ from the ⟨clist var ⟩. The ⟨item ⟩ comparison
takes place on a token basis, as for \tl_if_eq:nnTF.
TEXhackers note: The function may fail if the ⟨item ⟩ contains {, }, or # (assuming the
usual TEX category codes apply).
TEXhackers note: The result is returned within \unexpanded, which means that the
comma list does not expand further when appearing in an e-type or x-type argument expansion.
186
\clist_sort:Nn \clist_sort:Nn ⟨clist var ⟩ {⟨comparison code ⟩}
\clist_sort:cn
Sorts the items in the ⟨clist var ⟩ according to the ⟨comparison code ⟩, and assigns the
\clist_gsort:Nn
\clist_gsort:cn result to ⟨clist var ⟩. The details of sorting comparison are described in Section 6.1.
New: 2017-02-06
Tests if the ⟨item ⟩ is present in the ⟨clist var ⟩. In the case of an n-type ⟨comma list ⟩,
the usual rules of space trimming and brace stripping apply. Hence,
TEXhackers note: The function may fail if the ⟨item ⟩ contains {, }, or # (assuming the
usual TEX category codes apply).
187
When the comma list is given as an N-type argument, spaces have already been
trimmed on input, and items are simply stripped of one set of braces if any. This case is
more efficient than using n-type comma lists.
\clist_map_break: ✩ \clist_map_break:
Updated: 2012-06-29 Used to terminate a \clist_map_... function before all entries in the ⟨comma list ⟩ have
been processed. This normally takes place within a conditional statement, for example
\clist_map_inline:Nn \l_my_clist
{
\str_if_eq:nnTF { #1 } { bingo }
{ \clist_map_break: }
{
% Do something useful
}
}
Use outside of a \clist_map_... scenario leads to low level TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
further items are taken from the input stream. This depends on the design of the mapping
function.
188
\clist_map_break:n ✩ \clist_map_break:n {⟨code ⟩}
Updated: 2012-06-29 Used to terminate a \clist_map_... function before all entries in the ⟨comma list ⟩
have been processed, inserting the ⟨code ⟩ after the mapping has ended. This normally
takes place within a conditional statement, for example
\clist_map_inline:Nn \l_my_clist
{
\str_if_eq:nnTF { #1 } { bingo }
{ \clist_map_break:n { <code> } }
{
% Do something useful
}
}
Use outside of a \clist_map_... scenario leads to low level TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
the ⟨code ⟩ is inserted into the input stream. This depends on the design of the mapping function.
189
23.6 Using the content of comma lists directly
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨items ⟩ do not expand further when appearing in an e-type or x-type
argument expansion.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨items ⟩ do not expand further when appearing in an e-type or x-type
argument expansion.
190
\clist_use:nnnn ⋆ \clist_use:nnnn ⟨comma list ⟩ {⟨separator between two ⟩}
\clist_use:nn ⋆ {⟨separator between more than two ⟩} {⟨separator between final two ⟩}
\clist_use:nn ⟨comma list ⟩ {⟨separator ⟩}
New: 2021-05-10
Places the contents of the ⟨comma list ⟩ in the input stream, with the appropriate
⟨separator ⟩ between the items. As for \clist_set:Nn, blank items are omitted, spaces
are removed from both sides of each item, then a set of braces is removed if the resulting
space-trimmed item is braced. The ⟨separators ⟩ are then inserted in the same way as
for \clist_use:Nnnn and \clist_use:Nn, respectively.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨items ⟩ do not expand further when appearing in an e-type or x-type
argument expansion.
\clist_pop:NNTF \clist_pop:NNTF ⟨clist var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\clist_pop:cN
If the ⟨clist var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-14 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If
the ⟨clist var ⟩ is non-empty, pops the top item from the ⟨clist var ⟩ in the ⟨token
list variable ⟩, i.e. removes the item from the ⟨clist var ⟩. Both the ⟨clist var ⟩
and the ⟨token list variable ⟩ are assigned locally.
191
\clist_gpop:NNTF \clist_gpop:NNTF ⟨clist var ⟩ ⟨token list variable ⟩ {⟨true code ⟩} {⟨false code ⟩}
\clist_gpop:cN
If the ⟨clist var ⟩ is empty, leaves the ⟨false code ⟩ in the input stream. The value of
New: 2012-05-14 the ⟨token list variable ⟩ is not defined in this case and should not be relied upon. If
the ⟨clist var ⟩ is non-empty, pops the top item from the ⟨clist var ⟩ in the ⟨token
list variable ⟩, i.e. removes the item from the ⟨clist var ⟩. The ⟨clist var ⟩ is
modified globally, while the ⟨token list variable ⟩ is assigned locally.
Adds the {⟨items ⟩} to the top of the ⟨clist var ⟩. Spaces are removed from both sides
of each item as for any n-type comma list.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨item ⟩ does not expand further when appearing in an e-type or x-type
argument expansion.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the ⟨item ⟩ does not expand further when appearing in an e-type or x-type
argument expansion.
192
\clist_show:n \clist_show:n {⟨tokens ⟩}
Updated: 2013-08-03 Displays the entries in the comma list in the terminal.
\l_tmpa_clist Scratch comma lists for local assignment. These are never used by the kernel code, and
\l_tmpb_clist so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
New: 2011-09-06 by other non-kernel code and so should only be used for short-term storage.
\g_tmpa_clist Scratch comma lists for global assignment. These are never used by the kernel code, and
\g_tmpb_clist so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
New: 2011-09-06 by other non-kernel code and so should only be used for short-term storage.
193
Chapter 24
This module deals with tokens. Now this is perhaps not the most precise description so
let’s try with a better description: When programming in TEX, it is often desirable to
know just what a certain token is: is it a control sequence or something else. Similarly
one often needs to know if a control sequence is expandable or not, a macro or a primitive,
how many arguments it takes etc. Another thing of great importance (especially when it
comes to document commands) is looking ahead in the token stream to see if a certain
character is present and maybe even remove it or disregard other tokens while scanning.
This module provides functions for both and as such has two primary function categories:
\token_ for anything that deals with tokens and \peek_ for looking ahead in the token
stream.
Most functions we describe here can be used on control sequences, as those are tokens
as well.
It is important to distinguish two aspects of a token: its “shape” (for lack of a better
word), which affects the matching of delimited arguments and the comparison of token
lists containing this token, and its “meaning”, which affects whether the token expands
or what operation it performs. One can have tokens of different shapes with the same
meaning, but not the converse.
For instance, \if:w, \if_charcode:w, and \tex_if:D are three names for the same
internal operation of TEX, namely the primitive testing the next two characters for equal-
ity of their character code. They have the same meaning hence behave identically in many
situations. However, TEX distinguishes them when searching for a delimited argument.
Namely, the example function \show_until_if:w defined below takes everything until
\if:w as an argument, despite the presence of other copies of \if:w under different
names.
\cs_new:Npn \show_until_if:w #1 \if:w { \tl_show:n {#1} }
\show_until_if:w \tex_if:D \if_charcode:w \if:w
A list of all possible shapes and a list of all possible meanings are given in section 24.7.
194
24.1 Creating character tokens
• 4 (alignment)
• 6 (parameter)
• 7 (math superscript)
• 8 (math subscript)
• 10 (space)
• 11 (letter)
• 12 (other)
• 13 (active)
and other values raise an error. The ⟨charcode ⟩ may be any one valid for the engine in
use, except that for ⟨catcode ⟩ 10, ⟨charcode ⟩ 0 is not allowed. Active characters cannot
be generated in older versions of XETEX. Another way to build token lists with unusual
category codes is \regex_replace:nnN {.*} {⟨replacement ⟩} ⟨tl var ⟩.
TEXhackers note: Exactly two expansions are needed to produce the character.
\c_catcode_active_space_tl Token list containing one character with category code 13, (“active”), and character code
New: 2017-08-07 32 (space).
195
\c_catcode_other_space_tl Token list containing one character with category code 12, (“other”), and character code
New: 2011-09-05 32 (space).
Sets the category code of the ⟨character ⟩ to that indicated in the function name. De-
pending on the current category code of the ⟨token ⟩ the escape token may also be needed:
\char_set_catcode_other:N \%
The assignment is local.
196
\char_set_catcode_escape:n \char_set_catcode_letter:n {⟨integer expression ⟩}
\char_set_catcode_group_begin:n
\char_set_catcode_group_end:n
\char_set_catcode_math_toggle:n
\char_set_catcode_alignment:n
\char_set_catcode_end_line:n
\char_set_catcode_parameter:n
\char_set_catcode_math_superscript:n
\char_set_catcode_math_subscript:n
\char_set_catcode_ignore:n
\char_set_catcode_space:n
\char_set_catcode_letter:n
\char_set_catcode_other:n
\char_set_catcode_active:n
\char_set_catcode_comment:n
\char_set_catcode_invalid:n
Updated: 2015-11-11
Sets the category code of the ⟨character ⟩ which has character code as given by the
⟨integer expression ⟩. This version can be used to set up characters which cannot
otherwise be given (cf. the N-type variants). The assignment is local.
197
\char_value_lccode:n ⋆ \char_value_lccode:n {⟨integer expression ⟩}
Expands to the current lower case code of the ⟨character ⟩ with character code given by
the ⟨integer expression ⟩.
Displays the current math code of the ⟨character ⟩ with character code given by the
⟨integer expression ⟩ on the terminal.
198
\char_value_sfcode:n ⋆ \char_value_sfcode:n {⟨integer expression ⟩}
Expands to the current space factor for the ⟨character ⟩ with character code given by
the ⟨integer expression ⟩.
\l_char_active_seq Used to track which tokens may require special handling at the document level as they
New: 2012-01-23 are (or have been at some point) of category ⟨active ⟩ (catcode 13). Each entry in the
Updated: 2015-11-11 sequence consists of a single escaped token, for example \~. Active tokens should be
added to the sequence when they are defined for general document use.
\l_char_special_seq Used to track which tokens will require special handling when working with verbatim-like
New: 2012-01-23 material at the document level as they are not of categories ⟨letter ⟩ (catcode 11) or
Updated: 2015-11-11 ⟨other ⟩ (catcode 12). Each entry in the sequence consists of a single escaped token,
for example \\ for the backslash or \{ for an opening brace. Escaped tokens should be
added to the sequence when they are defined for general document use.
\c_group_begin_token These are implicit tokens which have the category code described by their name. They
\c_group_end_token are used internally for test purposes but are also available to the programmer for other
\c_math_toggle_token uses.
\c_alignment_token
\c_parameter_token
\c_math_superscript_token
\c_math_subscript_token
\c_space_token
\c_catcode_letter_token These are implicit tokens which have the category code described by their name. They
\c_catcode_other_token are used internally for test purposes and should not be used other than for category code
tests.
\c_catcode_active_tl A token list containing an active token. This is used internally for test purposes and
should not be used other than in appropriately-constructed category code tests.
199
24.4 Converting tokens
TEXhackers note: This is the TEX primitive \meaning. The ⟨token ⟩ can thus be an
explicit space token or an explicit begin-group or end-group character token ({ or } when normal
TEX category codes apply) even though these are not valid N-type arguments.
TEXhackers note: \token_to_str:N is the TEX primitive \string. The ⟨token ⟩ can thus
be an explicit space tokens or an explicit begin-group or end-group character token ({ or } when
normal TEX category codes apply) even though these are not valid N-type arguments.
Tests if ⟨token ⟩ has the category code of a begin group token ({ when normal TEX
category codes are in force). Note that an explicit begin group token cannot be tested in
this way, as it is not a valid N-type argument.
200
\token_if_math_toggle_p:N ⋆ \token_if_math_toggle_p:N ⟨token ⟩
\token_if_math_toggle:NTF ⋆ \token_if_math_toggle:NTF ⟨token ⟩ {⟨true code ⟩} {⟨false code ⟩}
Tests if ⟨token ⟩ has the category code of a math shift token ($ when normal TEX category
codes are in force).
Tests if ⟨token ⟩ has the category code of a superscript token (^ when normal TEX
category codes are in force).
Tests if ⟨token ⟩ has the category code of a subscript token (_ when normal TEX category
codes are in force).
201
\token_if_eq_charcode_p:NN ⋆ \token_if_eq_charcode_p:NN ⟨token1 ⟩ ⟨token2 ⟩
\token_if_eq_charcode:NNTF ⋆ \token_if_eq_charcode:NNTF ⟨token1 ⟩ ⟨token2 ⟩ {⟨true code ⟩} {⟨false code ⟩}
Tests if the two ⟨tokens ⟩ have the same meaning when expanded.
Tests if the ⟨token ⟩ is a protected macro: for a macro which is both protected and long
this returns false.
TEXhackers note: Booleans, boxes and small integer constants are implemented as
\chardefs.
202
\token_if_mathchardef_p:N ⋆ \token_if_mathchardef_p:N ⟨token ⟩
\token_if_mathchardef:NTF ⋆ \token_if_mathchardef:NTF ⟨token ⟩ {⟨true code ⟩} {⟨false code ⟩}
Updated: 2012-01-20
203
\token_case_catcode:Nn ⋆ \token_case_meaning:NnTF ⟨test token ⟩
\token_case_catcode:NnTF ⋆ {
\token_case_charcode:Nn ⋆ ⟨token case1 ⟩ {⟨code case1 ⟩}
\token_case_charcode:NnTF ⋆ ⟨token case2 ⟩ {⟨code case2 ⟩}
\token_case_meaning:Nn ⋆ ...
\token_case_meaning:NnTF ⋆ ⟨token casen ⟩ {⟨code casen ⟩}
}
New: 2020-12-03
{⟨true code ⟩}
{⟨false code ⟩}
This function compares the ⟨test token ⟩ in turn with each of the ⟨token cases ⟩.
If the two are equal (as described for \token_if_eq_catcode:NNTF, \token_if_eq_-
charcode:NNTF and \token_if_eq_meaning:NNTF, respectively) then the associated
⟨code ⟩ is left in the input stream and other cases are discarded. If any of the cases are
matched, the ⟨true code ⟩ is also inserted into the input stream (after the code for the
appropriate case), while if none match then the ⟨false code ⟩ is inserted. The functions
\token_case_catcode:Nn, \token_case_charcode:Nn, and \token_case_meaning:Nn,
which do nothing if there is no match, are also available.
\l_peek_token Token set by \peek_after:Nw and available for testing as described above.
\g_peek_token Token set by \peek_gafter:Nw and available for testing as described above.
204
\peek_catcode:NTF \peek_catcode:NTF ⟨test token ⟩ {⟨true code ⟩} {⟨false code ⟩}
Updated: 2012-12-20 Tests if the next ⟨token ⟩ in the input stream has the same category code as the ⟨test
token ⟩ (as defined by the test \token_if_eq_catcode:NNTF). Spaces are respected by
the test and the ⟨token ⟩ is left in the input stream after the ⟨true code ⟩ or ⟨false
code ⟩ (as appropriate to the result of the test).
205
\peek_remove_filler:n \peek_remove_filler:n {⟨code ⟩}
New: 2022-01-10 Peeks ahead and detect if the following token is a space (category code 10) or has meaning
equal to \scan_stop:. If so, removes the token and checks the next token. If neither
of these cases apply, expands the next token using f-type expansion, then checks the
resulting leading token in the same way. If after expansion the next token is neither of
the two test cases, the ⟨code ⟩ will be inserted into the input stream. Typically this will
contain a peek operation, but this is not required.
TEXhackers note: This is essentially a macro-based implementation of how TEX handles
the search for a left brace after for example \everypar, except that any non-expandable token
cleanly ends the ⟨filler ⟩ (i.e. it does not lead to a TEX error).
In contrast to TEX’s filler removal, a construct \exp_not:N \foo will be treated in the same
way as \foo.
206
\peek_analysis_map_inline:n \peek_analysis_map_inline:n {⟨inline function ⟩}
New: 2020-12-03
Updated: 2022-10-03
Repeatedly removes one ⟨token ⟩ from the input stream and applies the ⟨inline
function ⟩ to it, until \peek_analysis_map_break: is called. The ⟨inline function ⟩
receives three arguments for each ⟨token ⟩ in the input stream:
• ⟨tokens ⟩, which both o-expand and e/x-expand to the ⟨token ⟩. The detailed form
of ⟨tokens ⟩ may change in later releases.
• ⟨char code ⟩, a decimal representation of the character code of the ⟨token ⟩, −1 if
it is a control sequence.
• ⟨catcode ⟩, a capital hexadecimal digit which denotes the category code of the
⟨token ⟩ (0: control sequence, 1: begin-group, 2: end-group, 3: math shift, 4: align-
ment tab, 6: parameter, 7: superscript, 8: subscript, A: space, B: letter, C: other,
D: active). This can be converted to an integer by writing "⟨catcode ⟩.
These arguments are the same as for \tl_analysis_map_inline:nn defined in l3tl-
analysis. The ⟨char code ⟩ and ⟨catcode ⟩ do not take the meaning of a control sequence
or active character into account: for instance, upon encountering the token \c_group_-
begin_token in the input stream, \peek_analysis_map_inline:n calls the ⟨inline
function ⟩ with #1 being \exp_not:n { \c_group_begin_token } (with the current
implementation), #2 being −1, and #3 being 0, as for any other control sequence. In
contrast, upon encountering an explicit begin-group token {, the ⟨inline function ⟩ is
called with arguments \exp_after:wN { \if_false: } \fi:, 123 and 1.
The mapping is done at the current group level, i.e. any local assignments made by
the ⟨inline function ⟩ remain in effect after the loop. Within the code, \l_peek_token
is set equal (as a token, not a token list) to the token under consideration.
\peek_analysis_map_break: \peek_analysis_map_inline:n
\peek_analysis_map_break:n { ... \peek_analysis_map_break:n {⟨code ⟩} }
New: 2020-12-03 Stops the \peek_analysis_map_inline:n loop from seeking more tokens, and inserts
⟨code ⟩ in the input stream (empty for \peek_analysis_map_break:).
207
\peek_regex:nTF \peek_regex:nTF {⟨regex ⟩} {⟨true code ⟩} {⟨false code ⟩}
\peek_regex:NTF
Tests if the ⟨tokens ⟩ that follow in the input stream match the ⟨regular expression ⟩.
New: 2020-12-03 Any ⟨tokens ⟩ that have been read are left in the input stream after the ⟨true code ⟩ or
⟨false code ⟩ (as appropriate to the result of the test). See l3regex for documentation
of the syntax of regular expressions. The ⟨regular expression ⟩ is implicitly anchored
at the start, so for instance \peek_regex:nTF { a } is essentially equivalent to \peek_-
charcode:NTF a.
TEXhackers note: Implicit character tokens are correctly considered by \peek_regex:nTF
as control sequences, while functions that inspect individual tokens (for instance \peek_-
charcode:NTF) only take into account their meaning.
The \peek_regex:nTF function only inspects as few tokens as necessary to determine
whether the regular expression matches. For instance \peek_regex:nTF { abc | [a-z] }
{ } { } abc will only inspect the first token a even though the first branch abc of the al-
ternative is preferred in functions such as \peek_regex_remove_once:nTF. This may have an
effect on tokenization if the input stream has not yet been tokenized and category codes are
changed.
Tests if the ⟨tokens ⟩ that follow in the input stream match the ⟨regex ⟩. If the test is
true, the ⟨tokens ⟩ are removed from the input stream and the ⟨true code ⟩ is inserted,
while if the test is false, the ⟨false code ⟩ is inserted followed by the ⟨tokens ⟩ that
were originally in the input stream. See l3regex for documentation of the syntax of
regular expressions. The ⟨regular expression ⟩ is implicitly anchored at the start, so
for instance \peek_regex_remove_once:nTF { a } is essentially equivalent to \peek_-
charcode_remove:NTF a.
208
\peek_regex_replace_once:nn \peek_regex_replace_once:nnTF {⟨regex ⟩} {⟨replacement ⟩} {⟨true code ⟩}
\peek_regex_replace_once:nnTF {⟨false code ⟩}
\peek_regex_replace_once:Nn
\peek_regex_replace_once:NnTF
New: 2020-12-03
If the ⟨tokens ⟩ that follow in the input stream match the ⟨regex ⟩, replaces them ac-
cording to the ⟨replacement ⟩ as for \regex_replace_once:nnN, and leaves the result
in the input stream, after the ⟨true code ⟩. Otherwise, leaves ⟨false code ⟩ followed by
the ⟨tokens ⟩ that were originally in the input stream, with no modifications. See l3regex
for documentation of the syntax of regular expressions and of the ⟨replacement ⟩: for in-
stance \0 in the ⟨replacement ⟩ is replaced by the tokens that were matched in the input
stream. The ⟨regular expression ⟩ is implicitly anchored at the start. In contrast to
\regex_replace_once:nnN, no error arises if the ⟨replacement ⟩ leads to an unbalanced
token list: the tokens are inserted into the input stream without issue.
209
• An \outer endtemplate: can be encountered when peeking ahead at the next
token; this expands to another internal token, end of alignment template.
• Tricky programming might access a frozen \endwrite.
• Some frozen tokens can only be accessed in interactive sessions: \cr, \right,
\endgroup, \fi, \inaccessible.
• In LuaTEX, there is also the strange case of “bytes” ^^^^^^1100xy where x, y
are any two lowercase hexadecimal digits, so that the hexadecimal number ranges
from \text{110000}=1114112$ to~$1100ff = 1114367. These are used to output
individual bytes to files, rather than UTF-8. For the purposes of token comparisons
they behave like non-expandable primitive control sequences (not characters) whose
\meaning is the␣character␣ followed by the given byte. If this byte is in the range
80–ff this gives an “invalid utf-8 sequence” error: applying \token_to_str:N or
\token_to_meaning:N to these tokens is unsafe. Unfortunately, they don’t seem
to be detectable safely by any means except perhaps Lua code.
The meaning of a (non-active) character token is fixed by its category code (and
character code) and cannot be changed. We call these tokens explicit character tokens.
Category codes that a character token can have are listed below by giving a sample
output of the TEX primitive \meaning, together with their LATEX3 names and most
common example:
1 begin-group character (group_begin, often {),
2 end-group character (group_end, often }),
3 math shift character (math_toggle, often $),
4 alignment tab character (alignment, often &),
6 macro parameter character (parameter, often #),
7 superscript character (math_superscript, often ^),
8 subscript character (math_subscript, often _),
10 blank space (space, often character code 32),
11 the letter (letter, such as A),
12 the character (other, such as 0).
Category code 13 (active) is discussed below. Input characters can also have sev-
eral other category codes which do not lead to character tokens for later processing:
0 (escape), 5 (end_line), 9 (ignore), 14 (comment), and 15 (invalid).
The meaning of a control sequence or active character can be identical to that of any
character token listed above (with any character code), and we call such tokens implicit
character tokens. The meaning is otherwise in the following list:
• a macro, used in LATEX3 for most functions and some variables (tl, fp, seq, . . . ),
• a primitive such as \def or \topmark, used in LATEX3 for some functions,
• a register such as \count123, used in LATEX3 for the implementation of some vari-
ables (int, dim, . . . ),
210
• a constant integer such as \char"56 or \mathchar"121,
• a font selection command,
• undefined.
Macros can be \protected or not, \long or not (the opposite of what LATEX3 calls
nopar), and \outer or not (unused in LATEX3). Their \meaning takes the form
⟨prefix ⟩ macro:⟨argument ⟩->⟨replacement ⟩
211
Chapter 25
expl3 implements a ⟨property list ⟩ data type, which contain an unordered list of entries
each of which consists of a ⟨key ⟩ and an associated ⟨value ⟩. The ⟨key ⟩ and ⟨value ⟩
may both be any ⟨balanced text ⟩, the ⟨key ⟩ is processed using \tl_to_str:n, meaning
that category codes are ignored. It is possible to map functions to property lists such
that the function is applied to every key–value pair within the list.
Each entry in a property list must have a unique ⟨key ⟩: if an entry is added to a
property list which already contains the ⟨key ⟩ then the new entry overwrites the existing
one. The ⟨keys ⟩ are compared on a string basis, using the same method as \str_if_-
eq:nnTF.
Property lists are intended for storing key-based information for use within code.
This is in contrast to key–value lists, which are a form of input parsed by the l3keys
module.
212
\prop_set_eq:NN \prop_set_eq:NN ⟨property list1 ⟩ ⟨property list2 ⟩
\prop_set_eq:(cN|Nc|cc)
Sets the content of ⟨property list1 ⟩ equal to that of ⟨property list2 ⟩.
\prop_gset_eq:NN
\prop_gset_eq:(cN|Nc|cc)
213
25.2 Adding and updating property list entries
Adds an entry to the ⟨property list ⟩ which may be accessed using the ⟨key ⟩ and
which has ⟨value ⟩. If the ⟨key ⟩ is already present in the ⟨property list ⟩, the existing
entry is overwritten by the new ⟨value ⟩. Both the ⟨key ⟩ and ⟨value ⟩ may contain any
⟨balanced text ⟩. The ⟨key ⟩ is stored after processing with \tl_to_str:n, meaning
that category codes are ignored.
If the ⟨key ⟩ is present in the ⟨property list ⟩ then no action is taken. Otherwise, a
new entry is added as described for \prop_put:Nnn.
214
\prop_put_from_keyval:Nn \prop_put_from_keyval:Nn ⟨property list ⟩
\prop_put_from_keyval:cn {
\prop_gput_from_keyval:Nn ⟨key1⟩ = ⟨value1⟩ ,
\prop_gput_from_keyval:cn ⟨key2⟩ = ⟨value2⟩ , ...
}
New: 2021-05-16
Updated: 2021-11-07 Updates the ⟨property list ⟩ by adding entries for each key–value pair given in the
second argument. The addition is done through \prop_put:Nnn, hence if the ⟨property
list ⟩ already contains some of the keys, the corresponding values are discarded and
replaced by those given in the key–value list. If duplicate keys appear in the key–value
list then only the last of the values is kept.
The function is equivalent to storing the key–value pairs in a temporary property
list using \prop_set_from_keyval:Nn, then combining ⟨property list ⟩ with the tem-
porary variable using \prop_concat:NNN. In particular, the ⟨keys ⟩ and ⟨values ⟩ are
space-trimmed and unbraced as described in \prop_set_from_keyval:Nn. This function
correctly detects the = and , signs provided they have the standard category code 12 or
they are active.
Recovers the ⟨value ⟩ stored with ⟨key ⟩ from the ⟨property list ⟩, and places this in
the ⟨token list variable ⟩. If the ⟨key ⟩ is not found in the ⟨property list ⟩ then the
⟨token list variable ⟩ is set to the special marker \q_no_value. The ⟨token list
variable ⟩ is set within the current TEX group. See also \prop_get:NnNTF.
Recovers the ⟨value ⟩ stored with ⟨key ⟩ from the ⟨property list ⟩, and places this in
the ⟨token list variable ⟩. If the ⟨key ⟩ is not found in the ⟨property list ⟩ then
the ⟨token list variable ⟩ is set to the special marker \q_no_value. The ⟨key ⟩ and
⟨value ⟩ are then deleted from the property list. Both assignments are local. See also
\prop_pop:NnNTF.
Recovers the ⟨value ⟩ stored with ⟨key ⟩ from the ⟨property list ⟩, and places this in
the ⟨token list variable ⟩. If the ⟨key ⟩ is not found in the ⟨property list ⟩ then
the ⟨token list variable ⟩ is set to the special marker \q_no_value. The ⟨key ⟩ and
⟨value ⟩ are then deleted from the property list. The ⟨property list ⟩ is modified
globally, while the assignment of the ⟨token list variable ⟩ is local. See also \prop_-
gpop:NnNTF.
215
\prop_item:Nn ⋆ \prop_item:Nn ⟨property list ⟩ {⟨key ⟩}
\prop_item:(NV|Ne|No|cn|cV|ce|co) ⋆
New: 2014-07-17
Expands to the ⟨value ⟩ corresponding to the ⟨key ⟩ in the ⟨property list ⟩. If the
⟨key ⟩ is missing, this has an empty expansion.
TEXhackers note: This function is slower than the non-expandable analogue \prop_-
get:NnN. The result is returned within the \unexpanded primitive (\exp_not:n), which means
that the ⟨value ⟩ does not expand further when appearing in an e-type or x-type argument
expansion.
TEXhackers note: The result is returned within the \unexpanded primitive (\exp_not:n),
which means that the key–value list does not expand further when appearing in an e-type or
x-type argument expansion. It also needs exactly two steps of expansion.
Removes the entry listed under ⟨key ⟩ from the ⟨property list ⟩. If the ⟨key ⟩ is not
found in the ⟨property list ⟩ no change occurs, i.e there is no need to test for the
existence of a key before deleting it.
216
\prop_if_empty_p:N ⋆ \prop_if_empty_p:N ⟨property list ⟩
\prop_if_empty_p:c ⋆ \prop_if_empty:NTF ⟨property list ⟩ {⟨true code ⟩} {⟨false code ⟩}
\prop_if_empty:NTF ⋆
Tests if the ⟨property list ⟩ is empty (containing no entries).
\prop_if_empty:c ⋆
Tests if the ⟨key ⟩ is present in the ⟨property list ⟩, making the comparison using the
method described by \str_if_eq:nnTF.
TEXhackers note: This function iterates through every key–value pair in the ⟨property
list ⟩ and is therefore slower than using the non-expandable \prop_get:NnNTF.
If the ⟨key ⟩ is not present in the ⟨property list ⟩, leaves the ⟨false code ⟩ in the
input stream. The value of the ⟨token list variable ⟩ is not defined in this case and
should not be relied upon. If the ⟨key ⟩ is present in the ⟨property list ⟩, stores the
corresponding ⟨value ⟩ in the ⟨token list variable ⟩ without removing it from the
⟨property list ⟩, then leaves the ⟨true code ⟩ in the input stream. The ⟨token list
variable ⟩ is assigned locally.
If the ⟨key ⟩ is not present in the ⟨property list ⟩, leaves the ⟨false code ⟩ in the
input stream. The value of the ⟨token list variable ⟩ is not defined in this case
and should not be relied upon. If the ⟨key ⟩ is present in the ⟨property list ⟩, pops
the corresponding ⟨value ⟩ in the ⟨token list variable ⟩, i.e. removes the item from
the ⟨property list ⟩. Both the ⟨property list ⟩ and the ⟨token list variable ⟩ are
assigned locally.
217
\prop_gpop:NnNTF \prop_gpop:NnNTF ⟨property list ⟩ {⟨key ⟩} ⟨token list variable ⟩ {⟨true
\prop_gpop:(NVN|NoN|cnN|cVN|coN)TF code ⟩} {⟨false code ⟩}
New: 2011-08-18
Updated: 2012-05-19
If the ⟨key ⟩ is not present in the ⟨property list ⟩, leaves the ⟨false code ⟩ in the
input stream. The value of the ⟨token list variable ⟩ is not defined in this case and
should not be relied upon. If the ⟨key ⟩ is present in the ⟨property list ⟩, pops the
corresponding ⟨value ⟩ in the ⟨token list variable ⟩, i.e. removes the item from the
⟨property list ⟩. The ⟨property list ⟩ is modified globally, while the ⟨token list
variable ⟩ is assigned locally.
218
\prop_map_break: ✩ \prop_map_break:
Updated: 2012-06-29 Used to terminate a \prop_map_... function before all entries in the ⟨property list ⟩
have been processed. This normally takes place within a conditional statement, for
example
\prop_map_inline:Nn \l_my_prop
{
\str_if_eq:nnTF { #1 } { bingo }
{ \prop_map_break: }
{
% Do something useful
}
}
Use outside of a \prop_map_... scenario leads to low level TEX errors.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
further items are taken from the input stream. This depends on the design of the mapping
function.
TEXhackers note: When the mapping is broken, additional tokens may be inserted before
the ⟨code ⟩ is inserted into the input stream. This depends on the design of the mapping function.
219
\prop_log:N \prop_log:N ⟨property list ⟩
\prop_log:c
Writes the entries in the ⟨property list ⟩ in the log file.
New: 2014-08-12
Updated: 2021-04-29
\l_tmpa_prop Scratch property lists for local assignment. These are never used by the kernel code, and
\l_tmpb_prop so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
New: 2012-06-23 by other non-kernel code and so should only be used for short-term storage.
\g_tmpa_prop Scratch property lists for global assignment. These are never used by the kernel code, and
\g_tmpb_prop so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
New: 2012-06-23 by other non-kernel code and so should only be used for short-term storage.
25.10 Constants
220
Chapter 26
LATEX3 provides two general length variables: dim and skip. Lengths stored as dim
variables have a fixed length, whereas skip lengths have a rubber (stretch/shrink) com-
ponent. In addition, the muskip type is available for use in math mode: this is a special
form of skip where the lengths involved are determined by the current math font (in
mu). There are common features in the creation and setting of length variables, but for
clarity the functions are grouped by variable type.
Many functions take dimension expressions (“⟨dim expr ⟩”) or skip expressions
(“⟨skip expr ⟩”) as arguments.
221
\dim_if_exist_p:N ⋆ \dim_if_exist_p:N ⟨dimension ⟩
\dim_if_exist_p:c ⋆ \dim_if_exist:NTF ⟨dimension ⟩ {⟨true code ⟩} {⟨false code ⟩}
\dim_if_exist:NTF ⋆
Tests whether the ⟨dimension ⟩ is currently defined. This does not check that the
\dim_if_exist:c ⋆
⟨dimension ⟩ really is a dimension variable.
New: 2012-03-03
222
\dim_ratio:nn ✩ \dim_ratio:nn {⟨dim expr1 ⟩} {⟨dim expr2 ⟩}
Updated: 2011-10-22 Parses the two ⟨dim exprs ⟩ and converts the ratio of the two to a form suitable for use
inside a ⟨dim expr ⟩. This ratio is then left in the input stream, allowing syntax such as
\dim_set:Nn \l_my_dim
{ 10 pt * \dim_ratio:nn { 5 pt } { 10 pt } }
The output of \dim_ratio:nn on full expansion is a ratio expression between two integers,
with all distances converted to scaled points. Thus
\tl_set:Ne \l_my_tl { \dim_ratio:nn { 5 pt } { 10 pt } }
\tl_show:N \l_my_tl
displays 327680/655360 on the terminal.
223
\dim_compare_p:n ⋆ \dim_compare_p:n
\dim_compare:nTF ⋆ {
⟨dim expr1 ⟩ ⟨relation1 ⟩
Updated: 2013-01-13
...
⟨dim exprN ⟩ ⟨relationN ⟩
⟨dim exprN +1 ⟩
}
\dim_compare:nTF
{
⟨dim expr1 ⟩ ⟨relation1 ⟩
...
⟨dim exprN ⟩ ⟨relationN ⟩
⟨dim exprN +1 ⟩
}
{⟨true code ⟩} {⟨false code ⟩}
This function evaluates the ⟨dim exprs ⟩ as described for \dim_eval:n and compares
consecutive result using the corresponding ⟨relation ⟩, namely it compares ⟨dim expr1 ⟩
and ⟨dim expr2 ⟩ using the ⟨relation1 ⟩, then ⟨dim expr2 ⟩ and ⟨dim expr3 ⟩ using
the ⟨relation2 ⟩, until finally comparing ⟨dim exprN ⟩ and ⟨dim exprN +1 ⟩ using the
⟨relationN ⟩. The test yields true if all comparisons are true. Each ⟨dim expr ⟩ is
evaluated only once, and the evaluation is lazy, in the sense that if one comparison is
false, then no other ⟨dim expr ⟩ is evaluated and no other comparison is performed.
The ⟨relations ⟩ can be any of the following:
Equal = or ==
Greater than or equal to >=
Greater than >
Less than or equal to <=
Less than <
Not equal !=
This function is more flexible than \dim_compare:nNnTF but around 5 times slower.
224
\dim_case:nn ⋆ \dim_case:nnTF {⟨test dim expr ⟩}
\dim_case:nnTF ⋆ {
{⟨dim expr case1 ⟩} {⟨code case1 ⟩}
New: 2013-07-24
{⟨dim expr case2 ⟩} {⟨code case2 ⟩}
...
{⟨dim expr casen ⟩} {⟨code casen ⟩}
}
{⟨true code ⟩}
{⟨false code ⟩}
This function evaluates the ⟨test dim expr ⟩ and compares this in turn to each of the
⟨dim expr cases ⟩. If the two are equal then the associated ⟨code ⟩ is left in the input
stream and other cases are discarded. If any of the cases are matched, the ⟨true code ⟩
is also inserted into the input stream (after the code for the appropriate case), while if
none match then the ⟨false code ⟩ is inserted. The function \dim_case:nn, which does
nothing if there is no match, is also available. For example
\dim_set:Nn \l_tmpa_dim { 5 pt }
\dim_case:nnF
{ 2 \l_tmpa_dim }
{
{ 5 pt } { Small }
{ 4 pt + 6 pt } { Medium }
{ - 10 pt } { Negative }
}
{ No idea! }
leaves “Medium” in the input stream.
225
\dim_while_do:nNnn ✩ \dim_while_do:nNnn {⟨dim expr1 ⟩} ⟨relation ⟩ {⟨dim expr2 ⟩} {⟨code ⟩}
Evaluates the relationship between the two ⟨dim exprs ⟩ as described for \dim_-
compare:nNnTF, and then places the ⟨code ⟩ in the input stream if the ⟨relation ⟩ is
true. After the ⟨code ⟩ has been processed by TEX the test is repeated, and a loop
occurs until the test is false.
226
\dim_step_variable:nnnNn \dim_step_variable:nnnNn
{⟨initial value ⟩} {⟨step ⟩} {⟨final value ⟩} ⟨tl var ⟩ {⟨code ⟩}
New: 2018-02-18
This function first evaluates the ⟨initial value ⟩, ⟨step ⟩ and ⟨final value ⟩, all of
which should be dimension expressions. Then for each ⟨value ⟩ from the ⟨initial
value ⟩ to the ⟨final value ⟩ in turn (using ⟨step ⟩ between each ⟨value ⟩), the ⟨code ⟩
is inserted into the input stream, with the ⟨tl var ⟩ defined as the current ⟨value ⟩. Thus
the ⟨code ⟩ should make use of the ⟨tl var ⟩.
TEXhackers note: \dim_use:N is the TEX primitive \the: this is one of several LATEX3
names for this primitive.
\dim_to_decimal:n { 1bp }
leaves 1.00374 in the input stream, i.e. the magnitude of one “big point” when converted
to (TEX) points.
227
\dim_to_decimal_in_bp:n ⋆ \dim_to_decimal_in_bp:n {⟨dim expr ⟩}
New: 2014-07-15 Evaluates the ⟨dim expr ⟩, and leaves the result, expressed in big points (bp) in the input
Updated: 2023-05-20 stream, with no units. The result is rounded by TEX to at most five decimal places. If
the decimal part of the result is zero, it is omitted, together with the decimal marker.
For example
\dim_to_decimal_in_bp:n { 1pt }
leaves 0.99628 in the input stream, i.e. the magnitude of one (TEX) point when converted
to big points.
TEXhackers note: The implementation of this function is re-entrant: the result of
\dim_compare:nNnTF
{ <x>bp } =
{ \dim_to_decimal_in_bp:n { <x>bp } bp }
will be logically true. The decimal representations may differ provided they produce the same
TEX dimension.
1276.00215 cc
575.83174 cm
15312.02584 dd
226.70540 in
5758.31742 mm
1365.33333 pc
(Note that these are not all equal, but rather any larger value will overflow due to the
way TEX converts to sp.) Values given to five decimal places larger that these will result
in TEX errors; the behavior if additional decimal places are given depends on the TEX
internals and thus larger values are not supported by expl3.
TEXhackers note: The implementation of these functions is re-entrant: the result of
\dim_compare:nNnTF
{ <x><unit> } =
{ \dim_to_decimal_in_<unit>:n { <x><unit> } <unit> }
will be logically true. The decimal representations may differ provided they produce the same
TEX dimension.
228
\dim_to_decimal_in_sp:n ⋆ \dim_to_decimal_in_sp:n {⟨dim expr ⟩}
New: 2015-05-18 Evaluates the ⟨dim expr ⟩, and leaves the result, expressed in scaled points (sp) in the
input stream, with no units. The result is necessarily an integer.
Evaluates the ⟨dim exprs ⟩, and leaves the value of ⟨dim expr1 ⟩, expressed in a unit
given by ⟨dim expr2 ⟩, in the input stream. If the decimal part of the result is zero, it is
omitted, together with the decimal marker. The precisions of the result is limited to a
maximum of five decimal places with trailing zeros omitted.
For example
\dim_to_decimal_in_unit:nn { 1bp } { 1mm }
leaves 0.35278 in the input stream, i.e. the magnitude of one big point when expressed
in millimetres. The conversions do not guarantee that TEX would yield identical results
for the direct input in an equality test, thus for instance
\dim_compare:nNnTF
{ 1bp } =
{ \dim_to_decimal_in_unit:nn { 1bp } { 1mm } mm }
229
\dim_log:n \dim_log:n {⟨dim expr ⟩}
New: 2014-08-22 Writes the result of evaluating the ⟨dim expr ⟩ in the log file.
Updated: 2015-08-07
\c_max_dim The maximum value that can be stored as a dimension. This can also be used as a
component of a skip.
\c_zero_dim A zero length as a dimension. This can also be used as a component of a skip.
\l_tmpa_dim Scratch dimension for local assignment. These are never used by the kernel code, and so
\l_tmpb_dim are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
\g_tmpa_dim Scratch dimension for global assignment. These are never used by the kernel code, and
\g_tmpb_dim so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
by other non-kernel code and so should only be used for short-term storage.
230
\skip_zero_new:N \skip_zero_new:N ⟨skip ⟩
\skip_zero_new:c
Ensures that the ⟨skip ⟩ exists globally by applying \skip_new:N if necessary, then ap-
\skip_gzero_new:N
\skip_gzero_new:c plies \skip_(g)zero:N to leave the ⟨skip ⟩ set to zero.
New: 2012-01-07
Updated: 2011-10-22
231
26.13 Skip expression conditionals
TEXhackers note: \skip_use:N is the TEX primitive \the: this is one of several LATEX3
names for this primitive.
232
\skip_log:N \skip_log:N ⟨skip ⟩
\skip_log:c
Writes the value of the ⟨skip ⟩ in the log file.
New: 2014-08-22
Updated: 2015-08-03
\c_max_skip The maximum value that can be stored as a skip (equal to \c_max_dim in length), with
Updated: 2012-11-02 no stretch nor shrink component.
\l_tmpa_skip Scratch skip for local assignment. These are never used by the kernel code, and so are
\l_tmpb_skip safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
\g_tmpa_skip Scratch skip for global assignment. These are never used by the kernel code, and so are
\g_tmpb_skip safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
233
\skip_vertical:N \skip_vertical:N ⟨skip ⟩
\skip_vertical:c \skip_vertical:n {⟨skip expr ⟩}
\skip_vertical:n
Inserts a vertical ⟨skip ⟩ into the current list. The argument can also be a ⟨dim ⟩.
Updated: 2011-10-22
TEXhackers note: \skip_vertical:N is the TEX primitive \vskip.
234
\muskip_set:Nn \muskip_set:Nn ⟨muskip ⟩ {⟨muskip expr ⟩}
\muskip_set:cn
Sets ⟨muskip ⟩ to the value of ⟨muskip expr ⟩, which must evaluate to a math length
\muskip_gset:Nn
\muskip_gset:cn with units and may include a rubber component (for example 1 mu plus 0.5 mu.
Updated: 2011-10-22
TEXhackers note: \muskip_use:N is the TEX primitive \the: this is one of several LATEX3
names for this primitive.
235
\muskip_show:n \muskip_show:n {⟨muskip expr ⟩}
New: 2011-11-22 Displays the result of evaluating the ⟨muskip expr ⟩ on the terminal.
Updated: 2015-08-07
\c_max_muskip The maximum value that can be stored as a muskip, with no stretch nor shrink compo-
nent.
\l_tmpa_muskip Scratch muskip for local assignment. These are never used by the kernel code, and so
\l_tmpb_muskip are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
\g_tmpa_muskip Scratch muskip for global assignment. These are never used by the kernel code, and so
\g_tmpb_muskip are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
236
Chapter 27
The key–value method is a popular system for creating large numbers of settings for
controlling function or package behaviour. The system normally results in input of the
form
\MyModuleSetup{
key-one = value one,
key-two = value two
}
or
\MyModuleMacro[
key-one = value one,
key-two = value two
]{argument}
for the user.
The high level functions here are intended as a method to create key–value controls.
Keys are themselves created using a key–value interface, minimising the number of func-
tions and arguments required. Each key is created by setting one or more properties of
the key:
\keys_define:nn { mymodule }
{
key-one .code:n = code including parameter #1,
key-two .tl_set:N = \l_mymodule_store_tl
}
These values can then be set as with other key–value approaches:
\keys_set:nn { mymodule }
{
key-one = value one,
key-two = value two
}
237
As illustrated, keys are created inside a ⟨module ⟩: a set of related keys, typically those
for a single module/LATEX 2ε package. See Section for suggestions on how to divide large
numbers of keys for a single module.
At a document level, \keys_set:nn is used within a document function, for example
\DeclareDocumentCommand \MyModuleSetup { m }
{ \keys_set:nn { mymodule } { #1 } }
\DeclareDocumentCommand \MyModuleMacro { o m }
{
\group_begin:
\keys_set:nn { mymodule } { #1 }
% Main code for \MyModuleMacro
\group_end:
}
Key names may contain any tokens, as they are handled internally using \tl_to_-
str:n. As discussed in section 27.2, it is suggested that the character / is reserved for
sub-division of keys into logical groups. Functions and variables are not expanded when
creating key names, and so
\tl_set:Nn \l_mymodule_tmp_tl { key }
\keys_define:nn { mymodule }
{
\l_mymodule_tmp_tl .code:n = code
}
creates a key called \l_mymodule_tmp_tl, and not one called key.
\keys_define:nn { mymodule }
{
keyname .code:n = Some~code~using~#1,
keyname .value_required:n = true
}
where the properties of the key begin from the . after the key name.
The various properties available take either no arguments at all, or require one
or more arguments. This is indicated in the name of the property using an argument
specification. In the following discussion, each property is illustrated attached to an
arbitrary ⟨key ⟩, which when used may be supplied with a ⟨value ⟩. All key definitions
are local.
238
Key properties are applied in the reading order and so the ordering is significant.
Key properties which define “actions”, such as .code:n, .tl_set:N, etc., override one
another. Some other properties are mutually exclusive, notably .value_required:n and
.value_forbidden:n, and so they replace one another. However, properties covering
non-exclusive behaviours may be given in any order. Thus for example the following
definitions are equivalent.
\keys_define:nn { mymodule }
{
keyname .code:n = Some~code~using~#1,
keyname .value_required:n = true
}
\keys_define:nn { mymodule }
{
keyname .value_required:n = true,
keyname .code:n = Some~code~using~#1
}
Note that all key properties define the key within the current TEX group, with an ex-
ception that the special .undefine: property undefines the key within the current TEX
group.
239
.code:n ⟨key ⟩ .code:n = {⟨code ⟩}
Updated: 2013-07-10 Stores the ⟨code ⟩ for execution when ⟨key ⟩ is used. The ⟨code ⟩ can include one para-
meter (#1), which will be the ⟨value ⟩ given for the ⟨key ⟩.
240
.groups:n ⟨key ⟩ .groups:n = {⟨groups ⟩}
New: 2013-07-14 Defines ⟨key ⟩ as belonging to the ⟨groups ⟩ declared. Groups provide a “secondary axis”
for selectively setting keys, and are described in Section 27.7.
setting
\keys_set:nn { bar } { test = a }
will be equivalent to
\keys_set:nn { foo } { test = a }
Inheritance applies at point of use, not at definition, thus keys may be added to the
⟨parent ⟩ after the use of .inherit:n and will be active. If more than one ⟨parent ⟩ is
specified, the presence of the ⟨key ⟩ will be tested for each in turn, with the first successful
hit taking priority.
241
.meta:nn ⟨key ⟩ .meta:nn = {⟨path ⟩} {⟨keyval list ⟩}
New: 2013-07-10 Makes ⟨key ⟩ a meta-key, which will set ⟨keyval list ⟩ in one go using the ⟨path ⟩ in
place of the current one. The ⟨keyval list ⟩ can refer as #1 to the value given at the
time the ⟨key ⟩ is used (or, if no value is given, the ⟨key ⟩’s default value).
New: 2021-10-30
242
.tl_set:N ⟨key ⟩ .tl_set:N = ⟨token list variable ⟩
.tl_set:c
Defines ⟨key ⟩ to set ⟨token list variable ⟩ to ⟨value ⟩. If the variable does not exist,
.tl_gset:N
.tl_gset:c it is created globally at the point that the key is set up.
243
27.3 Choice and multiple choice keys
The l3keys system supports two types of choice key, in which a series of pre-defined input
values are linked to varying implementations. Choice keys are usually created so that the
various values are mutually-exclusive: only one can apply at any one time. “Multiple”
choice keys are also supported: these allow a selection of values to be chosen at the same
time.
Mutually-exclusive choices are created by setting the .choice: property:
\keys_define:nn { mymodule }
{ key .choice: }
For keys which are set up as choices, the valid choices are generated by creating sub-keys
of the choice key. This can be carried out in two ways.
In many cases, choices execute similar code which is dependant only on the name of
the choice or the position of the choice in the list of all possibilities. Here, the keys can
share the same code, and can be rapidly created using the .choices:nn property.
\keys_define:nn { mymodule }
{
key .choices:nn =
{ choice-a, choice-b, choice-c }
{
You~gave~choice~’\tl_use:N \l_keys_choice_tl’,~
which~is~in~position~\int_use:N \l_keys_choice_int \c_space_tl
in~the~list.
}
}
The index \l_keys_choice_int in the list of choices starts at 1.
\l_keys_choice_int Inside the code block for a choice generated using .choices:nn, the variables \l_keys_-
\l_keys_choice_tl choice_tl and \l_keys_choice_int are available to indicate the name of the current
choice, and its position in the comma list. The position is indexed from 1. Note that,
as with standard key code generated using .code:n, the value passed to the key (i.e. the
choice name) is also available as #1.
On the other hand, it is sometimes useful to create choices which use entirely different
code from one another. This can be achieved by setting the .choice: property of a key,
then manually defining sub-keys.
\keys_define:nn { mymodule }
{
key .choice:,
key / choice-a .code:n = code-a,
key / choice-b .code:n = code-b,
key / choice-c .code:n = code-c,
}
It is possible to mix the two methods, but manually-created choices should not
use \l_keys_choice_tl or \l_keys_choice_int. These variables do not have defined
244
behaviour when used outside of code created using .choices:nn (i.e. anything might
happen).
It is possible to allow choice keys to take values which have not previously been
defined by adding code for the special unknown choice. The general behavior of the
unknown key is described in Section 27.6. A typical example in the case of a choice would
be to issue a custom error message:
\keys_define:nn { mymodule }
{
key .choice:,
key / choice-a .code:n = code-a,
key / choice-b .code:n = code-b,
key / choice-c .code:n = code-c,
key / unknown .code:n =
\msg_error:nneee { mymodule } { unknown-choice }
{ key } % Name of choice key
{ choice-a , choice-b , choice-c } % Valid choices
{ \exp_not:n {#1} } % Invalid choice given
%
%
}
Multiple choices are created in a very similar manner to mutually-exclusive choices,
using the properties .multichoice: and .multichoices:nn. As with mutually exclusive
choices, multiple choices are define as sub-keys. Thus both
\keys_define:nn { mymodule }
{
key .multichoices:nn =
{ choice-a, choice-b, choice-c }
{
You~gave~choice~’\tl_use:N \l_keys_choice_tl’,~
which~is~in~position~
\int_use:N \l_keys_choice_int \c_space_tl
in~the~list.
}
}
and
\keys_define:nn { mymodule }
{
key .multichoice:,
key / choice-a .code:n = code-a,
key / choice-b .code:n = code-b,
key / choice-c .code:n = code-c,
}
are valid.
When a multiple choice key is set
245
\keys_set:nn { mymodule }
{
key = { a , b , c } % ’key’ defined as a multiple choice
}
each choice is applied in turn, equivalent to a clist mapping or to applying each value
individually:
\keys_set:nn { mymodule }
{
key = a ,
key = b ,
key = c ,
}
Thus each separate choice will have passed to it the \l_keys_choice_tl and \l_keys_-
choice_int in exactly the same way as described for .choices:nn.
\l_keys_usage_load_prop
\l_keys_usage_preamble_prop
New: 2022-01-10
l3keys itself does not attempt to redefine keys based on the usage scope. Rather, this
information is made available with these two property lists. These hold an entry for each
module (prefix); the value of each entry is a comma-separated list of the usage-restricted
key(s).
246
\l_keys_path_str For each key processed, information of the full path of the key, the name of the key and
\l_keys_key_str the value of the key is available within two string and one token list variables. These
\l_keys_value_tl may be used within the code of the key.
Updated: 2020-02-08 The path of the key is a “full” description of the key, and is unique for each key. It
consists of the module and full key name, thus for example
\keys_define:nn { mymodule }
{
unknown .code:n =
You~tried~to~set~key~’\l_keys_key_str’~to~’#1’.
}
These functions set keys which are known for the ⟨module ⟩, and simply ignore other keys.
The \keys_set_known:nn function parses the ⟨keyval list ⟩, and sets those keys which
are defined for ⟨module ⟩. Any keys which are unknown are not processed further by
the parser. In addition, \keys_set_known:nnN stores the key–value pairs in the ⟨tl ⟩ in
comma-separated form (i.e. an edited version of the ⟨keyval list ⟩). When a ⟨root ⟩ is
given (\keys_set_known:nnnN), the key–value entries are returned relative to this point
in the key tree. When it is absent, only the key name and value are provided. The correct
list is returned by nested calls.
247
27.7 Selective key setting
In some cases it may be useful to be able to select only some keys for setting, even though
these keys have the same path. For example, with a set of keys defined using
\keys_define:nn { mymodule }
{
key-one .code:n = { \my_func:n {#1} } ,
key-two .tl_set:N = \l_my_a_tl ,
key-three .tl_set:N = \l_my_b_tl ,
key-four .fp_set:N = \l_my_a_fp ,
}
the use of \keys_set:nn attempts to set all four keys. However, in some contexts it may
only be sensible to set some keys, or to control the order of setting. To do this, keys
may be assigned to groups: arbitrary sets which are independent of the key tree. Thus
modifying the example to read
\keys_define:nn { mymodule }
{
key-one .code:n = { \my_func:n {#1} } ,
key-one .groups:n = { first } ,
key-two .tl_set:N = \l_my_a_tl ,
key-two .groups:n = { first } ,
key-three .tl_set:N = \l_my_b_tl ,
key-three .groups:n = { second } ,
key-four .fp_set:N = \l_my_a_fp ,
}
assigns key-one and key-two to group first, key-three to group second, while
key-four is not assigned to a group.
Selective key setting may be achieved either by selecting one or more groups to be
made “active”, or by marking one or more groups to be ignored in key setting.
Activates key filtering in an “opt-out” sense: keys assigned to any of the ⟨groups ⟩ spec-
ified are ignored. The ⟨groups ⟩ are given as a comma-separated list. Unknown keys are
not assigned to any group and are thus always set. The key–value pairs for each key
which is filtered out are stored in the ⟨tl ⟩ in a comma-separated form (i.e. an edited
version of the ⟨keyval list ⟩). The \keys_set_filter:nnn version skips this stage.
Use of \keys_set_filter:nnnN can be nested, with the correct residual ⟨keyval
list ⟩ returned at each stage. In the version which takes a ⟨root ⟩ argument, the key list
is returned relative to that point in the key tree. In the cases without a ⟨root ⟩ argument,
only the key names and values are returned.
248
\keys_set_groups:nnn \keys_set_groups:nnn {⟨module ⟩} {⟨groups ⟩} {⟨keyval list ⟩}
\keys_set_groups:(nnV|nnv|nno)
New: 2013-07-14
Updated: 2017-05-27
Activates key filtering in an “opt-in” sense: only keys assigned to one or more of the
⟨groups ⟩ specified are set. The ⟨groups ⟩ are given as a comma-separated list. Unknown
keys are not assigned to any group and are thus never set.
Tests if the ⟨choice ⟩ is defined for the ⟨key ⟩ within the ⟨module ⟩, i.e. if any code has
been defined for ⟨key ⟩/⟨choice ⟩. The test is false if the ⟨key ⟩ itself is not defined.
249
27.10 Low-level interface for parsing key–val lists
To re-cap from earlier, a key–value list is input of the form
KeyOne = ValueOne ,
KeyTwo = ValueTwo ,
KeyThree
where each key–value pair is separated by a comma from the rest of the list, and each
key–value pair does not necessarily contain an equals sign or a value! Processing this
type of input correctly requires a number of careful steps, to correctly account for braces,
spaces and the category codes of separators.
While the functions described earlier are used as a high-level interface for processing
such input, in special circumstances you may wish to use a lower-level approach. The low-
level parsing system converts a ⟨key–value list ⟩ into ⟨keys ⟩ and associated ⟨values ⟩.
After the parsing phase is completed, the resulting keys and values (or keys alone) are
available for further processing. This processing is not carried out by the low-level parser
itself, and so the parser requires the names of two functions along with the key–value
list. One function is needed to process key–value pairs (it receives two arguments), and
a second function is required for keys given without any value (it is called with a single
argument).
The parser does not double # tokens or expand any input. Active tokens = and ,
appearing at the outer level of braces are converted to category “other” (12) so that the
parser does not “miss” any due to category code changes. Spaces are removed from the
ends of the keys and values. Keys and values which are given in braces have exactly one
set removed (after space trimming), thus
key = {value here},
and
250
\keyval_parse:nnn ✩ \keyval_parse:nnn {⟨code1 ⟩} {⟨code2 ⟩} {⟨key–value list ⟩}
\keyval_parse:(nnV|nnv) ✩
Parses the ⟨key–value list ⟩ into a series of ⟨keys ⟩ and associated ⟨values ⟩, or keys
New: 2020-12-19 alone (if no ⟨value ⟩ was given). ⟨code1 ⟩ receives each ⟨key ⟩ (with no ⟨value ⟩) as a
Updated: 2021-05-10 trailing brace group, whereas ⟨code2 ⟩ is appended by two brace groups, the ⟨key ⟩ and
⟨value ⟩. The order of the ⟨keys ⟩ in the ⟨key–value list ⟩ is preserved. Thus
\keyval_parse:nnn
{ \use_none:nn { code 1 } }
{ \use_none:nnn { code 2 } }
{ key1 = value1 , key2 = value2, key3 = , key4 }
Note that there is a difference between an empty value (an equals sign followed by noth-
ing) and a missing value (no equals sign at all). Spaces are trimmed from the ends of the
⟨key ⟩ and ⟨value ⟩, then one outer set of braces is removed from the ⟨key ⟩ and ⟨value ⟩
as part of the processing. If you need exactly the output shown above, you’ll need to
either e-type or x-type expand the function.
TEXhackers note: The result of each list element is returned within \exp_not:n, which
means that the converted input stream does not expand further when appearing in an e-type or
x-type argument expansion.
251
\keyval_parse:NNn ✩ \keyval_parse:NNn ⟨function1 ⟩ ⟨function2 ⟩ {⟨key–value list ⟩}
\keyval_parse:(NNV|NNv) ✩
Parses the ⟨key–value list ⟩ into a series of ⟨keys ⟩ and associated ⟨values ⟩, or
Updated: 2021-05-10 keys alone (if no ⟨value ⟩ was given). ⟨function1 ⟩ should take one argument, while
⟨function2 ⟩ should absorb two arguments. After \keyval_parse:NNn has parsed
the ⟨key–value list ⟩, ⟨function1 ⟩ is used to process keys given with no value and
⟨function2 ⟩ is used to process keys given with a value. The order of the ⟨keys ⟩ in the
⟨key–value list ⟩ is preserved. Thus
\keyval_parse:NNn \function:n \function:nn
{ key1 = value1 , key2 = value2, key3 = , key4 }
TEXhackers note: The result is returned within \exp_not:n, which means that the con-
verted input stream does not expand further when appearing in an e-type or x-type argument
expansion.
252
Chapter 28
The use of intarray data is therefore recommended for cases where the need for fast
access is of paramount importance.
253
\intarray_const_from_clist:Nn \intarray_const_from_clist:Nn ⟨intarray var ⟩ ⟨int expr clist ⟩
\intarray_const_from_clist:cn
New: 2018-05-04
Creates a new constant ⟨integer array variable ⟩ or raises an error if the name is
already taken. The ⟨integer array variable ⟩ is set (globally) to contain as its items
the results of evaluating each ⟨integer expression ⟩ in the ⟨comma list ⟩.
254
Chapter 29
A decimal floating point number is one which is stored as a significand and a separate
exponent. The module implements expandably a wide set of arithmetic, trigonometric,
and other operations on decimal floating point numbers, to be used within floating point
expressions. Floating point expressions (“⟨fp expr ⟩”) support the following operations
with their usual precedence.
(not yet) Hyperbolic functions and their inverse functions: sinh x, cosh x, tanh x, coth x,
sech x, csch, and asinh x, acosh x, atanh x, acoth x, asech x, acsch x.
• Extrema: max(x1 , x2 , . . .), min(x1 , x2 , . . .), abs(x).
• Rounding functions, controlled by two optional values, n (number of places, 0 by
default) and t (behavior on a tie, nan by default):
– trunc(x, n) rounds towards zero,
– floor(x, n) rounds towards −∞,
255
– ceil(x, n) rounds towards +∞,
– round(x, n, t) rounds to the closest value, with ties rounded to an even value
by default, towards zero if t = 0, towards +∞ if t > 0 and towards −∞ if
t < 0.
And (not yet) modulo, and “quantize”.
• Random numbers: rand(), randint(m, n).
\documentclass{article}
\usepackage{siunitx}
\ExplSyntaxOn
\NewDocumentCommand { \calcnum } { m }
{ \num { \fp_to_scientific:n {#1} } }
\ExplSyntaxOff
\begin{document}
\calcnum { 2 pi * sin ( 2.3 ^ 5 ) }
\end{document}
See the documentation of siunitx for various options of \num.
256
29.1 Creating and initialising floating point variables
Updated: 2012-05-08
257
\fp_sub:Nn \fp_sub:Nn ⟨fp var ⟩ {⟨fp expr ⟩}
\fp_sub:cn
Subtracts the result of computing the ⟨floating point expression ⟩ from the ⟨fp var ⟩.
\fp_gsub:Nn
\fp_gsub:cn This also applies if ⟨fp var ⟩ and ⟨floating point expression ⟩ evaluate to tuples of
the same size.
Updated: 2012-05-08
258
\fp_to_scientific:N ⋆ \fp_to_scientific:N ⟨fp var ⟩
\fp_to_scientific:c ⋆ \fp_to_scientific:n {⟨fp expr ⟩}
\fp_to_scientific:n ⋆
Evaluates the ⟨fp expr ⟩ and expresses the result in scientific notation:
New: 2012-05-08
Updated: 2016-03-22 ⟨optional - ⟩⟨digit ⟩.⟨15 digits ⟩e⟨optional sign ⟩⟨exponent ⟩
The leading ⟨digit ⟩ is non-zero except in the case of ±0. The values ±∞ and nan trigger
an “invalid operation” exception. Normal category codes apply: thus the e is category
code 11 (a letter). For a tuple, each item is converted using \fp_to_scientific:n and
they are combined as (⟨fp1 ⟩,␣⟨fp2 ⟩,␣. . . ⟨fpn ⟩) if n > 1 and (⟨fp1 ⟩,) or () for fewer
items.
259
\fp_compare_p:nNn ⋆ \fp_compare_p:nNn {⟨fp expr1 ⟩} ⟨relation ⟩ {⟨fp expr2 ⟩}
\fp_compare:nNnTF ⋆ \fp_compare:nNnTF {⟨fp expr1 ⟩} ⟨relation ⟩ {⟨fp expr2 ⟩} {⟨true code ⟩} {⟨false code ⟩}
Updated: 2012-05-08 Compares the ⟨fp expr1 ⟩ and the ⟨fp expr2 ⟩, and returns true if the ⟨relation ⟩ is
obeyed. Two floating points x and y may obey four mutually exclusive relations: x < y,
x = y, x > y, or x?y (“not ordered”). The last case occurs exactly if one or both operands
is nan or is a tuple, unless they are equal tuples. Note that a nan is distinct from any
value, even another nan, hence x = x is not true for a nan. To test if a value is nan,
compare it to an arbitrary number with the “not ordered” relation.
\fp_compare:nNnTF { <value> } ? { 0 }
{ } % <value> is nan
{ } % <value> is not nan
Tuples are equal if they have the same number of items and items compare equal (in
particular there must be no nan). At present any other comparison with tuples yields ?
(not ordered). This is experimental.
This function is less flexible than \fp_compare:nTF but slightly faster. It is provided
for consistency with \int_compare:nNnTF and \dim_compare:nNnTF.
260
\fp_compare_p:n ⋆ \fp_compare_p:n
\fp_compare:nTF ⋆ {
⟨fp expr1 ⟩ ⟨relation1 ⟩
Updated: 2013-12-14
...
⟨fp exprN ⟩ ⟨relationN ⟩
⟨fp exprN +1 ⟩
}
\fp_compare:nTF
{
⟨fp expr1 ⟩ ⟨relation1 ⟩
...
⟨fp exprN ⟩ ⟨relationN ⟩
⟨fp exprN +1 ⟩
}
{⟨true code ⟩} {⟨false code ⟩}
Evaluates the ⟨fp exprs ⟩ as described for \fp_eval:n and compares consecutive result
using the corresponding ⟨relation ⟩, namely it compares ⟨fp expr1 ⟩ and ⟨fp expr2 ⟩
using the ⟨relation1 ⟩, then ⟨fp expr2 ⟩ and ⟨fp expr3 ⟩ using the ⟨relation2 ⟩, until
finally comparing ⟨fp exprN ⟩ and ⟨fp exprN +1 ⟩ using the ⟨relationN ⟩. The test yields
true if all comparisons are true. Each ⟨floating point expression ⟩ is evaluated
only once. Contrarily to \int_compare:nTF, all ⟨fp exprs ⟩ are computed, even if one
comparison is false. Two floating points x and y may obey four mutually exclusive
relations: x < y, x = y, x > y, or x?y (“not ordered”). The last case occurs exactly if
one or both operands is nan or is a tuple, unless they are equal tuples. Each ⟨relation ⟩
can be any (non-empty) combination of <, =, >, and ?, plus an optional leading ! (which
negates the ⟨relation ⟩), with the restriction that the ⟨relation ⟩ may not start with ?,
as this symbol has a different meaning (in combination with :) within floating point
expressions. The comparison x ⟨relation ⟩ y is then true if the ⟨relation ⟩ does not
start with ! and the actual relation (<, =, >, or ?) between x and y appears within the
⟨relation ⟩, or on the contrary if the ⟨relation ⟩ starts with ! and the relation between
x and y does not appear within the ⟨relation ⟩. Common choices of ⟨relation ⟩ include
>= (greater or equal), != (not equal), !? or <=> (comparable).
This function is more flexible than \fp_compare:nNnTF and only slightly slower.
261
\fp_do_while:nNnn ✩ \fp_do_while:nNnn {⟨fp expr1 ⟩} ⟨relation ⟩ {⟨fp expr2 ⟩} {⟨code ⟩}
New: 2012-08-16 Places the ⟨code ⟩ in the input stream for TEX to process, and then evaluates the
relationship between the two ⟨floating point expressions ⟩ as described for \fp_-
compare:nNnTF. If the test is true then the ⟨code ⟩ is inserted into the input stream
again and a loop occurs until the ⟨relation ⟩ is false.
262
\fp_step_function:nnnN ✩ \fp_step_function:nnnN {⟨initial value ⟩} {⟨step ⟩} {⟨final value ⟩} ⟨function ⟩
\fp_step_function:nnnc ✩
This function first evaluates the ⟨initial value ⟩, ⟨step ⟩ and ⟨final value ⟩, each of
New: 2016-11-21 which should be a floating point expression evaluating to a floating point number, not a
Updated: 2016-12-06 tuple. The ⟨function ⟩ is then placed in front of each ⟨value ⟩ from the ⟨initial value ⟩
to the ⟨final value ⟩ in turn (using ⟨step ⟩ between each ⟨value ⟩). The ⟨step ⟩ must
be non-zero. If the ⟨step ⟩ is positive, the loop stops when the ⟨value ⟩ becomes larger
than the ⟨final value ⟩. If the ⟨step ⟩ is negative, the loop stops when the ⟨value ⟩
becomes smaller than the ⟨final value ⟩. The ⟨function ⟩ should absorb one numerical
argument. For example
TEXhackers note: Due to rounding, it may happen that adding the ⟨step ⟩ to the ⟨value ⟩
does not change the ⟨value ⟩; such cases give an error, as they would otherwise lead to an infinite
loop.
\fp_step_variable:nnnNn \fp_step_variable:nnnNn
{⟨initial value ⟩} {⟨step ⟩} {⟨final value ⟩} ⟨tl var ⟩ {⟨code ⟩}
New: 2017-04-12
This function first evaluates the ⟨initial value ⟩, ⟨step ⟩ and ⟨final value ⟩, all of
which should be floating point expressions evaluating to a floating point number, not a
tuple. Then for each ⟨value ⟩ from the ⟨initial value ⟩ to the ⟨final value ⟩ in turn
(using ⟨step ⟩ between each ⟨value ⟩), the ⟨code ⟩ is inserted into the input stream, with
the ⟨tl var ⟩ defined as the current ⟨value ⟩. Thus the ⟨code ⟩ should make use of the
⟨tl var ⟩.
263
\fp_show:n { \l_tmpb_fp }
\fp_show:N \l_tmpb_fp
\fp_set_variable:nn { A } { 0 }
\fp_show:n { \l_tmpb_fp }
\fp_show:N \l_tmpb_fp
defines A to be a variable, then defines \l_tmpb_fp to stand for 1*sin(A)+9 (note that
3**2 is evaluated, but the 1* product is not simplified away). Until \l_tmpb_fp is
changed, \fp_show:N \l_tmpb_fp will show ((1*sin(A))+9) regardless of the value
of A. The next step defines A to be equal to pi/2: then \fp_show:n { \l_tmpb_fp }
will evaluate \l_tmpb_fp and show 10. We then redefine A to be 0: since \l_tmpb_-
fp still stands for 1*sin(A)+9, the value shown is then 9. Variables can be set with
\fp_set_variable:nn to arbitrary floating point expressions including other variables.
\fp_new_variable:n { A }
\fp_new_variable:n { B }
\fp_new_variable:n { C }
\fp_set_variable:nn { A } { 3 }
\fp_set_variable:nn { C } { A ** 2 + B * 1 }
\fp_show:n { C + 4 }
\fp_set_variable:nn { A } { 4 }
\fp_show:n { C + 4 }
shows ((9+(B*1))+4) twice: changing the value of A to 4 does not alter C because A was
replaced by its value 3 when evaluating A**2+B*1.
264
\fp_clear_variable:n \fp_clear_variable:n {⟨identifier ⟩}
New: 2023-10-19 Removes any value given by \fp_set_variable:nn to the variable with this ⟨identifier ⟩.
For instance,
\fp_new_variable:n { A }
\fp_set_variable:nn { A } { 3 }
\fp_show:n { A ^ 2 }
\fp_clear_variable:n { A }
\fp_show:n { A ^ 2 }
shows (foo(3, foo(3), A))^(2). If the declaration was missing, the parser would
complain about an “Unknown fp word ’foo’”. The ⟨identifier ⟩ must consist entirely
of Latin letters [a-zA-Z].
265
29.8 Some useful constants, and scratch variables
\c_inf_fp Infinity, with either sign. These can be input directly in a floating point expression as
\c_minus_inf_fp inf and -inf.
New: 2012-05-08
\c_nan_fp Not a number. This can be input directly in a floating point expression as nan.
New: 2012-05-08
\c_pi_fp The value of π. This can be input directly in a floating point expression as pi.
Updated: 2013-11-17
\c_one_degree_fp The value of 1◦ in radians. Multiply an angle given in degrees by this value to obtain a
New: 2012-05-08 result in radians. Note that trigonometric functions expecting an argument in radians or
Updated: 2013-11-17 in degrees are both available. Within floating point expressions, this can be accessed as
deg.
\l_tmpa_fp Scratch floating points for local assignment. These are never used by the kernel code, and
\l_tmpb_fp so are safe for use with any LAT X3-defined function. However, they may be overwritten
E
by other non-kernel code and so should only be used for short-term storage.
\g_tmpa_fp Scratch floating points for global assignment. These are never used by the kernel code,
\g_tmpb_fp and so are safe for use with any LAT X3-defined function. However, they may be over-
E
written by other non-kernel code and so should only be used for short-term storage.
266
29.10 Floating point exceptions
The functions defined in this section are experimental, and their functionality may be
altered or removed altogether.
“Exceptions” may occur when performing some floating point operations, such as
0 / 0, or 10 ** 1e9999. The relevant IEEE standard defines 5 types of exceptions, of
which we implement 4.
• Overflow occurs whenever the result of an operation is too large to be represented
as a normal floating point number. This results in ±∞.
• Underflow occurs whenever the result of an operation is too close to 0 to be repre-
sented as a normal floating point number. This results in ±0.
• Invalid operation occurs for operations with no defined outcome, for instance 0/0
or sin(∞), and results in a nan. It also occurs for conversion functions whose target
type does not have the appropriate infinite or nan value (e.g., \fp_to_dim:n).
• Division by zero occurs when dividing a non-zero number by 0, or when evaluating
functions at poles, e.g., ln(0) or cot(0). This results in ±∞.
(not yet) Inexact occurs whenever the result of a computation is not exact, in other words,
almost always. At the moment, this exception is entirely ignored in LATEX3.
To each exception we associate a “flag”: fp_overflow, fp_underflow, fp_invalid_-
operation and fp_division_by_zero. The state of these flags can be tested and mod-
ified with commands from l3flag
By default, the “invalid operation” exception triggers an (expandable) error, and
raises the corresponding flag. Other exceptions raise the corresponding flag but do not
trigger an error. The behaviour when an exception occurs can be modified (using \fp_-
trap:nn) to either produce an error and raise the flag, or only raise the flag, or do nothing
at all.
• flag: the ⟨exception ⟩ will turn the corresponding flag on when it occurs;
• error: additionally, the ⟨exception ⟩ will halt the TEX run and display some
information about the current operation in the terminal.
This function is experimental, and may be altered or removed.
267
29.11 Viewing floating points
268
The result is thus ±0 if and only if ⟨significand ⟩ contains no non-zero digit (i.e.,
consists only in characters 0, and an optional period), or if there is an underflow. Note
that a single dot is currently a valid floating point number, equal to +0, but that is not
guaranteed to remain true.
The ⟨significand ⟩ must be non-empty, so e1 and e-1 are not valid floating point
numbers. Note that the latter could be mistaken with the difference of “e” and 1. To
avoid confusions, the base of natural logarithms cannot be input as e and should be input
as exp(1) or \c_e_fp (which is faster).
Special numbers are input as follows:
• inf represents +∞, and can be preceded by any ⟨sign ⟩, yielding ±∞ as appropri-
ate.
• nan represents a (quiet) non-number. It can be preceded by any sign, but that sign
is ignored.
269
The precedence of operations can be overridden using parentheses. In particular, the
precedence of juxtaposition implies that
1/2pi = 1/(2π),
1/2pi(pi + pi) = (2π)−1 (π + π) ≃ 1,
sin2pi = sin(2)π ̸= 0,
2ˆ2max(3, 5) = 22 max(3, 5) = 20,
1in/1cm = (1in)/(1cm) = 2.54.
Functions are called on the value of their argument, contrarily to TEX macros.
29.12.3 Operations
We now present the various operations allowed in floating point expressions, from the
lowest precedence to the highest. When used as a truth value, a floating point expression
is false if it is ±0, and true otherwise, including when it is nan or a tuple such as (0, 0).
Tuples are only supported to some extent by operations that work with truth values
(?:, ||, &&, !), by comparisons (!<=>?), and by +, -, *, /. Unless otherwise specified,
providing a tuple as an argument of any other operation yields the “invalid operation”
exception and a nan result.
\fp_eval:n
{
1 + 3 > 4 ? 1 :
2 + 4 > 5 ? 2 :
3 + 5 > 6 ? 3 : 4
}
first tests whether 1 + 3 > 4; since this isn’t true, the branch following : is taken, and
2 + 4 > 5 is compared; since this is true, the branch before : is taken, and everything else
is (evaluated then) ignored. That allows testing for various cases in a concise manner,
with the drawback that all computations are made in all cases.
270
< \fp_eval:n
= {
> ⟨operand1 ⟩ ⟨relation1 ⟩
? ...
⟨operandN ⟩ ⟨relationN ⟩
Updated: 2013-12-14
⟨operandN +1 ⟩
}
Each ⟨relation ⟩ consists of a non-empty string of <, =, >, and ?, optionally preceded
by !, and may not start with ?. This evaluates to +1 if all comparisons ⟨operandi ⟩
⟨relationi ⟩ ⟨operandi+1 ⟩ are true, and +0 otherwise. All ⟨operands ⟩ are evaluated
(once) in all cases. See \fp_compare:nTF for details.
+ \fp_eval:n { + ⟨operand ⟩ }
- \fp_eval:n { - ⟨operand ⟩ }
! \fp_eval:n { ! ⟨operand ⟩ }
The unary + does nothing, the unary - changes the sign of the ⟨operand ⟩ (for a tuple,
of all its components), and ! ⟨operand ⟩ evaluates to 1 if ⟨operand ⟩ is false (is ±0) and
0 otherwise (this is the not boolean function). Those operations never raise exceptions.
271
exp \fp_eval:n { exp( ⟨fp expr ⟩ ) }
Computes the exponential of the ⟨fp expr ⟩. “Underflow” and “overflow” occur when
appropriate. If the operand is a tuple, “invalid operation” occurs.
272
round \fp_eval:n { round ( ⟨fp expr ⟩ ) }
trunc \fp_eval:n { round ( ⟨fp expr1 ⟩ , ⟨fp expr2 ⟩ ) }
ceil \fp_eval:n { round ( ⟨fp expr1 ⟩ , ⟨fp expr2 ⟩ , ⟨fp expr3 ⟩ ) }
floor
Only round accepts a third argument. Evaluates ⟨fp expr1 ⟩ = x and ⟨fp expr2 ⟩ = n
New: 2013-12-14 and ⟨fp expr3 ⟩ = t then rounds x to n places. If n is an integer, this rounds x to a
Updated: 2015-08-08 multiple of 10−n ; if n = +∞, this always yields x; if n = −∞, this yields one of ±0, ±∞,
or nan; if n = nan, this yields nan; if n is neither ±∞ nor an integer, then an “invalid
operation” exception is raised. When ⟨fp expr2 ⟩ is omitted, n = 0, i.e., ⟨fp expr1 ⟩ is
rounded to an integer. The rounding direction depends on the function.
• round yields the multiple of 10−n closest to x, with ties (x half-way between two
such multiples) rounded as follows. If t is nan (or not given) the even multiple is
chosen (“ties to even”), if t = ±0 the multiple closest to 0 is chosen (“ties to zero”),
if t is positive/negative the multiple closest to ∞/−∞ is chosen (“ties towards
positive/negative infinity”).
• floor yields the largest multiple of 10−n smaller or equal to x (“round towards
negative infinity”);
• ceil yields the smallest multiple of 10−n greater or equal to x (“round towards
positive infinity”);
• trunc yields a multiple of 10−n with the same sign as x and with the largest
absolute value less than that of x (“round towards zero”).
“Overflow” occurs if x is finite and the result is infinite (this can only happen if
⟨fp expr2 ⟩ < −9984). If any operand is a tuple, “invalid operation” occurs.
273
sind \fp_eval:n { sind( ⟨fp expr ⟩ ) }
cosd \fp_eval:n { cosd( ⟨fp expr ⟩ ) }
tand \fp_eval:n { tand( ⟨fp expr ⟩ ) }
cotd \fp_eval:n { cotd( ⟨fp expr ⟩ ) }
cscd \fp_eval:n { cscd( ⟨fp expr ⟩ ) }
secd \fp_eval:n { secd( ⟨fp expr ⟩ ) }
New: 2013-11-02 Computes the sine, cosine, tangent, cotangent, cosecant, or secant of the ⟨fp expr ⟩
given in degrees. For arguments given in radians, see sin, cos, etc. Note that since π is
irrational, sin(8pi) is not quite zero, while its analogue sind(8 × 180) is exactly zero. The
trigonometric functions are undefined for an argument of ±∞, leading to the “invalid
operation” exception. Additionally, evaluating tangent, cotangent, cosecant, or secant at
one of their poles leads to a “division by zero” exception. “Underflow” and “overflow”
occur when appropriate. If the operand is a tuple, “invalid operation” occurs.
274
atan \fp_eval:n { atan( ⟨fp expr ⟩ ) }
acot \fp_eval:n { atan( ⟨fp expr1 ⟩ , ⟨fp expr2 ⟩ ) }
\fp_eval:n { acot( ⟨fp expr ⟩ ) }
New: 2013-11-02
\fp_eval:n { acot( ⟨fp expr1 ⟩ , ⟨fp expr2 ⟩ ) }
Those functions yield an angle in radians: atand and acotd are their analogs in de-
grees. The one-argument versions compute the arctangent or arccotangent of the ⟨fp
expr ⟩: arctangent takes values in the range [−π/2, π/2], and arccotangent in the range
[0, π]. The two-argument arctangent computes the angle in polar coordinates of the
point with Cartesian coordinates (⟨fp expr2 ⟩, ⟨fp expr1 ⟩): this is the arctangent of
⟨fp expr1 ⟩/⟨fp expr2 ⟩, possibly shifted by π depending on the signs of ⟨fp expr1 ⟩ and
⟨fp expr2 ⟩. The two-argument arccotangent computes the angle in polar coordinates of
the point (⟨fp expr1 ⟩, ⟨fp expr2 ⟩), equal to the arccotangent of ⟨fp expr1 ⟩/⟨fp expr2 ⟩,
possibly shifted by π. Both two-argument functions take values in the wider range [−π, π].
The ratio ⟨fp expr1 ⟩/⟨fp expr2 ⟩ need not be defined for the two-argument arctangent:
when both expressions yield ±0, or when both yield ±∞, the resulting angle is one
of {±π/4, ±3π/4} depending on signs. The “underflow” exception can occur. If any
operand is a tuple, “invalid operation” occurs.
275
rand \fp_eval:n { rand() }
New: 2016-12-05 Produces a pseudo-random floating-point number (multiple of 10−16 ) between 0 included
and 1 excluded. This is not available in older versions of XETEX. The random seed can
be queried using \sys_rand_seed: and set using \sys_gset_rand_seed:n.
TEXhackers note: This is based on pseudo-random numbers provided by the engine’s
primitive \pdfuniformdeviate in pdfTEX, pTEX, upTEX and \uniformdeviate in LuaTEX and
XETEX. The underlying code is based on Metapost, which follows an additive scheme recom-
mended in Section 3.6 of “The Art of Computer Programming, Volume 2”.
While we are more careful than \uniformdeviate to preserve uniformity of the underlying
stream of 28-bit pseudo-random integers, these pseudo-random numbers should of course not be
relied upon for serious numerical computations nor cryptography.
inf The special values +∞, −∞, and nan are represented as inf, -inf and nan (see \c_-
nan inf_fp, \c_minus_inf_fp and \c_nan_fp).
276
em Those units of measurement are equal to their values in pt, namely
ex
in 1 in = 72.27 pt
pt
1 pt = 1 pt
pc
cm 1 pc = 12 pt
mm 1
dd 1 cm = in = 28.45275590551181 pt
2.54
cc 1
nd 1 mm = in = 2.845275590551181 pt
nc
25.4
bp 1 dd = 0.376065 mm = 1.07000856496063 pt
sp 1 cc = 12 dd = 12.84010277952756 pt
1 nd = 0.375 mm = 1.066978346456693 pt
1 nc = 12 nd = 12.80374015748031 pt
1
1 bp = in = 1.00375 pt
72
1 sp = 2−16 pt = 1.52587890625 × 10−5 pt.
The values of the (font-dependent) units em and ex are gathered from TEX when the
surrounding floating point expression is evaluated.
277
• Support signalling nan.
• Modulo and remainder, and rounding function quantize (and its friends analogous
to trunc, ceil, floor).
• \fp_format:nn {⟨fp expr ⟩} {⟨format ⟩}, but what should ⟨format ⟩ be? More
general pretty printing?
• Add and, or, xor? Perhaps under the names all, any, and xor?
• Add log(x, b) for logarithm of x in base b.
• hypot (Euclidean length). Cartesian-to-polar transform.
• Hyperbolic functions cosh, sinh, tanh.
• Inverse hyperbolics.
• Base conversion, input such as 0xAB.CDEF.
• Factorial (not with !), gamma function.
• Improve coefficients of the sin and tan series.
• Treat upper and lower case letters identically in identifiers, and ignore underscores.
• Add an array(1,2,3) and i=complex(0,1).
• Provide an experimental map function? Perhaps easier to implement if it is a single
character, @sin(1,2)?
• Provide an isnan function analogue of \fp_if_nan:nTF?
• Support keyword arguments?
Pgfmath also provides box-measurements (depth, height, width), but boxes are not pos-
sible expandably.
Bugs, and tests to add.
• Check that functions are monotonic when they should.
• Add exceptions to ?:, !<=>?, &&, ||, and !.
• Logarithms of numbers very close to 1 are inaccurate.
• When rounding towards −∞, \dim_to_fp:n {0pt} should return −0, not +0.
• The result of (±0) + (±0), of x + (−x), and of (−x) + x should depend on the
rounding mode.
• 0e9999999999 gives a TEX “number too large” error.
• Subnormals are not implemented.
Possible optimizations/improvements.
• Document that l3trial/l3fp-types introduces tools for adding new types.
• In subsection 29.12.1, write a grammar.
278
• It would be nice if the parse auxiliaries for each operation were set up in the
corresponding module, rather than centralizing in l3fp-parse.
• Some functions should get an _o ending to indicate that they expand after their
result.
• More care should be given to distinguish expandable/restricted expandable (auxil-
iary and internal) functions.
• The code for the ternary set of functions is ugly.
279
Chapter 30
280
Chapter 31
A category code table enables rapid switching of all category codes in one operation. For
LuaTEX, this is possible over the entire Unicode range. For other engines, only the 8-bit
range (0–255) is covered by such tables. The implementation of category code tables in
expl3 also saves and restores the TEX \endlinechar primitive value, meaning they could
be used for example to implement \ExplSyntaxOn.
281
31.2 Using category code tables
\cctab_end: \cctab_end:
Updated: 2020-07-02 Ends the scope of a ⟨category code table ⟩ started using \cctab_begin:N, returning
the codes to those in force before the matching \cctab_begin:N was used. This must
be used within the same TEX group (and at the same TEX group level) as the matching
\cctab_begin:N.
\c_code_cctab Category code table for the expl3 code environment; this does not include @, which is
Updated: 2020-07-10 retained as an “other” character. Sets the \endlinechar value to 32 (a space).
\c_document_cctab Category code table for a standard LATEX document, as set by the LATEX kernel. In
Updated: 2020-07-08 particular, the upper-half of the 8-bit range will be set to “active” with pdfTEX only.
No babel shorthands will be activated. Sets the \endlinechar value to 13 (normal line
ending).
282
\c_initex_cctab Category code table as set up by iniTEX.
Updated: 2020-07-02
\c_other_cctab Category code table where all characters have category code 12 (other). Sets the
Updated: 2020-07-02 \endlinechar value to −1.
\c_str_cctab Category code table where all characters have category code 12 (other) with the exception
Updated: 2020-07-02 of spaces, which have category code 10 (space). Sets the \endlinechar value to −1.
283
Part V
Text manipulation
284
Chapter 32
This module provides Unicode-specific functions along with loading data from a range
of Unicode Consortium files. Most of the code here is internal, but there are a small set
of public functions. These work with Unicode ⟨codepoints ⟩ and are designed to give
useable results with both Unicode-aware and 8-bit engines.
285
\codepoint_generate:nn ⋆ \codepoint_generate:nn {⟨codepoint ⟩} {⟨catcode ⟩}
New: 2022-10-09 Generates one or more character tokens representing the ⟨codepoint ⟩. With Unicode
Updated: 2022-11-09 engines, exactly one character token will be generated, and this will have the ⟨catcode ⟩
specified as the second argument:
• 1 (begin group)
• 2 (end group)
• 3 (math toggle)
• 4 (alignment)
• 6 (parameter)
• 7 (math superscript)
• 8 (math subscript)
• 10 (space)
• 11 (letter)
• 12 (other)
• 13 (active)
For 8-bit engines, between one and four character tokens will be produced: these will be
the bytes of the UTF-8 representation of the ⟨codepoint ⟩. For all codepoints outside of
the classical ASCII range, the generated character tokens will be active (category code
13); for codepoints in the ASCII range, the given ⟨catcode ⟩ will be used. To allow the
result of this function to be used inside a expansion context, the result is protected by
\exp_not:n.
TEXhackers note: Users of (u)pTEX note that these engines are treated as 8-bit in this
context. In particular, for upTEX, irrespective of the \kcatcode of the ⟨codepoint ⟩, any value
outside the ASCII range will result in a series of active bytes being generated.
Generates one or more character tokens representing the ⟨codepoint ⟩. With Unicode
engines, exactly one character token will be generated. For 8-bit engines, between one
and four character tokens will be produced: these will be the bytes of the UTF-8 repre-
sentation of the ⟨codepoint ⟩. All of the generated character tokens will be of category
code 12, except any spaces (codepoint 32), which will be category code 10.
286
\codepoint_to_category:n ⋆ \codepoint_to_category:n {⟨codepoint ⟩}
New: 2023-06-19 Expands to the Unicode general category identifier of the ⟨codepoint ⟩. The general
category identifier is a string made up of two letter characters, the first uppercase and
the second lowercase. The uppercase letters divide codepoints into broader groups, which
are then refined by the lowercase letter. For example, codepoints representing letters all
have identifiers starting L, for example Lu (uppercase letter), Lt (titlecase letter), etc.
Full details are available in the documentation provided by the Unicode Consortium: see
https://www.unicode.org/reports/tr44/#General_Category_Values
287
Chapter 33
This module deals with manipulation of (formatted) text; such material is comprised of
a restricted set of token list content. The functions provided here concern conversion of
textual content for example in case changing, generation of bookmarks and extraction
to tags. All of the major functions operate by expansion. Begin-group and end-group
tokens in the ⟨text ⟩ are normalized and become { and }, respectively.
Declares that the ⟨replacement ⟩ tokens should be used whenever the ⟨cmd ⟩ (a single
token) is encountered. The ⟨replacement ⟩ tokens should be expandable. A token can
be “replaced” by itself if the defined replacement wraps it in \exp_not:n, for example
\text_declare_expand_equivalent:Nn \’ { \exp_not:n { \’ } }
288
33.2 Case changing
Upper- and lowercase have the obvious meanings. Titlecasing may be regarded
informally as converting the first character of the ⟨tokens ⟩ to uppercase. However, the
process is more complex than this as there are some situations where a single lowercase
character maps to a special form, for example ij in Dutch which becomes IJ. There are
two functions available for titlecasing: one which applies the change to each “word” and a
second which only applies at the start of the input. (Here, “word” boundaries are spaces:
at present, full Unicode word breaking is not attempted.)
Importantly, notice that these functions are intended for working with user text for
typesetting. For case changing programmatic data see the l3str module and discussion
there of \str_lowercase:n, \str_uppercase:n and \str_casefold:n.
Case changing does not take place within math mode material so for example
\text_uppercase:n { Some~text~$y = mx + c$~with~{Braces} }
becomes
SOME TEXT $y = mx + c$ WITH {BRACES}
The first mandatory argument of commands listed in \l_text_case_exclude_arg_-
tl is excluded from case changing; the latter are entirely non-textual content (such as
labels).
The standard mappings here follow those defined by the Unicode Consortium in
UnicodeData.txt and SpecialCasing.txt. For pTEX, only the ASCII range is covered
as the engine treats input outside of this range as east Asian.
Locale-sensitive conversions are enabled using the ⟨BCP-47⟩ argument, and follow
Unicode Consortium guidelines. Currently, the locale strings recognized for special han-
dling are as follows.
• Armenian (hy and hy-x-yiwn) The setting hy maps the codepoint U+0587, the
ligature of letters ech and yiwn, to the codepoints for capital ech and vew when
uppercasing: this follows the spelling reform which is used in Armenia. The alter-
native hy-x-yiwn maps U+0587 to capital ech and yiwn on uppercasing (also the
output if Armenian is not selected at all).
• Azeri and Turkish (az and tr). The case pairs I/i-dotless and I-dot/i are activated
for these languages. The combining dot mark is removed when lowercasing I-dot
and introduced when upper casing i-dotless.
• German (de-x-eszett). An alternative mapping for German in which the lower-
case Eszett maps to a großes Eszett.
289
• Greek (el). Removes accents from Greek letters when uppercasing; titlecasing
leaves accents in place. A variant el-x-iota is available which converts the ypoge-
grammeni (subscript muted iota) to capital iota when uppercasing: the standard
version retains the subscript versions.
• Lithuanian (lt). The lowercase letters i and j should retain a dot above when the
accents grave, acute or tilde are present. This is implemented for lowercasing of the
relevant uppercase letters both when input as single Unicode codepoints and when
using combining accents. The combining dot is removed when uppercasing in these
cases. Note that only the accents used in Lithuanian are covered: the behaviour of
other accents are not modified.
• Medieval Latin (la-x-medieval). The characters u and V are interchanged on case
changing.
Declares that the ⟨replacement ⟩ tokens should be used whenever the ⟨cmd ⟩ (a single
token) is encountered during case changing.
Declares that the ⟨replacement ⟩ tokens should be used when case mapping the
⟨codepoint ⟩, rather than the standard mapping given in the Unicode data files. The
nnn version takes a BCP-47 tag, which can be used to specify that the customisation
only applies to that locale.
290
33.3 Removing formatting from text
Declares that the ⟨replacement ⟩ tokens should be used whenever the ⟨cmd ⟩ (a single
token) is encountered. The ⟨replacement ⟩ tokens should be expandable.
\l_text_math_arg_tl Lists commands present in the ⟨text ⟩ where the argument of the command should
be treated as math mode material. The treatment here is similar to \l_text_math_-
delims_tl but for a command rather than paired delimiters.
\l_text_math_delims_tl Lists pairs of tokens which delimit (in-line) math mode content; such content may be
excluded from processing.
\l_text_case_exclude_arg_tl
Lists commands where the first mandatory argument is excluded from case changing.
\l_text_expand_exclude_tl Lists commands which are excluded from expansion. This protection includes everything
up to and including their first braced argument.
\l_text_titlecase_check_letter_bool
Controls how the start of titlecasing is handled: when true, the first letter in text is
considered. The standard setting is true.
291
33.5 Mapping to graphemes
Grapheme splitting is implemented using the algorithm described in Unicode Standard
Annex #29. This includes support for extended grapheme clusters. Text starting with a
line feed or carriage return character will drop this due to standard TEX processing. At
present extended pictograms are not supported: these may be added in a future release.
\text_map_break: ✩ \text_map_break:
\text_map_break:n ✩ \text_map_break:n {⟨code ⟩}
New: 2022-08-04 Used to terminate a \text_map_... function before all entries in the ⟨text ⟩ have been
processed. This normally takes place within a conditional statement.
292
Part VI
Typesetting
293
Chapter 34
Box variables contain typeset material that can be inserted on the page or in other
boxes. Their contents cannot be converted back to lists of tokens. There are three
kinds of box operations: horizontal mode denoted with prefix \hbox_, vertical mode
with prefix \vbox_, and the generic operations working in both modes with prefix \box_.
For instance, a new box variable containing the words “Hello, world!” (in a horizontal
box) can be obtained by the following code.
\box_new:N \l_hello_box
\hbox_set:Nn \l_hello_box { Hello, ~ world! }
The argument is typeset inside a TEX group so that any variables assigned during the
construction of this box restores its value afterwards.
Box variables from l3box are compatible with those of LATEX 2ε and plain TEX and
can be used interchangeably. The l3box commands to construct boxes, such as \hbox:n
or \hbox_set:Nn, are “color-safe”, meaning that
\hbox:n { \color_select:n { blue } Hello, } ~ world!
will result in “Hello,” taking the color blue, but “world!” remaining with the prevailing
color outside the box.
294
\box_clear_new:N \box_clear_new:N ⟨box ⟩
\box_clear_new:c
Ensures that the ⟨box ⟩ exists globally by applying \box_new:N if necessary, then applies
\box_gclear_new:N
\box_gclear_new:c \box_(g)clear:N to leave the ⟨box ⟩ empty.
295
34.3 Measuring and setting box dimensions
296
34.4 Box conditionals
\c_empty_box This is a permanently empty box, which is neither set as horizontal nor vertical.
Updated: 2012-11-04
TEXhackers note: At the TEX level this is a void box.
\l_tmpa_box Scratch boxes for local assignment. These are never used by the kernel code, and so are
\l_tmpb_box safe for use with any LATEX3-defined function. However, they may be overwritten by
Updated: 2012-11-04 other non-kernel code and so should only be used for short-term storage.
\g_tmpa_box Scratch boxes for global assignment. These are never used by the kernel code, and so
\g_tmpb_box are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
other non-kernel code and so should only be used for short-term storage.
297
34.8 Viewing box contents
298
\hbox_set_to_wd:Nnn \hbox_set_to_wd:Nnn ⟨box ⟩ {⟨dim expr ⟩} {⟨contents ⟩}
\hbox_set_to_wd:cnn
Typesets the ⟨contents ⟩ to the width given by the ⟨dim expr ⟩ and then stores the result
\hbox_gset_to_wd:Nnn
\hbox_gset_to_wd:cnn inside the ⟨box ⟩.
Updated: 2017-04-05
299
_top boxes, where the reference point is that of the first item added. These tend to have
a large depth and small height, although the latter is typically non-zero.
Updated: 2017-04-05
300
\vbox_set_to_ht:Nnw \vbox_set_to_ht:Nnw ⟨box ⟩ {⟨dim expr ⟩} ⟨contents ⟩ \vbox_set_end:
\vbox_set_to_ht:cnw
Typesets the ⟨contents ⟩ to the height given by the ⟨dim expr ⟩ and then stores the result
\vbox_gset_to_ht:Nnw
\vbox_gset_to_ht:cnw inside the ⟨box ⟩. In contrast to \vbox_set_to_ht:Nnn this function does not absorb the
argument when finding the ⟨content ⟩, and so can be used in circumstances where the
New: 2017-06-08
⟨content ⟩ may not be a simple argument
Sets ⟨box1 ⟩ to contain material to the height given by the ⟨dim expr ⟩ by removing
content from the top of ⟨box2 ⟩ (which must be a vertical box).
301
\box_use_drop:N \box_use_drop:N ⟨box ⟩
\box_use_drop:c
Inserts the current content of the ⟨box ⟩ onto the current list for typesetting then drops
the box content. An error is raised if the variable does not exist or if it is invalid. This
function may be applied to local or global boxes.
302
\box_autosize_to_wd_and_ht:Nnn \box_autosize_to_wd_and_ht:Nnn ⟨box ⟩ {⟨x-size ⟩} {⟨y-size ⟩}
\box_autosize_to_wd_and_ht:cnn
\box_gautosize_to_wd_and_ht:Nnn
\box_gautosize_to_wd_and_ht:cnn
New: 2017-04-04
Updated: 2019-01-22
Resizes the ⟨box ⟩ to fit within the given ⟨x-size ⟩ (horizontally) and ⟨y-size ⟩ (verti-
cally); both of the sizes are dimension expressions. The ⟨y-size ⟩ is the height only: it
does not include any depth. The updated ⟨box ⟩ is an hbox, irrespective of the nature
of the ⟨box ⟩ before the resizing is applied. The final size of the ⟨box ⟩ is the smaller of
{⟨x-size ⟩} and {⟨y-size ⟩}, i.e. the result fits within the dimensions specified. Negative
sizes cause the material in the ⟨box ⟩ to be reversed in direction, but the reference point
of the ⟨box ⟩ is unchanged. Thus a negative ⟨y-size ⟩ results in the ⟨box ⟩ having a depth
dependent on the height of the original and vice versa.
Resizes the ⟨box ⟩ to fit within the given ⟨x-size ⟩ (horizontally) and ⟨y-size ⟩ (verti-
cally); both of the sizes are dimension expressions. The ⟨y-size ⟩ is the total vertical size
(height plus depth). The updated ⟨box ⟩ is an hbox, irrespective of the nature of the ⟨box ⟩
before the resizing is applied. The final size of the ⟨box ⟩ is the smaller of {⟨x-size ⟩}
and {⟨y-size ⟩}, i.e. the result fits within the dimensions specified. Negative sizes cause
the material in the ⟨box ⟩ to be reversed in direction, but the reference point of the ⟨box ⟩
is unchanged. Thus a negative ⟨y-size ⟩ results in the ⟨box ⟩ having a depth dependent
on the height of the original and vice versa.
303
\box_resize_to_ht_plus_dp:Nn \box_resize_to_ht_plus_dp:Nn ⟨box ⟩ {⟨y-size ⟩}
\box_resize_to_ht_plus_dp:cn
\box_gresize_to_ht_plus_dp:Nn
\box_gresize_to_ht_plus_dp:cn
Updated: 2019-01-22
Resizes the ⟨box ⟩ to ⟨y-size ⟩ (vertically), scaling the horizontal size by the same amount;
⟨y-size ⟩ is a dimension expression. The ⟨y-size ⟩ is the total vertical size (height plus
depth). The updated ⟨box ⟩ is an hbox, irrespective of the nature of the ⟨box ⟩ before the
resizing is applied. A negative ⟨y-size ⟩ causes the material in the ⟨box ⟩ to be reversed
in direction, but the reference point of the ⟨box ⟩ is unchanged. Thus a negative ⟨y-size ⟩
results in the ⟨box ⟩ having a depth dependent on the height of the original and vice versa.
Resizes the ⟨box ⟩ to ⟨x-size ⟩ (horizontally) and ⟨y-size ⟩ (vertically): both of the sizes
are dimension expressions. The ⟨y-size ⟩ is the height only and does not include any
depth. The updated ⟨box ⟩ is an hbox, irrespective of the nature of the ⟨box ⟩ before
the resizing is applied. Negative sizes cause the material in the ⟨box ⟩ to be reversed in
direction, but the reference point of the ⟨box ⟩ is unchanged. Thus a negative ⟨y-size ⟩
results in the ⟨box ⟩ having a depth dependent on the height of the original and vice versa.
Resizes the ⟨box ⟩ to ⟨x-size ⟩ (horizontally) and ⟨y-size ⟩ (vertically): both of the sizes
are dimension expressions. The ⟨y-size ⟩ is the total vertical size (height plus depth).
The updated ⟨box ⟩ is an hbox, irrespective of the nature of the ⟨box ⟩ before the resizing
is applied. Negative sizes cause the material in the ⟨box ⟩ to be reversed in direction, but
the reference point of the ⟨box ⟩ is unchanged. Thus a negative ⟨y-size ⟩ results in the
⟨box ⟩ having a depth dependent on the height of the original and vice versa.
304
\box_rotate:Nn \box_rotate:Nn ⟨box ⟩ {⟨angle ⟩}
\box_rotate:cn
Rotates the ⟨box ⟩ by ⟨angle ⟩ (in degrees) anti-clockwise about its reference point. The
\box_grotate:Nn
\box_grotate:cn reference point of the updated box is moved horizontally such that it is at the left side
of the smallest rectangle enclosing the rotated material. The updated ⟨box ⟩ is an hbox,
Updated: 2019-01-22
irrespective of the nature of the ⟨box ⟩ before the rotation is applied.
305
34.15 Primitive box conditionals
306
Chapter 35
The material in this module provides the low-level support system for coffins. For details
about the design concept of a coffin, see the xcoffins module (in the l3experimental bundle).
307
35.2 Setting coffin content and poles
Sets the ⟨pole ⟩ to run horizontally through the ⟨coffin ⟩. The ⟨pole ⟩ is placed at
the ⟨offset ⟩ from the baseline of the ⟨coffin ⟩. The ⟨offset ⟩ should be given as a
dimension expression.
308
\coffin_set_vertical_pole:Nnn \coffin_set_vertical_pole:Nnn ⟨coffin ⟩ {⟨pole ⟩} {⟨offset ⟩}
\coffin_set_vertical_pole:cnn
\coffin_gset_vertical_pole:Nnn
\coffin_gset_vertical_pole:cnn
New: 2012-07-20
Updated: 2019-01-21
Sets the ⟨pole ⟩ to run vertically through the ⟨coffin ⟩. The ⟨pole ⟩ is placed at the
⟨offset ⟩ from the left-hand edge of the bounding box of the ⟨coffin ⟩. The ⟨offset ⟩
should be given as a dimension expression.
309
35.4 Joining and using coffins
\coffin_attach:NnnNnnnn \coffin_attach:NnnNnnnn
\coffin_attach:(cnnNnnnn|Nnncnnnn|cnncnnnn) ⟨coffin1 ⟩ {⟨coffin1 -pole1 ⟩} {⟨coffin1 -pole2 ⟩}
\coffin_gattach:NnnNnnnn ⟨coffin2 ⟩ {⟨coffin2 -pole1 ⟩} {⟨coffin2 -pole2 ⟩}
\coffin_gattach:(cnnNnnnn|Nnncnnnn|cnncnnnn) {⟨x-offset ⟩} {⟨y-offset ⟩}
Updated: 2019-01-22
This function attaches ⟨coffin2 ⟩ to ⟨coffin1 ⟩ such that the bounding box of ⟨coffin1 ⟩
is not altered, i.e. ⟨coffin2 ⟩ can protrude outside of the bounding box of the coffin.
The alignment is carried out by first calculating ⟨handle1 ⟩, the point of intersection
of ⟨coffin1 -pole1 ⟩ and ⟨coffin1 -pole2 ⟩, and ⟨handle2 ⟩, the point of intersection of
⟨coffin2 -pole1 ⟩ and ⟨coffin2 -pole2 ⟩. ⟨coffin2 ⟩ is then attached to ⟨coffin1 ⟩ such
that the relationship between ⟨handle1 ⟩ and ⟨handle2 ⟩ is described by the ⟨x-offset ⟩
and ⟨y-offset ⟩. The two offsets should be given as dimension expressions.
\coffin_join:NnnNnnnn \coffin_join:NnnNnnnn
\coffin_join:(cnnNnnnn|Nnncnnnn|cnncnnnn) ⟨coffin1 ⟩ {⟨coffin1 -pole1 ⟩} {⟨coffin1 -pole2 ⟩}
\coffin_gjoin:NnnNnnnn ⟨coffin2 ⟩ {⟨coffin2 -pole1 ⟩} {⟨coffin2 -pole2 ⟩}
\coffin_gjoin:(cnnNnnnn|Nnncnnnn|cnncnnnn) {⟨x-offset ⟩} {⟨y-offset ⟩}
Updated: 2019-01-22
This function joins ⟨coffin2 ⟩ to ⟨coffin1 ⟩ such that the bounding box of ⟨coffin1 ⟩
may expand. The new bounding box covers the area containing the bounding boxes of
the two original coffins. The alignment is carried out by first calculating ⟨handle1 ⟩, the
point of intersection of ⟨coffin1 -pole1 ⟩ and ⟨coffin1 -pole2 ⟩, and ⟨handle2 ⟩, the point
of intersection of ⟨coffin2 -pole1 ⟩ and ⟨coffin2 -pole2 ⟩. ⟨coffin2 ⟩ is then attached to
⟨coffin1 ⟩ such that the relationship between ⟨handle1 ⟩ and ⟨handle2 ⟩ is described by the
⟨x-offset ⟩ and ⟨y-offset ⟩. The two offsets should be given as dimension expressions.
310
\coffin_ht:N \coffin_ht:N ⟨coffin ⟩
\coffin_ht:c
Calculates the height (above the baseline) of the ⟨coffin ⟩ in a form suitable for use in
a ⟨dim expr ⟩.
311
\coffin_show:Nnn \coffin_show:Nnn ⟨coffin ⟩ {⟨int expr1 ⟩} {⟨int expr2 ⟩}
\coffin_show:cnn \coffin_log:Nnn ⟨coffin ⟩ {⟨int expr1 ⟩} {⟨int expr2 ⟩}
\coffin_log:Nnn
Shows poles and contents of the ⟨coffin ⟩ in the terminal or log file, showing the first ⟨int
\coffin_log:cnn
expr1 ⟩ items in the coffin, and descending into ⟨int expr2 ⟩ group levels. See \coffin_-
New: 2021-05-11 show_structure:N and \box_show:Nnn to show separately the pole structure and the
contents.
\l_tmpa_coffin Scratch coffins for local assignment. These are never used by the kernel code, and so
\l_tmpb_coffin are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
New: 2012-06-19 other non-kernel code and so should only be used for short-term storage.
\g_tmpa_coffin Scratch coffins for global assignment. These are never used by the kernel code, and so
\g_tmpb_coffin are safe for use with any LAT X3-defined function. However, they may be overwritten by
E
New: 2019-01-24 other non-kernel code and so should only be used for short-term storage.
312
Chapter 36
\color_group_begin: \color_group_begin:
\color_group_end: ...
\color_group_end:
New: 2011-09-03
Creates a color group: one used to “trap” color settings. This grouping is built in to for
example \hbox_set:Nn.
\color_ensure_current: \color_ensure_current:
New: 2011-09-03 Ensures that material inside a box uses the foreground color at the point where the box
is set, rather than that in force when the box is used. This function should usually be
used within a \color_group_begin: . . . \color_group_end: group.
313
• cmyk Cyan-magenta-yellow-black color, with four axes, one for each of the compo-
nents
There are also interface models: these are convenient for users but have to be manipu-
lated before storing/passing to the backend. Interface models are primarily integer-based:
see below for more detail. The supported interface models are
• Gray Grayscale color, with a single axis running from 0 (fully black) to 15 (fully
white)
• hsb Hue-saturation-brightness color, with three axes,all real values in the range
[0, 1] for hue saturation and brightness
• Hsb Hue-saturation-brightness color, with three axes, integer in the range [0, 360]
for hue, real values in the range [0, 1] for saturation and brightness
• HSB Hue-saturation-brightness color, with three axes, integers in the range [0, 240]
for hue, saturation and brightness
• HTML HTML format representation of RGB color given as a single six-digit hexadec-
imal number
• RGB Red-green-blue color, with three axes, one for each of the components, values
as integers from 0 to 255
• wave Light wavelength, a real number in the range 380 to 780 (nanometres)
All interface models are internally stored as rgb.
Finally, there are a small number of models which are parsed to allow data transfer
from xcolor but which should not be used by end-users. These are
• cmy Cyan-magenta-yellow color with three axes, one for each of the components;
converted to cmyk
• tHsb “Tuned” hue-saturation-brightness color with three axes, integer in the range
[0, 360] for hue, real values in the range [0, 1] for saturation and brightness; converted
to rgb using the standard tuning map defined by xcolor
• &spot Spot color tint with one value; treated as a gray tint as spot color data is
not available for extraction
To allow parsing of data from xcolor, any leading model up the first : will be
discarded; the approach of selecting an internal form for data is not used in l3color.
Additional models may be created to allow mixing of separation colors with each
other or with those from other models. See Section 36.9 for more detail of color support
for additional models.
When color is selected by model, the ⟨values ⟩ given are specified as a comma-
separated list. The length of the list will therefore be determined by the detail of the
model involved.
Color models (and interconversion) are complex, and more details are given in the
manual to the LATEX 2ε xcolor package and in the PostScript Language Reference Manual,
published by Addison–Wesley.
314
36.3 Color expressions
In addition to allowing specification of color by model and values, l3color also supports
color expressions. These are created by combining one or more color names, with the
amount of each specified as a value in the range 0–100. The value should be given between
! symbols in the expression. Thus for example
red!50!green
is a mixture of 50 % red and 50 % green. A trailing value is interpreted as implicitly
followed by !white, and so
red!25
will result in a color specification using the rgb model, made up of 50 % red and 50 %
of cyan expressed in rgb. This may be important as color model interconversion is not
exact.
The one exception to the above is where the first model in an expression is gray. In
this case, the order of mixing is “swapped” internally, so that for example
black!50!red
has the same result as
red!50!black
(the predefined colors black and white use the gray model).
Where more than two colors are mixed in an expression, evaluation takes place in a
stepwise fashion. Thus in
cyan!50!magenta!10!yellow
the sub-expression
cyan!50!magenta
is first evaluated to give an intermediate color specification, before the second step
<intermediate>!10!yellow
where <intermediate> represents this transitory calculated value.
Within a color expression, . may be used to represent the color active for typesetting
(the current color). This allows for example
.!50
to mean a mixture of 50 % of current color with white.
(Color expressions supported here are a subset of those provided by the LATEX 2ε
xcolor package. At present, only such features as are clearly useful have been added
here.)
315
36.4 Named colors
Color names are stored in a single namespace, which makes them accessible as part of
color expressions. Whilst they are not reserved in a technical sense, the names black,
white, red, green, blue, cyan, magenta and yellow have special meaning and should
not be redefined. Color names should be made up of letters, numbers and spaces only:
other characters are reserved for use in color expressions. In particular, . represents the
current color at the start of a color expression.
\l_color_fixed_model_tl When this is set to a non-empty value, colors will be converted to the specified model
when they are selected. Note that included images and similar are not influenced by this
setting.
316
36.6 Colors for fills and strokes
Colors for drawing operations and so forth are split into strokes and fills (the latter may
also be referred to as non-stroke color). The fill color is used for text under normal
circumstances. Depending on the backend, stroke color may use a stack, in which case
it exhibits the same page breaking behavior as general color. However, dvips/dvisvgm
do not support this, and so color will need to be contained within a scope, such as
\draw_begin:/\draw_end:.
color.sc When using dvips, this PostScript variables hold the stroke color.
\l_color_math_active_tl This list controls which tokens are considered as math active and should therefore be
New: 2022-01-26 replaced by their definition during searching for sub/superscripts.
317
The manually-specified conversion will be used in preference to automated calculation
whenever the model(s) listed are used: both in expressions and when a fixed model is
active.
Similarly, the same syntax can be applied to directly selecting a color.
\color_select:nn { cmyk / rgb }
{ 0.1 , 0.2 , 0.3 , 0.4 / 0.1, 0.2 , 0.3 }
Again, this list is used when a fixed model is active: the first entry is used unless there
is a fixed model matching one of the other entries.
318
36.9 Creating new color models
Additional color models are required to support specialist workflows, for example those in-
volving separations (see https://helpx.adobe.com/indesign/using/spot-process-colors.
html for details of the use of separations in print). Color models may be split into fami-
lies; for the standard device-based color models (DeviceCMYK, DeviceRGB, DeviceGray),
these are synonymous. This is not generally the case: see the PDF reference for more
details. (Note that l3color uses the shorter names cmyk, etc.)
(The ⟨family ⟩ may be given in mixed case as-in the PDF reference: internally, case of
these strings is folded.) Depending on the ⟨family ⟩, one or more ⟨params ⟩ are mandatory
or optional.
For a Separation space, there are three compulsory keys.
• name The name of the Separation, for example the formal name of a spot color ink.
Such a ⟨name ⟩ may contain spaces, etc., which are not permitted in the ⟨model ⟩.
• alternative-model An alternative device colorspace, one of cmyk, rgb, gray or
CIELAB. The three parameter-based models work as described above; see below for
details of CIELAB colors.
319
36.9.1 Color profiles
Color profiles are used to ensure color accuracy by linking to collaboration. Applying a
profile can be used to standardise color which is otherwise device-dependence.
320
Chapter 37
37.1 Objects
321
\pdf_object_unnamed_write:nn \pdf_object_unnamed_write:nn {⟨type ⟩} {⟨content ⟩}
\pdf_object_unnamed_write:ne
New: 2021-02-10
Writes the ⟨content ⟩ as content of an anonymous object. Depending on the ⟨type ⟩, the
format required for the ⟨data ⟩ will vary
array A space-separated list of values
dict Key–value pairs in the form /⟨key ⟩ ⟨value ⟩
\pdf_object_ref_last: ⋆ \pdf_object_ref_last:
New: 2021-02-10 Inserts the appropriate information to reference the last ⟨object ⟩ created. This is par-
ticularly useful for anonymous objects.
37.2 Version
Compares the version of the PDF being created with the ⟨version ⟩ string specified,
using the ⟨comparator ⟩. Either the ⟨true code ⟩ or ⟨false code ⟩ will be left in the
output stream.
\pdf_version: ⋆ \pdf_version:
\pdf_version_major: ⋆
Expands to the currently-active PDF version.
\pdf_version_minor: ⋆
New: 2021-02-10
322
37.3 Page (media) size
37.4 Compression
\pdf_uncompress: \pdf_uncompress:
New: 2021-02-10 Disables any compression of the PDF, where possible.
This function may only be used up to the point where the PDF file is initialised.
37.5 Destinations
Destinations are the places a link jumped too. Unlike the name may suggest they don’t
described an exact location in the PDF. Instead a destination contains a reference to a
page along with an instruction how to display this page. The normally used “XYZ top
left zoom” for example instructs the viewer to show the page with the given zoom and the
top left corner at the top left coordinates—which then gives the impression that there is
an anchor at this position.
If an instruction takes a coordinate, it is calculated by the following commands
relative to the location the command is issued. So to get a specific coordinate one has to
move the command to the right place.
323
\pdf_destination:nn \pdf_destination:nn {⟨name ⟩} {⟨type or integer ⟩}
New: 2021-01-03 This creates a destination. {⟨type or integer ⟩} can be one of fit, fith, fitv, fitb,
fitbh, fitbv, fitr, xyz or an integer representing a scale factor in percent. fitr here
gives only a lightweight version of /FitR: The backend code defines fitr so that it will
with pdfLATEX and LuaLATEX use the coordinates of the surrounding box, with dvips
and dvipdfmx it falls back to fit. For full control use \pdf_destination:nnnn.
The keywords match to the PDF names as described in the following tabular.
324
Part VII
Additions and removals
325
Chapter 38
As such, the functions here may not remain in their current form,
or indeed at all, in l3kernel in the future.
In contrast to the material in l3experimental, the functions here are all small additions to
the kernel. We encourage programmers to test them out and report back on the LaTeX-L
mailing list.
Thus, if you intend to use any of these functions from the candidate module in a
public package offered to others for productive use (e.g., being placed on CTAN) please
consider the following points carefully:
• Be prepared that your public packages might require updating when such functions
are being finalized.
• Consider informing us that you use a particular function in your public package,
e.g., by discussing this on the LaTeX-L mailing list. This way it becomes easier to
coordinate any updates necessary without issues for the users of your package.
• Discussing and understanding use cases for a particular addition or concept also
helps to ensure that we provide the right interfaces in the final version so please
give us feedback if you consider a certain candidate function useful (or not).
We only add functions in this space if we consider them being serious candidates for
a final inclusion into the kernel. However, real use sometimes leads to better ideas, so
functions from this module are not necessarily stable and we may have to adjust them!
326
38.2 Additions to l3seq
327
Index
The italic numbers denote the pages where the corresponding entry is described, numbers
underlined point to the definition, all others indicate the places where it is used.
328
\bool_set_true:N . . . . . . . . . . . . . . 67 \box_if_vertical:NTF . . . . . . . . . 297
\bool_show:N . . . . . . . . . . . . . . . . . 68 \box_if_vertical_p:N . . . . . . . . . 297
\bool_show:n . . . . . . . . . . . . . . . . . 68 \box_log:N . . . . . . . . . . . . . . . . . . 298
\bool_to_str:N . . . . . . . . . . . . . . . 68 \box_log:Nnn . . . . . . . . . . . . . . . . 298
\bool_to_str:n . . . . . . . . . . . . . . . 68 \box_move_down:nn . . . . . . . . . . . . 295
\bool_until_do:Nn . . . . . . . . . . . . . 71 \box_move_left:nn . . . . . . . . . . . . 295
\bool_until_do:nn . . . . . . . . . . . . . 71 \box_move_right:nn . . . . . . . . . . . 295
\bool_while_do:Nn . . . . . . . . . . . . . 71 \box_move_up:nn . . . . . . . . . . . . . 295
\bool_while_do:nn . . . . . . . . . . . . . 72 \box_new:N . . . . . . . . . . . . . . . 294, 295
\bool_xor:nnTF . . . . . . . . . . . . . . . 71 \box_resize_to_ht:Nn . . . . . . . . . 303
\bool_xor_p:nn . . . . . . . . . . . . . . . 71 \box_resize_to_ht_plus_dp:Nn . . 304
\c_false_bool . . . . . . . . . . . . . 67, 68 \box_resize_to_wd:Nn . . . . . . . . . 304
\g_tmpa_bool . . . . . . . . . . . . . . . . . 69 \box_resize_to_wd_and_ht:Nnn . . 304
\l_tmpa_bool . . . . . . . . . . . . . . . . . 68 \box_resize_to_wd_and_ht_plus_-
\g_tmpb_bool . . . . . . . . . . . . . . . . . 69 dp:Nnn . . . . . . . . . . . . . . . . . . . 304
\l_tmpb_bool . . . . . . . . . . . . . . . . . 68 \box_rotate:Nn . . . . . . . . . . . . . . 305
\c_true_bool . . . . . . . . . . . . . . 67, 68 \box_scale:Nnn . . . . . . . . . . . . . . 305
box commands: \box_set_clipped:N . . . . . . . . . . . 305
\box_autosize_to_wd_and_ht:Nnn . 303 \box_set_dp:Nn . . . . . . . . . . . . . . 296
\box_autosize_to_wd_and_ht_plus_- \box_set_eq:NN . . . . . . . . . . . . . . 295
dp:Nnn . . . . . . . . . . . . . . . . . . . 303 \box_set_eq_drop:NN . . . . . . . . . . 302
\box_clear:N . . . . . . . . . . . . . 294, 295 \box_set_ht:Nn . . . . . . . . . . . . . . 296
\box_clear_new:N . . . . . . . . . . . . . 295 \box_set_to_last:N . . . . . . . . . . . 297
\box_dp:N . . . . . . . . . . . . . . . . . . . 296 \box_set_trim:Nnnnn . . . . . . . . . . 305
\box_gautosize_to_wd_and_ht:Nnn 303 \box_set_viewport:Nnnnn . . . . . . . 305
\box_gautosize_to_wd_and_ht_- \box_set_wd:Nn . . . . . . . . . . . . . . 296
plus_dp:Nnn . . . . . . . . . . . . . . . 303 \box_show:N . . . . . . . . . . 298, 301, 311
\box_gclear:N . . . . . . . . . . . . . . . 294 \box_show:Nnn . . . . . . . . . . . . 298, 312
\box_gclear_new:N . . . . . . . . . . . . 295 \box_use:N . . . . . . . . . . . . . . . . . . 295
\box_gresize_to_ht:Nn . . . . . . . . 303 \box_use_drop:N . . . . . . . . . . . . . 302
\box_gresize_to_ht_plus_dp:Nn . . 304 \box_wd:N . . . . . . . . . . . . . . . . . . . 296
\box_gresize_to_wd:Nn . . . . . . . . 304 \c_empty_box . . . . . . . . . . . . . 294, 297
\box_gresize_to_wd_and_ht:Nnn . . 304 \g_tmpa_box . . . . . . . . . . . . . . . . . 297
\box_gresize_to_wd_and_ht_plus_- \l_tmpa_box . . . . . . . . . . . . . . . . . 297
dp:Nnn . . . . . . . . . . . . . . . . . . . 304 \g_tmpb_box . . . . . . . . . . . . . . . . . 297
\box_grotate:Nn . . . . . . . . . . . . . 305 \l_tmpb_box . . . . . . . . . . . . . . . . . 297
\box_gscale:Nnn . . . . . . . . . . . . . 305 bp . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
\box_gset_clipped:N . . . . . . . . . . 305
\box_gset_dp:Nn . . . . . . . . . . . . . 296 C
\box_gset_eq:NN . . . . . . . . . . . . . 295 cc . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
\box_gset_eq_drop:NN . . . . . . . . . 302 cctab commands:
\box_gset_ht:Nn . . . . . . . . . . . . . 296 \cctab_begin:N . . . . . . . ....... 282
\box_gset_to_last:N . . . . . . . . . . 297 \cctab_const:Nn . . . . . . .. . . 281, 282
\box_gset_trim:Nnnnn . . . . . . . . . 305 \cctab_end: . . . . . . . . . . ....... 282
\box_gset_viewport:Nnnnn . . . . . . 305 \cctab_gsave_current:N . ....... 281
\box_gset_wd:Nn . . . . . . . . . . . . . 296 \cctab_gset:Nn . . . . . . . .. . . 281, 282
\box_ht:N . . . . . . . . . . . . . . . . . . . 296 \cctab_if_exist:NTF . . . ....... 282
\box_ht_plus_dp:N . . . . . . . . . . . . 296 \cctab_if_exist_p:N . . . ....... 282
\box_if_empty:NTF . . . . . . . . . . . . 297 \cctab_item:Nn . . . . . . . ....... 282
\box_if_empty_p:N . . . . . . . . . . . . 297 \cctab_new:N . . . . . . . . . ....... 281
\box_if_exist:NTF . . . . . . . . . . . . 295 \cctab_select:N . . . . . . 126, 281, 282
\box_if_exist_p:N . . . . . . . . . . . . 295 \c_code_cctab . . . . . . . . ....... 282
\box_if_horizontal:NTF . . . . . . . . 297 \c_document_cctab . . . . . ....... 282
\box_if_horizontal_p:N . . . . . . . . 297 \c_initex_cctab . . . . . . ....... 283
329
\c_other_cctab . . . . . . . . . . . . . . 283 \char_show_value_catcode:n ... . 197
\g_tmpa_cctab . . . . . . . . . . . . . . . 283 \char_show_value_lccode:n . ... . 198
\g_tmpb_cctab . . . . . . . . . . . . . . . 283 \char_show_value_mathcode:n .. . 198
ceil . . . . . . . . . . . . . . . . . . . . . . . . . . 273 \char_show_value_sfcode:n . ... . 199
char commands: \char_show_value_uccode:n . ... . 198
\l_char_active_seq . . . . . . . . 91, 199 \l_char_special_seq . . . . . . ... . 199
\char_foldcase:N . . . . . . . . . . . . . 211 \char_str_foldcase:N . . . . . ... . 211
\char_generate:nn . . . . . . . . . 125, 195 \char_str_lowercase:N . . . . ... . 211
\char_gset_active_eq:NN . . . . . . . 195 \char_str_titlecase:N . . . . ... . 211
\char_gset_active_eq:nN . . . . . . . 195 \char_str_uppercase:N . . . . ... . 211
\char_lowercase:N . . . . . . . . . . . . 211 \char_titlecase:N . . . . . . . . ... . 211
\char_set_active_eq:NN . . . . . . . . 195 \char_uppercase:N . . . . . . . . ... . 211
\char_set_active_eq:nN . . . . . . . . 195 \char_value_catcode:n . . . . ... . 197
\char_set_catcode:nn . . . . . . . . . 197 \char_value_lccode:n . . . . . ... . 198
\char_set_catcode_active:N . . . . 196 \char_value_mathcode:n . . . . ... . 198
\char_set_catcode_active:n . . . . 197 \char_value_sfcode:n . . . . . ... . 199
\char_set_catcode_alignment:N . . 196 \char_value_uccode:n . . . . . ... . 198
\char_set_catcode_alignment:n . . 197 choice commands:
\char_set_catcode_comment:N . . . 196 .choice: . . . . . . . . . . . . . . . . . . . 239
\char_set_catcode_comment:n . . . 197 choices commands:
\char_set_catcode_end_line:N . . 196 .choices:nn . . . . . . . . . . . . . . . . . 239
\char_set_catcode_end_line:n . . 197 clist commands:
\char_set_catcode_escape:N . . . . 196 \clist_clear:N . . . . . . . . . . . ... 184
\char_set_catcode_escape:n . . . . 197 \clist_clear_new:N . . . . . . . . ... 184
\char_set_catcode_group_begin:N 196 \clist_concat:NNN . . . . . . . . . ... 185
\char_set_catcode_group_begin:n 197 \clist_const:Nn . . . . . . . . . . ... 184
\char_set_catcode_group_end:N . . 196 \clist_count:N . . . . . . . . . . . 189, 192
\char_set_catcode_group_end:n . . 197 \clist_count:n . . . . . . . . . . . ... 189
\char_set_catcode_ignore:N . . . . 196 \clist_gclear:N . . . . . . . . . . ... 184
\char_set_catcode_ignore:n . . . . 197 \clist_gclear_new:N . . . . . . . ... 184
\char_set_catcode_invalid:N . . . 196 \clist_gconcat:NNN . . . . . . . . ... 185
\char_set_catcode_invalid:n . . . 197 \clist_get:NN . . . . . . . . . . . . ... 191
\char_set_catcode_letter:N . . . . 196 \clist_get:NNTF . . . . . . . . . . ... 191
\char_set_catcode_letter:n . . . . 197 \clist_gpop:NN . . . . . . . . . . . ... 191
\char_set_catcode_math_subscript:N \clist_gpop:NNTF . . . . . . . . . . ... 192
. . . . . . . . . . . . . . . . . . . . . . . . . 196 \clist_gpush:Nn . . . . . . . . . . ... 192
\char_set_catcode_math_subscript:n \clist_gput_left:Nn . . . . . . . ... 185
. . . . . . . . . . . . . . . . . . . . . . . . . 197 \clist_gput_right:Nn . . . . . . ... 185
\char_set_catcode_math_superscript:N \clist_gremove_all:Nn . . . . . ... 186
. . . . . . . . . . . . . . . . . . . . . . . . . 196 \clist_gremove_duplicates:N ... 186
\char_set_catcode_math_superscript:n \clist_greverse:N . . . . . . . . . ... 186
. . . . . . . . . . . . . . . . . . . . . . . . . 197 .clist_gset:N . . . . . . . . . . . . ... 239
\char_set_catcode_math_toggle:N 196 \clist_gset:Nn . . . . . . . . . . . ... 185
\char_set_catcode_math_toggle:n 197 \clist_gset_eq:NN . . . . . . . . . ... 184
\char_set_catcode_other:N . . . . . 196 \clist_gset_from_seq:NN . . . . ... 184
\char_set_catcode_other:n . . . . . 197 \clist_gsort:Nn . . . . . . . . . . ... 187
\char_set_catcode_parameter:N . . 196 \clist_if_empty:NTF . . . . . . . ... 187
\char_set_catcode_parameter:n . . 197 \clist_if_empty:nTF . . . . . . . ... 187
\char_set_catcode_space:N . . . . . 196 \clist_if_empty_p:N . . . . . . . ... 187
\char_set_catcode_space:n . . . . . 197 \clist_if_empty_p:n . . . . . . . ... 187
\char_set_lccode:nn . . . . . . . . . . 197 \clist_if_exist:NTF . . . . . . . ... 185
\char_set_mathcode:nn . . . . . . . . 198 \clist_if_exist_p:N . . . . . . . ... 185
\char_set_sfcode:nn . . . . . . . . . . 198 \clist_if_in:NnTF . . . . . . . . . 184, 187
\char_set_uccode:nn . . . . . . . . . . 198 \clist_if_in:nnTF . . . . . . . . . ... 187
330
\clist_item:Nn . . . . . . . . . . . ... 192 \coffin_dp:N . . . . . . . . . . . . . . . . 310
\clist_item:nn . . . . . . . . . . . ... 192 \coffin_gattach:NnnNnnnn . . . . . . 310
\clist_log:N . . . . . . . . . . . . . ... 193 \coffin_gclear:N . . . . . . . . . . . . . 307
\clist_log:n . . . . . . . . . . . . . ... 193 \coffin_gjoin:NnnNnnnn . . . . . . . . 310
\clist_map_break: . . . . . . . . . ... 188 \coffin_greset_poles:N . . . . . . . . 309
\clist_map_break:n . . . . . . . . ... 189 \coffin_gresize:Nnn . . . . . . . . . . 309
\clist_map_function:NN . . . . . ... 188 \coffin_grotate:Nn . . . . . . . . . . . 309
\clist_map_function:nN . . . . . ... 188 \coffin_gscale:Nnn . . . . . . . . . . . 309
\clist_map_inline:Nn . . . . . . ... 188 \coffin_gset_eq:NN . . . . . . . . . . . 307
\clist_map_inline:nn . . . . . . ... 188 \coffin_gset_horizontal_pole:Nnn 308
\clist_map_tokens:Nn . . . . . . ... 188 \coffin_gset_vertical_pole:Nnn . 309
\clist_map_tokens:nn . . . . . . ... 188 \coffin_ht:N . . . . . . . . . . . . . . . . 311
\clist_map_variable:NNn . . . . ... 188 \coffin_if_exist:NTF . . . . . . . . . 307
\clist_map_variable:nNn . . . . ... 188 \coffin_if_exist_p:N . . . . . . . . . 307
\clist_new:N . . . . . . . . . . . . . ... 184 \coffin_join:NnnNnnnn . . . . . . . . 310
\clist_pop:NN . . . . . . . . . . . . ... 191 \coffin_log:N . . . . . . . . . . . . . . . 311
\clist_pop:NNTF . . . . . . . . . . ... 191 \coffin_log:Nnn . . . . . . . . . . . . . 312
\clist_push:Nn . . . . . . . . . . . ... 192 \coffin_log_structure:N . . . . . . . 311
\clist_put_left:Nn . . . . . . . . ... 185 \coffin_mark_handle:Nnnn . . . . . . 311
\clist_put_right:Nn . . . . . . . ... 185 \coffin_new:N . . . . . . . . . . . . . . . 307
\clist_rand_item:N . . . . . . . . ... 192 \coffin_reset_poles:N . . . . . . . . 309
\clist_rand_item:n . . . . . . . . 78, 192 \coffin_resize:Nnn . . . . . . . . . . . 309
\clist_remove_all:Nn . . . . . . ... 186 \coffin_rotate:Nn . . . . . . . . . . . . 309
\clist_remove_duplicates:N . 184, 186 \coffin_scale:Nnn . . . . . . . . . . . . 309
\clist_reverse:N . . . . . . . . . . ... 186 \coffin_set_eq:NN . . . . . . . . . . . . 307
\clist_reverse:n . . . . . . . . . . ... 186 \coffin_set_horizontal_pole:Nnn 308
.clist_set:N . . . . . . . . . . . . . ... 239 \coffin_set_vertical_pole:Nnn . . 309
\clist_set:Nn . . . . . . . . . . . . 185, 191 \coffin_show:N . . . . . . . . . . . . . . 311
\clist_set_eq:NN . . . . . . . . . . ... 184 \coffin_show:Nnn . . . . . . . . . . . . . 312
\clist_set_from_seq:NN . . . . . ... 184 \coffin_show_structure:N . . . 311, 312
\clist_show:N . . . . . . . . . . . . 192, 193 \coffin_typeset:Nnnnn . . . . . . . . 310
\clist_show:n . . . . . . . . . . . . ... 193 \coffin_wd:N . . . . . . . . . . . . . . . . 311
\clist_sort:Nn . . . . . . . . . . . ... 187 \c_empty_coffin . . . . . . . . . . . . . 312
\clist_use:Nn . . . . . . . . . . . . 190, 191 \g_tmpa_coffin . . . . . . . . . . . . . . 312
\clist_use:nn . . . . . . . . . . . . ... 191 \l_tmpa_coffin . . . . . . . . . . . . . . 312
\clist_use:Nnnn . . . . . . . . . . 190, 191 \g_tmpb_coffin . . . . . . . . . . . . . . 312
\clist_use:nnnn . . . . . . . . . . ... 191 \l_tmpb_coffin . . . . . . . . . . . . . . 312
\c_empty_clist . . . . . . . . . . . ... 193 color commands:
\g_tmpa_clist . . . . . . . . . . . . ... 193 color.sc . . . . . . . . . . . . . . . . . . . 317
\l_tmpa_clist . . . . . . . . . . . . ... 193 \color_ensure_current: . . . . . . . . 313
\g_tmpb_clist . . . . . . . . . . . . ... 193 \color_export:nnN . . . . . . . . . . . . 318
\l_tmpb_clist . . . . . . . . . . . . ... 193 \color_export:nnnN . . . . . . . . . . . 318
cm . . . . . . . . . . . . . . . . . . . . . . . . ... 277 \color_fill:n . . . . . . . . . . . . . . . 317
code commands: \color_fill:nn . . . . . . . . . . . . . . 317
.code:n . . . . . . . . . . . . . . . . . . . . 240 \l_color_fixed_model_tl . . . . . . . 316
codepoint commands: \color_group_begin: . . . . . . . . . . 313
\codepoint_generate:nn . . . . . . . . 286 \color_group_end: . . . . . . . . . . . . 313
\codepoint_str_generate:n . . . . . 286 \color_if_exist:nTF . . . . . . . . . . 316
\codepoint_to_category:n . . . . . . 287 \color_if_exist_p:n . . . . . . . . . . 316
\codepoint_to_nfd:n . . . . . . . . . . 287 \color_log:n . . . . . . . . . . . . . . . . 316
coffin commands: \color_math:nn . . . . . . . . . . . . . . 317
\coffin_attach:NnnNnnnn . . . . . . . 310 \color_math:nnn . . . . . . . . . . . . . 317
\coffin_clear:N . . . . . . . . . . . . . 307 \l_color_math_active_tl . . . . . . . 317
\coffin_display_handles:Nn . . . . 311 \color_model_new:nnn . . . . . . . . . 319
331
\color_profile_apply:nn . . . . . . . 320 \cs_new_nopar:Npn . . . . . . . . . . . . . 15
\color_select:n . . . . . . . . . . . . . 316 \cs_new_nopar:Npx . . . . . . . . . . . . . 15
\color_select:nn . . . . . . . . . . . . . 316 \cs_new_protected:Nn . . . . . . . . . . 18
\color_set:nn . . . . . . . . . . . . . . . 316 \cs_new_protected:Npe . . . . . . . . . 15
\color_set:nnn . . . . . . . . . . . . . . 316 \cs_new_protected:Npn . . . . . . . . . 15
\color_set_eq:nn . . . . . . . . . . . . . 316 \cs_new_protected:Npx . . . . . . . . . 15
\color_show:n . . . . . . . . . . . . . . . 316 \cs_new_protected_nopar:Nn . . . . . 18
\color_stroke:n . . . . . . . . . . . . . 317 \cs_new_protected_nopar:Npe . . . . 16
\color_stroke:nn . . . . . . . . . . . . . 317 \cs_new_protected_nopar:Npn . . . . 16
cos . . . . . . . . . . . . . . . . . . . . . . . . . . 273 \cs_new_protected_nopar:Npx . . . . 16
cosd . . . . . . . . . . . . . . . . . . . . . . . . . . 274 \cs_parameter_spec:N . . . . . . . . . . 23
cot . . . . . . . . . . . . . . . . . . . . . . . . . . 273 \cs_prefix_spec:N . . . . . . . . . . . . . 22
cotd . . . . . . . . . . . . . . . . . . . . . . . . . . 274 \cs_replacement_spec:N . . . . . . . . . 23
cs commands: \cs_set:Nn . . . . . . . . . . . . . . . . . . . 18
\cs:w . . . . . . . . . . . . . . . . . . . . 21, 22 .cs_set:Np . . . . . . . . . . . . . . . . . . 240
\cs_end: . . . . . . . . . . . . . . . . . . . . 21 \cs_set:Npe . . . . . . . . . . . . . . . . . . 16
\cs_generate_from_arg_count:NNnn 19 \cs_set:Npn . . . . . . . . . . 14, 16, 64, 65
\cs_generate_variant:Nn 15, 32–34, 66 \cs_set:Npx . . . . . . . . . . . . . . . . . . 16
\cs_gset:Nn . . . . . . . . . . . . . . . . . . 19 \cs_set_eq:NN . . . . . . . . . . . . . 20, 66
.cs_gset:Np . . . . . . . . . . . . . . . . . 240 \cs_set_nopar:Nn . . . . . . . . . . . . . . 18
\cs_gset:Npe . . . . . . . . . . . . . . . . . 17 \cs_set_nopar:Npe . . . . . . . . . . . . . 16
\cs_gset:Npn . . . . . . . . . . . . . . 14, 17 \cs_set_nopar:Npn . . . . . . . 15, 16, 200
\cs_gset:Npx . . . . . . . . . . . . . . . . . 17 \cs_set_nopar:Npx . . . . . . . . . . . . . 16
\cs_gset_eq:NN . . . . . . . . . . . . . . . 20 \cs_set_protected:Nn . . . . . . . . . . 18
\cs_gset_nopar:Nn . . . . . . . . . . . . . 19 .cs_set_protected:Np . . . . . . . . . 240
\cs_gset_nopar:Npe . . . . . . . . . . . . 17 \cs_set_protected:Npe . . . . . . . . . 16
\cs_gset_nopar:Npn . . . . . . . . . . . . 17 \cs_set_protected:Npn . . . . . . 15, 16
\cs_gset_nopar:Npx . . . . . . . . . . . . 17 \cs_set_protected:Npx . . . . . . . . . 16
\cs_gset_protected:Nn . . . . . . . . . 19 \cs_set_protected_nopar:Nn . . . . . 18
.cs_gset_protected:Np . . . . . . . . 240 \cs_set_protected_nopar:Npe . . . . 16
\cs_gset_protected:Npe . . . . . . . . . 17 \cs_set_protected_nopar:Npn . . . . 16
\cs_gset_protected:Npn . . . . . . . . . 17 \cs_set_protected_nopar:Npx . . . . 16
\cs_gset_protected:Npx . . . . . . . . . 17 \cs_show:N . . . . . . . . . . . . . 20, 21, 28
\cs_gset_protected_nopar:Nn . . . . 19 \cs_split_function:N . . . . . . . . . . 22
\cs_gset_protected_nopar:Npe . . . 17 \cs_to_str:N . . . . . . . . 6, 22, 116, 129
\cs_gset_protected_nopar:Npn . . . 17 \cs_undefine:N . . . . . . . . . . . . . . . 20
\cs_gset_protected_nopar:Npx . . . 17 csc . . . . . . . . . . . . . . . . . . . . . . . . . . 273
\cs_if_eq:NNTF . . . . . . . . . . . . . . . 28 cscd . . . . . . . . . . . . . . . . . . . . . . . . . . 274
\cs_if_eq_p:NN . . . . . . . . . . . . . . . 28
\cs_if_exist:NTF . . . . . . . . . . . 21, 28 D
\cs_if_exist_p:N . . . . . . . . . . . . . . 28 dd . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
\cs_if_exist_use:N . . . . . . . . . . . . 21 debug commands:
\cs_if_exist_use:NTF . . . . . . . . . . 21 \debug_off:n . . .... . . . . . . . . . . . 30
\cs_if_free:NTF . . . . . . . . . . . 28, 64 \debug_on:n . . . .... . . . . . . . . . . . 30
\cs_if_free_p:N . . . . . . . . 27, 28, 64 \debug_resume: .... . . . . . . . . . . . 30
\cs_log:N . . . . . . . . . . . . . . . . . . . . 21 \debug_suspend: ... . . . . . . . . . . . 30
\cs_meaning:N . . . . . . . . . . . . . . . . 20 default commands:
\cs_new:Nn . . . . . . . . . . . . . . . . 17, 65 .default:n . . . . . . . . . . . . . . . . . . 240
\cs_new:Npe . . . . . . . . . . . . 15, 39, 40 deg . . . . . . . . . . . . . . . . . . . . . . . . . . 276
\cs_new:Npn . . . . . . . 14, 15, 19, 64, 65 dim commands:
\cs_new:Npx . . . . . . . . . . . . . . . . . . 15 \dim_abs:n . . . . . . . . . . . . . . . . . . 222
\cs_new_eq:NN . . . . . . . . . . . . . 20, 66 \dim_add:Nn . . . . . . . . . . . . . . . . . 222
\cs_new_nopar:Nn . . . . . . . . . . . . . . 17 \dim_case:nn . . . . . . . . . . . . . . . . 225
\cs_new_nopar:Npe . . . . . . . . . . . . . 15 \dim_case:nnTF . . . . . . . . . . . . . . 225
332
\dim_compare:nNnTF . . . . 223–226, 260 \g_tmpa_dim . . . . . . . . . . . . . . . . . 230
\dim_compare:nTF . . . . . . 223, 224, 226 \l_tmpa_dim . . . . . . . . . . . . . . . . . 230
\dim_compare_p:n . . . . . . . . . . . . . 224 \g_tmpb_dim . . . . . . . . . . . . . . . . . 230
\dim_compare_p:nNn . . . . . . . . . . . 223 \l_tmpb_dim . . . . . . . . . . . . . . . . . 230
\dim_const:Nn . . . . . . . . . . . . . . . 221 \c_zero_dim . . . . . . . . . . . . . . . . . 230
\dim_do_until:nn . . . . . . . . . . . . . 226 draw commands:
\dim_do_until:nNnn . . . . . . . . . . . 225 \draw_begin: . . . . . . . . . . . . . . . . 317
\dim_do_while:nn . . . . . . . . . . . . . 226 \draw_end: . . . . . . . . . . . . . . . . . . 317
\dim_do_while:nNnn . . . . . . . . . . . 225
\dim_eval:n . . . . . . . . . . 223, 224, 227 E
\dim_gadd:Nn . . . . . . . . . . . . . . . . 222 else commands:
.dim_gset:N . . . . . . . . . . . . . . . . . 240 \else: 28, 66, 73, 100, 179, 180, 236, 306
\dim_gset:Nn . . . . . . . . . . . . . . . . 222 em . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
\dim_gset_eq:NN . . . . . . . . . . . . . 222 ex . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
\dim_gsub:Nn . . . . . . . . . . . . . . . . 222 exp . . . . . . . . . . . . . . . . . . . . . . . . . . 272
\dim_gzero:N . . . . . . . . . . . . . . . . 221 exp commands:
\dim_gzero_new:N . . . . . . . . . . . . . 221 \exp:w . . . . . . . . . . . . . . . . . . . 41, 42
\dim_if_exist:NTF . . . . . . . . . . . . 222 \exp_after:wN . . . . . . . 39, 41, 42, 207
\dim_if_exist_p:N . . . . . . . . . . . . 222 \exp_args:cc . . . . . . . . . . . . . . . . . 36
\dim_log:N . . . . . . . . . . . . . . . . . . 229 \exp_args:Nc . . . . . . . . . . . . . . 33, 36
\dim_log:n . . . . . . . . . . . . . . . . . . 230 \exp_args:Ncc . . . . . . . . . . . . . . . . 37
\dim_max:nn . . . . . . . . . . . . . . . . . 222 \exp_args:Nccc . . . . . . . . . . . . . . . 37
\dim_min:nn . . . . . . . . . . . . . . . . . 222 \exp_args:Ncco . . . . . . . . . . . . . . . 37
\dim_new:N . . . . . . . . . . . . . . . . . . 221 \exp_args:Nccx . . . . . . . . . . . . . . . 38
\dim_ratio:nn . . . . . . . . . . . . . . . 223 \exp_args:Ncf . . . . . . . . . . . . . . . . 37
.dim_set:N . . . . . . . . . . . . . . . . . . 240 \exp_args:NcNc . . . . . . . . . . . . . . . 37
\dim_set:Nn . . . . . . . . . . . . . . . . . 222 \exp_args:NcNo . . . . . . . . . . . . . . . 37
\dim_set_eq:NN . . . . . . . . . . . . . . 222 \exp_args:Ncno . . . . . . . . . . . . . . . 38
\dim_show:N . . . . . . . . . . . . . . . . . 229 \exp_args:NcnV . . . . . . . . . . . . . . . 38
\dim_show:n . . . . . . . . . . . . . . . . . 229 \exp_args:Ncnx . . . . . . . . . . . . . . . 38
\dim_sign:n . . . . . . . . . . . . . . . . . 227 \exp_args:Nco . . . . . . . . . . . . . . . . 37
\dim_step_function:nnnN . . . . . . . 226 \exp_args:Ncoo . . . . . . . . . . . . . . . 38
\dim_step_inline:nnnn . . . . . . . . 226 \exp_args:NcV . . . . . . . . . . . . . . . . 37
\dim_step_variable:nnnNn . . . . . . 227 \exp_args:Ncv . . . . . . . . . . . . . . . . 37
\dim_sub:Nn . . . . . . . . . . . . . . . . . 222 \exp_args:NcVV . . . . . . . . . . . . . . . 38
\dim_to_decimal:n . . . . . . . . . . . . 227 \exp_args:Ncx . . . . . . . . . . . . . . . . 37
\dim_to_decimal_in_bp:n . . . . . . . 228 \exp_args:Ne . . . . . . . . . . . . . . . . . 36
\dim_to_decimal_in_cc:n . . . . . . . 228 \exp_args:Nee . . . . . . . . . . . . . . . . 37
\dim_to_decimal_in_cm:n . . . . . . . 228 \exp_args:Neee . . . . . . . . . . . . . . . 38
\dim_to_decimal_in_dd:n . . . . . . . 228 \exp_args:Nf . . . . . . . . . . . . . . . . . 36
\dim_to_decimal_in_in:n . . . . . . . 228 \exp_args:Nff . . . . . . . . . . . . . . . . 37
\dim_to_decimal_in_mm:n . . . . . . . 228 \exp_args:Nffo . . . . . . . . . . . . . . . 38
\dim_to_decimal_in_pc:n . . . . . . . 228 \exp_args:Nfo . . . . . . . . . . . . . . . . 37
\dim_to_decimal_in_sp:n . . . . . . . 229 \exp_args:NNc . . . . . . . . . . . . . . . . 37
\dim_to_decimal_in_unit:nn . . . . 229 \exp_args:Nnc . . . . . . . . . . . . . . . . 37
\dim_to_fp:n . . . . . . . . . . . . . . . . 229 \exp_args:NNcf . . . . . . . . . . . . . . . 38
\dim_until_do:nn . . . . . . . . . . . . . 226 \exp_args:NNe . . . . . . . . . . . . . . . . 37
\dim_until_do:nNnn . . . . . . . . . . . 225 \exp_args:Nne . . . . . . . . . . . . . . . . 37
\dim_use:N . . . . . . . . . . . . . . . . . . 227 \exp_args:NNf . . . . . . . . . . . . . . . . 37
\dim_while_do:nn . . . . . . . . . . . . . 226 \exp_args:Nnf . . . . . . . . . . . . . . . . 37
\dim_while_do:nNnn . . . . . . . . . . . 226 \exp_args:Nnff . . . . . . . . . . . . . . . 38
\dim_zero:N . . . . . . . . . . . . . . . . . 221 \exp_args:Nnnc . . . . . . . . . . . . . . . 38
\dim_zero_new:N . . . . . . . . . . . . . 221 \exp_args:NNNe . . . . . . . . . . . . . . . 37
\c_max_dim . . . . . . . . . . . 228, 230, 233 \exp_args:Nnnf . . . . . . . . . . . . . . . 38
333
\exp_args:NNNo . . . . . . . . . . . . . .. 37 \exp_last_unbraced:Nno . . . . . . . . . 38
\exp_args:NNno . . . . . . . . . . . . . .. 38 \exp_last_unbraced:NNV . . . . . . . . . 38
\exp_args:Nnno . . . . . . . . . . . . . .. 38 \exp_last_unbraced:No . . . . . . . . . 38
\exp_args:NNNV . . . . . . . . . . . . . .. 37 \exp_last_unbraced:Noo . . . . . . . . . 38
\exp_args:NNNv . . . . . . . . . . . . . .. 37 \exp_last_unbraced:NV . . . . . . . . . 38
\exp_args:NNnV . . . . . . . . . . . . . .. 38 \exp_last_unbraced:Nv . . . . . . . . . 38
\exp_args:NNNx . . . . . . . . . . . . . .. 38 \exp_last_unbraced:Nx . . . . . . . . . 39
\exp_args:NNnx . . . . . . . . . . . . . .. 38 \exp_not:N . . . . . . 39, 99, 166, 167, 277
\exp_args:Nnnx . . . . . . . . . . . . . .. 38 \exp_not:n . . . . . . . . 39, 40, 52, 99,
\exp_args:NNo . . . . . . . . . . . . . 31, 37 121–124, 154, 160, 161, 166, 167,
\exp_args:Nno . . . . . . . . . . . . . . .. 37 190–192, 207, 216, 251, 252, 286, 288
\exp_args:NNoo . . . . . . . . . . . . . .. 38 \exp_stop_f: . . . . . . . . . . . 40, 42, 179
\exp_args:NNox . . . . . . . . . . . . . .. 38 \ExplFileDate . . . . . . . . . . . . . . . . . . . 10
\exp_args:Nnox . . . . . . . . . . . . . .. 38 \ExplFileDescription . . . . . . . . . . . . . 10
\exp_args:NNV . . . . . . . . . . . . . . .. 37 \ExplFileName . . . . . . . . . . . . . . . . . . . 10
\exp_args:NNv . . . . . . . . . . . . . . .. 37 \ExplFileVersion . . . . . . . . . . . . . . . . 10
\exp_args:NnV . . . . . . . . . . . . . . .. 37 \ExplSyntaxOff . . . . . . . . . . . . . 5, 9, 183
\exp_args:Nnv . . . . . . . . . . . . . . .. 37 \ExplSyntaxOn . . . . . . . . . . . 5, 9, 183, 281
\exp_args:NNVV . . . . . . . . . . . . . .. 38
\exp_args:NNx . . . . . . . . . . . . . . .. 37 F
\exp_args:Nnx . . . . . . . . . . . . . . .. 37 fact . . . . . . . . . . . . . . . . . . . . . . . . . . 272
\exp_args:No . . . . . . . . . . . . . . 33, 36 false . . . . . . . . . . . . . . . . . . . . . . . . . 277
\exp_args:Noc . . . . . . . . . . . . . . .. 37 fi commands:
\exp_args:Nof . . . . . . . . . . . . . . .. 37 \fi: . . . . . . . . . . . . . . . . . . . . . 28,
\exp_args:Noo . . . . . . . . . . . . . . .. 37 66, 73, 100, 179, 180, 207, 236, 306
\exp_args:Noof . . . . . . . . . . . . . .. 38 file commands:
\exp_args:Nooo . . . . . . . . . . . . . .. 38 \file_compare_timestamp:nNnTF . . 104
\exp_args:Noox . . . . . . . . . . . . . .. 38 \file_compare_timestamp_p:nNn . . 104
\exp_args:Nox . . . . . . . . . . . . . . .. 37 \g_file_curr_dir_str . . . . . . . . . 100
\exp_args:NV . . . . . . . . . . . . . . . .. 36 \g_file_curr_ext_str . . . . . . . . . 100
\exp_args:Nv . . . . . . . . . . . . . . . .. 36 \g_file_curr_name_str . . . . . . . . 100
\exp_args:NVo . . . . . . . . . . . . . . .. 37 \file_full_name:n . . . . . . . . . . . . 101
\exp_args:NVV . . . . . . . . . . . . . . .. 37 \file_get:nnN . . . . . . . . . . . . . . . 101
\exp_args:Nx . . . . . . . . . . . . . . . .. 36 \file_get:nnNTF . . . . . . . . . . . . . 101
\exp_args:Nxo . . . . . . . . . . . . . . .. 37 \file_get_full_name:nN . . . . . . . . 101
\exp_args:Nxx . . . . . . . . . . . . . . .. 37 \file_get_full_name:nNTF . . . . . . 101
\exp_args_generate:n . . . . . . . . .. 34 \file_get_hex_dump:nN . . . . . . . . 103
\exp_end: . . . . . . . . . . . . . . . . . 41, 42 \file_get_hex_dump:nnnN . . . . . . . 103
\exp_end_continue_f:nw . . . . . . . .. 42 \file_get_hex_dump:nnnNTF . . . . . 103
\exp_end_continue_f:w . . . . . . . .. 42 \file_get_hex_dump:nNTF . . . . . . . 103
\exp_last_two_unbraced:Nnn . . . .. 39 \file_get_mdfive_hash:nN . . . . . . 103
\exp_last_unbraced:Nco . . . . . . . .. 38 \file_get_mdfive_hash:nNTF . . . . 103
\exp_last_unbraced:NcV . . . . . . . .. 38 \file_get_size:nN . . . . . . . . . . . . 103
\exp_last_unbraced:Ne . . . . . . . .. 38 \file_get_size:nNTF . . . . . . . . . . 103
\exp_last_unbraced:Nf . . . . . . . .. 38 \file_get_timestamp:nN . . . . . . . . 104
\exp_last_unbraced:Nfo . . . . . . . .. 38 \file_get_timestamp:nNTF . . . . . . 104
\exp_last_unbraced:NNf . . . . . . . .. 38 \file_hex_dump:n . . . . . . . . . . 102, 103
\exp_last_unbraced:NNNf . . . . . . .. 38 \file_hex_dump:nnn . . . . . . . . 102, 103
\exp_last_unbraced:NNNNf . . . . . .. 38 \file_if_exist:nTF . . . . . . . . 101, 104
\exp_last_unbraced:NNNNo . . . . . .. 38 \file_if_exist_input:n . . . . . . . . 104
\exp_last_unbraced:NNNo . . . . . . .. 38 \file_if_exist_input:nTF . . . . . . 104
\exp_last_unbraced:NnNo . . . . . . .. 38 \file_if_exist_p:n . . . . . . . . . . . 101
\exp_last_unbraced:NNNV . . . . . . .. 38 \file_input:n . . . . . . . . . . . . 104, 105
\exp_last_unbraced:NNo . . . . . . . .. 38 \file_input_raw:n . . . . . . . . . . . . 104
334
\file_input_stop: . . . . . . . . . . . . 105 \fp_if_nan:nTF . . . . . . . . . . . 261, 278
\file_log_list: . . . . . . . . . . . . . 105 \fp_if_nan_p:n . . . . . . . . . . . . . . 261
\file_mdfive_hash:n . . . . . . . . . . 103 \fp_log:N . . . . . . . . . . . . . . . . . . . 268
\file_parse_full_name:n . . . . . . . 102 \fp_log:n . . . . . . . . . . . . . . . . . . . 268
\file_parse_full_name:nNNN . . . . 102 \fp_max:nn . . . . . . . . . . . . . . . . . . 277
\file_parse_full_name_apply:nN . 102 \fp_min:nn . . . . . . . . . . . . . . . . . . 277
\l_file_search_path_seq . . . . 101–104 \fp_new:N . . . . . . . . . . . . . . . . . . . 257
\file_show_list: . . . . . . . . . . . . . 105 \fp_new_function:n . . . . . . . . . . . 265
\file_size:n . . . . . . . . . . . . . . . . 103 \fp_new_variable:n . . . . . . . . 263–265
\file_timestamp:n . . . . . . 75, 103, 104 .fp_set:N . . . . . . . . . . . . . . . . . . . 240
flag commands: \fp_set:Nn . . . . . . . . . . . . . . . 257, 263
\flag_clear:n . . . . . . . . . . . . 181, 182 \fp_set_eq:NN . . . . . . . . . . . . . . . 257
\flag_clear_new:n . . . . . . . . . . . . 182 \fp_set_function:nnn . . . . . . . . . 265
\flag_ensure_raised:n . . . . . . . . 182 \fp_set_variable:nn . . . . . . . 263–265
\flag_height:n . . . . . . . . . . . . . . 182 \fp_show:N . . . . . . . . . . . 263, 264, 268
\flag_if_exist:nTF . . . . . . . . . . . 182 \fp_show:n . . . . . . . . . . . 263–265, 268
\flag_if_exist_p:n . . . . . . . . . . . 182 \fp_sign:n . . . . . . . . . . . . . . . . . . 258
\flag_if_raised:nTF . . . . . . . . . . 182 \fp_step_function:nnnN . . . . . . . . 263
\flag_if_raised_p:n . . . . . . . . . . 182 \fp_step_inline:nnnn . . . . . . . . . 263
\flag_log:n . . . . . . . . . . . . . . . . . 182 \fp_step_variable:nnnNn . . . . . . . 263
\flag_new:n . . . . . . . . . . . . . . 181, 182 \fp_sub:Nn . . . . . . . . . . . . . . . . . . 258
\flag_raise:n . . . . . . . . . . . . . . . 182 \fp_to_decimal:N . . . . . . . . . . 258, 259
\flag_show:n . . . . . . . . . . . . . . . . 182 \fp_to_decimal:n . . . . . . . . . . 258, 259
floor . . . . . . . . . . . . . . . . . . . . . . . . . 273 \fp_to_dim:N . . . . . . . . . . . . . . . . 258
fp commands: \fp_to_dim:n . . . . . . . . . . . . . 258, 267
\c_e_fp . . . . . . . . . . . . . . . . . 266, 269 \fp_to_int:N . . . . . . . . . . . . . . . . 258
flag␣fp_division_by_zero . . . . . . 267 \fp_to_int:n . . . . . . . . . . . . . . . . 258
flag␣fp_invalid_operation . . . . . 267 \fp_to_scientific:N . . . . . . . . . . 259
flag␣fp_overflow . . . . . . . . . . . . . 267 \fp_to_scientific:n . . . . . . . . . . 259
flag␣fp_underflow . . . . . . . . . . . . 267 \fp_to_tl:N . . . . . . . . . . . . . . 259, 280
\fp_abs:n . . . . . . . . . . . . . . . . 271, 277 \fp_to_tl:n . . . . . . . . . . . . . . . . . 259
\fp_add:Nn . . . . . . . . . . . . . . . . . . 257 \fp_trap:nn . . . . . . . . . . . . . . . . . 267
\fp_clear_function:n . . . . . . . . . 265 \fp_until_do:nn . . . . . . . . . . . . . 262
\fp_clear_variable:n . . . . . . . . . 265 \fp_until_do:nNnn . . . . . . . . . . . . 262
\fp_compare:nNnTF . . . . . . . . . 260–262 \fp_use:N . . . . . . . . . . . . . . . . 259, 280
\fp_compare:nTF . . . . . . 260–262, 271 \fp_while_do:nn . . . . . . . . . . . . . 262
\fp_compare_p:n . . . . . . . . . . . . . 261 \fp_while_do:nNnn . . . . . . . . . . . . 262
\fp_compare_p:nNn . . . . . . . . . . . . 260 \fp_zero:N . . . . . . . . . . . . . . . . . . 257
\fp_const:Nn . . . . . . . . . . . . . . . . 257 \fp_zero_new:N . . . . . . . . . . . . . . 257
\fp_do_until:nn . . . . . . . . . . . . . 262 \c_inf_fp . . . . . . . . . . . . . . . . 266, 276
\fp_do_until:nNnn . . . . . . . . . . . . 261 \c_minus_inf_fp . . . . . . . . . . 266, 276
\fp_do_while:nn . . . . . . . . . . . . . 262 \c_minus_zero_fp . . . . . . . . . . . . . 266
\fp_do_while:nNnn . . . . . . . . . . . . 262 \c_nan_fp . . . . . . . . . . . . . . . . 266, 276
\fp_eval:n . . . . 258, 261, 265, 270–277 \c_one_degree_fp . . . . . . . . . . 266, 276
\fp_format:nn . . . . . . . . . . . . . . . 278 \c_one_fp . . . . . . . . . . . . . . . . . . . 266
\fp_gadd:Nn . . . . . . . . . . . . . . . . . 257 \c_pi_fp . . . . . . . . . . . . . . . . 266, 276
.fp_gset:N . . . . . . . . . . . . . . . . . . 240 \g_tmpa_fp . . . . . . . . . . . . . . . . . . 266
\fp_gset:Nn . . . . . . . . . . . . . . . . . 257 \l_tmpa_fp . . . . . . . . . . . . . . . . . . 266
\fp_gset_eq:NN . . . . . . . . . . . . . . 257 \g_tmpb_fp . . . . . . . . . . . . . . . . . . 266
\fp_gsub:Nn . . . . . . . . . . . . . . . . . 258 \l_tmpb_fp . . . . . . . . . . . 263, 264, 266
\fp_gzero:N . . . . . . . . . . . . . . . . . 257 \c_zero_fp . . . . . . . . . . . . . . . . . . 266
\fp_gzero_new:N . . . . . . . . . . . . . 257 fparray commands:
\fp_if_exist:NTF . . . . . . . . . . . . . 259 \fparray_count:N . . . . . . . . . . . . . 280
\fp_if_exist_p:N . . . . . . . . . . . . . 259 \fparray_gset:Nnn . . . . . . . . . . . . 280
335
\fparray_gzero:N . . . . . . . . . . . . . 280 \if_charcode:w . . . . . . . . . . . 29, 194
\fparray_item:Nn . . . . . . . . . . . . . 280 \if_cs_exist:N . . . . . . . . . . . . . . . 29
\fparray_item_to_tl:Nn . . . . . . . . 280 \if_cs_exist:w . . . . . . . . . . . . . . . 29
\fparray_new:Nn . . . . . . . . . . . . . 280 \if_dim:w . . . . . . . . . . . . . . . . . . . 236
\if_eof:w . . . . . . . . . . . . . . . . . . . 100
G \if_false: . . . . . . . . . . . . . 28, 66, 207
\GetIdInfo . . . . . . . . . . . . . . . . . . . . . 10 \if_hbox:N . . . . . . . . . . . . . . . . . . 306
group commands: \if_int_compare:w . . . . . . . . . 28, 179
\group_align_safe_begin: . . . . . . . 74 \if_int_odd:w . . . . . . . . . . . . . . . 180
\group_align_safe_end: . . . . . . . . . 74 \if_meaning:w . . . . . . . . . . . . . . . . 29
\group_begin: . . . . . . . . . . . . . . . . 13 \if_mode_horizontal: . . . . . . . . . . 29
\c_group_begin_token . . . . . . 115, 207 \if_mode_inner: . . . . . . . . . . . . . . 29
\group_end: . . . . . . . . . . . . . . . 13, 14 \if_mode_math: . . . . . . . . . . . . . . . 29
\group_insert_after:N . . . . . . . . . 14 \if_mode_vertical: . . . . . . . . . . . . 29
\group_log_list: . . . . . . . . . . . . . . 14 \if_predicate:w . . . . . . . . . 64, 66, 73
\group_show_list: . . . . . . . . . . . . . 14 \if_true: . . . . . . . . . . . . . . . . . 28, 66
groups commands: \if_vbox:N . . . . . . . . . . . . . . . . . . 306
.groups:n . . . . . . . . . . . . . . . . . . . 241 in . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
inf . . . . . . . . . . . . . . . . . . . . . . . . . . 276
H inherit commands:
hbox commands: .inherit:n . . . . . . . . . . . . . . . . . . 241
\hbox:n . . . . . . . . . . . . . . . . . 294, 298 initial commands:
\hbox_gset:Nn . . . . . . . . . . . . . . . 298 .initial:n . . . . . . . . . . . . . . . . . . 241
\hbox_gset:Nw . . . . . . . . . . . . . . . 299 int commands:
\hbox_gset_end: . . . . . . . . . . . . . 299 \int_abs:n . . . . . . . . . . . . . . . . . . 168
\hbox_gset_to_wd:Nnn . . . . . . . . . 299 \int_add:Nn . . . . . . . . . . . . . . . . . 169
\hbox_gset_to_wd:Nnw . . . . . . . . . 299 \int_case:nn . . . . . . . . . . . . . . . . 172
\hbox_overlap_center:n . . . . . . . . 299 \int_case:nnTF . . . . . . . . . . . . . . 172
\hbox_overlap_left:n . . . . . . . . . 299 \int_compare:nNnTF . . . . 170–173, 260
\hbox_overlap_right:n . . . . . . . . 299 \int_compare:nTF . . 170, 171, 173, 261
\hbox_set:Nn . . . . . 294, 298, 299, 313 \int_compare_p:n . . . . . . . . . . . . . 171
\hbox_set:Nw . . . . . . . . . . . . . . . . 299 \int_compare_p:nNn . . . . . . . . 28, 170
\hbox_set_end: . . . . . . . . . . . . . . 299 \int_const:Nn . . . . . . . . . . . . . . . 168
\hbox_set_to_wd:Nnn . . . . . . . . . . 299 \int_decr:N . . . . . . . . . . . . . . . . . 169
\hbox_set_to_wd:Nnw . . . . . . . . . . 299 \int_div_round:nn . . . . . . . . . . . . 168
\hbox_to_wd:nn . . . . . . . . . . . . . . 298 \int_div_truncate:nn . . . . . . . . . 168
\hbox_to_zero:n . . . . . . . . . . . . . 298 \int_do_until:nn . . . . . . . . . . . . . 173
\hbox_unpack:N . . . . . . . . . . . . . . 299 \int_do_until:nNnn . . . . . . . . . . . 172
\hbox_unpack_drop:N . . . . . . . . . . 302 \int_do_while:nn . . . . . . . . . . . . . 173
hcoffin commands: \int_do_while:nNnn . . . . . . . . . . . 173
\hcoffin_gset:Nn . . . . . . . . . . . . . 308 \int_eval:n . . . . . 19, 34, 166–172, 179
\hcoffin_gset:Nw . . . . . . . . . . . . . 308 \int_eval:w . . . . . . . . . . . . . . . . . 167
\hcoffin_gset_end: . . . . . . . . . . . 308 \int_from_alph:n . . . . . . . . . . . . . 176
\hcoffin_set:Nn . . . . . . . . . . 308, 309 \int_from_base:nn . . . . . . . . . . . . 177
\hcoffin_set:Nw . . . . . . . . . . . . . 308 \int_from_bin:n . . . . . . . . . . . . . 176
\hcoffin_set_end: . . . . . . . . . . . . 308 \int_from_hex:n . . . . . . . . . . . . . 177
\int_from_oct:n . . . . . . . . . . . . . 177
I \int_from_roman:n . . . . . . . . . . . . 177
if commands: \int_gadd:Nn . . . . . . . . . . . . . . . . 169
\if:w . . . . . . . . ... . . . . . . 28, 29, 194 \int_gdecr:N . . . . . . . . . . . . . . . . 169
\if_bool:N . . . . ... . . . . . . ...... 73 \int_gincr:N . . . . . . . . . . . . . . . . 169
\if_box_empty:N .. . . . . . . ..... 306 .int_gset:N . . . . . . . . . . . . . . . . . 241
\if_case:w . . . . ... . . . . . . ..... 179 \int_gset:Nn . . . . . . . . . . . . . . . . 169
\if_catcode:w . ... . . . . . . ...... 29 \int_gset_eq:NN . . . . . . . . . . . . . 169
336
\int_gsub:Nn . . . . . . . . . . . . . . . . 170 \int_while_do:nn . . . . . . . . . . . . . 173
\int_gzero:N . . . . . . . . . . . . . . . . 169 \int_while_do:nNnn . . . . . . . . . . . 173
\int_gzero_new:N . . . . . . . . . . . . . 169 \int_zero:N . . . . . . . . . . . . . . . . . 169
\int_if_even:nTF . . . . . . . . . . . . . 172 \int_zero_new:N . . . . . . . . . . . . . 169
\int_if_even_p:n . . . . . . . . . . . . . 172 \c_max_char_int . . . . . . . . . . . . . 178
\int_if_exist:NTF . . . . . . . . . . . . 169 \c_max_int . . . . . . . . . . . . . . . 178, 253
\int_if_exist_p:N . . . . . . . . . . . . 169 \c_max_register_int . . . . . . . . . . 178
\int_if_odd:nTF . . . . . . . . . . . . . 172 \c_one_int . . . . . . . . . . . . . . . . . . 178
\int_if_odd_p:n . . . . . . . . . . . . . 172 \g_tmpa_int . . . . . . . . . . . . . . . . . 178
\int_if_zero:nTF . . . . . . . . . . . . . 172 \l_tmpa_int . . . . . . . . . . . . . 4, 53, 178
\int_if_zero_p:n . . . . . . . . . . . . . 172 \g_tmpb_int . . . . . . . . . . . . . . . . . 178
\int_incr:N . . . . . . . . . . . . . . . . . 169 \l_tmpb_int . . . . . . . . . . . . . . . 4, 178
\int_log:N . . . . . . . . . . . . . . . . . . 178 \c_zero_int . . . . . . . . . . . . . . . . . 178
\int_log:n . . . . . . . . . . . . . . . . . . 178 intarray commands:
\int_max:nn . . . . . . . . . . . . . . . . . 168 \intarray_const_from_clist:Nn . . 254
\int_min:nn . . . . . . . . . . . . . . . . . 168 \intarray_count:N . . . . . . . . . 253, 254
\int_mod:nn . . . . . . . . . . . . . . . . . 168 \intarray_gset:Nnn . . . . . . . . . . . 253
\int_new:N . . . . . . . . . . . . . . . 168, 169 \intarray_gzero:N . . . . . . . . . . . . 254
\int_rand:n . . . . . . . . . . . . . . . . . 177 \intarray_item:Nn . . . . . . . . . . . . 254
\int_rand:nn . . . . . . . . . . . . . 78, 177 \intarray_log:N . . . . . . . . . . . . . 254
.int_set:N . . . . . . . . . . . . . . . . . . 241 \intarray_new:Nn . . . . . . . . . . . . . 253
\int_set:Nn . . . . . . . . . . . . . . . . . 169 \intarray_rand_item:N . . . . . . . . 254
\int_set_eq:NN . . . . . . . . . . . . . . 169 \intarray_show:N . . . . . . . . . . . . . 254
\int_show:N . . . . . . . . . . . . . . . . . 177 ior commands:
\int_show:n . . . . . . . . . . . . . . . . . 178 \ior_close:N . . . . . . . . . . . . . . 92, 93
\int_sign:n . . . . . . . . . . . . . . . . . 168 \ior_get:NN . . . . . . . . . . . . . 93–95, 97
\int_step_function:nN . . . . . . . . 174 \ior_get:NNTF . . . . . . . . . . . . . . . . 94
\int_step_function:nnN . . . . . . . . 174 \ior_get_term:nN . . . . . . . . . . . . . . 97
\int_step_function:nnnN . . . . 74, 174 \ior_if_eof:NTF . . . . . . . . . . . . . . 96
\int_step_inline:nn . . . . . . . . . . 174 \ior_if_eof_p:N . . . . . . . . . . . . . . 96
\int_step_inline:nnn . . . . . . . . . 174 \ior_log:N . . . . . . . . . . . . . . . . . . . 93
\int_step_inline:nnnn . . . . . . . . 174 \ior_log_list: . . . . . . . . . . . . . . . 93
\int_step_variable:nNn . . . . . . . . 174 \ior_map_break: . . . . . . . . . . . . . . 96
\int_step_variable:nnNn . . . . . . . 174 \ior_map_break:n . . . . . . . . . . . . . . 96
\int_step_variable:nnnNn . . . . . . 174 \ior_map_inline:Nn . . . . . . . . . . . . 95
\int_sub:Nn . . . . . . . . . . . . . . . . . 170 \ior_map_variable:NNn . . . . . . . . . 95
\int_to_Alph:n . . . . . . . . . . . 175, 176 \ior_new:N . . . . . . . . . . . . . . . . . . . 92
\int_to_alph:n . . . . . . . . . . . 175, 176 \ior_open:Nn . . . . . . . . . . . . . . . . . 92
\int_to_arabic:n . . . . . . . . . . . . . 175 \ior_open:NnTF . . . . . . . . . . . . . . . 92
\int_to_Base:n . . . . . . . . . . . . . . 176 \ior_shell_open:Nn . . . . . . . . . . . . 92
\int_to_base:n . . . . . . . . . . . . . . 176 \ior_show:N . . . . . . . . . . . . . . . . . . 93
\int_to_Base:nn . . . . . . . . . . 176, 177 \ior_show_list: . . . . . . . . . . . . . . 93
\int_to_base:nn . . . . . . . . . . 176, 177 \ior_str_get:NN . . . . . . . . 93, 94, 97
\int_to_bin:n . . . . . . . . . . . . . . . 176 \ior_str_get:NNTF . . . . . . . . . . . . . 94
\int_to_Hex:n . . . . . . . . . . . . 176, 177 \ior_str_get_term:nN . . . . . . . . . . 97
\int_to_hex:n . . . . . . . . . . . . 176, 177 \ior_str_map_inline:Nn . . . . . . . . . 95
\int_to_oct:n . . . . . . . . . . . . 176, 177 \ior_str_map_variable:NNn . . . . . . 95
\int_to_Roman:n . . . . . . . . . . 176, 177 \g_tmpa_ior . . . . . . . . . . . . . . . . . 100
\int_to_roman:n . . . . . . . . . . 176, 177 \g_tmpb_ior . . . . . . . . . . . . . . . . . 100
\int_to_symbols:nnn . . . . . . . . . . 175 iow commands:
\int_until_do:nn . . . . . . . . . . . . . 173 \iow_char:N . . . . . . . . . . . . . . . 84, 98
\int_until_do:nNnn . . . . . . . . . . . 173 \iow_close:N . . . . . . . . . . . . . . 92, 93
\int_use:N . . . . . . . . . . . 165, 167, 170 \iow_indent:n . . . . . . . . . . . . . . . . 99
\int_value:w . . . . . . . . . . . . . 166, 179 \l_iow_line_count_int . . . . . 99, 100
337
\iow_log:N . . . . . . . . . . . . . . . . . . . 93 \legacy_if_gset_false:n . . . . . . . 109
\iow_log:n . . . . . . . . . . . . . . . . . . . 97 .legacy_if_gset_inverse:n . . . . . 241
\iow_log_list: . . . . . . . . . . . . . . . 93 \legacy_if_gset_true:n . . . . . . . . 109
\iow_new:N . . . . . . . . . . . . . . . . . . . 92 \legacy_if_p:n . . . . . . . . . . . . . . 109
\iow_newline: . . . . . . . . . . . 84, 97–99 .legacy_if_set:n . . . . . . . . . . . . . 241
\iow_now:Nn . . . . . . . . . . . . . . . 97, 98 \legacy_if_set:nn . . . . . . . . . . . . 109
\iow_open:Nn . . . . . . . . . . . . . . . . . 92 \legacy_if_set_false:n . . . . . . . . 109
\iow_shell_open:Nn . . . . . . . . . . . . 92 .legacy_if_set_inverse:n . . . . . . 241
\iow_shipout:Nn . . . . . . . . . . . 97, 98 \legacy_if_set_true:n . . . . . . . . 109
\iow_shipout_e:Nn . . . . . . . . . . 97, 98 ln . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
\iow_show:N . . . . . . . . . . . . . . . . . . 93 logb . . . . . . . . . . . . . . . . . . . . . . . . . . 272
\iow_show_list: . . . . . . . . . . . . . . 93 ltx.utils . . . . . . . . . . . . . . . . . . . . . 107
\iow_term:n . . . . . . . . . . . . . . . . . . 97 ltx.utils.filedump . . . . . . . . . . . . . . 107
\iow_wrap:nnnN . . . . . . . . . . . . 97–100 ltx.utils.filemd5sum . . . . . . . . . . . . 107
\iow_wrap_allow_break: . . . . . . . . . 99 ltx.utils.filemoddate . . . . . . . . . . . 107
\c_log_iow . . . . . . . . . . . . . . . . . . 100 ltx.utils.filesize . . . . . . . . . . . . . . 108
\c_term_iow . . . . . . . . . . . . . . . . . 100 lua commands:
\g_tmpa_iow . . . . . . . . . . . . . . . . . 100 \lua_escape:n . . . . . . . . . . . . ... 107
\g_tmpb_iow . . . . . . . . . . . . . . . . . 100 \lua_load_module:n . . . . . . . . ... 107
\lua_now:n . . . . . . . . . . . . . . . 106, 107
K \lua_shipout:n . . . . . . . . . . . ... 106
keys commands: \lua_shipout_e:n . . . . . . . . . . ... 106
\l_keys_choice_int 239, 242, 244, 246
\l_keys_choice_tl . 239, 242, 244, 246 M
\keys_define:nn . . . . . . . . . . . . . 238 max . . . . . . . . . . . . . . . . . . . . . . . . . . 272
\keys_if_choice_exist:nnnTF . . . 249 meta commands:
\keys_if_choice_exist_p:nnn . . . 249 .meta:n . . . . . . . . . . . . . . . . . . . . 241
\keys_if_exist:nnTF . . . . . . . . . . 249 .meta:nn . . . . . . . . . . . . . . . . . . . 242
\keys_if_exist_p:nn . . . . . . . . . . 249 min . . . . . . . . . . . . . . . . . . . . . . . . . . 272
\l_keys_key_str . . . . . . . . . . . . . 247 mm . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
\keys_log:nn . . . . . . . . . . . . . . . . 249 mode commands:
\l_keys_path_str . . . . . . . . . . . . . 247 \mode_if_horizontal:TF . . . . . . . . . 72
\keys_precompile:nnN . . . . . . . . . 249 \mode_if_horizontal_p: . . . . . . . . . 72
\keys_set:nn . . 238, 240, 241, 246–249 \mode_if_inner:TF . . . . . . . . . . . . . 73
\keys_set_filter:nnn . . . . . . . . . 248 \mode_if_inner_p: . . . . . . . . . . . . . 73
\keys_set_filter:nnnN . . . . . . . . 248 \mode_if_math:TF . . . . . . . . . . . . . . 73
\keys_set_filter:nnnnN . . . . . . . . 248 \mode_if_math_p: . . . . . . . . . . . . . . 73
\keys_set_groups:nnn . . . . . . . . . 249 \mode_if_vertical:TF . . . . . . . . . . 73
\keys_set_known:nn . . . . . . . . . . . 247 \mode_if_vertical_p: . . . . . . . . . . 73
\keys_set_known:nnN . . . . . . . . . . 247 \mode_leave_vertical: . . . . . . . . . 29
\keys_set_known:nnnN . . . . . . . . . 247 msg commands:
\keys_show:nn . . . . . . . . . . . . . . . 249 \msg_critical:nn . . . . . . . . . . 85, 105
\l_keys_usage_load_prop . . . . . . . 246 \msg_critical:nnn . . . . . . . . . . . . . 85
\l_keys_usage_preamble_prop . . . 246 \msg_critical:nnnn . . . . . . . . . . . . 85
\l_keys_value_tl . . . . . . . . . . . . . 247 \msg_critical:nnnnn . . . . . . . . . . . 85
keyval commands: \msg_critical:nnnnnn . . . . . . . . . . 85
\keyval_parse:NNn . . . . . . . . . . . . 252 \msg_critical_text:n . . . . . . . . . . 83
\keyval_parse:nnn . . . . . . . . . 251, 252 \msg_error:nn . . . . . . . . . . . . . . . . 85
\msg_error:nnn . . . . . . . . . . . . . . . 85
L \msg_error:nnnn . . . . . . . . . . . . . . 85
legacy commands: \msg_error:nnnnn . . . . . . . . . . . . . . 85
\legacy_if:nTF . . . . . . . . . . . . . . 109 \msg_error:nnnnnn . . . . . . . . . . 85, 88
.legacy_if_gset:n . . . . . . . . . . . . 241 \msg_error_text:n . . . . . . . . . . . . . 83
\legacy_if_gset:nn . . . . . . . . . . . 109 \msg_expandable_error:nn . . . . . . . 89
338
\msg_expandable_error:nnn . . . . .. 89 \msg_show_item:n . . . . . . . . . . . . . . 88
\msg_expandable_error:nnnn . . . .. 89 \msg_show_item:nn . . . . . . . . . . . . . 88
\msg_expandable_error:nnnnn . . .. 89 \msg_show_item_unbraced:n . . . . . . 88
\msg_expandable_error:nnnnnn . .. 89 \msg_show_item_unbraced:nn . . . . . 88
\msg_fatal:nn . . . . . . . . . . . . . . .. 85 \msg_term:nn . . . . . . . . . . . . . . . . . 87
\msg_fatal:nnn . . . . . . . . . . . . . .. 85 \msg_term:nnn . . . . . . . . . . . . . . . . 87
\msg_fatal:nnnn . . . . . . . . . . . . .. 85 \msg_term:nnnn . . . . . . . . . . . . . . . 87
\msg_fatal:nnnnn . . . . . . . . . . . . .. 85 \msg_term:nnnnn . . . . . . . . . . . . . . 87
\msg_fatal:nnnnnn . . . . . . . . . . . .. 85 \msg_term:nnnnnn . . . . . . . . . . . . . . 87
\msg_fatal_text:n . . . . . . . . . . . .. 83 \msg_warning:nn . . . . . . . . . . . . . . 86
\msg_gset:nnn . . . . . . . . . . . . . . .. 82 \msg_warning:nnn . . . . . . . . . . . . . . 86
\msg_gset:nnnn . . . . . . . . . . . . . .. 82 \msg_warning:nnnn . . . . . . . . . . . . . 86
\msg_if_exist:nnTF . . . . . . . . . . .. 82 \msg_warning:nnnnn . . . . . . . . . . . . 86
\msg_if_exist_p:nn . . . . . . . . . . .. 82 \msg_warning:nnnnnn . . . . . . . . . . . 86
\msg_info:nn . . . . . . . . . . . . . . . .. 86 \msg_warning_text:n . . . . . . . . . . . 83
\msg_info:nnn . . . . . . . . . . . . . . .. 86 multichoice commands:
\msg_info:nnnn . . . . . . . . . . . . . .. 86 .multichoice: . . . . . . . . . . . . . . . 242
\msg_info:nnnnn . . . . . . . . . . . . .. 86 multichoices commands:
\msg_info:nnnnnn . . . . . . . . . . . 86, 87 .multichoices:nn . . . . . . . . . . . . . 242
\msg_info_text:n . . . . . . . . . . . . .. 83 muskip commands:
\msg_line_context: . . . . . . . . . . .. 83 \c_max_muskip . . . . . . . . . . . . . . . 236
\msg_line_number: . . . . . . . . . . . .. 83 \muskip_add:Nn . . . . . . . . . . . . . . 234
\msg_log:nn . . . . . . . . . . . . . . . . .. 87 \muskip_const:Nn . . . . . . . . . . . . . 234
\msg_log:nnn . . . . . . . . . . . . . . . .. 87 \muskip_eval:n . . . . . . . . . . . . . . 235
\msg_log:nnnn . . . . . . . . . . . . . . .. 87 \muskip_gadd:Nn . . . . . . . . . . . . . 234
\msg_log:nnnnn . . . . . . . . . . . . . .. 87 .muskip_gset:N . . . . . . . . . . . . . . 242
\msg_log:nnnnnn . . . . . . . . . . . . .. 87 \muskip_gset:Nn . . . . . . . . . . . . . 235
\msg_module_name:n . . . . . . . . . 82, 84 \muskip_gset_eq:NN . . . . . . . . . . . 235
\g_msg_module_name_prop . . . . . . .. 82 \muskip_gsub:Nn . . . . . . . . . . . . . 235
\msg_module_type:n . . . . . . . . . 82, 83 \muskip_gzero:N . . . . . . . . . . . . . 234
\g_msg_module_type_prop . . . . . . .. 82 \muskip_gzero_new:N . . . . . . . . . . 234
\msg_new:nnn . . . . . . . . . . . . . . . .. 82 \muskip_if_exist:NTF . . . . . . . . . 234
\msg_new:nnnn . . . . . . . . . . . . . . .. 82 \muskip_if_exist_p:N . . . . . . . . . 234
\msg_none:nn . . . . . . . . . . . . . . . .. 87 \muskip_log:N . . . . . . . . . . . . . . . 236
\msg_none:nnn . . . . . . . . . . . . . . .. 87 \muskip_log:n . . . . . . . . . . . . . . . 236
\msg_none:nnnn . . . . . . . . . . . . . .. 87 \muskip_new:N . . . . . . . . . . . . . . . 234
\msg_none:nnnnn . . . . . . . . . . . . .. 87 .muskip_set:N . . . . . . . . . . . . . . . 242
\msg_none:nnnnnn . . . . . . . . . . . . .. 87 \muskip_set:Nn . . . . . . . . . . . . . . 235
\msg_note:nn . . . . . . . . . . . . . . . .. 86 \muskip_set_eq:NN . . . . . . . . . . . . 235
\msg_note:nnn . . . . . . . . . . . . . . .. 86 \muskip_show:N . . . . . . . . . . . . . . 235
\msg_note:nnnn . . . . . . . . . . . . . .. 86 \muskip_show:n . . . . . . . . . . . . . . 236
\msg_note:nnnnn . . . . . . . . . . . . .. 86 \muskip_sub:Nn . . . . . . . . . . . . . . 235
\msg_note:nnnnnn . . . . . . . . . . . . .. 86 \muskip_use:N . . . . . . . . . . . . . . . 235
\msg_redirect_class:nn . . . . . . . .. 90 \muskip_zero:N . . . . . . . . . . . . . . 234
\msg_redirect_module:nnn . . . . . .. 90 \muskip_zero_new:N . . . . . . . . . . . 234
\msg_redirect_name:nnn . . . . . . . .. 90 \g_tmpa_muskip . . . . . . . . . . . . . . 236
\msg_see_documentation_text:n . .. 84 \l_tmpa_muskip . . . . . . . . . . . . . . 236
\msg_set:nnn . . . . . . . . . . . . . . . .. 82 \g_tmpb_muskip . . . . . . . . . . . . . . 236
\msg_set:nnnn . . . . . . . . . . . . . . .. 82 \l_tmpb_muskip . . . . . . . . . . . . . . 236
\msg_show:nn . . . . . . . . . . . . . . . .. 88 \c_zero_muskip . . . . . . . . . . . . . . 236
\msg_show:nnn . . . . . . . . . . . . . . .. 88
\msg_show:nnnn . . . . . . . . . . . . . .. 88 N
\msg_show:nnnnn . . . . . . . . . . . . .. 88 nan . . . . . . . . . . . . . . . . . . . . . . . . . . 276
\msg_show:nnnnnn . . . . . . . . . . . . .. 88 nc . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
339
nd . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 \peek_regex_replace_once:nn . . . 209
\notexpanded: ⟨token ⟩ . . . . . . . . . . 209 \peek_regex_replace_once:NnTF . . 209
\num . . . . . . . . . . . . . . . . . . . . . . . . . . 256 \peek_regex_replace_once:nnTF . . 209
\peek_remove_filler:n . . . . . . . . 206
O \peek_remove_spaces:n . . . . . . . . 205
or commands: \g_peek_token . . . . . . . . . . . . . . . 204
\or: . . . . . . . . . . . . . . . . . . . . . . . 179 \l_peek_token . . . . . . . . . . . . 204, 207
pi . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
P prg commands:
\par . . . . . . . . . . . . . . . . . . . . . . 15–19, 94 \prg_break: . . . . . . . . . . . . . . . . . . 74
pc . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 \prg_break:n . . . . . . . . . . . . . . . . . 74
pdf commands: \prg_break_point: . . . . . . . . . . . . . 74
\pdf_destination:nn . . . . . . . . . . 324 \prg_break_point:Nn . . . . . 73, 74, 149
\pdf_destination:nnnn . . . . . . . . 324 \prg_do_nothing: . . . . . . . . . . . 13, 74
\pdf_object_if_exist:nTF . . . . . . 322 \prg_generate_conditional_-
\pdf_object_if_exist_p:n . . . . . . 322 variant:Nnn . . . . . . . . . . . . . 33, 66
\pdf_object_new:n . . . . . . . . . . . . 321 \prg_gset_conditional:Nnn . . . . . . 64
\pdf_object_ref:n . . . . . . . . . . . . 321 \prg_gset_conditional:Npnn . . . . . 64
\pdf_object_ref_last: . . . . . . . . 322 \prg_gset_eq_conditional:NNn . . . 66
\pdf_object_unnamed_write:nn . . 322 \prg_gset_protected_conditional:Nnn
\pdf_object_write:nn . . . . . . . . . 321 . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\pdf_object_write:nnn . . . . . . . . 321 \prg_gset_protected_conditional:Npnn
\pdf_pageobject_ref:n . . . . . . . . 322 . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\pdf_pagesize_gset:nn . . . . . . . . 323 \prg_map_break:Nn . . . . . . . . . . 73, 74
\pdf_pagobject_ref:n . . . . . . . . . 322 \prg_new_conditional:Nnn . . . . . . . 64
\pdf_uncompress: . . . . . . . . . . . . . 323 \prg_new_conditional:Npnn . . . 64–66
\pdf_version: . . . . . . . . . . . . . . . 322 \prg_new_eq_conditional:NNn . . . . 66
\pdf_version_compare:Nn . . . . . . . 322 \prg_new_protected_conditional:Nnn
\pdf_version_compare:NnTF . . . . . 322 . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\pdf_version_compare_p:Nn . . . . . 322 \prg_new_protected_conditional:Npnn
\pdf_version_gset:n . . . . . . . . . . 322 . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\pdf_version_major: . . . . . . . . . . 322 \prg_replicate:nn . . . . . . 72, 119, 158
\pdf_version_min_gset:n . . . . . . . 322 \prg_return_false: . . . . . . . . . 65, 66
\pdf_version_minor: . . . . . . . . . . 322 \prg_return_true: . . . . . . . . . . 65, 66
\pdfstrcmp . . . . . . . . . . . . . . . . . . . . 133 \prg_set_conditional:Nnn . . . . . . . 64
peek commands: \prg_set_conditional:Npnn . . . 64–66
\peek_after:Nw . . . . . . . . . . . 74, 204 \prg_set_eq_conditional:NNn . . . . 66
\peek_analysis_map_break: . . . . . 207 \prg_set_protected_conditional:Nnn
\peek_analysis_map_break:n . . . . 207 . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\peek_analysis_map_inline:n . . . . \prg_set_protected_conditional:Npnn
. . . . . . . . . . . . . . . . . . 46, 204, 207 . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\peek_catcode:NTF . . . . . . . . . . . . 205 prop commands:
\peek_catcode_remove:NTF . . . . . . 205 \c_empty_prop . . . . . . . . . . . . . . . 220
\peek_charcode:NTF . . . . 205, 208, 209 \prop_clear:N . . . . . . . . . . . . . . . 212
\peek_charcode_remove:NTF . . 205, 208 \prop_clear_new:N . . . . . . . . . . . . 212
\peek_gafter:Nw . . . . . . . . . . . . . 204 \prop_concat:NNN . . . . . . . . . . 214, 215
\peek_meaning:NTF . . . . . . . . . . . . 205 \prop_const_from_keyval:Nn . . . . 213
\peek_meaning_remove:NTF . . . . . . 205 \prop_count:N . . . . . . . . . . . . . . . 216
\peek_N_type:TF . . . . . . . . . . . . . 206 \prop_gclear:N . . . . . . . . . . . . . . 212
\peek_regex:NTF . . . . . . . . . . . . . 208 \prop_gclear_new:N . . . . . . . . . . . 212
\peek_regex:nTF . . . . . . . . . . . . . 208 \prop_gconcat:NNN . . . . . . . . . . . . 214
\peek_regex_remove_once:NTF . . . 208 \prop_get:NnN . . . . 146, 147, 215, 216
\peek_regex_remove_once:nTF . . . 208 \prop_get:NnNTF . . . . . . . . . . 215, 217
\peek_regex_replace_once:Nn . . . 209 \prop_gpop:NnN . . . . . . . . . . . . . . 215
340
\prop_gpop:NnNTF . . . . . . . . . . 215, 218 \quark_if_no_value_p:N . . . . . . . . 147
.prop_gput:N . . . . . . . . . . . . . ... 242 \quark_if_no_value_p:n . . . . . . . . 147
\prop_gput:Nnn . . . . . . . . . . . ... 214 \quark_if_recursion_tail_-
\prop_gput_from_keyval:Nn . . ... 215 break:NN . . . . . . . . . . . . . . . . . 149
\prop_gput_if_new:Nnn . . . . . ... 214 \quark_if_recursion_tail_-
\prop_gremove:Nn . . . . . . . . . . ... 216 break:nN . . . . . . . . . . . . . . . . . 149
\prop_gset_eq:NN . . . . . . . . . . ... 213 \quark_if_recursion_tail_stop:N 148
\prop_gset_from_keyval:Nn . . ... 213 \quark_if_recursion_tail_stop:n 148
\prop_if_empty:NTF . . . . . . . . ... 217 \quark_if_recursion_tail_stop_-
\prop_if_empty_p:N . . . . . . . . ... 217 do:Nn . . . . . . . . . . . . . . . . . . . . 148
\prop_if_exist:NTF . . . . . . . . ... 216 \quark_if_recursion_tail_stop_-
\prop_if_exist_p:N . . . . . . . . ... 216 do:nn . . . . . . . . . . . . . . . . . . . . 148
\prop_if_in:NnTF . . . . . . . . . . ... 217 \quark_new:N . . . . . . . . . . . . . . . . 147
\prop_if_in_p:Nn . . . . . . . . . . ... 217 \q_recursion_stop . . . 26, 27, 148, 149
\prop_item:Nn . . . . . . . . . . . . 216, 218 \q_recursion_tail . . . . . . . . . 148, 149
\prop_log:N . . . . . . . . . . . . . . ... 220 \q_stop . . . . . 26, 27, 38, 121, 146, 147
\prop_map_break: . . . . . . . . . . ... 219
\prop_map_break:n . . . . . . . . . ... 219 R
\prop_map_function:NN . . . . . 88, 218 rand . . . . . . . . . . . . . . . . . . . . . . . . . . 276
\prop_map_inline:Nn . . . . . . . ... 218 randint . . . . . . . . . . . . . . . . . . . . . . . 276
\prop_map_tokens:Nn . . . . . . . ... 218 regex commands:
\prop_new:N . . . . . . . . . . . . . . ... 212 \regex_const:Nn . . . . . . . . . . . . . . 55
\prop_pop:NnN . . . . . . . . . . . . ... 215 \regex_count:NnN . . . . . . . . . . . . . . 56
\prop_pop:NnNTF . . . . . . . . . . 215, 217 \regex_count:nnN . . . . . . . . . . . . . . 56
.prop_put:N . . . . . . . . . . . . . . ... 242 \regex_extract_all:NnN . . . . . . . . . 58
\prop_put:Nnn . . . . . . . . . . . . 214, 215 \regex_extract_all:nnN . . . . . . 48, 58
\prop_put_from_keyval:Nn . . . ... 215 \regex_extract_all:NnNTF . . . . . . . 58
\prop_put_if_new:Nnn . . . . . . ... 214 \regex_extract_all:nnNTF . . . . . . . 58
\prop_remove:Nn . . . . . . . . . . ... 216 \regex_extract_once:NnN . . . . . . . . 57
\prop_set_eq:NN . . . . . . . . . . ... 213 \regex_extract_once:nnN . . . . . 57, 58
\prop_set_from_keyval:Nn . . . 213, 215 \regex_extract_once:NnNTF . . . . . . 57
\prop_show:N . . . . . . . . . . . . . ... 219 \regex_extract_once:nnNTF . . . 51, 57
\prop_to_keyval:N . . . . . . . . . ... 216 \regex_gset:Nn . . . . . . . . . . . . . . . 55
\g_tmpa_prop . . . . . . . . . . . . . ... 220 \regex_log:N . . . . . . . . . . . . . . . . . 56
\l_tmpa_prop . . . . . . . . . . . . . ... 220 \regex_log:n . . . . . . . . . . . . . . . . . 56
\g_tmpb_prop . . . . . . . . . . . . . ... 220 \regex_match:NnTF . . . . . . . . . . . . . 56
\l_tmpb_prop . . . . . . . . . . . . . ... 220 \regex_match:nnTF . . . . . . . . . . 56, 57
\ProvidesExplClass . . . . . . . . . . . .... . 9 \regex_match_case:nn . . . . . . . 57, 59
\ProvidesExplFile . . . . . . . . . . . .... . 9 \regex_match_case:nnTF . . . . . . . . . 57
\ProvidesExplPackage . . . . . . . . . .... . 9 \regex_new:N . . . . . . . . . . . . . . . . . 55
pt . . . . . . . . . . . . . . . . . . . . . . . . ... 277 \regex_replace:nnN . . . . . . . . . . . 195
\regex_replace_all:NnN . . . . . . . . . 59
Q \regex_replace_all:nnN . . . . . . 48, 59
quark commands: \regex_replace_all:NnNTF . . . . . . . 59
\q_mark . . . . . . . . . . . . . . . . . . . . 147 \regex_replace_all:nnNTF . . . . . . . 59
\q_nil . . . . . . . . . . . . 26, 27, 127, 147 \regex_replace_case_all:nN . . . . . 60
\q_no_value . . . . . 78, 94, 101, 103, \regex_replace_case_all:nNTF . . . 60
104, 146, 147, 153, 154, 161, 191, 215 \regex_replace_case_once:nN . . . . 59
\quark_if_nil:NTF . . . . . . . . . . . . 147 \regex_replace_case_once:nNTF . . . 59
\quark_if_nil:nTF . . . . . . . . . . . . 147 \regex_replace_once:NnN . . . . . . . . 58
\quark_if_nil_p:N . . . . . . . . . . . . 147 \regex_replace_once:nnN . . 57–59, 209
\quark_if_nil_p:n . . . . . . . . . . . . 147 \regex_replace_once:NnNTF . . . . . . 58
\quark_if_no_value:NTF . . . . . . . . 147 \regex_replace_once:nnNTF . . . . . . 58
\quark_if_no_value:nTF . . . . . . . . 147 \regex_set:Nn . . . . . . . . . . 47, 55, 56
341
\regex_show:N . . . . . . . . . . . ..... 56 \seq_gset_item:NnnTF . . . . . . . . . 156
\regex_show:n . . . . . . . . . . . 48, 53, 56 \seq_gset_map:NNn . . . . . . . . . . . . 159
\regex_split:NnN . . . . . . . . . ..... 58 \seq_gset_map_e:NNn . . . . . . . . . . 160
\regex_split:nnN . . . . . . . . . ..... 58 \seq_gset_split:Nnn . . . . . . . . . . 152
\regex_split:NnNTF . . . . . . . ..... 58 \seq_gset_split_keep_spaces:Nnn 152
\regex_split:nnNTF . . . . . . . ..... 58 \seq_gshuffle:N . . . . . . . . . . . . . 157
\g_tmpa_regex . . . . . . . . . . . ..... 60 \seq_gsort:Nn . . . . . . . . . . . . . . . 157
\l_tmpa_regex . . . . . . . . . . . ..... 60 \seq_if_empty:NTF . . . . . . . . . . . . 157
\g_tmpb_regex . . . . . . . . . . . ..... 60 \seq_if_empty_p:N . . . . . . . . . . . . 157
\l_tmpb_regex . . . . . . . . . . . ..... 60 \seq_if_exist:NTF . . . . . . . . . . . . 153
reverse commands: \seq_if_exist_p:N . . . . . . . . . . . . 153
\reverse_if:N . . . . . . . . . . . . . . . . 28 \seq_if_in:NnTF . . . . . . 157, 162, 163
round . . . . . . . . . . . . . . . . . . . . . . . . . 273 \seq_item:Nn . . . . . . . . . . . . . 57, 154
\seq_log:N . . . . . . . . . . . . . . . . . . 164
S \seq_map_break: . . . . . . 159, 160, 327
scan commands: \seq_map_break:n . . . . . . . . . . . . . 159
\scan_new:N . . . . . . . . . . . . . . . . . 150 \seq_map_function:NN . 6, 88, 157, 158
\scan_stop: . . 13, 22, 23, 150, 167, 206 \seq_map_indexed_function:NN . . 158
\s_stop . . . . . . . . . . . . . . . . . . . . 150 \seq_map_indexed_inline:Nn . . . . 158
sec . . . . . . . . . . . . . . . . . . . . . . . . . . 273 \seq_map_inline:Nn . . . . 157, 158, 163
secd . . . . . . . . . . . . . . . . . . . . . . . . . . 274 \seq_map_pairwise_function:NNN . 158
seq commands: \seq_map_tokens:Nn . . . . . . . . 157, 158
\c_empty_seq . . . . . . . . . . . . . . . . 163 \seq_map_variable:NNn . . . . . . . . 158
\seq_clear:N . . . . . . . . . . . . . 151, 163 \seq_new:N . . . . . . . . . . . . . . . . 6, 151
\seq_clear_new:N . . . . . . . . . . . . . 151 \seq_pop:NN . . . . . . . . . . . . . . . . . 161
\seq_concat:NNN . . . . . . . . . . 153, 163 \seq_pop:NNTF . . . . . . . . . . . . . . . 162
\seq_const_from_clist:Nn . . . . . . 152 \seq_pop_left:NN . . . . . . . . . . . . . 154
\seq_count:N . . . . . 154, 160, 162, 253 \seq_pop_left:NNTF . . . . . . . . . . . 155
\seq_gclear:N . . . . . . . . . . . . . . . 151 \seq_pop_right:NN . . . . . . . . . . . . 154
\seq_gclear_new:N . . . . . . . . . . . . 151 \seq_pop_right:NNTF . . . . . . . . . . 155
\seq_gconcat:NNN . . . . . . . . . . . . . 153 \seq_push:Nn . . . . . . . . . . . . . . . . 162
\seq_get:NN . . . . . . . . . . . . . . . . . 161 \seq_put_left:Nn . . . . . . . . . . . . . 153
\seq_get:NNTF . . . . . . . . . . . . . . . 161 \seq_put_right:Nn . . . . . 153, 162, 163
\seq_get_left:NN . . . . . . . . . . . . . 153 \seq_rand_item:N . . . . . . . . . . . . . 154
\seq_get_left:NNTF . . . . . . . . . . . 155 \seq_remove_all:Nn 152, 156, 162, 163
\seq_get_right:NN . . . . . . . . . . . . 153 \seq_remove_duplicates:N 156, 162, 163
\seq_get_right:NNTF . . . . . . . . . . 155 \seq_reverse:N . . . . . . . . . . . . . . 156
\seq_gpop:NN . . . . . . . . . . . . . . . . 161 \seq_set_eq:NN . . . . . . . . . . . 151, 163
\seq_gpop:NNTF . . . . . . . . . . . . . . 162 \seq_set_filter:NNn . . . . . . . . . . 327
\seq_gpop_left:NN . . . . . . . . . . . . 154 \seq_set_from_clist:NN . . . . . . . . 152
\seq_gpop_left:NNTF . . . . . . . . . . 155 \seq_set_from_clist:Nn . . . . . 152, 184
\seq_gpop_right:NN . . . . . . . . . . . 154 \seq_set_item:Nnn . . . . . . . . . . . . 156
\seq_gpop_right:NNTF . . . . . . . . . 156 \seq_set_item:NnnTF . . . . . . . . . . 156
\seq_gpush:Nn . . . . . . . . . . . . 31, 162 \seq_set_map:NNn . . . . . . . . . . . . . 159
\seq_gput_left:Nn . . . . . . . . . . . . 153 \seq_set_map_e:NNn . . . . . . . . . . . 160
\seq_gput_right:Nn . . . . . . . . . . . 153 \seq_set_split:Nnn . . . . . . . . . . . 152
\seq_gremove_all:Nn . . . . . . . . . . 156 \seq_set_split_keep_spaces:Nnn . 152
\seq_gremove_duplicates:N . . . . . 156 \seq_show:N . . . . . . . . . . . . . . . . . 164
\seq_greverse:N . . . . . . . . . . . . . 156 \seq_shuffle:N . . . . . . . . . . . . . . 157
\seq_gset_eq:NN . . . . . . . . . . . . . 151 \seq_sort:Nn . . . . . . . . . . . . . 45, 157
\seq_gset_filter:NNn . . . . . . . . . 327 \seq_use:Nn . . . . . . . . . . . . . . . . . 161
\seq_gset_from_clist:NN . . . . . . . 152 \seq_use:Nnnn . . . . . . . . . . . . . . . 160
\seq_gset_from_clist:Nn . . . . . . . 152 \g_tmpa_seq . . . . . . . . . . . . . . . . . 164
\seq_gset_item:Nnn . . . . . . . . . . . 156 \l_tmpa_seq . . . . . . . . . . . . . . . . . 164
342
\g_tmpb_seq . . . . . . . . . . . . . . . . . 164 \c_colon_str . . . . . . . . . . . . . . . . 141
\l_tmpb_seq . . . . . . . . . . . . . . . . . 164 \c_dollar_str . . . . . . . . . . . . . . . 141
sign . . . . . . . . . . . . . . . . . . . . . . . . . . 273 \c_hash_str . . . . . . . . . . . . . . . . . 141
sin . . . . . . . . . . . . . . . . . . . . . . . . . . 273 \c_left_brace_str . . . . . . . . . . . . 141
sind . . . . . . . . . . . . . . . . . . . . . . . . . . 274 \c_percent_str . . . . . . . . . . . . . . 141
skip commands: \c_right_brace_str . . . . . . . . . . . 141
\c_max_skip . . . . . . . . . . ....... 233 \str_case:Nn . . . . . . . . . . . . . . . . 132
\skip_add:Nn . . . . . . . . . ....... 231 \str_case:nn . . . . . . . . . . . . . . . . 132
\skip_const:Nn . . . . . . . ....... 230 \str_case:NnTF . . . . . . . . . . . . . . 132
\skip_eval:n . . . . . . . . . ....... 232 \str_case:nnTF . . . . . . . . . . . . . . 132
\skip_gadd:Nn . . . . . . . . ....... 231 \str_case_e:nn . . . . . . . . . . . . . . 133
.skip_gset:N . . . . . . . . . ....... 242 \str_case_e:nnTF . . . . . . . . . . . . . 133
\skip_gset:Nn . . . . . . . . ....... 231 \str_casefold:n . . . . . . 139–141, 289
\skip_gset_eq:NN . . . . . . ....... 231 \c_str_cctab . . . . . . . . . . . . . . . . 283
\skip_gsub:Nn . . . . . . . . ....... 231 \str_clear:N . . . . . . . . . . . . . . . . 130
\skip_gzero:N . . . . . . . . ....... 230 \str_clear_new:N . . . . . . . . . . . . . 130
\skip_gzero_new:N . . . . . ....... 231 \str_compare:nNnTF . . . . . . . . . . . 133
\skip_horizontal:N . . . . ....... 233 \str_compare_p:nNn . . . . . . . . . . . 133
\skip_horizontal:n . . . . ....... 233 \str_concat:NNN . . . . . . . . . . . . . 130
\skip_if_eq:nnTF . . . . . . ....... 232 \str_const:Nn . . . . . . . . . . . . . . . 130
\skip_if_eq_p:nn . . . . . . ....... 232 \str_convert_pdfname:n . . . . . . . . 144
\skip_if_exist:NTF . . . . ....... 231 \str_count:N . . . . . . . . . . . . . . . . 135
\skip_if_exist_p:N . . . . ....... 231 \str_count:n . . . . . . . . . . . . . . . . 135
\skip_if_finite:nTF . . . ....... 232 \str_count_ignore_spaces:n . . . . 135
\skip_if_finite_p:n . . . ....... 232 \str_count_spaces:N . . . . . . . . . . 135
\skip_log:N . . . . . . . . . . ....... 233 \str_count_spaces:n . . . . . . . . . . 135
\skip_log:n . . . . . . . . . . ....... 233 \str_foldcase:n . . . . . . . . . . 141, 211
\skip_new:N . . . . . . . . . . .. . . 230, 231 \str_gclear:N . . . . . . . . . . . . . . . 130
.skip_set:N . . . . . . . . . . ....... 242 \str_gconcat:NNN . . . . . . . . . . . . . 130
\skip_set:Nn . . . . . . . . . ....... 231 \str_gput_left:Nn . . . . . . . . . . . . 131
\skip_set_eq:NN . . . . . . ....... 231 \str_gput_right:Nn . . . . . . . . . . . 131
\skip_show:N . . . . . . . . . ....... 232 \str_gremove_all:Nn . . . . . . . . . . 138
\skip_show:n . . . . . . . . . ....... 232 \str_gremove_once:Nn . . . . . . . . . 138
\skip_sub:Nn . . . . . . . . . ....... 231 \str_greplace_all:Nnn . . . . . . . . 138
\skip_use:N . . . . . . . . . . ....... 232 \str_greplace_once:Nnn . . . . . . . . 138
\skip_vertical:N . . . . . . ....... 234 .str_gset:N . . . . . . . . . . . . . . . . . 242
\skip_vertical:n . . . . . . ....... 234 \str_gset:Nn . . . . . . . . . . . . . . . . 131
\skip_zero:N . . . . . . . . . 230, 231, 234 \str_gset_convert:Nnnn . . . . . . . . 144
\skip_zero_new:N . . . . . . ....... 231 \str_gset_convert:NnnnTF . . . . . . 144
\g_tmpa_skip . . . . . . . . . ....... 233 .str_gset_e:N . . . . . . . . . . . . . . . 242
\l_tmpa_skip . . . . . . . . . ....... 233 \str_gset_eq:NN . . . . . . . . . . . . . 130
\g_tmpb_skip . . . . . . . . . ....... 233 \str_head:N . . . . . . . . . . . . . . . . . 136
\l_tmpb_skip . . . . . . . . . ....... 233 \str_head:n . . . . . . . . . . . . . . . . . 136
\c_zero_skip . . . . . . . . . ....... 233 \str_head_ignore_spaces:n . . . . . 136
sort commands: \str_if_empty:NTF . . . . . . . . . . . . 131
\sort_return_same: . . .. . . . . . 44, 45 \str_if_empty:nTF . . . . . . . . . . . . 131
\sort_return_swapped: . . . . . . 44, 45 \str_if_empty_p:N . . . . . . . . . . . . 131
sp . . . . . . . . . . . . . . . . . . .. . . . . . . . 277 \str_if_empty_p:n . . . . . . . . . . . . 131
sqrt . . . . . . . . . . . . . . . . . .. . . . . . . . 275 \str_if_eq:NNTF . . . . . . . . . . . . . 131
str commands: \str_if_eq:nnTF . . . . . . . . . . . . . .
\c_ampersand_str . . . . . . . . . . . . . 141 . . . 113, 114, 132, 133, 212, 217, 218
\c_atsign_str . . . . . . . . . . . . . . . 141 \str_if_eq_p:NN . . . . . . . . . . . . . 131
\c_backslash_str . . . . . . . . . . . . . 141 \str_if_eq_p:nn . . . . . . . . . . . . . 132
\c_circumflex_str . . . . . . . . . . . . 141 \str_if_exist:NTF . . . . . . . . . . . . 130
343
\str_if_exist_p:N . . . . . . . . . . . . 130 \c_sys_engine_format_str . . . . . . . 76
\str_if_in:NnTF . . . . . . . . . . . . . 132 \c_sys_engine_str . . . . . . . . . . . . . 76
\str_if_in:nnTF . . . . . . . . . . . . . 132 \c_sys_engine_version_str . . . . . . 76
\str_item:Nn . . . . . . . . . . . . . . . . 136 \sys_ensure_backend: . . . . . . . . . . 79
\str_item:nn . . . . . . . . . . . . . . . . 136 \sys_finalise: . . . . . . . . . . . . . . . 80
\str_item_ignore_spaces:nn . . . . 136 \sys_get_shell:nnN . . . . . . . . . . . . 78
\str_log:N . . . . . . . . . . . . . . . . . . 140 \sys_get_shell:nnNTF . . . . . . . 78, 92
\str_log:n . . . . . . . . . . . . . . . . . . 140 \sys_gset_rand_seed:n . . . . . 78, 276
\str_lowercase:n . . . . . . . . . . 139, 289 \c_sys_hour_int . . . . . . . . . . . . . . 75
\str_map_break: . . . . . . . . . . . . . 134 \sys_if_engine_luatex:TF . . . 76, 106
\str_map_break:n . . . . . . . . . . 134, 135 \sys_if_engine_luatex_p: . . . . . . . 76
\str_map_function:NN . . . . . . . . . 133 \sys_if_engine_pdftex:TF . . . . . . . 76
\str_map_function:nN . . . . . . 133, 134 \sys_if_engine_pdftex_p: . . . . . . . 76
\str_map_inline:Nn . . . . . . . . . . . 134 \sys_if_engine_ptex:TF . . . . . . . . . 76
\str_map_inline:nn . . . . . . . . . . . 134 \sys_if_engine_ptex_p: . . . . . . . . . 76
\str_map_tokens:Nn . . . . . . . . . . . 134 \sys_if_engine_uptex:TF . . . . . . . . 76
\str_map_tokens:nn . . . . . . . . . . . 134 \sys_if_engine_uptex_p: . . . . . . . . 76
\str_map_variable:NNn . . . . . . . . 134 \sys_if_engine_xetex:TF . . . . . . 6, 76
\str_map_variable:nNn . . . . . . . . 134 \sys_if_engine_xetex_p: . . . . . . . . 76
\str_mdfive_hash:n . . . . . . . . . . . 140 \sys_if_output_dvi:TF . . . . . . . . . 77
\str_new:N . . . . . . . . . . . . . . . . . . 130
\sys_if_output_dvi_p: . . . . . . . . . 77
\str_put_left:Nn . . . . . . . . . . . . . 131
\sys_if_output_pdf:TF . . . . . . . . . 77
\str_put_right:Nn . . . . . . . . . . . . 131
\sys_if_output_pdf_p: . . . . . . . . . 77
\str_range:Nnn . . . . . . . . . . . . . . 137
\sys_if_platform_unix:TF . . . . . . . 77
\str_range:nnn . . . . . . . . . . . 102, 137
\sys_if_platform_unix_p: . . . . . . . 77
\str_range_ignore_spaces:nnn . . 137
\sys_if_platform_windows:TF . . . . 77
\str_remove_all:Nn . . . . . . . . . . . 138
\sys_if_platform_windows_p: . . . . 77
\str_remove_once:Nn . . . . . . . . . . 138
\sys_if_shell:TF . . . . . . . . . . . 78, 79
\str_replace_all:Nnn . . . . . . . . . 138
\sys_if_shell_p: . . . . . . . . . . . . . . 78
\str_replace_once:Nnn . . . . . . . . 138
\sys_if_shell_restricted:TF . . . . 79
.str_set:N . . . . . . . . . . . . . . . . . . 242
\str_set:Nn . . . . . . . . . . 131, 138, 242 \sys_if_shell_restricted_p: . . . . 79
\str_set_convert:Nnnn . . . . . 144, 145 \sys_if_shell_unrestricted:TF . . . 78
\str_set_convert:NnnnTF . . . . . . . 144 \sys_if_shell_unrestricted_p: . . . 78
.str_set_e:N . . . . . . . . . . . . . . . . 242 \sys_if_timer_exist:TF . . . . . . . . . 77
\str_set_eq:NN . . . . . . . . . . . . . . 130 \sys_if_timer_exist_p: . . . . . . . . . 77
\str_show:N . . . . . . . . . . . . . . . . . 140 \c_sys_jobname_str . . . . . . . . 75, 100
\str_show:n . . . . . . . . . . . . . . . . . 140 \sys_load_backend:n . . . . . . . . . . . 79
\str_tail:N . . . . . . . . . . . . . . . . . 136 \sys_load_debug: . . . . . . . . . . . . . . 79
\str_tail:n . . . . . . . . . . . . . . . . . 136 \c_sys_minute_int . . . . . . . . . . . . . 75
\str_tail_ignore_spaces:n . . . . . 136 \c_sys_month_int . . . . . . . . . . . . . . 75
\str_uppercase:n . . . . . . . . . . 139, 289 \c_sys_output_str . . . . . . . . . . . . . 77
\str_use:N . . . . . . . . . . . . . . . . . . 135 \c_sys_platform_str . . . . . . . . . . . 77
\c_tilde_str . . . . . . . . . . . . . . . . 141 \sys_rand_seed: . . . . . . . 77, 157, 276
\g_tmpa_str . . . . . . . . . . . . . . . . . 141 \c_sys_shell_escape_int . . . . . . . . 78
\l_tmpa_str . . . . . . . . . . . . . . 138, 141 \sys_shell_now:n . . . . . . . . . . . . . . 79
\g_tmpb_str . . . . . . . . . . . . . . . . . 141 \sys_shell_shipout:n . . . . . . . . . . 79
\l_tmpb_str . . . . . . . . . . . . . . . . . 141 \sys_timer: . . . . . . . . . . . . . . . . . . 76
\c_underscore_str . . . . . . . . . . . . 141 \c_sys_timestamp_str . . . . . . . . . . 75
\c_zero_str . . . . . . . . . . . . . . . . . 141 \c_sys_year_int . . . . . . . . . . . . . . 75
sys commands:
\c_sys_backend_str . . . . . . . . . . . . 79 T
\c_sys_day_int . . . . . . . . . . . . . . . 75 tan . . . . . . . . . . . . . . . . . . . . . . . . . . 273
\c_sys_engine_exec_str . . . . . . . . . 76 tand . . . . . . . . . . . . . . . . . . . . . . . . . . 274
344
TEX and LATEX 2ε commands: \input@path . . . . . . . . . . . . . . . . . 101
\@filelist . . . . . . . . . . . . . . . . . . 105 \jobname . . . . . . . . . . . . . . . . . . . . 75
\@firstofone . . . . . . . . . . . . . . . . . 24 \kcatcode . . . . . . . . . . . . . . . . . . . 286
\@gobbbletwo . . . . . . . . . . . . . . . . . 26 \leavevmode . . . . . . . . . . . . . . . . . . 29
\@gobble . . . . . . . . . . . . . . . . . . . . 26 \long . . . . . . . . . . . . . . . . . . . . 5, 211
\aftergroup . . . . . . . . . . . . . . . . . . 14 \luaescapestring . . . . . . . . . . . . . 107
\box . . . . . . . . . . . . . . . . . . . . . . . 302 \makeatletter . . . . . . . . . . . . . . . . . 9
\char . . . . . . . . . . . . . . . . . . . . . . 211 \mathchar . . . . . . . . . . . . . . . . . . . 211
\chardef . . . . . . . . . . . . . . . . 202, 203 \mathchardef . . . . . . . . . . . . . . . . 203
\copy . . . . . . . . . . . . . . . . . . . . . . 295 \mathord . . . . . . . . . . . . . . . . . . . 317
\count . . . . . . . . . . . . . . . . . . . . . 210 \maxdimen . . . . . . . . . . . . . . . . . . . 228
\csname . . . . . . . . . . . . . . . . . . . . . 21 \meaning . . . . . . . . . 20, 200, 210, 211
\day . . . . . . . . . . . . . . . . . . . . . . . . 75 \message . . . . . . . . . . . . . . . . . . . . 34
\def . . . . . . . . . . . . . . . . . . . . . . . 210 \month . . . . . . . . . . . . . . . . . . . . . . 75
\detokenize . . . . . . . . . . . . . . . . . 116 \newif . . . . . . . . . . . . . . . . . . 67, 109
\directlua . . . . . . . . . . . . . . . . . . 106 \newlinechar . . . . . . . . . . . . . . . . 126
\dp . . . . . . . . . . . . . . . . . . . . . . . . 296 \newtoks . . . . . . . . . . . . . . . . . . . . 44
\edef . . . . . . . . . . . . . . . . . . . . . . 3, 6 \noexpand . . . . . . . . . . . . . . . . 39, 209
\else . . . . . . . . . . . . . . . . . . . . . . . 28 \number . . . . . . . . . . . . . . . . . . . . 179
\endcsname . . . . . . . . . . . . . . . . . . . 21 \or . . . . . . . . . . . . . . . . . . . . . . . . 179
\endinput . . . . . . . . . . . . . . . . . . . . 85 \outer . . . . . . . . . . . . . . . . . . . 7, 211
\endlinechar . . . . . . 94, 126, 281–283 \parindent . . . . . . . . . . . . . . . . . . . 29
\endtemplate . . . . . . . . . . . . . . . . . 74 \pdfescapename . . . . . . . . . . . . . . 143
\escapechar . . . . . . . . . . . . . . . . . 116 \pdfescapestring . . . . . . . . . . . . . 143
\everypar . . . . . . . . . . . . . . . . 29, 206 \pdfuniformdeviate . . . . . . . . . . . 276
\expandafter . . . . . . . . . . . . . . 39, 41 \pi . . . . . . . . . . . . . . . . . . . . . . . . 269
\expanded . . . . . . . . . . . . . . 3, 6, 26, 34 \protected . . . . . . . . . . . . . . . . . . 211
\fi . . . . . . . . . . . . . . . . . . . . . 28, 209 \ProvidesClass . . . . . . . . . . . . . . . . 9
\fmtname . . . . . . . . . . . . . . . . . . . . 76 \ProvidesFile . . . . . . . . . . . . . . . . . 9
\font . . . . . . . . . . . . . . . . . . . . . . 209 \ProvidesPackage . . . . . . . . . . . . . . . 9
\fontdimen . . . . . . . . . . . . . . . 62, 254 \read . . . . . . . . . . . . . . . . . . . . . . . 94
\halign . . . . . . . . . . . . . . . . . 74, 104 \readline . . . . . . . . . . . . . . . . . . . . 94
\hskip . . . . . . . . . . . . . . . . . . . . . 233 \relax . . . . . . . . . . . . . . . . . . 28, 209
\ht . . . . . . . . . . . . . . . . . . . . . . . . 296 \RequirePackage . . . . . . . . . . . . . . 10
\if . . . . . . . . . . . . . . . . . . . . . . . . . 29 \romannumeral . . . . . . . . . . . . . . . . 41
\ifcase . . . . . . . . . . . . . . . . . . . . 179 \scantokens . . . . . . . . . . . . . . 126, 145
\ifcat . . . . . . . . . . . . . . . . . . . . . . 29 \show . . . . . . . . . . . . . . . . . . . 20, 118
\ifcsname . . . . . . . . . . . . . . . . . . . . 29 \showgroups . . . . . . . . . . . . . . . . . . 14
\ifdefined . . . . . . . . . . . . . . . . . . . 29 \showtokens . . . . . . . . . . . . . . . . . 118
\ifdim . . . . . . . . . . . . . . . . . . . . . 236 \sin . . . . . . . . . . . . . . . . . . . . . . . 269
\ifeof . . . . . . . . . . . . . . . . . . . . . 100 \string . . . . . . . . . . . . . . . . . . . . 200
\iffalse . . . . . . . . . . . . . . . . . 28, 67 \tenrm . . . . . . . . . . . . . . . . . . . . . 209
\ifhbox . . . . . . . . . . . . . . . . . . . . 306 \the . . . . . . . . . 170, 209, 227, 232, 235
\ifhmode . . . . . . . . . . . . . . . . . . . . 29 \time . . . . . . . . . . . . . . . . . . . . . . . 75
\ifinner . . . . . . . . . . . . . . . . . . . . 29 \toks . . . . . . . . . . . . . . . . 44, 157, 179
\ifmmode . . . . . . . . . . . . . . . . . . . . 29 \topmark . . . . . . . . . . . . . . . . . . . 210
\ifnum . . . . . . . . . . . . . . . . . . . . . 179 \unexpanded . . . . 40, 117, 118, 122,
\ifodd . . . . . . . . . . . . . . . . . . . . . 180 123, 154, 160, 161, 186, 190–192, 216
\iftrue . . . . . . . . . . . . . . . . . . 28, 67 \unhbox . . . . . . . . . . . . . . . . . . . . 302
\ifvbox . . . . . . . . . . . . . . . . . . . . 306 \unhcopy . . . . . . . . . . . . . . . . . . . 299
\ifvmode . . . . . . . . . . . . . . . . . . . . 29 \uniformdeviate . . . . . . . . . . . . . 276
\ifvoid . . . . . . . . . . . . . . . . . . . . 306 \unless . . . . . . . . . . . . . . . . . . . . . 28
\ifx . . . . . . . . . . . . . . . . . . . . . . . . 29 \unvbox . . . . . . . . . . . . . . . . . . . . 302
\infty . . . . . . . . . . . . . . . . . . . . . 269 \unvcopy . . . . . . . . . . . . . . . . . . . 301
345
\value . . . . . . . . . . . . . . . . . . . . . 166 \tl_analysis_log:n . . . . . . . . . . . . 46
\verb . . . . . . . . . . . . . . . . . . . . . . 126 \tl_analysis_map_inline:Nn . . . . . 46
\vskip . . . . . . . . . . . . . . . . . . . . . 234 \tl_analysis_map_inline:nn . 46, 207
\wd . . . . . . . . . . . . . . . . . . . . . . . . 296 \tl_analysis_show:N . . . . . . . . . . . 46
\write . . . . . . . . . . . . . . . . . . . . . . 98 \tl_analysis_show:n . . . . . . . . . . . 46
\year . . . . . . . . . . . . . . . . . . . . . . . 75 \tl_build_begin:N . . . . . . . . . 128, 327
text commands: \tl_build_end:N . . . . . . . . . . . . . 128
\l_text_case_exclude_arg_tl . . . . \tl_build_gbegin:N . . . . . . . . 128, 327
. . . . . . . . . . . . . . . . . . 288, 289, 291 \tl_build_gend:N . . . . . . . . . . . . . 128
\text_case_switch:nnnn . . . . . . . . 290 \tl_build_get:NN . . . . . . . . . . . . . 327
\text_declare_case_equivalent:Nn 290 \tl_build_gput_left:Nn . . . . . . . . 128
\text_declare_expand_equivalent:Nn \tl_build_gput_right:Nn . . . . . . . 128
. . . . . . . . . . . . . . . . . . . . . . . . . 288 \tl_build_put_left:Nn . . . . . . . . 128
\text_declare_lowercase_mapping:nn \tl_build_put_right:Nn . . . . . . . . 128
. . . . . . . . . . . . . . . . . . . . . . . . . 290 \tl_clear:N . . . . . . . . . . . . . . . . . 112
\text_declare_lowercase_mapping:nnn \tl_clear_new:N . . . . . . . . . . . . . 112
. . . . . . . . . . . . . . . . . . . . . . . . . 290 \tl_concat:NNN . . . . . . . . . . . . . . 112
\text_declare_purify_equivalent:Nn \tl_const:Nn . . . . . . . . . . . . . . . . 112
. . . . . . . . . . . . . . . . . . . . . . . . . 291 \tl_count:N . . . . . . . . . . . 33, 114, 117
\text_declare_titlecase_mapping:nn \tl_count:n . . . . . . . . . . . 33, 114, 117
. . . . . . . . . . . . . . . . . . . . . . . . . 290 \tl_count_tokens:n . . . . . . . . . . . 117
\text_declare_titlecase_mapping:nnn \tl_gclear:N . . . . . . . . . . . . . . . . 112
. . . . . . . . . . . . . . . . . . . . . . . . . 290 \tl_gclear_new:N . . . . . . . . . . . . . 112
\text_declare_uppercase_mapping:nn \tl_gconcat:NNN . . . . . . . . . . . . . 112
. . . . . . . . . . . . . . . . . . . . . . . . . 290 \tl_gput_left:Nn . . . . . . . . . . . . . 112
\text_declare_uppercase_mapping:nnn \tl_gput_right:Nn . . . . . . . . . . . . 113
. . . . . . . . . . . . . . . . . . . . . . . . . 290 \tl_gremove_all:Nn . . . . . . . . . . . 125
\text_expand:n . . . 288, 289, 291, 292 \tl_gremove_once:Nn . . . . . . . . . . 125
\l_text_expand_exclude_tl . . 288, 291 \tl_greplace_all:Nnn . . . . . . . . . 125
\text_lowercase:n . . . . . 139, 197, 289 \tl_greplace_once:Nnn . . . . . . . . 124
\text_lowercase:nn . . . . . . . . . . . 289 \tl_greverse:N . . . . . . . . . . . . . . 117
\text_map_break: . . . . . . . . . . . . . 292 .tl_gset:N . . . . . . . . . . . . . . . . . . 243
\text_map_break:n . . . . . . . . . . . . 292 \tl_gset:Nn . . . . . . . . . . 112, 128, 153
\text_map_function:nN . . . . . . . . 292 .tl_gset_e:N . . . . . . . . . . . . . . . . 243
\text_map_inline:nn . . . . . . . . . . 292 \tl_gset_eq:NN . . . . . . . . . . . . . . 112
\l_text_math_arg_tl . . . . . . . 288, 291 \tl_gset_rescan:Nnn . . . . . . . . . . 126
\l_text_math_delims_tl . . . . . 288, 291 \tl_gsort:Nn . . . . . . . . . . . . . . . . 124
\text_purify:n . . . . . . . . . . . . . . 291 \tl_gtrim_spaces:N . . . . . . . . . . . 118
\text_titlecase_all:n . 139, 211, 289 \tl_head:N . . . . . . . . . . . . . . . . . . 121
\text_titlecase_all:nn . . . . . . . . 289 \tl_head:n . . . . . . . . . . . . . . . . . . 121
\l_text_titlecase_check_letter_- \tl_head:w . . . . . . . . . . . . . . . . . . 121
bool . . . . . . . . . . . . . . . . . 290, 291 \tl_if_blank:nTF . . . . . . . . . . 113, 121
\text_titlecase_first:n . . . . . . . 289 \tl_if_blank_p:n . . . . . . . . . . . . . 113
\text_titlecase_first:nn . . . . . . 289 \tl_if_empty:NTF . . . . . . . . . . . . . 113
\text_uppercase:n . 139, 198, 211, 289 \tl_if_empty:nTF . . . . . . . . . . . . . 113
\text_uppercase:nn . . . . . . . . . . . 289 \tl_if_empty_p:N . . . . . . . . . . . . . 113
tl commands: \tl_if_empty_p:n . . . . . . . . . . . . . 113
\c_catcode_active_space_tl . . . . 195 \tl_if_eq:NNTF . . . 113, 114, 131, 146
\c_catcode_active_tl . . . . . . . . . 199 \tl_if_eq:NnTF . . . . . . . . . . . . . . 113
\c_catcode_other_space_tl . . . . . 196 \tl_if_eq:nnTF . . . 114, 132, 156, 186
\c_empty_tl . . . . . . . . . . . . . . . . . 126 \tl_if_eq_p:NN . . . . . . . . . . . . . . 113
\c_novalue_tl . . . . . . . . . . . . 114, 127 \tl_if_exist:NTF . . . . . . . . . . . . . 112
\c_space_tl . . . . . . . . . . . . . . . . . 127 \tl_if_exist_p:N . . . . . . . . . . . . . 112
\tl_analysis_log:N . . . . . . . . . . . . 46 \tl_if_head_eq_catcode:nNTF . . . 115
346
\tl_if_head_eq_catcode_p:nN . . . 115 \tl_set_eq:NN . . . . . . . . . . . . 112, 184
\tl_if_head_eq_charcode:nNTF . . 115 \tl_set_rescan:Nnn . . . . . . . . 126, 282
\tl_if_head_eq_charcode_p:nN . . 115 \tl_show:N . . . . . . . . . . . . . . . 118, 184
\tl_if_head_eq_meaning:nNTF . . . 115 \tl_show:n . . . . . . . . . . . . . . . 88, 118
\tl_if_head_eq_meaning_p:nN . . . 115 \tl_sort:Nn . . . . . . . . . . . . . . . . . 124
\tl_if_head_is_group:nTF . . . . . . 115 \tl_sort:nN . . . . . . . . . . . . . . . . . 124
\tl_if_head_is_group_p:n . . . . . . 115 \tl_tail:N . . . . . . . . . . . . . . . . . . 121
\tl_if_head_is_N_type:nTF . . . . . 115 \tl_tail:n . . . . . . . . . . . . . . . . . . 121
\tl_if_head_is_N_type_p:n . . . . . 115 \tl_to_str:N . . . . . . . . . . 99, 116, 129
\tl_if_head_is_space:nTF . . . 116, 122 \tl_to_str:n . . . . . . 52, 54, 78, 99,
\tl_if_head_is_space_p:n . . . . . . 116 116, 126, 129, 139, 140, 212–214, 238
\tl_if_in:NnTF . . . . . . . . . . . . . . 114 \tl_trim_spaces:N . . . . . . . . . . . . 118
\tl_if_in:nnTF . . . . . . . . . . . . . . 114 \tl_trim_spaces:n . . . . . . . . . . . . 118
\tl_if_novalue:nTF . . . . . . . . . . . 114 \tl_trim_spaces_apply:nN . . . . . . 118
\tl_if_novalue_p:n . . . . . . . . . . . 114 \tl_use:N . . . . . . . . 116, 227, 232, 235
\tl_if_single:NTF . . . . . . . . . . . . 114 \g_tmpa_tl . . . . . . . . . . . . . . . . . . 127
\tl_if_single:nTF . . . . . . . . . . . . 114 \l_tmpa_tl . . . . . . . . . . 6, 60, 125, 127
\tl_if_single_p:N . . . . . . . . . . . . 114 \g_tmpb_tl . . . . . . . . . . . . . . . . . . 127
\tl_if_single_p:n . . . . . . . . . . . . 114 \l_tmpb_tl . . . . . . . . . . . . . . . . . . 127
\tl_if_single_token:nTF . . . . . . . 114 token commands:
\tl_if_single_token_p:n . . . . . . . 114 \c_alignment_token . . . . . . . . . . . 199
\tl_item:Nn . . . . . . . . . . . . . . . . . 122 \c_catcode_letter_token . . . . . . . 199
\tl_item:nn . . . . . . . . . . . . . . . . . 122 \c_catcode_other_token . . . . . . . . 199
\tl_log:N . . . . . . . . . . . . . . . . . . . 118 \c_group_begin_token . . . . . . . . . 199
\tl_log:n . . . . . . . . . . . . . . . . . . . 118 \c_group_end_token . . . . . . . . . . . 199
\tl_map_break: . . . . . . . . . . . 62, 120 \c_math_subscript_token . . . . . . . 199
\tl_map_break:n . . . . . . . . . . . . . 120 \c_math_superscript_token . . . . . 199
\tl_map_function:NN . . . . . . . . . . 119 \c_math_toggle_token . . . . . . . . . 199
\tl_map_function:nN . . . . . . . . . . 119 \c_parameter_token . . . . . . . . . . . 199
\tl_map_inline:Nn . . . . . . . . . . . . 119 \c_space_token . 39, 116, 127, 199, 206
\tl_map_inline:nn . . . . . 119, 120, 149 \token_case_catcode:Nn . . . . . . . . 204
\tl_map_tokens:Nn . . . . . . . . . . . . 119 \token_case_catcode:NnTF . . . . . . 204
\tl_map_tokens:nn . . . . . . . . . . . . 119 \token_case_charcode:Nn . . . . . . . 204
\tl_map_variable:NNn . . . . . . . . . 119 \token_case_charcode:NnTF . . . . . 204
\tl_map_variable:nNn . . . . . . . . . 120 \token_case_meaning:Nn . . . . . . . . 204
\tl_new:N . . . . . . . . . . . . 111, 112, 200 \token_case_meaning:NnTF . . . . . . 204
\tl_put_left:Nn . . . . . . . . . . . . . 112 \token_if_active:NTF . . . . . . . . . 201
\tl_put_right:Nn . . . . . . . . . . 113, 128 \token_if_active_p:N . . . . . . . . . 201
\tl_rand_item:N . . . . . . . . . . . . . 122 \token_if_alignment:NTF . . . . . . . 201
\tl_rand_item:n . . . . . . . . . . . . . 122 \token_if_alignment_p:N . . . . . . . 201
\tl_range:Nnn . . . . . . . . . . . . . . . 123 \token_if_chardef:NTF . . . . . . . . 202
\tl_range:nnn . . . . . . . . . . . . 123, 137 \token_if_chardef_p:N . . . . . . . . 202
\tl_remove_all:Nn . . . . . . . . . . . . 125 \token_if_cs:NTF . . . . . . . . . . . . . 202
\tl_remove_once:Nn . . . . . . . . . . . 125 \token_if_cs_p:N . . . . . . . . . . . . . 202
\tl_replace_all:Nnn . . . . . . . . . . 125 \token_if_dim_register:NTF . . . . 203
\tl_replace_once:Nnn . . . . . . . . . 124 \token_if_dim_register_p:N . . . . 203
\tl_rescan:nn . . . . . . . . . . . . 126, 282 \token_if_eq_catcode:NNTF . . . . . .
\tl_reverse:N . . . . . . . . . . . . . . . 117 . . . . . . . . . . . . . . . . . . 201, 204, 205
\tl_reverse:n . . . . . . . . . . . . . . . 117 \token_if_eq_catcode_p:NN . . . . . 201
\tl_reverse_items:n . . . . . . . . . . 117 \token_if_eq_charcode:NNTF . . . . .
.tl_set:N . . . . . . . . . . . . . . . . . . . 243 . . . . . . . . . . . . . . . . . . 202, 204, 205
\tl_set:Nn . . . . . . . . . . . . . . . . . . . \token_if_eq_charcode_p:NN . . . . 202
. . . 112, 125, 126, 128, 153, 243, 327 \token_if_eq_meaning:NNTF . . . . . .
.tl_set_e:N . . . . . . . . . . . . . . . . . 243 . . . . . . . . . . . . . . . . . . 202, 204, 205
347
\token_if_eq_meaning_p:NN . . . . . 202 usage commands:
\token_if_expandable:NTF . . . . . . 202 .usage:n . . . . . . . . . . . . . . . . . . . 246
\token_if_expandable_p:N . . . . . . 202 use commands:
\token_if_font_selection:NTF . . 203 \use:N . . . . . . . . . . . . . . . . . . 21, 181
\token_if_font_selection_p:N . . 203 \use:n . . . . . . . . . . . . 24, 26, 111, 209
\token_if_group_begin:NTF . . . . . 200 \use:nn . . . . . . . . . . . . . . . . . . . . . 24
\token_if_group_begin_p:N . . . . . 200 \use:nnn . . . . . . . . . . . . . . . . . . . . 24
\token_if_group_end:NTF . . . . . . . 200 \use:nnnn . . . . . . . . . . . . . . . . . . . . 24
\token_if_group_end_p:N . . . . . . . 200 \use_i:nn . . . . . . . . . . . . . . . . . . . . 25
\token_if_int_register:NTF . . . . 203 \use_i:nnn . . . . . . . . . . . . . . . . . . . 25
\token_if_int_register_p:N . . . . 203 \use_i:nnnn . . . . . . . . . . . . . . . . . . 25
\token_if_letter:NTF . . . . . . . . . 201 \use_i:nnnnn . . . . . . . . . . . . . . . . . 25
\token_if_letter_p:N . . . . . . . . . 201 \use_i:nnnnnn . . . . . . . . . . . . . . . . 25
\token_if_long_macro:NTF . . . . . . 202 \use_i:nnnnnnn . . . . . . . . . . . . . . . 25
\token_if_long_macro_p:N . . . . . . 202 \use_i:nnnnnnnn . . . . . . . . . . . . . . 25
\token_if_macro:NTF . . . . . . . . . . 202 \use_i:nnnnnnnnn . . . . . . . . . . . . . . 25
\token_if_macro_p:N . . . . . . . . . . 202 \use_i_delimit_by_q_nil:nw . . . . . 27
\token_if_math_subscript:NTF . . 201 \use_i_delimit_by_q_recursion_-
\token_if_math_subscript_p:N . . 201 stop:nw . . . . . . . . . . . . . . . . . . . 27
\token_if_math_superscript:NTF . 201 \use_i_delimit_by_q_recursion_-
\token_if_math_superscript_p:N . 201 stop:w . . . . . . . . . . . . . . . . . . . 148
\token_if_math_toggle:NTF . . . . . 201 \use_i_delimit_by_q_stop:nw . . . . 27
\token_if_math_toggle_p:N . . . . . 201 \use_i_ii:nnn . . . . . . . . . . . . . 25, 26
\token_if_mathchardef:NTF . . . . . 203 \use_ii:nn . . . . . . . . . . . . . . . . 25, 73
\token_if_mathchardef_p:N . . . . . 203 \use_ii:nnn . . . . . . . . . . . . . . . . . . 25
\token_if_muskip_register:NTF . . 203 \use_ii:nnnn . . . . . . . . . . . . . . . . . 25
\token_if_muskip_register_p:N . . 203 \use_ii:nnnnn . . . . . . . . . . . . . . . . 25
\token_if_other:NTF . . . . . . . . . . 201 \use_ii:nnnnnn . . . . . . . . . . . . . . . 25
\token_if_other_p:N . . . . . . . . . . 201 \use_ii:nnnnnnn . . . . . . . . . . . . . . 25
\token_if_parameter:NTF . . . . . . . 201 \use_ii:nnnnnnnn . . . . . . . . . . . . . . 25
\token_if_parameter_p:N . . . . . . . 201 \use_ii:nnnnnnnnn . . . . . . . . . . . . . 25
\token_if_primitive:NTF . . . . . . . 203 \use_ii_i:nn . . . . . . . . . . . . . . . . . 26
\token_if_primitive_p:N . . . . . . . 203 \use_iii:nnn . . . . . . . . . . . . . . . . . 25
\token_if_protected_long_- \use_iii:nnnn . . . . . . . . . . . . . . . . 25
macro:NTF . . . . . . . . . . . . . . . . 202 \use_iii:nnnnn . . . . . . . . . . . . . . . 25
\token_if_protected_long_macro_- \use_iii:nnnnnn . . . . . . . . . . . . . . 25
p:N . . . . . . . . . . . . . . . . . . . . . 202 \use_iii:nnnnnnn . . . . . . . . . . . . . . 25
\token_if_protected_macro:NTF . . 202 \use_iii:nnnnnnnn . . . . . . . . . . . . . 25
\token_if_protected_macro_p:N . . 202 \use_iii:nnnnnnnnn . . . . . . . . . . . . 25
\token_if_skip_register:NTF . . . 203 \use_iv:nnnn . . . . . . . . . . . . . . . . . 25
\token_if_skip_register_p:N . . . 203 \use_iv:nnnnn . . . . . . . . . . . . . . . . 25
\token_if_space:NTF . . . . . . . . . . 201 \use_iv:nnnnnn . . . . . . . . . . . . . . . 25
\token_if_space_p:N . . . . . . . . . . 201 \use_iv:nnnnnnn . . . . . . . . . . . . . . 25
\token_if_toks_register:NTF . . . 203 \use_iv:nnnnnnnn . . . . . . . . . . . . . . 25
\token_if_toks_register_p:N . . . 203 \use_iv:nnnnnnnnn . . . . . . . . . . . . . 25
\token_to_catcode:N . . . . . . . . . . 200 \use_ix:nnnnnnnnn . . . . . . . . . . . . . 25
\token_to_meaning:N . . . . 20, 200, 210 \use_none:n . . . . . . . . . . . . . . . . . . 26
\token_to_str:N 7, 22, 99, 129, 200, 210 \use_none:nn . . . . . . . . . . . . . . . . . 26
true . . . . . . . . . . . . . . . . . . . . . . . . . . 277 \use_none:nnn . . . . . . . . . . . . . . . . 26
trunc . . . . . . . . . . . . . . . . . . . . . . . . . 273 \use_none:nnnn . . . . . . . . . . . . . . . 26
\use_none:nnnnn . . . . . . . . . . . . . . 26
U \use_none:nnnnnn . . . . . . . . . . . . . . 26
undefine commands: \use_none:nnnnnnn . . . . . . . . . . . . . 26
.undefine: . . . . . . . . . . . . . . . . . . 243 \use_none:nnnnnnnn . . . . . . . . . . . . 26
348
\use_none:nnnnnnnnn . . . . . . . . . . . 26 \vbox_gset:Nn . . . . . . . . . . . . ... 300
\use_none_delimit_by_q_nil:w . . . 26 \vbox_gset:Nw . . . . . . . . . . . . ... 300
\use_none_delimit_by_q_recursion_- \vbox_gset_end: . . . . . . . . . . ... 300
stop:w . . . . . . . . . . . . . . . . 26, 148 \vbox_gset_split_to_ht:NNn . ... 301
\use_none_delimit_by_q_stop:w . . . 26 \vbox_gset_to_ht:Nnn . . . . . . ... 300
\use_none_delimit_by_s_stop:w . . 150 \vbox_gset_to_ht:Nnw . . . . . . ... 301
\use_v:nnnnn . . . . . . . . . . . . . . . . . 25 \vbox_gset_top:Nn . . . . . . . . . ... 300
\use_v:nnnnnn . . . . . . . . . . . . . . . . 25 \vbox_set:Nn . . . . . . . . . . . . . ... 300
\use_v:nnnnnnn . . . . . . . . . . . . . . . 25 \vbox_set:Nw . . . . . . . . . . . . . ... 300
\use_v:nnnnnnnn . . . . . . . . . . . . . . 25 \vbox_set_end: . . . . . . . . . . . 300, 301
\use_v:nnnnnnnnn . . . . . . . . . . . . . . 25 \vbox_set_split_to_ht:NNn . . ... 301
\use_vi:nnnnnn . . . . . . . . . . . . . . . 25 \vbox_set_to_ht:Nnn . . . . . . . 300, 301
\use_vi:nnnnnnn . . . . . . . . . . . . . . 25 \vbox_set_to_ht:Nnw . . . . . . . ... 301
\use_vi:nnnnnnnn . . . . . . . . . . . . . . 25 \vbox_set_top:Nn . . . . . . . . . . ... 300
\use_vi:nnnnnnnnn . . . . . . . . . . . . . 25 \vbox_to_ht:nn . . . . . . . . . . . ... 300
\use_vii:nnnnnnn . . . . . . . . . . . . . . 25 \vbox_to_zero:n . . . . . . . . . . ... 300
\use_vii:nnnnnnnn . . . . . . . . . . . . . 25 \vbox_top:n . . . . . . . . . . . . . . ... 300
\use_vii:nnnnnnnnn . . . . . . . . . . . . 25 \vbox_unpack:N . . . . . . . . . . . ... 301
\use_viii:nnnnnnnnn . . . . . . . . . . . 25 \vbox_unpack_drop:N . . . . . . . ... 302
vcoffin commands:
V \vcoffin_gset:Nnn . . . . . . . . . . . . 308
value commands: \vcoffin_gset:Nnw . . . . . . . . . . . . 308
.value_forbidden:n . . . . . . . . . . . 243 \vcoffin_gset_end: . . . . . . . . . . . 308
.value_required:n . . . . . . . . . . . . 243 \vcoffin_set:Nnn . . . . . . . . . . . . . 308
vbox commands: \vcoffin_set:Nnw . . . . . . . . . . . . . 308
\vbox:n . . . . . . . . . . . . . . . . . 295, 300 \vcoffin_set_end: . . . . . . . . . . . . 308
349