Currently, I have a chapter function (see below). I want to add to this function that after the first page of the chapter, the chapter title is on the top left, and page is on the right. How do I do that? I don’t mind adding additional functions or something. I just don’t know how to do it.
#let chapter(
title: none,
epigraph: none,
branding-colour: branding-colour,
body
) = {
// Increment chapter counter and get its value
chapter-counter.step()
// Retrieve the new current value
let ch = context { chapter-counter.get().first() }
// No header on the first page
set page(header: none)
Hello, welsome to the forum! Make sure to read the guide How to post in the Questions category
and to edit your post approprately, namely keeping in mind
and
Currently, your code sample does not compile.
Also, if I may propose a small re-write, I suggest that the way you display the chapter title be changed to a heading. This allows for more introspection, and has the added benefit of chapters showing up as bookmarked, allowing PDF readers to show them in a menu:
On to the question: with the re-write, you could set the header to query for the chapter and style it depending on the answer:
#let chapter(
title: none,
epigraph: none,
branding-colour: purple, // change as needed
body
) = {
set page(header: context {
let heading-query = query(
selector(heading).after(here())
)
let has-heading = if heading-query.len() >= 1 {
heading-query.first().location().page() == here().page()
} else {
false
}
if not has-heading {
[#title #h(1fr) #here().page()]
}
})
set heading(numbering: (..nums) => {
"Chapter " + numbering("1.1", ..nums)
}, supplement: "Chapter")
show heading.where(level: 1): set align(right)
// title
heading(level: 1, text(fill: branding-colour, size: 24pt)[#title])
// Now the main content of the chapter
body
}
Note that I removed/changed some irrelevant parts in the sample