Thanks to help from many here, most of my issues setting up my template have been resolved, but I have one more. Here is my code example, modified to take in recent solutions.
// Page layout including headers and footer, removed on blank pages
#import "@preview/hydra:0.6.1": hydra
/// Check whether a page is an empty page.
#let is-page-empty() = {
let page-num = here().page()
query(selector.or(<ep-start>, <ep-end>))
.chunks(2)
.any(((start, end)) => {
start.location().page() < page-num and page-num < end.location().page()
})
}
#set page(
paper: "a7",
margin: (inside: 1.5cm, outside: 1cm, y: 1.5cm),
header: context if not is-page-empty() {
if calc.odd(here().page()) {
align(right, smallcaps(hydra(1)))
} else {
align(left, emph(hydra(2)))
}
v(-0.5em
)
line(length: 100%)
},
footer: context if not is-page-empty() {
align(center, counter(page).display())
},
)
#show pagebreak: it => [#metadata[]<ep-start>] + it + [#metadata[]<ep-end>]
#show heading.where(level: 1): it => {
set align(center)
set text(18pt, weight: "semibold")
pagebreak(weak: true, to: "odd") + it
}
#show heading.where(level: 2): set text(14pt, weight: "semibold")
= Part 1
#lorem(75)
== Section 1.a
#lorem(50)
= Part 2
#lorem(75)
== Section 2.a
#lorem(25)
However, I would like, book style, to have a separation, of say 5em, between the header and the Part heading. I have tried everything I can think of using a block or #v but, with my efforts, at best they have had no effect, at worst the heading disappears completely.
Can someone please help me to accomplish this? Thanks.
Hm. In my example it didn’t do that, so maybe you can share the complete code?
Ok I can take your example and it seems to work. There’s a separate thing with hydra (just tweak what happens on new part pages) that can be solved separately.
// Page layout including headers and footer, removed on blank pages
#import "@preview/hydra:0.6.1": hydra
/// Check whether a page is an empty page.
#let is-page-empty() = {
let page-num = here().page()
query(selector.or(<ep-start>, <ep-end>))
.chunks(2)
.any(((start, end)) => {
start.location().page() < page-num and page-num < end.location().page()
})
}
#set page(
paper: "a7",
margin: (inside: 1.5cm, outside: 1cm, y: 1.5cm),
header: context if not is-page-empty() {
if calc.odd(here().page()) {
align(right, smallcaps(hydra(1)))
} else {
align(left, emph(hydra(2)))
}
v(-0.5em
)
line(length: 100%)
},
footer: context if not is-page-empty() {
align(center, counter(page).display())
},
)
#show pagebreak: it => [#metadata[]<ep-start>] + it + [#metadata[]<ep-end>]
#show heading.where(level: 1): it => {
set align(center)
set text(18pt, weight: "semibold")
pagebreak(weak: true, to: "odd") + v(5em) + it
}
#show heading.where(level: 2): set text(14pt, weight: "semibold")
= Part 1
#lorem(75)
== Section 1.a
#lorem(50)
= Part 2
#lorem(75)
== Section 2.a
#lorem(25)
Thank you for this. In all my attempts the one thing I did not try was putting + before the (5em)! You say:
Ok I can take your example and it seems to work. There’s a separate thing with hydra (just tweak what happens on new part pages) that can be solved separately.
Absolutely, but as always I’m stymied in trying to combine the “tweak” with existing code. The manual says:
But where this should be placed in the code and in what form is not made at all clear to the likes of me! Again I just end up with errors that I can’t resolve.
I have to say that I had read the manual many times, but couldn’t get that to work; it just returned an error that I couldn’t resolve, so I don’t know what I had typed wrong. As I have said, where the example code doesn’t match the more complex code you already have working, marrying the two is not immediately obvious to us beginners.