I want to set page margins that scale with the paper size, something like a percentage of the page dimensions, but clamped to a minimum and maximum in terms of line-height multiples.
The ideal would be something like:
let line-height = font-size * leading-ratio
set page(
margin: (
x: calc.clamp(page.width * 0.12, line-height * 2, line-height * 6),
y: calc.clamp(page.height * 0.10, line-height * 2, line-height * 5),
)
)
The problems I’ve run into:
page.width/page.heightrequire a context, butset page(margin:)doesn’t accept acontextblockcalc.clampwon’t mix ratio and length types, so12%andline-height * 2can’t be compared- Wrapping the body in
show: it => context { set page(...); it }works in isolation but creates a new page in my template
Is there any way to compute a length-valued margin that depends on the page dimensions? Or a way to use context inside set page?