andreasKroepelin / polylux

A package for creating slides in Typst
https://polylux.dev/book
MIT License
1.18k stars 55 forks source link

Implement #alert #71

Closed Drodt closed 1 year ago

Drodt commented 1 year ago

Implement an alert function similar to LaTeX beamer's \alert.

#alert("2-3", color: blue)[Some text] will render the content normally except for subslides 2 and 3, where Some text will be blue.

This is a draft, because we require a way for themes to set the alert color to some appropriate color.

Drodt commented 1 year ago

Like I wrote, I would like to set the color in the themes but I am not familiar enough with Typst to figure this out. I would appreciate some help on this.

andreasKroepelin commented 1 year ago

Interesting idea. So far, the metropolis theme has a custom alert function. I think that is also a reasonable way to make sure that alert fits the theme if each of them defines their own.

Regarding the dependence on the subslide: You can currently produce that using alternatives. I am planning to implement more flexible versions of that which will make it more convenient.

Drodt commented 1 year ago

Interesting idea. So far, the metropolis theme has a custom alert function. I think that is also a reasonable way to make sure that alert fits the theme if each of them defines their own.

Ideally, I think, alert should be in logic since this functionality is very common in beamer.

Regarding the dependence on the subslide: You can currently produce that using alternatives. I am planning to implement more flexible versions of that which will make it more convenient.

I would be curious to see what your plans are.

As an aside: should alternatives work for non-text elements, e.g., figures? Because there I encountered problems?

andreasKroepelin commented 1 year ago

Ideally, I think, alert should be in logic since this functionality is very common in beamer.

Placing something in logic is not some kind of honour because of frequent use, though.

I would be curious to see what your plans are.

I just merged #76. You can now have something like

#alternatives-cases(("1,3", "2"), case => [
  #set text(fill: red) if case == 1
  Highlighted on subslide 2
])

As an aside: should alternatives work for non-text elements, e.g., figures? Because there I encountered problems?

alternatives (and its new friends) rely on measure so I guess that becomes difficult when you include whole figures in it. I guess you can put alternatives into the figure, though?