How to set-up marginalia with a variable containing the margins and the book value?

I try to cleanup four alternative layouts for a book with wide margins. I want to set the margins with marginalia, but have the values fixed in one place and used as variables:

#let marginalia-wo-tufte = (
       inner: ( far: 10mm, width: 80mm, sep: 8mm ),
        top: 27mm,
        bottom: 27mm,
        book: true,
        clearance: 12mm,
        )

and then:

  show: marginalia.setup.with( marginalia-wo-tufte)

in the layout function where appropriate.

This seems to work, BUT for the ‘book: true’ value. What should I change to achieve the book (even/odd page) layout?

I have a suspicion about what’s wrong. (With a full example that we can compile ourselves, we would be sure.)

marginalia-wo-tufte is a dictionary but you need to pass its contents as individual arguments. It should look like this:

#show: marginalia.setup.with(..marginalia-wo-tufte)

Using .. to spread the dictionary into multiple arguments. That way the inner key becomes the inner parameter, book key the book parameter and so on. Let us know if that resolves it.

1 Like

Thank you, that was it. I am not yet really sure how and when to use the spread operator, not ever seen it in any other language I used.

I see. I this case it does the same job as the ** operator in Python; where it would be function(**kwargs) to spread a dictionary kwargs into keyword arguments. The details differ a little bit, but it’s the same concept in another dynamic language.