Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing argument value depending on slide #142

Open
Ekleog opened this issue Jan 8, 2025 · 1 comment
Open

Changing argument value depending on slide #142

Ekleog opened this issue Jan 8, 2025 · 1 comment

Comments

@Ekleog
Copy link

Ekleog commented Jan 8, 2025

Hey!

I'm new to touying and typst, so please forgive me if I missed something in the docs.

I'm trying to color a grid cell differently depending on which slide it's on. Here is what I'm currently trying out:

#slide(repeat: 2, self => [
  #grid(
    columns: 1,
    grid.cell(fill: alternatives(blue, red))[#alternatives[Foo][Bar]],
  )
])

The contents alternatives works perfectly, but having the blue/red alternatives seems to completely break compilation:

error: expected color, gradient, pattern, none, or auto, found content
   ┌─ example.typ:67:20
   │
67 │     grid.cell(fill: alternatives(blue, red))[#alternatives[Test][Bar]],
   │                     ^^^^^^^^^^^^^^^^^^^^^^^

As far as I can read, alternatives & co are only supported inside contents.

I also tried the utils.methods(self) variant, but the break seemed even worse, as even the contents-only variant returned this error:

error: expected function, found dictionary
   ┌─ example.typ:68:26
   │
68 │     grid.cell(fill: red)[#alternatives[Test][Bar]],
   │                           ^^^^^^^^^^^^

Is there any way to put alternatives in other places of the AST, like in the value of the fill argument in my case?

Anyway, thank you for your work on touying! I'll just copy-paste the whole slide for now and can most likely live with it, even though it's quite a mastodon with its 50 lines of definition.

@Ekleog Ekleog changed the title Color grid cell depending on slide Changing argument value depending on slide Jan 8, 2025
@Ekleog
Copy link
Author

Ekleog commented Jan 8, 2025

Actually, I'm also looking for a way to change which cells are in the grid or not, but I guess this can be summed up as a way to alternate non-contents arguments to any typst function :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant