Single-item enumeration item takes style from label

I try to change the style of enumeration labels, but revert the change for the item text.
This does however not work for single-item (sub) enumerations:

#set enum(numbering: "a.1.i.")
#show enum: set text(blue, weight: "bold")
#show enum.item: set text(black, weight: "regular")

+ wrong
  + correct
  + correct
    + wrong
  + correct
    + correct
      + still wrong#parbreak()
    + correct

Adding a paragraph break as suggested for a related issue here does not help:

Based on this thread I can get the desired result, but it looks far less elegant that the snippet above:

#set enum(
  numbering: (..n) => {
    n = n.pos()
    let i = n.len()
    text(blue, weight: "bold", numbering(
      ("a.", "1.", "i.").at(calc.rem(i, 3) - 1),
      ..n.slice(i - 1)))
  },
  full: true,
)

+ now correct
  + correct
  + correct
    + also correct
  + correct
    + correct
      + also correct#parbreak()
    + correct

Is there a way to fix the first snippet, or is the second one ‘the right way’ to style enumeration labels?

I think the second one is the right way. There is unfortunately a kind of complexity cliff when you need to customize a full numbering. But maybe it doesn’t look so bad if you separate styling from the numbering logic:

#let full-numbering(patterns: ("a.", "1.", "i."), ..args) = {
  let n = args.pos()
  let i = n.len()
  let pattern = patterns.at(calc.rem(i, patterns.len()) - 1)
  numbering(pattern, ..n.slice(i - 1))
}

#set enum(
  full: true,
  numbering: (..args) => text(blue, weight: "bold", full-numbering(..args)),
)

+ now correct
  + correct
  + correct
    + also correct
  + correct
    + correct
      + also correct#parbreak()
    + correct

Thanks, so would you happen to know whether the behaviour of my first snippet is a bug or a feature? I think your code looks a lot better than my second snippet, but it’s still a lot more complicated than the three lines of the first.

I would say a bug since there’s an inconsistency here that doesn’t make sense for the user. It’s been reported already: `#show enum.item` doesn't apply to `#enum` · Issue #1274 · typst/typst · GitHub

1 Like