touying-typ / touying

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

Show how to change global settings #3

Closed KronosTheLate closed 5 months ago

KronosTheLate commented 6 months ago

I am interested in changing the fontsize globally. I figured our how to do this, relying on the "simple" coding style with #slides:

#let my_template(body) = {
  set text(1.1em)
  slides(body)
}

#show: my_template

I am however not sure if this is the best way. I am also uncertain about how to do with if I was using #slides instead, as I get the error "only element functions can be used in set rules" when I do the following:

#set slide(settings: body=>{
  set text(1.1em)
  body
})

A section in the docs on "How to change global settings" or something to that effect would be great ^_^

OrangeX4 commented 6 months ago

You can use #set text(1.1em) to add to the global settings as normal, just put it after #show: init.

It's not usually necessary, but if you really want to change the setting parameters of #slide globally, you can

#let slide = slide.with(setting: body => {
  set text(1.1em)
  body
})
KronosTheLate commented 6 months ago

It turns out that #set text(1.2em) has to be placed after #show: init, AND before #show: slides. Before the formed had no effect, and after the latter ended up making my = Section One show up as a normal heading inside the slide content.

Code used for testing:

```typst #import "@preview/touying:0.2.0": * #let s = themes.metropolis.register(s, aspect-ratio: "16-9", footer: self => self.info.institution) #let (init, slide, slides) = utils.methods(s) #show: init #set text(1.1em) #show: slides = Section one == Title 3 #utils.fit-to-height(1fr)[ Test 3 ] ```
KronosTheLate commented 6 months ago

Given that there are ways for this to go wrong, and that I managed to misread this section to mean that I had to get fancy to change the style, I think there is some reason to add a short section on how this is done properly, and just briefly mention what will not work.

OrangeX4 commented 6 months ago

Yes, you're right, I'll add a more detailed document.

KronosTheLate commented 6 months ago

Awesome! Thanks for taking my feedback seriously ^_^

OrangeX4 commented 5 months ago

The 0.3.1 released, close the issue by https://touying-typ.github.io/touying/docs/global-settings