I’ve read a few posts on this, including this issue posted by @Andrew, but I’m still unclear on the best way to fix it (aside from avoiding it, which isn’t an option for now).
In short, I’m working with a Quarto-typst template and through a combination of their lua filters and our Julia code, our figure captions in the intermediate .typ file look like this:
#figure(
box(width: 1in,height: 1in, fill: blue),
caption: [
#lorem(15)
]
)
The newlines inside [ ] result in additional whitespace being prepended to the outline entry for the figure.
It’s less of an issue for short captions, but it’s definitely noticeable for longer captions, which are common for our reports. I was able to resolve the issue using a combination of content-to-string conversion and show figure rule:
#let stringify(content) = {
if content.has("text") {
if type(content.text) == str {
content.text
} else {
stringify(content.text)
}
} else if content.has("children") {
content.children.map(stringify).join("")
} else if content.has("body") {
stringify(content.body)
} else if content == [ ] {
""
}
}
#show figure: it => {
if it.kind == "mod-figure" {return it}
figure(
it.body,
caption: stringify(it.caption.body),
kind: "mod-figure",
supplement: [Figure]
)
}
My question is whether there’s a better way to handle this?

