In the following code, I step the counter and retrieve its value in a loop.
I used three methods to call n.get(), but only the first method (a.) gives the correct result.
(The other two always give one, as if I only stepped once.)
Why?
#set enum(numbering: ..) // Use a fancy format for readability
#let n = counter("n")
#for _ in "repeat" {
n.step()
context enum.item[#n.get()] // a.
enum.item[#context n.get()] // b.
context enum.item[#context n.get()] // c.
}
Full code
#set page(height: auto, width: auto, margin: 1em)
#set enum(numbering: n => if calc.rem(n, 3) == 1 {
numbering("1", calc.ceil(n / 3)) + "a."
} else {
numbering("a.", calc.rem(n - 1, 3) + 1)
})
#let n = counter("n")
#for _ in "repeat" {
n.step()
context enum.item[#n.get()]
enum.item[#context n.get()]
context enum.item[#context n.get()]
}
My attempt
Replace enum.item with box or rect
Suddenly all methods work as expected.
![]()
Wrap the methods
If I wrap the three methods in an enum({..}), then all n.get() are corrected too.
#set enum(numbering: "1a.")
#let n = counter("n")
#for _ in "repeat" {
n.step()
enum({
context enum.item[#n.get()]
enum.item[#context n.get()]
context enum.item[#context n.get()]
})
}
The same thing also happens to grid.
#let n = counter("n")
#for _ in "repeat" {
n.step()
grid(
columns: 3,
context enum.item[#n.get()],
enum.item[#context n.get()],
context enum.item[#context n.get()],
)
}
However, if I wrap with enum.item({..}) instead, they all become one.
#set enum(numbering: "1a.")
#let n = counter("n")
#for _ in "repeat" {
n.step()
enum.item({
context enum.item[#n.get()]
enum.item[#context n.get()]
context enum.item[#context n.get()]
})
}
Final: #context n.get()
Wrapping with context enum.item({..}), enum.item(context {..}), context enum.item(context {..}), or similar variants of list.item makes no difference.






