tingerrr / hydra

A typst package for displaying the active section in the page header or footer.
MIT License
26 stars 3 forks source link

Starting page redundancy check fails in the presence of some `heading` show rules #16

Open tingerrr opened 5 months ago

tingerrr commented 5 months ago

Given a show rule which introduces an "invisible" element such as v(...) before the heading, the margin redundancy check fails, causing hydra to display the last heading on a page which starts with a new heading.

#import "@preview/hydra:0.4.0": hydra

#set page(header: context hydra(1))
#set heading(numbering: "1.1")

#show heading.where(level: 1) : it => pagebreak(weak: true) + {
  // uncommenting this or adding a block around this whole rule fixes the issue
  // metadata(())
  v(1em)
  it
}

= First
#lorem(10)

= Second
#lorem(10)

#pagebreak()
#lorem(10)

To work around this, consider surrounding your headings with a container, i.e. a block or box, avoid using metadata as it is likely not intended to cause the location collapse, see the upstream issue.

Upstream issue: typst#4029. Supersedes #2.