Provide enum nesting depth to numbering function even without `full: true`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 56.1k
- Forks
- 1.7k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 22
Description
Description
#set enum(
numbering: (..numbers) => {
let numbers = numbers.pos();
if numbers.len() == 1 {
return numbering("1.", numbers.at(0))
}
if numbers.len() == 2 {
return numbering("a.", numbers.at(1))
}
},
full: false
)
+ + Hello
#set enum(
numbering: (..numbers) => {
let numbers = numbers.pos();
if numbers.len() == 1 {
return numbering("1.", numbers.at(0))
}
if numbers.len() == 2 {
return numbering("a.", numbers.at(1))
}
},
full: true
)
+ + Hello
#set enum(numbering: "1.a.", full: false)
+ + Hello
#set enum(numbering: "1.a.", full: true)
+ + Hello
The output is:
I intuitively expect
#set enum(numbering: s)
And
#set enum(numbering: nums => numbering(s, nums))
Should be equivalent. However that's not the case: when using a string argument, the indices of outer layers are considered (at least they are supplied as placeholders to trigger different numbering styles) even if full is set to false. When using a function argument, if full is set to false, the indices of outer layers are not passed to the function, resulting in the function not knowing which layer it is at.
I think all the indices of outer layers should be passed to the numbering function, since supplying a custom numbering function is an attempt to override the default behavior. Also the current behavior of full is very non-orthogonal: when using numbering strings, it doesn't behave by only considering the current single enum, contrast to when using numbering functions.
Reproduction URL
No response
Operating system
Linux
Typst version
- I am using the latest version of Typst
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Typst reproduction in the issue and tracing the enum numbering implementation that handles custom numbering functions and the full setting. Done means outer enum indices are available to the function consistently with string numbering, while the shown nested-enum cases produce the expected equivalent results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100