How to label an element in a function from outside the function?

Unfortunately this didn’t work with the i-figured package, because i-figured creates yet another copy. That means that your fix for the duplicated footnote didn’t work.

But I found a solution using this function to determine which counter to reset. Seems to be working well.

Here is the updated figure function:

#let fig(
  caption: [], 
  source: [],
  show_source: true,
  fig
) = {  
  let styled_figure = {  
    show figure.caption: it => {
      if show_source {
        if (it.kind == "i-figured-image" or it.kind == "i-figured-raw") and source == [] {
          it + footnote([Quelle: Eigene Darstellung])
        } else if it.kind == "i-figured-table" and source == [] {
          it + footnote([Quelle: Autor])
        } else {
          it + footnote([Quelle: #source])
        }
      } else {
        it
      }
    } 

    let fig_type = get_type(fig)
    if fig_type == TYPE_IMG {
      let c = counter(figure.where(kind: "i-figured-image"))
      context c.update(c.get().at(0) - 1)
    } else if fig_type == TYPE_TBL {
      let c = counter(figure.where(kind: "i-figured-table"))
      context c.update(c.get().at(0) - 1)
    } else if fig_type == TYPE_RAW {
      let c = counter(figure.where(kind: "i-figured-raw"))
      context c.update(c.get().at(0) - 1) 
    }     
       
    figure(caption: caption, fig) 
  }
  
  return figure(styled_figure)
}