andreasKroepelin / polylux

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

fix: `alternatives` utils should not modify the layout #112

Closed drupol closed 1 year ago

drupol commented 1 year ago

Hi,

I'm working with a custom theme for work and have encountered an issue when using the alternatives helper on a focus slide. Specifically, using alternatives ends up breaking the layout, making it difficult to incorporate into my work.

The Issue

When I use alternatives, the content gets wrapped in a box element with specific width and height attributes. I find this to be problematic for a utility helper, as it alters the layout in an unexpected way.

Proposed Solution

I've opened a PR that proposes a fix for this issue. The PR removes the box wrapping around the content, thus eliminating the layout modification. I believe utility helpers like alternatives and alike should strictly implement specific logic without affecting layout.

I've been using this fix in my own work and haven't encountered any issues so far.

I'd love to hear your thoughts on this. Do you share the same vision that utility helpers like alternatives should not modify the layout?

Your feedback would be highly appreciated.

andreasKroepelin commented 1 year ago

Please have a look at the section in the book where alternatives is explained. It also shows why we need all this measuring and boxing behaviour. It's just what alternatives is there for.

I do see that their might be the need for other utilities that just strictly exchange content without boxing it. We can discuss this in a separate issue.

drupol commented 1 year ago

Thanks for the clarification.

If you want, I could update the PR and add an argument to alternatives: updateLayout (or something else), set to true. When set to false, this would not wrap the content. WDYT?

On another subject and while working on this, I also noticed that using citations @<something> doesn't work when using alternatives. I couldn't find the reason.

andreasKroepelin commented 1 year ago

I'd prefer separate functions. As I said, let's discuss further things in separate issues. The citing thing is new to me.