#Customise `figure.caption` only for figures of `code` kind

5 messages · Page 1 of 1 (latest)

storm hamlet
#

is there a way to modify figure.caption only for figures of a certain kind?
im customising some code blocks, but unless i match it will restyle the "Table, Figure" etc. text in other elements

// #show figure.where(kind: "code"): [
  #show figure.caption: it => [
    #set text(0.65em, fill: gray)
    // #if figure.kind == "code" [
      #it.supplement
      #h(1fr)
    // ]

    #set text(9pt, fill: black)
    #context it.counter.display(it.numbering): #text(it.body)
  ]
// ]

im aware of the .where(): set pattern and also how to control the caption's body
additionally, this could be approached differently if it is possible to customize the text indicating the figure type (like "Figure", "Table", "Listing") differently from the specific supplement text provided in #figure(... supplement: "Example text) ?
when using #it.supplement they seem to be grouped together

sullen oriole
#

?r


#show figure.caption.where(kind: "code"): it => {
  text(fill:red)[#it.supplement~#it.numbering#it.separator]
  it.body
}

#figure(caption:[a caption])[]
#figure(caption:[A great function], kind: "code", supplement: "Code")[This is some code]
sullen oriole
#

Is that what you wanted to do? @storm hamlet
Here, I catch the caption specifically, and manage to write the supplement/numbering in red.

storm hamlet
#

heyyy @sullen oriole yea i had to adapt it for my needs but that was it 💜 i still struggle with how to compose the syntax sometimes, thanks again typstguy