Hello everyone,
For a personal project, i want to set a rectangle on the side of a pages in a book based on the section the current page is and based on the oddity of the current page. My code look a little bit like this :
#set page(
paper: "a6",
margin: CONFIG.MARGIN,
numbering: "1",
number-align: left,
background: context{
let current-page = here().page() // Get number of page
// get chapter (or section) based on number of heading
let section = query(selector(heading.where(level : 1)).before(here())).len()
// place rectangle based on the page number & book section
let r-height = current-layout.height / total-section
let offset = section* r-height
let r = rect(fill: black,width: 0.3cm, height: r-height)
let side = right
if calc.odd(current-page){side = right} else {side = left}
place(side, r, dy: offset)
},
header: [...]
)
I basically want to prevent the placing of this rectangle on pages where there’s a heading of level 1 and wanted to know if it was possible. Maybe something like :
#let l1-heading = query(selector(heading.where(level: 1)).on-page(current-page)).len()
#if l1-heading > 0 {place(side, r, dy: offset)}
Thank you in advance for your help