I want my L1 headings to be on right pages only and want to insert completely blank pages before them if necessary. (1)
I also have a header and footer that should only be shown on pages that are both
- not inserted blank pages before a L1 heading
- pages containig L1 headings (2)
Previously I just had a pagebreak(to: odd) for (1) but this way the header and footer were shown on the inserted page. To solve that problem I'm currently trying to use the solution described here.
For (2) I'm using something like this as my header
set page(header: locate(loc => if not page-is-inserted(loc) {
// Find next L1 heading
let next_heading = query(
selector(heading.where(level:1)).after(loc, inclusive: true),
loc,
)
if next_heading == () {
return []
}
let next_heading = next_heading.first()
[
Currently on page #loc.page()
Next L1 heading is #next_heading.body at page #next_heading.location().page()
]
// If next L1 heading is on current page, don't print header
if next_heading.location().page() == loc.page() {
return []
}
// actual header content...
However, the approach linked above interferes with header "logic". During debugging I've found that I get two different values for loc.page() on the same physical page (see image below)