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

Any reason that `=` is not translated to `#chapter`?

Open Andrew-S-Rosen opened this issue 1 year ago • 4 comments

When using typst, it is common for people to switch between different templates to see what they like and don't like. This is a bit challenging to do with the typst-orange-template because = is seemingly not accounted for in a logical way. I would propose that the use of = should be equivalent to #chapter (with the default arguments) so that at least the file can be rendered in a reasonable way.

Andrew-S-Rosen avatar Aug 24 '24 13:08 Andrew-S-Rosen

Hi, when I developed it, it was not possible due to a Typst limitation. I will try to fix it with the last version of Typst to see if it works.

flavio20002 avatar Aug 24 '24 14:08 flavio20002

The code of #chapter is essentially an heading of level 1 with page break and parte change to false. It was not possibile to embed it in heading with a show rule without create useless empty pages. Another problem is that each chapter has a different image, and using a named function resolved also this problem.

#let chapter(title, image:none, l: none) = {
  pagebreak(to: "odd")
  heading-image.update(x =>
    image
  )
  if l != none [
    #heading(level: 1, title) #label(l)
  ] else [
    #heading(level: 1, title) 
  ]
  part-change.update(x =>
    false
  )
}

flavio20002 avatar Aug 24 '24 14:08 flavio20002

That's understandable. Thanks for the reply! Feel free to close this issue if you would like.

Andrew-S-Rosen avatar Aug 24 '24 15:08 Andrew-S-Rosen

Hi, I fixed this with the last commit. I will publish on typst package manager soon.

// Chapter can also be defined in this way
#update-heading-image(image: image("./orange2.jpg"))
= In-text Element Examples

flavio20002 avatar Oct 05 '24 09:10 flavio20002

Fixed in "0.3.0"

flavio20002 avatar Oct 24 '24 15:10 flavio20002