Formating enum without overriding - custom enum

I’m really stuck on this one. If anyone could help I will appreciate it a lot.

This one works

#set enum(numbering: "1)a)", spacing: 1.5em)

and this one also works

#set enum(numbering:  it => {
  text(fill: purple, weight: "bold", [#it] })

How can achieve both?

Everything I’ve tried so far overrides one option or it brokes the code.

Hope anyone can bring some light here.

Thank you in advance!

Hi @SilverWolf,

as far as I know, it’s currently a bit tricky.

#set enum(
  full: true, 
  spacing: 1.5em,
  numbering: (..nums, last) => {
    text(
      fill: purple, 
      weight: "bold", 
      numbering(("1)","a)").at(nums.pos().len(), default: "I)"), last)
    )
  }
)


+ first
  + second
    + third 
+ fourth

1 Like

WOOOO :astonished: it works like a champ! Thanks a lot. Would you mind sharing how you figured it out? Why did you need that “last”? I spent hours without success. You nailed it!

Thanks @flokl !!

1 Like

My starting point were amazing answers to questions about numbering enum items per level, here and on Discord. With full: true you get an array containing the numbers of the parent enumerations and the number of the current item.

+ a    (1,)
++ b   (1, 1)
++ c   (1, 2)
+++ d  (1, 2, 1)
+ e    (2,)

The ..nums is a sink which collects all excess arguments (parent numbers) and last is the last array item (the number of the current enum item).

I hope that clarifies the code a bit.

Hi! Sorry for the delay in answering, I was dealing with a heavy workload. Thank you very much for your response, I just joined the Discord server! I’m going to study your explanation, I love Typst (from someone who has been using LaTeX for 15 years). You are amazing! See you in the amazing Typst universe haha

1 Like