How to make figure caption text have the same width as the figure?

in that case you need to still wrap in in a layout call, to give it the context it needs

#show figure: it => layout( sz => {
	let w = measure(
			it.body,
			width: sz.width
		).width
	set par(justify: true)
	show figure.caption: cap => box(width: w, align(left,emph(cap)))
	it
})

3 Likes