How to add z-axis to `stack()` func?

when i want to make a heading style like
the section number lies in a little rect box ahead of a bordered box with the section name in another rect, and the little section number shadows the border line of the big one, i made it like this

#show heading.where(level: 2): t => context {
  align(
    center,
    stack(
      dir: btt,
      spacing: -0.5em,
      rect(width: 100%, fill: white, stroke: blue, inset: 1em)[
        #set text(
          fill: blue.transparentize(30%),
        )
        #t.body
      ],
      rect(fill: white, stroke: none, outset: 0pt)[
        #set text(
          fill: blue,
        )
        #math.section #counter(heading).display("1.1")
      ],
    ),
  )
}

intuitively, i hope i can order it from top to bottom, but hope the z-axis to be from top to bottom, since i expect the white little rect should cover the big one on the border, but no. so i turn to the bottom to top one.

so, i hope there be z-axis arguments to customize the layers’ order for stack func :grinning:
and btw, hoping the spacing function can be passed with an array, so that it could be more flexible to order the space between any to ajacent items

1 Like

Hi there! To be honest I don’t really understand your question, but I think the shadowbox package might help. Here’s a minimal example, but you can of course customize it further:

#import "@preview/showybox:2.0.4": showybox
#show heading.where(level: 2): t => [#showybox(
  // width: 11cm,
  // frame: (title-color: rgb(0, 8, 97), border-color: rgb(0, 8, 97)),
  title-style: (
    // color: white,
    boxed-style: (
      anchor: (x: center, y: horizon),
      offset: (x: 0em, y: 0em),
    ),
  ),
  title: [#math.section #counter(heading).display("1.1")],
  [
    #align(center)[#t.body]
  ]
)
]
= a heading
== some second level heading