#figure(
{
let fname = "plot_" + str(figure.counter.display("1")) + ".png"
image(fname, width: 100%)
},
caption: [_Boxplot showing the difference in alpha diversity between responders and non-responders. All treatment timepoints are cumulated._],
)
figure does not have a counter member, but counter can access the current figure counter through counter(figure). Since this is also context-aware function, you need to add context somewhere fitting.
#figure(
context {
let fname = "plot_" + str(counter(figure.where(kind: image)).display("1")) + ".png"
image(fname, width: 100%)
},
caption: [_Boxplot showing the difference in alpha diversity between responders and non-responders. All treatment timepoints are cumulated._],
)
Also noticed, if you want all captions to have a specific style, you can add a #show figure.caption: ... rule à la How to make captions italic?
Edit: changed counter(figure) to counter(figure.where(kind: image)) to be more specific
I think you will need to use counter(figure.where(kind: image)) and similar, so that you get the right counter, since they are separate for images and tables and so on.