In addition to what @Eric said, I want to point out the use of state
. From your example, it is apparent that you are just counting natural numbers, therefore you should use counter
instead. Also, the .update()
method, if the function is passed, expects a new value, but you provided none
. For state
this will therefore set the new value to none
, for counter
this will give an error.
Here is what you should use instead:
#let c = counter("test")
#let fun(id) = [#c.step()#label(id)]
#fun("test")
#pagebreak()
#link(label("test"))[link]
#context c.get().first()
Although this still looks somewhat strange to do without additional context/information.