How to customize numbering for nested enum items?

To complete @bluss’s answer, if you set full: true to your enum, the numbering function will receive all numbers corresponding to the enum.items. That is, the first item will send (1,), the nested item will send (1, 1).

You can receive these arguments using arguments as such:

#let nb = (..n) => { ... }

Then, n will be of type arguments. The easiest here is to convert it directly to an array and look at its length and slice for each level. A full example below. You do need to be careful to either define a default behaviour, or not use any levels with no customization.

// Configure Enums:
  #set enum(
    numbering: (..n) => {
      n = n.pos()
      let level = n.len()
      if level == 1 {
        text(blue, numbering("1.", ..n))
      } else if level == 2 {
        text(gray, numbering("a.", ..n.slice(1)))
      } else {
        // panic("Enum level not set")
        // or
        numbering("1.", ..n)
      }
    },
    full: true,
  )

+ ABC
   + DEF
   + DEF
     + DEF
2 Likes