I am trying to use typst to design a cover sheet informing people what they should be getting, e.g. “You should have a 20-page paper and a 34-page supplementary material in front of you.”.
Since I want to staple the paper and the supplementary material individually, they are generated as individual PDFs.
In my cover sheet document, I can render them using #paper() and #supp_material(). However I would like to only get the page count they would add to the document without actually rendering them in the final PDF. Is that possible in typst?
Hi, welcome to the forum! I don’t know how to do that without rendering the main document, but with the experimental bundle feature you can render the main document to one file, and count its pages and show the number in another file:
#document("main.pdf", title: [Main])[
#metadata(none)<begin>
#lorem(1000)
#metadata(none)<end>
]
#let page-count() = context {
locate(<end>).page() - locate(<begin>).page() + 1
}
#document("cover.pdf", title: [Cover])[
The main document has #page-count() pages.
]
If you write this in a file docs.typ you can compile with
typst c --features bundle --format bundle docs.typ