How to display short figure caption in bold and long in italic?

Hi all, I’m currently learning Typst and plan to use it for my thesis.

I have the following issue: I would like to give each figure and short and long caption. In the table of content, only the short caption should be displayed. In the figure itself, I would like to have all text in italic, an additionally, the Figure word, the figure number and the short caption in bold. Thanks to this forum, I’ve already managed to give each figure a long and short caption with the following snippet:

#let in-outline = state("in-outline", false)

#show outline: it => {
  in-outline.update(true)
  it
  in-outline.update(false)
}
#let flex-caption(long, short) = context if in-outline.get() { short } else { long }

I would like to modify this function like this (concat the short and long string):

#let flex-caption(long, short) = context if in-outline.get() { short } else { short + long }

To make the figure word and figure number in bold and italic, and the rest only in italic, I’ve found this snippet:

#show figure.caption: it => [
  #emph[*#it.supplement #context it.counter.display(it.numbering):*~#it.body]
]

How can I now modify this code that I get the following:
Figure 1: This is the short caption. This is the long caption.

Hi. Here you go:

#let in-outline = state("in-outline", false)

#let flex-caption(short, long) = context {
  if in-outline.get() [#short] else [#strong(short). #long]
}

#show outline: it => in-outline.update(true) + it + in-outline.update(false)

#show figure.caption.where(kind: image): it => {
  let numbering = if it.numbering != none {
    [~] + context it.counter.display(it.numbering)
  }
  emph[*#it.supplement#numbering#it.separator*#it.body]
}

#outline(target: figure.where(kind: image))

#figure(rect(), caption: flex-caption[Short][Long #lorem(9)])

Hey @typst_user, welcome to the forum! I’ve changed your question post’s title to better fit our guidelines: How to post in the Questions category

For future posts, make sure your title is a question you’d ask to a friend about Typst. :wink: