How can I customize the placement and appearance of subpar subfigure captions?

Hello everyone,

i want to customize the captions of the subfigures from the subpar-package [subpar – Typst Universe] with the following specifications:

  1. The subcaptions should be above the subfigures
  2. The subcaptions should be ennumerated with A, B, … (bold, no separator)
  3. The subcaption text size should be custom- and different from the global textsize

It should look roughly like this:

(i did this in inkscape, so no code here. This is just a example of how i would like it to look like)

I have tried to look for the answer in the package documentation, but i haven´t found a satisfying solution. If someone could provide some help (maybe this is possible with clever show-rules?) or craft a hacky workaround, i would be very thankful.

Best

Hi @Elias_Riedling!
Here’s a quick example. It’s not exactly like in the picture, but it includes all three of your specified points.
I hope it helps.

#import "@preview/subpar:0.2.2"

#let my-subfig(..args) = subpar.grid(
  numbering-sub: "A",
  numbering-sub-ref: (..nums) => numbering("1 A", ..nums),
  show-sub-caption: (num, it) => {
    set text(size: 3em)
    // subcaption numbering
    text(weight: "bold", num)
    sym.space
    // subcaption body
    it.body
  },
  show-sub: it => {
    // subcaption on top
     set figure.caption(position: top)
     it
  },
 ..args
) 



#my-subfig(
  columns: 2,
  caption: [#lorem(30)],
  label: <fig>,
  figure(
    rect(fill: red),
    caption: [Red]
  ), <a>,
  figure(
    rect(fill: blue),
    caption: [Blue]
  ), <b>,
)

@fig \
@a \
@b

1 Like