How to make captions italic?

Could someone explain how to make captions italic, for both images and tables?

I tried

#show caption: set text(style: "italic")

but this produces an error.

I also tried

#show figure: set text(style: "italic")

but the second solution affects the tables themselves, not just their captions.

Hello,

You can configure the caption component of the figure component to your liking using #show. This affects of course only the captions!

#figure( // Typst default
  image("cat.png"),
  caption: [This is a cat!]
)

#show figure.caption: set text(style: "italic")

#figure( // Typst default with italic caption
  image("cat.png"),
  caption: [This is a cat!]
)

The same applies to the tables!

#show figure.caption: set text(style: "italic")

#figure(
  table(columns: (8%,) * 10,
  ..range(100).map(x => ([#(x+1)],)).flatten(),
  ),
  caption: [This is a table!],
)

image

This is probably one of many solutions, so more compact solutions might exist. But I hope this helps you!

1 Like

And to create some custom captions, following for example only emphasizes the label:

#show figure.caption: it => {
  [#emph[#it.supplement #it.numbering]#it.separator#it.body]
}

image

1 Like