Why does showing a figure in a box not put the figure inline?

Why does the first approach not work but the second does in making the figure become inline?

// first approach
#{
  show figure: box
  figure(lorem(10), caption: [some lorem words])
}

// second approach
#box(figure(lorem(10), caption: [some lorem words]))

I’m confused why the first doesn’t work but changing the show rule to be show figure: it => box(stroke: 1pt, it) does apply the stroke but does not make the figure inline.

2 Likes

Indeed, it’s weird. The only explanation is that some internal show rule adds a block wrapper. The same goes for it.body or it.caption. Default show-set align rule prevents inlining figure with box show rule · Issue #7001 · typst/typst · GitHub.

2 Likes