You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow leading labels to attach to their enclosing elements #9113
Currently, Typst attaches a label to the closest preceding labelable element within the same scope. If a label is placed at the beginning of a content sequence, it has no preceding element to attach to.
I propose that, in such cases, the label attach to the enclosing element instead, where one exists.
For example,
#block[<foo> Some content]
would be equivalent to:
#block[Some content] <foo>
This would preserve the existing behavior of labels following elements while giving a useful meaning to otherwise unattached leading labels.
Use case
In mathematical writing, it is common to divide a theorem or proposition into several individually labeled assertions. Placing labels at the beginning of enumeration items is often more natural, particularly when an item contains multiple paragraphs:
+ <first> First assertion.
+ <second> Second assertion.
Under the proposed semantics, these labels would attach directly to their respective enum.item elements.
Currently, the itemize package provides elabel as a workaround, which allows one to write:
+ #itemize.elabel(<first>) First assertion.
+ #itemize.elabel(<second>) Second assertion.
Internally, this function creates an invisible metadata element to which the label is attached. It would be desirable to support leading labels natively through a general rule rather than requiring such workarounds.
This proposal is independent of #779, which concerns making enumeration items referenceable. It is instead a general change to the semantics of label attachment that would also benefit querying and styling.
A related proposal is #1943, which discusses extending the search for suitable label targets.
Activity
Lege19 commentedon Nov 26, 2026
Applying this for syntax sugars and for blocks are separate features IMO.
I like this for syntax sugar for making it easier to label list items.
Now you mention it I wonder why this isn't the syntax for labelleing a heading.
For blocks I'm not sure this is needed.
AprilGrimoire commentedon Nov 26, 2026
I'm not too familiar with Typst's typesetting model, but I'm imagining list items and such are all blocks? I think that's a paradigm in Typst. https://forum.typst.app/t/confusion-about-syntax-making-formulae-page-breakable/7571
Lege19 commentedon Nov 26, 2026
yes, they are blocks. I meant blocks in the syntactic sense of
[...]