How to make blocks sticky inside a breakable block?

For example, I want the table inside a figure to be breakable, but I don’t want its caption to be orphaned. So I tried the following:

#show figure: set block(breakable: true)
#show figure.caption: set block(sticky: true)
#set figure.caption(position: top)

#lorem(640)
#figure(
  table(
    columns: 3,
    ..range(9).map(str)
  ),
  caption: "test",
)

However, this doesn’t work.

I then started investigating the issue and found that when sticky blocks (in this case, the caption and table) are inside a breakable block (the figure), they don’t behave as expected:

#lorem(600)
// sticky
#{
  set block(stroke: yellow, sticky: true)
  block(lorem(30))
  block(lorem(30))
}

And:

#lorem(600)
// no longer sticky
#block(
  breakable: true,
  {
    set block(stroke: yellow, sticky: true)
    block(lorem(30))
    block(lorem(30))
  },
)

Is this a bug, or are there alternative ways to control where breaks can occur (and where they should not) inside a breakable block?

1 Like

There in fact seems to be an issue with sticky blocks inside another breakable block:

2 Likes