#Have a level 1 heading always on the right page

7 messages · Page 1 of 1 (latest)

maiden creek
#

Hello friends,
I currently use the binding parameter for my document as I want to print it out as a book later. This means that the margin from the center of the book to switches from the page depending if the page is on the left or right side of the center.
Now one of my styling rules say, that everytime I use a level heading (such as = chapter 1 it has to be on the right page, so that the center of the book is to the left).
Can anyone help me with the function? It would basically be something like "if the heading of level 1 is on a page that is on the left, a pagebreak() is set before it"

midnight night
#

Maybe something like this will do it:

show heading.where(level: 1): it => {
  pagebreak(to: "odd") // or "even"
  it
}

Can't test it right now as I'm on my phone

winter linden
#
#show heading.where(level: 1): it => {
  pagebreak(to: "odd", weak: true)
  it
}

Yes. That should work. Also add weak: true to prevent having multiple blank pages inserted in some cases.

maiden creek
#

Appears to work, thank you guys. I appreciate it

maiden creek
#

Late update, but I just noticed: Originally my first x pages had a roman numbering system, which I did by applying
#set heading(numbering: "I")
to the start of the pages until the part of the book that had to start with arabic numbers with #set heading(numbering: "1.1")

Due to the function now, those rules get overridden, is there a way to set a priority? Or should the condition just be edited?

midnight night
#

I don't think the set rules should get overridden, and I also can't reproduce that. The following code works for me on the web app:

#set page(numbering: "1")

// Show first-level headings on right pages
#show heading.where(level: 1): it => {
  pagebreak(to: "odd", weak: true)
  it
}

// Start with Roman numbering
#set heading(numbering: "I.")

= First chapter
#lorem(1000)

= Second chapter
#lorem(500)

// Use arabic numbering starting from here
#set heading(numbering: "1.")

= Third chapter
#lorem(500)

= Fourth chapter
#lorem(200)
maiden creek
#

I apologize, that was a stupid mistake on my part. I actually meant not the headings, but the pagination. I guess I mixed it up with another thread of mine.

I actually meant this code:

  // Page numbering
  set page(footer: locate(loc => {
    if calc.even(loc.page()) {
      align(left, counter(page).display())
    } else {
      align(right, counter(page).display())
    }
  }))

Seems to overwrite my
#set page(numbering: "I")
For roman numbers