andreasKroepelin / polylux

A package for creating slides in Typst
https://polylux.dev/book
MIT License
1.05k stars 53 forks source link

Simple theme overlaps sectioning #119

Open cmarcotte opened 7 months ago

cmarcotte commented 7 months ago

A made a short demo presentation in which we create multiple sections. Rather than the second section having no section-based header (like the first), it includes the previous section name in the header.

This is lexically quite confusing. I think there should be additional logic to check whether the current slide is also the beginning of a section, and if so, reject the previous-section header. It's unclear to me how one might implement this check, however. I tried adding set header(outline: false) at the end of the else block of the conditional on line 51, to no avail. Is this a simple behavior to modify?

Code from simple theme reproduced below for the slide function:

#let slide(body) = {
  let deco-format(it) = text(size: .6em, fill: gray, it)
  set page(
    header: locate( loc => {
      let sections = query(heading.where(level: 1, outlined: true).before(loc), loc)
      if sections == () [] else { deco-format(sections.last().body) }
    }),
    footer: deco-format({
      simple-footer.display(); h(1fr); logic.logical-slide.display()
    }),
    footer-descent: 1em,
    header-ascent: 1em,
  )
  logic.polylux-slide(body)
}

Where the issue is that the before(loc) excludes any new section which may appear on that page, so we get the previous section in the header on a new section.

andreasKroepelin commented 7 months ago

Can you please put the misbehaving code in the issue here as well?