How can I style the content (not numbering) of an enum?

I’d like to enclose the contents of each item in a nested numbered list in a colored box, leaving the number out of the box. I tried:

+ aaa
  + bbb
  + ccc
+ ddd


#set enum(
  full: true,
)

#show enum.item: box.with(
  width: 100%,
  stroke: 1pt + red,
  radius: 3pt,
  inset: 6pt,
)

+ aaa
  + bbb
  + ccc
+ ddd

Which yields this below (surprisingly to me, the numbering is also now broken). Why is that, and can I enclose just the content/body of each node?

It’s not so easy to achieve that. However, you can use the itemize package. For example:

#import "@preview/itemize:0.2.0" as el
#set enum(full: true)
#show: el.default-enum-list.with(
  body-format: (
    inner: (
      stroke: 1pt + red,
      radius: 3pt,
      inset: 6pt,
    )
  )
)

For more complex customization of enum body formatting, see the package documentation.

2 Likes

Related to Can I use show rule only in content of enum but not numbering?