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
Make function supplement return the number as well #2990
Many elements have a supplement parameter. While it is useful, the fact that it only lets you customize what is displayed before a number is limiting.
We should allow supplements to be functions that accept the formatted number (as content), and return some content that contains the number with its supplement. For example, x => [Before #x after.].
What if we allowed an extension to the supplement syntax: if you type @label[custom supp] then we allow you to use <label> as though it were a variable in the inner markup block? So you could write: @thm:A[Theorem <thm:A> by Author].
If you don't include <label> then we can make the supplement default to prefix of the reference, or add a set rule that changes it to postfix.
Fair. I chose that because placing the label again doesn't have any current meaning. Some alternatives if this is desirable might be repeating @label or maybe using just a raw @ or #@.
I do think this style has potential to solve the context-dependent supplement problem.
Is the need for this single-ref context-dependance really that common that it deserves custom syntax? I'd imagine that you'd typically either rather want to configure this in a set rule (as a function), not ad-hoc for a single reference.
I just realized that this proposal can't be implemented this way, because supplements can already be functions that accept the element's body. (#2990 (comment))
Could the issue title be modified for future reference? For example:
Change the return value of supplement functions from Figure to Figure 1.
Current: (a figure element) ↦ [Figure].
Possible changes:
(1,) ↦ [Figure 1]
(a figure element,) ↦ [Figure 1]
(a figure element, 1) ↦ [Figure 1]
(a figure element, supplement: [Fig.]) ↦ [Fig. 1], where [Fig.] is given by writing @key[Fig.].
In a show ref function, we have to recreate a link.
If link and ref have different styles (e.g., different text color), then the style for the created link will override the style for ref, which is not desired.
Activity
Dherse commentedon Dec 17, 2023
Be careful with just
thas the super otherwise you'll get21thor103thwhich just looks weird![-]Proposal: Function as `supplement`[/-][+]Function as `supplement`[/+]MDLC01 commentedon Dec 17, 2023
Yes of course. This was just the first example I could think of. In practice, I guess the "th" would be part of the numbering pattern.
MDLC01 commentedon Dec 17, 2023
I just realized that this proposal can't be implemented this way, because supplements can already be functions that accept the element's body.
I think the underlying feature request is still interesting, though.
wrzian commentedon Nov 11, 2024
What if we allowed an extension to the supplement syntax: if you type
@label[custom supp]then we allow you to use<label>as though it were a variable in the inner markup block? So you could write:@thm:A[Theorem <thm:A> by Author].If you don't include
<label>then we can make the supplement default to prefix of the reference, or add a set rule that changes it to postfix.laurmaedje commentedon Nov 11, 2024
Making the label suddenly evaluate to content seems strange to me, to be honest. It's not really the principle of least surprise.
wrzian commentedon Nov 11, 2024
Fair. I chose that because placing the label again doesn't have any current meaning. Some alternatives if this is desirable might be repeating
@labelor maybe using just a raw@or#@.I do think this style has potential to solve the context-dependent supplement problem.
laurmaedje commentedon Nov 11, 2024
Is the need for this single-ref context-dependance really that common that it deserves custom syntax? I'd imagine that you'd typically either rather want to configure this in a set rule (as a function), not ad-hoc for a single reference.
YDX-2147483647 commentedon Dec 1, 2025
Could the issue title be modified for future reference? For example:
figureelement) ↦[Figure].(1,)↦[Figure 1]figureelement,) ↦[Figure 1]figureelement,1) ↦[Figure 1]figureelement, supplement:[Fig.]) ↦[Fig. 1], where[Fig.]is given by writing@key[Fig.].Update on 2026-04-17
The proposed
{figure,heading,…}.supplementfunction API has an advantage overshow ref: it => {…}customization:In a
show reffunction, we have to recreate alink.If
linkandrefhave different styles (e.g., different text color), then the style for the createdlinkwill override the style forref, which is not desired.Example:
[-]Function as `supplement`[/-][+]Make function `supplement` return the number as well[/+]