I'm trying to create a counter to label paragraphs.
First, I create a counter like this:
#let gParagraphCounter = counter("para-counter")
Then, I create a couple of functions to work with the counter.
#let ParLabelReset() = {
gParagraphCounter.update(42)
}
#let ParLabel() = context {
gParagraphCounter.step()
let num = gParagraphCounter.get().last()
return str(num) + ")"
}
Then, the usage is supposed to be:
// At the beginning of the document/chapter.
// Reset the paragraph counter.
#ParLabelReset()
// ... later in the document
#ParLabel() This is some text in paragraph 1.
#ParLabel() This is some text in paragraph 2.
The problem:
The value returned by #ParLabel() is always 42. The gParagraphCounter.step() doesn't seem to have an effect.
How can I have the #ParLabel() update the value of the counter, prior to returning the updated value?