Because of user input, I have to search for a specific heading in its show rule, therefore it’s the only place where I can introduce a location mark, state update, etc.
To affect heading numbering in the PDF’s Document Outline, tope-level set heading(numbering) must be used.
The only way to check for the state to conditionally remove heading numbering is with a callback function, but it will trigger the h(0.3em) spacing in the heading, but also a space in the Document Outline. I can technically cancel h, but I need to remove the leading space in the Document Outline.
Moreover, a related issue that needs to be fixed is that the numbering callback doesn’t see the state update inside of same-heading’s show rule, so a numbering for the special heading is still present, even though the spacing can be removed.
Yeah, you can replace it with custom heading rendering logic to fix the last point, but it will bloat the complexity and amount of code big time, plus the issue in the Document Outline still exists.
#let started = state("started", false)
#set heading(numbering: (..n) => if not started.get() { numbering("I.", ..n) })
#show heading: it => {
let s = started.get()
if lower(it.body.text) == "very special" {
s = true
started.update(s)
}
show h.where(amount: 0.3em): if s { none } else { x => x }
it
}
// #let started() = query(selector(<start>).before(here())) != ()
// #set heading(numbering: (..n) => if not started() { numbering("I.", ..n) })
// #show heading: it => {
// let s = started()
// if lower(it.body.text) == "very special" {
// s = true
// [#metadata(none)<start>]
// }
// show h.where(amount: 0.3em): if s { none } else { x => x }
// it
// }
= Heading
= Another
= Very special
= Last
#bibliography(bytes(""))
