I want to set my book template to show even pages aligned left with “# | chapter number” and odd pages aligned right with “book title | #”, but I can’t quite figure out how within the header/page numbering documentation.
most likely will need separate sections for each chapter, but that’s fine.
also want the page numbers to start on the first chapter (page 7 in the file) and preferably be hidden on blank pages
set page(header: context {
let page = counter(page).get().first()
let body = if calc.odd(page) [Section #chapter_num #section_num #h(0.5cm) #section #h(0.5cm) *#str(page)*]
else [*#str(page)* #h(0.5cm) Chapter #chapter_num #h(0.5cm) #chapter]
let alignment = if calc.odd(page) { right } else { left }
align(alignment, body)
}
which gives you alternating chapter/section header.
If you want a struct more like title | #, then you can use
context {
let h = (
counter(page).display(),
h(1fr),
hydra(1)
)
if calc.odd(here().page()) { h.join() } else { h.rev().join() }
}
which will give you alternating page number/ title.
That’s as simple as using
#set page(numbering: none)
when you don’t want any numbering! Once your chapters start, you can re-enable numbering.
I don’t think it’s possible to detect blank page? Except if you introduce one with a hard pagebreak(). In which case, you can set page numbering to none before breaking the page and re-enable it afterwards.
that gives me alternating page numbers but again, there is no variable for defining the title or section info - is that just something I set up outside the header? that’s the piece I’m lost on.
Ah! I see your problem. What hydra does internally is query the current chapter hydra(1), or section hydra(2), i.e. heading(level: 1) or heading(level: 2).
There is no variable for that, everything is done using query.
Hence, all you need to do is write your headings as usual, and the page header will be evaluated every time it needs to be (on every page). The contextual expression in the page header parameter will output on each page the return value of hydra(1) or hydra(2), i.e. the current chapter or section.