touying-typ / touying

Touying is a powerful package for creating presentation slides in Typst.
https://touying-typ.github.io/
MIT License
717 stars 17 forks source link

Bad slide layout when overriding `heading` using function #61

Closed mohe2015 closed 1 month ago

mohe2015 commented 2 months ago

Hi,

the following code produces a missing slide and then a broken page layout. If you replace the line by either of the commented out lines it works. Do you have an idea why and whether this can be fixed? Is this documented somewhere? The line is based on https://typst.app/docs/tutorial/advanced-styling/#columns-and-headings.

#import "@preview/touying:0.4.2": *

#let slide(self: none, title: none, ..args) = {
  (self.methods.touying-slide)(self: self, title: title, setting: body => {
    title
    body
  }, ..args)
}

#let title-slide(self: none, ..args) = {
  self = utils.empty-page(self)
  (self.methods.touying-slide)(self: self, repeat: none, [Title Slide])
}

#let new-section-slide(self: none, section) = {
  self = utils.empty-page(self, margin: none)
  (self.methods.touying-slide)(self: self, repeat: none, section: section, heading(level: 1, states.current-section-with-numbering(self)))
}

#let register(
  self: themes.default.register(),
  ..args,
) = {
  self.methods.slide = slide
  self.methods.title-slide = title-slide
  self.methods.touying-new-section-slide = new-section-slide
  self.methods.init = (self: none, body) => {
    //show heading.where(level: 1): set text(size: 42pt)
    //show heading.where(level: 1): it => text(size: 42pt, it.body + [.])
    show heading.where(level: 1): it => text(size: 42pt, it.body)
    body
  }
  self
}

#let s = register()

#let (init, slides) = utils.methods(s)
#show: init

#let (slide, title-slide) = utils.slides(s)
#show: slides

#title-slide()

= Section

== First Slide

Hello, Touying!

Related

https://github.com/touying-typ/touying/issues/50

OrangeX4 commented 1 month ago

Does this issue still exist in 0.5.0?

mohe2015 commented 1 month ago

I think it is fixed. Otherwise I will just reopen.