Expand description
The lists feature (Lists): list environments whose items are begun
by \item, the label shown beside each item, and references to items. By
default the list environments are itemize, enumerate and
description.
§Lists and list kinds
A list is an environment whose body is a sequence of items, each begun
by \item. Each list environment has one list kind, which the
feature’s configuration, ListsConfig, declares under the environment’s
name: for each list kind, whether its items are numbered and which label is shown beside them
at each nesting depth (ListKind). The default configuration declares
three list kinds:
\begin{itemize} \begin{enumerate} \begin{description}
\item First \item First \item[Term] What it means.
\item Second \item Second \item[Other] More.
\end{itemize} \end{enumerate} \end{description}
• First 1. First Term What it means.
• Second 2. Second Other More.A list nested in an item of another list of the same list kind is at the
next nesting depth, and shows the list kind’s next label template:
- then ▸ for itemize, (i) then a- for enumerate; the last
template serves every deeper list. Only lists of the same list kind are
counted: an enumerate inside an itemize inside an enumerate is at
depth 2 and shows (i), as in LaTeX. The
language guide describes lists for
authors.
§The optional argument of a list
Each list environment takes an optional argument, a key-value argument with two keys:
labelis the list’s own label template, used beside its items in place of the depth’s template. It is written in the language of a counter style’s number template: every#{name}is the item’s number in the number formatname, and every other character is FLM text written as is.refis the list’s own reference template, in the same language: the template through which a reference to one of its items writes the item’s number, in place of the depth’s reference template. The key is named after the key of LaTeX’senumitempackage that does the same.
label= written alone sets both templates to the same text:
\begin{enumerate}[label=(#{alph})] % (a), (b); \ref: Item~(b)
\begin{enumerate}[label=#{arabic}:, ref=#{arabic}] % 1:, 2:; \ref: Item~2
\begin{itemize}[label={--}] % a dash beside every itemA bracket holding no = and made only of the characters []().:-+*aAiI1
is a short form of label=, the syntax of LaTeX’s enumerate
package. With one of the characters a, A, i, I, 1, that
character stands for the number in the number format it shows: [(i)] is
label=(#{roman}), [1.] is label=#{arabic}., [a-] is
label=#{alph}-. With none of them, the text is a fixed label: [-],
[*], [+]. A short form that writes a number also sets the reference
template: the same text with every full stop, colon and hyphen at its end
dropped, so [1.:] is label=#{arabic}.:, ref=#{arabic} and [(i)]
refers to its items as (#{roman}). A fixed short form refers to its
items by its label. Any other text, a Unicode bullet included, is written
with label={…}; a ] inside the bracket is protected by braces. A short
form holding two of the five characters is an error, since it could mean
two things (BadLabelForm). See list_options, short_form and
short_form_ref.
A ref= on a list whose list kind is not numbered has no number to
write. It is accepted and reported as a Note (RefIgnored), so that a
list can be switched between a numbered and an unnumbered list kind
without its bracket being rewritten.
§Items
Inside a list’s body, and nowhere else, \item begins an item. \item
is declared in a scoped package (ScopedPackageDef), PACKAGE:
a set of element declarations that can be written only inside the bodies
and arguments whose declarations refer to the package (see
scoped packages); the
body of every list environment refers to it. Everything after an \item
up to the next one, or to the end of the body, is the item’s content,
which is block content (e.g. paragraphs, nested lists). An
empty item is still an item. Whitespace and comments before the first
\item are skipped; any other content there is the error
ContentBeforeItem.
An \item takes an optional key-value argument with one key, tag: FLM
content shown as the item’s label in place of the list’s template, in a
numbered list as in an unnumbered one. A bracket holding no = outside
braces is the whole tag: \item[My tag] is \item[tag={My tag}], and
\item[tag={a=b}] protects a =. See item_options.
After an \item and its bracket, \label{item:…} fields attach labels to
the item, several of them if needed, as they do after a heading’s title.
A label is the text an author writes as \label{type:label} after a
construct (see
labels);
an item accepts the label type item only (LABEL_TYPES).
§The label beside an item
The label shown beside an item is, in this order: its tag; else the list’s own label template; else the label template the list kind declares for the list’s depth.
- A template that writes a number writes the item’s number through that
label template, without the word a reference writes before it:
2.beside the item,Item~2in a reference. The numbering feature’s stageNUMBER, which records each reference point’s counter value in the counter table, records each item’s number with the counter style of the list’s depth, whose number format is the list’s reference template. To write the label, the list’s rule takes that counter style, replaces its number format by the label template (CounterStyle::with_number_format), and compiles the result once per list when the list is lowered. - A template that writes no number is a fixed label, shown beside every item.
- A list of a list kind that declares no template (
description) writes no label of its own, and an item there without a tag is the errorMissingTag.
A fixed template on a numbered list (\begin{enumerate}[label={*}])
shows * beside every item. Every item is still counted and has its
number, which a reference writes through the same template, Item~*,
since label= alone sets the reference template too. An explicit empty
label={} shows no label at all. Whether a list is numbered depends on
its list kind, never on its template: a template that writes a number on
an unnumbered list is the error LabelNamesNumber, and the depth’s
template is used instead.
§Numbers
The items of a numbered list kind are numbered by the
numbering feature, and by nothing
else. Each numbered list kind declares a counter
(CounterDecl) and
one counter style
(CounterStyleDecl)
per depth, whose number format is the depth’s reference template
(numbers). Each list environment of the list kind is a scoped instance
of the counter (see
scoped instances
and, for authors, the
numbering guide), so that
each list numbers its own items from one, a list nested in a numbered item
of another list is counted within that item, and the enclosing list
continues after it.
An item carrying a tag is counted in no counter and has no number:
\item[Custom] \item \item shows Custom, 1., 2., as in LaTeX.
In a registry without the numbering feature, nothing numbers items. The
counters and counter styles are dropped when the registry is built, with
one Note for each of the numbering feature’s two service slots, and a
numbered list whose label writes a number shows
no label and is reported once (NoNumbering); a fixed label and a tag
are still shown.
§References to items
Every \item of a list is one reference point: one place in a document
that can be referred to, numbered, or given an anchor
(RefPoint; see
reference points).
Its reference kind is item (KIND), and its anchor is derived from
its first label or, for an unlabeled item, from its position
(ANCHOR_PREFIX). \ref{item:x} shows what is shown beside the item,
through the ordinary path of the
references feature:
- for a numbered item, the word and the number written through the list’s
reference template:
Item~2,Item~(ii), and(ii)under\ref[noprefix]; - for an item carrying a tag, the tag, however it is written
(
\item[Custom],tag=Custom,tag={Custom}); - for an untagged item of an unnumbered list, its label: the list’s own
(
[-],label=*,label={--}) where it writes one that can be used, else the label template the list kind declares for the depth, so that\ref{item:x}on anitemizeitem shows•.
An unnumbered list kind’s reference templates, and a ref= on its lists,
have no effect. ItemElement describes how the reference point carries
that content.
§What the feature registers
Under a ListsConfig, the feature registers:
- one value of the element type
LIST(flm.lists.list) per list kind, written as the environment of the list kind’s name, carrying aListElement; - the scoped package
PACKAGEholding\item, whose elementITEM(flm.lists.item) carries anItemElement, the item’s reference point; - for each numbered list kind, a counter and its counter styles, as peer
contributions to the numbering feature’s service slots (
numbers); - peer declarations (
PeerName) of the numbering feature’s counter table and of the references feature’s anchors table, which the list rule reads where they exist, and of the references feature’s argument roleDEFINED_LABEL_ARG_ROLE, the role of the argument of an item’s\labelfield; - a build hook (
LateInit) that compiles every list kind’s label templates, and a numbered list kind’s reference templates, once the registry’s parsing language (BuiltLang) is built; a template that does not compile, or a label template of an unnumbered list kind that writes a number format, fails the registry build; - the lowering rules
RULEandITEM_RULE, and the recomposition rulelatex::LATEX_RULEof thelatex-recomposedbackend; - its settings: the fields of
ListsConfigas data (crate::core::settings).
§How a list is lowered
On every backend except latex-recomposed, the lowering rule RULE
(ListRule) lowers a list to one
flm.pres.list node holding, per
item, a label content slot and an item content slot. Its kind tokens
are, in this order:
- the list kind’s structural token:
LIST_NUMBEREDfor a numbered list kind,LIST_UNNUMBEREDfor an unnumbered list kind that declares label templates,LIST_TERMSfor a list kind that declares none; - the environment’s name;
LIST_LABELED, since every item’s label is written as content of thelabelslot.
Each item’s anchor (the identifier its reference point was given) is
carried on the list’s payload
(ListPayload), one per
entry, read from the references feature’s anchors table where there is
one, so that a link to the item leads to it. A list inside a footnote
keeps its items’ numbers and anchors where the
xnotes feature gathers the
footnotes, because the footnotes are shown there with their own content,
not with a copy of it.
What each backend makes of the flm.pres.list node:
- HTML: an
<ol>,<ul>or<dl>chosen by the structural kind token, as the HTML contract states; thelabeledkind token switches off the marker the browser would draw. - Text: each label followed by the item’s blocks, every item’s blocks aligned at one column.
latex-recomposed: the general rule is not used; the recomposition ruleLATEX_RULEwrites the list back as its environment and its items as\items (latex).
A list inside a
synthesized value
(for example a label template that holds a list) has items that the
references feature’s stage
ANCHORS_STAGE, which
gives each reference point its anchor, and the numbering stage never saw.
The list is reported once for each table that holds no entry for those
items (flm.run.missing-entry), and it is still written, those items
without an anchor and without a number.
ITEM_RULE (ItemRule), the default on every backend, lowers an
\item that is inside a list but not directly in its body, which begins
no item, to nothing, and reports ItemOutsideList.
§Interactions with other features
- The
numberingfeature numbers the items of numbered lists; without it, see Numbers. - The
refsfeature checks the labels, computes the anchors and resolves\ref; without it, no item has an anchor, and nothing is reported. - The
refpointsfeature collects the items’ reference points. - The LaTeX family (the
latexhelpers and thelatex-recomposedbackend) owns the constructs the recomposition rule stages; without them, that rule is set aside (excluded from rule selection; seePeerName) and the registry still builds.
§Diagnostics
Every condition is reported under flm.lists.* by the lowering rules;
each is an Error except the Note RefIgnored, and each item’s
documentation states the recovery: UnknownKey, MissingValue,
BadLabelForm, BadLabel, LabelNamesNumber, RefIgnored,
ContentBeforeItem, MissingTag, NoNumbering,
ItemOutsideList, NoEnumitemFormat, NumberReadAsCharacters.
The mistakes in how a list is written (its optional arguments, the
content before its first item, an item missing its tag) and the problems
of the label beside its items (a template that cannot be used, a numbered
list that nothing numbers) are reported by whichever rule lowers the
list, so every backend reports them alike, the recomposed LaTeX included.
The recomposition rule alone reports NoEnumitemFormat and
NumberReadAsCharacters, since only it writes a list’s own templates as
LaTeX. A list’s own template that does not compile is reported once: the
reference template of a numbered list in a registry with the numbering
feature by the numbering stage, which compiles it
(flm.numbering.bad-number-format), and every other template by the
list’s rule (BadLabel).
§Items of this module
- The feature:
Lists,feature,FEATURE; its configurationListsConfig,ListKind. - Names: the elements
LISTandITEM, the commandITEM_COMMAND, the scoped packagePACKAGE, the argumentOPTIONS_ARGand its keysLABEL_KEY,REF_KEY,TAG_KEY, the reference kindKIND, the label typesLABEL_TYPES, the anchor prefixANCHOR_PREFIX, the rulesRULEandITEM_RULE. - Element values:
ListElement,ItemElement. - Reading a list:
list_items,item_of,is_item,enclosing_list,nesting_chain,ListBody,ListItem; its optional arguments:list_options,item_options,short_form,short_form_ref,ListOptions,OwnLabel,ItemOptions,ItemTag. - Lowering:
ListRule,ItemRule; the recomposed LaTeX:latex. - Numbers:
numbers. - Conditions: listed under Diagnostics.
Modules§
- latex
- The recomposition rule of the
listsfeature for thelatex-recomposedbackend (LATEX_RULE,ListLatexRule): it writes a list back as its LaTeX environment, under the list kind’s name, and each item as\item. The rule is the default on thelatex-recomposedbackend only; the rendering guide describes the output for authors. - numbers
- The numbers of list items: the counter and the counter styles that each
numbered list kind declares to the
numberingfeature.
Structs§
- BadLabel
- The error that is reported when a label template or a reference template
in the optional argument of a list is not valid (
flm.lists.bad-label). - BadLabel
Form - The error that is reported when a short label form contains more than one
of the characters
a,A,i,Iand1(flm.lists.bad-label-form). - Content
Before Item - The error that is reported when the body of a list contains content before
its first
\item(flm.lists.content-before-item). Whitespace, blank lines and comments do not count as content here. - Item
Element - The data of the
ITEMelement, and itsReferenceableaspect, which declares the reference point of the item an\itembegins. - Item
Options - What an
\item’s optional argument gives: the item’s tag, where it writes one. Returned byitem_options. - Item
Outside List - The error that is reported when an
\iteminside a list is not placed directly in the body of the list (flm.lists.item-outside-list). - Item
Rule - The lowering rule
ITEM_RULEof an\item, the default on every backend. A list’s rule lowers the content of its items and never an\itemnode, so an\itemthat the lowering reaches on its own is one that begins no item. The rule writes nothing for it and reports it asItemOutsideList. - ItemTag
- An item’s tag, as
item_optionsreads it: the content the author wrote for the item’s label, from\item[My tag],\item[tag=My tag]or\item[tag={My tag}]. - Label
Names Number - The error that is reported when the label template of an unnumbered list
contains a number format (
flm.lists.label-names-number). - List
Body - A list’s body as
list_itemsreads it, with the label templates that apply to its items. - List
Element - The data of one element value of
LIST: the list kind it is. - List
Item - One item of a list, as
list_itemsreads it: its\item, its tag, its labels and its content. - List
Kind - A list kind: what every list environment of one name is, how its items are numbered and which labels are shown beside them.
- List
Options - What a list’s optional argument gives: the list’s own label template and
its own reference template, where it writes them in a way that can be
read. Returned by
list_options. - List
Rule - The lowering rule
RULEof a list, the default on every backend exceptlatex-recomposed. It stages (builds into the lowered tree; seeLowerer) oneflm.pres.listnode whose kind tokens are the list kind’s structural token, the list environment’s name andLIST_LABELED, and which holds one entry per item: the item’s label in thelabelcontent slot, the item’s content lowered through the rules in theitemcontent slot, and the item’s anchor on the payload (ListPayload). The module documentation of the feature describes the result in full. The rule reports every mistake in how the list is written and every problem of its labels (see the feature’s diagnostics). - Lists
- The
listsfeature (FlmFeature). Under aListsConfig, it registers oneflm.lists.listelement value per list kind, written as the environment of the list kind’s name; the scoped package holding\item; the counters and counter styles of the numbered list kinds, as peer contributions to the numbering feature; the build hook (LateInit) that compiles every list kind’s label templates and a numbered list kind’s reference templates; and the lowering rulesRULE,ITEM_RULEandlatex::LATEX_RULE. See the module documentation. - Lists
Config - The configuration of the
Listsfeature: the list environments, each environment’s name mapped to its list kind (ListKind). - Missing
Tag - The error that is reported when an item has no tag in a list that has no
label template (
flm.lists.missing-tag). - Missing
Value - The error that is reported when a key in the optional argument of a list
or of an
\itemis written without=(flm.lists.missing-value). - NoEnumitem
Format - The error that is reported on the
latex-recomposedbackend when the label template or the reference template of a list contains a number format that LaTeX’senumitempackage does not support (idflm.lists.no-enumitem-format). - NoNumbering
- The error that is reported when the items of a numbered list need a number
and the registry does not contain the
numberingfeature (idflm.lists.no-numbering). - Number
Read AsCharacters - The error that is reported on the
latex-recomposedbackend when the label template or the reference template of a list contains a number format inside content that is read as characters, such as verbatim content (idflm.lists.number-read-as-characters). - OwnLabel
- The label template a list writes in its optional argument, as
list_optionsreads it. - RefIgnored
- The note that is reported when the optional argument of an unnumbered list
contains the key
ref(flm.lists.ref-ignored). - Unknown
Key - The error that is reported when the optional argument of a list or of an
\itemcontains an unknown key (flm.lists.unknown-key).
Constants§
- ANCHOR_
PREFIX - The prefix of an item’s anchor,
item: an unlabeled item’s anchor isitem--<position><four letters>, a labeled item’s anchor isitem-<label>(seeANCHORS). - FEATURE
- The feature’s registered name,
lists. - ITEM
- The element of
\item,flm.lists.item, carrying anItemElement. - ITEM_
COMMAND - The name of the command that begins an item,
item. - ITEM_
RULE - The name of the lowering rule of the element
ITEM,flm.lists.item.lower.default(ItemRule): the rule of an\itemthat begins no item. - KIND
- The reference kind of an item’s reference point,
item. - LABEL_
KEY - The key of a list environment’s optional argument that gives the list’s
own label template,
label. - LABEL_
TYPES - The label types an item accepts:
itemonly.\label{item:first}labels an item; a label of another type written after an\itemdefines nothing and is reported by the label check asflm.refs.label-type-not-accepted. - LIST
- The element type name shared by every list kind,
flm.lists.list. Each list kind is one element value of this type, carrying aListElement. - OPTIONS_
ARG - The name of the optional key-value argument of a list environment and of
an
\item,options. - PACKAGE
- The name of the scoped package (
ScopedPackageDef) that holds\item,flm.lists.items. The body of every list environment refers to it, so\itemcan be written inside a list’s body and nowhere else. - REF_KEY
- The key of a list environment’s optional argument that gives the list’s
own reference template,
ref: the name the LaTeX packageenumitemgives the same key. - RULE
- The name of the general lowering rule of the element
LIST,flm.lists.list.lower.default(ListRule), the default on every backend exceptlatex-recomposed. - TAG_KEY
- The only key of an
\item’s optional argument,tag: the item’s tag.
Functions§
- enclosing_
list - The list in which the
\itemnodenodebegins an item: the list environment whose body holdsnodeas a direct child.Nonefor an\itemlocated anywhere else, such as in a group or an argument inside a list, which begins no item. - feature
- The
Listsfeature under the default configuration (the list kindsitemize,enumerateanddescription), ready to be listed in a package entry. - is_item
- Whether
nodeis an\item. - item_of
- The
\itemnodenoderead on its own: its tag and its labels, with no content.Nonefor a node that is not an\item. - item_
options - Reads the optional argument of the
\itemnodenode: the item’s tag, and what could not be read. This function reports nothing; the list’s lowering rule reports what could not be read. - list_
items - The items of the list environment
node, split at the\itemnodes of its body, with the label templates that apply to them. - list_
options - Reads the optional argument of the list environment
node: the list’s own label template, its own reference template, and what could not be read. This function reports nothing; the list’s lowering rule reports what could not be read. - nesting_
chain - The lists of the same list kind as
listthat containlist,listincluded, outermost first: its nesting chain. Their number islist’s nesting depth; for a node that is not a list, the chain is empty. For a numbered list kind, the scoped instances under which an item oflistis counted are taken from this chain:listitself, and every list of the chain whose item holding the next list is untagged (seeItemElement). - short_
form - The label template that the short label form
textstands for:Some(Ok(template))for a text made only of the short form’s characters and holding at most one of the five number charactersa,A,i,I,1;Some(Err((first, second)))for one holding more (its readings with the first and with the second as the number); andNonefor a text that is not a short form. - short_
form_ ref - The reference template that the short label form
textgives its list. Whereshort_formreadstextas a template that writes a number, it istextwith every full stop, colon and hyphen at its end dropped, then translated:1.:gives#{arabic},a-gives#{alph},(i)gives(#{roman}). A short form that writes no number is a fixed label, and its reference template is the label itself:-gives-.Nonewhereshort_formdoes not return a template.