typst-orange-template icon indicating copy to clipboard operation
typst-orange-template copied to clipboard

Cross-references to chapters and sections

Open yexiang92 opened this issue 1 year ago • 1 comments

Thank you for your contribution to the typst community. While using this template, I discovered that #chapter cannot be @ referenced. Other heading are referenced with the number appearing on the left side of the page. Is it possible to fix them?

yexiang92 avatar Mar 19 '24 13:03 yexiang92

Hi, fixed chapter referencing (see example.typ chap1). The other are more difficult, I will fix in the future.

flavio20002 avatar Mar 22 '24 21:03 flavio20002

~~hi, unfortunately when referencing to a subsection (prexixed with == or ===) or #heading via <label> the styles and linebreaks are transferred as well so the style is not entirely overridden when referencing to subchapters/sections. so line breaks are happening after the chapter prefix~~ removed, because actually identical with above question

freshNfunky avatar Sep 05 '24 13:09 freshNfunky

you could use something like this:

#show ref: it => {
  let eq = heading
  let el = it.element
  // let numberingFormat = if appendix-state != none {"A.1"} else {"1.1"}  //appendix state must be sourced somehow 
  let numberingFormat = {"1.1"}
  if el != none and el.func() == eq {
    let arrayEq = counter(eq).at(el.location())
    [#el.supplement #numbering(numberingFormat, ..arrayEq) ]
  } else {
    it
  }
}

freshNfunky avatar Sep 06 '24 13:09 freshNfunky

Fixed with version 0.2.0

flavio20002 avatar Oct 03 '24 08:10 flavio20002