touying-typ / touying

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

feat: better show-slides mode #11

Closed OrangeX4 closed 4 months ago

OrangeX4 commented 4 months ago

As mentioned in #7 and #8, we plan to implement a more powerful show-slides mode, which can be broadly divided into the following three parts:

  1. Use the slide-level parameter in slides to represent the structural depth. For example, the default setting for the university theme is slide-level: 1, where heading 1 and 2 represent section and title, respectively. If we use #show: slides.with(slide-level: 2), heading 1, 2, and 3 will represent section, subsection, and title, respectively.
  2. Simplifying the implementation of the slides mode with themes, eliminating the need to register the slide-in-slides method. Instead, we adopt the "convention over configuration" philosophy to simplify the implementation. Specifically, in the slides mode, the default call is made to the self.methods.slide method. Additionally, if we have a self.methods.touying-new-section-slide method, = Section will be automatically translated into self.methods.touying-new-section-slide[Section].
  3. Through syntax like #let (slide, focus-slide) = utils.slides(s), we can use syntax like #slide[] and #focus-slide[] in the show-slides mode, providing more powerful functionality and clearer structure. In this syntax, section, subsection, and title will be automatically passed into #slide[]. (Because "slide" is registered in self.slides = ("slide",), it can be automatically passed in)

Here is a specific example:

#import "../lib.typ": *

#let s = themes.university.register(s)
#let s = (s.methods.info)(
  self: s,
  title: [Title],
  subtitle: [Subtitle],
  author: [Authors],
  date: datetime.today(),
  institution: [Institution],
)
#let (init, slides) = utils.methods(s)
#show: init

#let (slide, focus-slide) = utils.slides(s)
#show: slides.with(slide-level: 2)

= Section

== Subsection

=== Title

#slide[
  AAA
]

#slide[
  BBB
]

#focus-slide[
  CCC
]

image

cc @fbob and @HPDell

HPDell commented 4 months ago

That is exactly what I want. Thank you!

BTW, how can I map == headings to slide titles? In most cases, I won't need subsections.

OrangeX4 commented 4 months ago

Do you think there should be a way to do this? is it not convenient to use ===?

HPDell commented 4 months ago

Do you think there should be a way to do this? is it not convenient to use ===?

Thanks for your reply. In fact, I think it is convenient enough to use ===. So if you don't think it is necessary to map == headings as slide titles, please ignore my question. The only reason that I want to use == instead of === to represent the slide titles is that I think the following document looks a bit strange.

= Section 1

=== Title 1.1

=== Title 1.2

= Section 2

=== Title 2.1

=== Ttile 2.2

So forget it if you don't think so.

fbob commented 4 months ago

A slide level in the header's hierarchy could be defined to specify that headings with the specified level create slides. See for example Pandoc.

Regards,

HPDell commented 4 months ago

Another quick question: shall I use the callback-style functions to use the animations like cover and uncover?

OrangeX4 commented 4 months ago

Yes, while maybe I could provide a non-callback function of only and uncover (with some limitations), I think there are two styles that make touying more difficult to understand.

OrangeX4 commented 4 months ago

I've added the slide-level parameter. We use the slide-level parameter in slides to represent the structural depth. For example, the default setting for the university theme is slide-level: 1, where heading 1 and 2 represent section and title, respectively. If we use #show: slides.with(slide-level: 2), heading 1, 2, and 3 will represent section, subsection, and title, respectively.

HPDell commented 4 months ago

I've added the slide-level parameter. We use the slide-level parameter in slides to represent the structural depth. For example, the default setting for the university theme is slide-level: 1, where heading 1 and 2 represent section and title, respectively. If we use #show: slides.with(slide-level: 2), heading 1, 2, and 3 will represent section, subsection, and title, respectively.

So the number starts from 0 😄

OrangeX4 commented 4 months ago

Yes, I think so, I've merged it :-)

fbob commented 4 months ago

Many thanks @OrangeX4 for this great feature !

OrangeX4 commented 4 months ago

Touying 0.3.1 has been released :-)