I am creating a template that has a state update at the footer of the page to store some values. However, the current method to do this is using set rules. As the set page(footer: ..)
can be overridden by user, my state update will be gone if they set their own footer. How I can do this?
Depending on how a new page is being added. You have footer, header, background, foreground.
I came up with a solution that’s quite close to @Andrew 's idea, the foreground. However, to keep user not to overwrite this accidentally, I did this
show: rest => context {
set page(foreground: page.foreground + my-counter.step())
rest
}
which, in my opinion, is very cursed. It is prone to convergence problem.
What is this state for? Or I guess a counter.
It is a literal page counter (like an index that must count for every page). I am creating a package for making slides, and default page counter I have used it for page number, which must be frozen during the subslide animations.
Can you use here().page()
, the “physical page count”? It’s not a counter but it seems to have the same value as your current counter, and you can query that kind of page number from many kinds of elements.
Otherwise if you have a state update that’s critical for the package you might expose it in a function and explain to the user that they need to place it in the page header (if they configure the page header).
‘Literal page’ means we count all of the pages whatever they are slides, subslides, title page, or any animation frames. While normal page number only counts the actual ‘content’ i.e. it does not count the subslide, title page, nor the animation frames.
Yeah, telling users might be the best option rn. Thank you!
here().page()
is exactly this literal page counter: it gives the physical page number of the context
used when calling `here():
#set page(width: 3cm, height: 3cm, margin: 1cm, numbering: "1")
#context here().page()
#pagebreak()
#counter(page).update(5)
#context here().page()
Oh, I’ve just tried this and it really solved my page counter problem. I haven’t known this before. Thank you very much!