How to reference styled figures?

Perhaps using this trick to reference metadata?

#show ref: it => {
  if it.element != none and it.element.func() == metadata {
    // do whatever here using it.element
    link(it.element.location())[_referencing metadata with value_ «#it.element.value;»]
  } else {
    it
  }
}

#sidefigure(
  rect(),
  caption: "Figure Caption",
  dy: -2em,
) #metadata("Bar")<fig:1>

@fig:1 // works
1 Like