How to continue `enum` throughout entire document?

Hi @miles-1 ,

while @maucejo solution is very good and suitable for most cases, I want to point out that this is actually possible to configure with a simple show rule if you want to keep using the enum syntax and don’t care for nested enumerations.

#let item-counter = counter("item-counter")
#set enum(start: 0)

#show enum: it => {
  if it.start != 0 { return it }
  let args = it.fields()
  let items = args.remove("children")
  context enum(..args, start: item-counter.get().first() + 1, ..items)
  item-counter.update(i => i + it.children.len())
}

What this does is to create a counter that keeps track of the number of already processed items and set the start parameter of the enumeration according to that counter. The line #set enum(start: 0) is a trick to prevent the show rule being called recursively.

Now this:

  + Item
  + Item

  Some text in between
  
  + Item
  + Item
  
  Some more text in between
  
  + Item
  + Item

will produce the following output:
image

2 Likes