Marmare314 / lemmify

A library for typesetting mathematical theorems in typst.
GNU General Public License v3.0
11 stars 7 forks source link

Only show some headings when numbering #10

Closed ParadaCarleton closed 9 months ago

ParadaCarleton commented 10 months ago

Occasionally I'll be using sub-subheadings, in which case I end up with theorems like Theorem 1.1.1.1. Is there a way to fix this, e.g. by only displaying headings and subheadings? I expected max-reset-level to handle this, but it looks like it doesn't; it just restarts the count at a different number.

Marmare314 commented 10 months ago

For now you need to adjust display-heading-counter-at from util.typ.

#let display-heading-counter-at(loc) = {
  let locations = query(selector(heading).before(loc), loc)
  if locations.len() == 0 {
    [0]
  } else {
    let numb = query(selector(heading).before(loc), loc).last().numbering
    if numb != none {
      // only use first and second level headings
      let c = counter(heading).at(loc)
      if c.len() > 2 {
        c = c.slice(0, 2)
      }
      numbering(numb, ..c)
    } else {
      panic("No numbering set for headings. Try setting the heading numbering or use a different thm-numbering")
    }
  }
}

Then you can use this to define your own numbering style (see thm-numbering-heading in styles.typ) which you then just need to pass to the default-theorems function.

But I will add a parameter to the thm-numbering-heading function so this will become a lot easier.