Skip to content

Commit

Permalink
Better chapter numbering hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekkio committed Feb 12, 2024
1 parent 265a953 commit c261b7e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gbctr.typ
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
})

#counter(heading).update(0)
<maincontent>
#[
#show heading.where(level: 1): it => [
#pagebreak()
Expand All @@ -99,11 +100,10 @@
#locate(loc => {
// Don't reset heading numbering when a new part starts
let cnt = counter(heading)
let elems = query(selector(heading).before(loc), loc)
elems.pop()
let part = cnt.at(loc).at(0)
let rest = cnt.at(elems.last().location()).slice(1)
return cnt.update((part, ..rest))
let elems = query(selector(heading.where(level: 2)).after(<maincontent>).before(loc), loc)
let chapter = elems.len()
return cnt.update((part, chapter))
})
]
#show heading.where(level: 2): it => [
Expand Down

0 comments on commit c261b7e

Please sign in to comment.