tingerrr / hydra

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

Some `show` rules break redundancy check #2

Closed tingerrr closed 5 months ago

tingerrr commented 11 months ago

With some show rules for vertical spacing on first-level headings, omitting block wrapping breaks the redundancy check. Adding the block back fixes the issue.

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

#set page(header: hydra(
  display: (_, it) => {
    if it.numbering != none [
      Chapter #counter(heading).display()
    ]
    it.body
  })
)
#set heading(numbering: "1.1")

// if the block is removed this will no longer check for redundancy correctly,
// some of the spacing also subtly changes.
#show heading.where(level: 1) : it => pagebreak(weak: true) + block({
  set text(2em, weight: "bold")
  v(8em)
  if it.numbering != none [
    Chapter #counter(heading).display()
    #v(.5em)
  ]
  it.body
  v(0.5em)
})

= First
asda

= Second
a

= Third
asd

#pagebreak()

asdas

Removing the block will cause each page to reference its next section instead of the last/none.

tingerrr commented 6 months ago

It seems that there are a few things at play here:

I believe this is intended to make introspection more sensible to the end user, but I will inquire about this. What surprised me is that adding metadata before the spacing/styling elements fixed it too, meaning despite being invisible it causes the location to change. This on the other hand seems unintended.

tingerrr commented 5 months ago

I'm closing this in favor of #16.

drupol commented 5 months ago

Which issue?

tingerrr commented 5 months ago

I have just created it and linked to it.