How to customize the styling of caption supplements?

I want to have figures with a bold supplement+number+separator, but I don’t want my references to the figure to be in bold.

I have multiple figure types (Figure, Algorithm, Table) so I want the solution to be DRY if possible (I don’t want to repeat the same boilerplate for every figure/type).

However, the following code does not work, as it does not increment the figure number in the caption (but it does in the figure references):

#show figure.caption: it => box(
  inset: (left: 1em, right: 1em),
  align(left)[
    *#it.supplement~#it.numbering#it.separator*#it.body
  ]
)

#figure(
  box(stroke: 1pt, inset: 5pt)[This is a figure],
  caption: [This is a caption]
) <fig1>

#figure(
  box(stroke: 1pt, inset: 5pt)[This is a figure],
  caption: [This is a caption]
) <fig2>

@fig1 @fig2

How to fix this?

Hello, the it.numbering is actually the numbering scheme. You have to use it.counter.display().
Here is how I would write it

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

image

1 Like

Regarding #it.counter().display(), be careful if you use it with floating figures, see How to customize the style of equation numbering? - #8 by xkevio.

1 Like