-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to have a counter across pages? #68
Comments
It is possible, as the entire structure is in |
I didn't consider it, I'll take it into consideration when I rework on the book package, which was made in ancient typst (for about v0.6.0 :)). |
I considered it carefully and came up with some solutions but they were all bad.
Recently I have some initial idea about it, which utilize the PDF (ebook) target. The ebook target is the compilation where we composes all chapters into a single PDF book, so we can perform some calculation and export it to some file. Then, we can read the file and recover the state of the counter. Overall, we will have the following steps to make state shared across pages:
The cross-page counter of this issue as an example: #let ebook-query-main(content) = {
let figures = query(figure);
[
#metadata(somehow-check-figures-for-query(figures)) <ebook-query-set>
]
}
show: ebook-query-main
// chapter1.typ
== Chapter 1
#figure(..) <figure1>
#figure(..) <figure2>
// chapter2.typ
== Chapter 2
// chapter3.typ
== Chapter 1
#figure(..) <figure3>
#figure(..) <figure4>
Then we'll get a {
"/api/v1/figures/counter/figure1": "1.1",
"/api/v1/figures/counter/figure2": "1.2",
"/api/v1/figures/counter/figure3": "3.1",
"/api/v1/figures/counter/figure4": "3.2",
} Then, when we export the web target, we can recovery the counter values by reading this query file: #let query-set = json("all-state.json")
#let counter-of-figure(figure-label) = {
query-set.at({
"/api/v1/figures/counter/"
str(figure-label)
})
}
#counter-of-figure(<figure2>) // 1.2 You can find that, the above approach doesn't require any development of shiroa, and we can experiment it a bit by official |
I want the number of images and equations automatically increased across pages (or chapters). Is this possible, and how can we achieve it?
The text was updated successfully, but these errors were encountered: