I was missing LaTeX’s \textwidth command, as I needed to use it for some scaling stuff, so here you go:
/// Computes the current page's textwidth
/// -> length
#let textwidth() = context {
// Margins are set automatically to 2.5/21 times the smaller dimension of the
// page.
let default-margin = (2.5 / 21) * calc.min(page.width, page.height)
if page.margin == auto {
return page.width - (2 * default-margin)
}
if "x" in page.margin {
return page.width - (2 * page.margin.x.length)
}
let left-margin = if "left" in page.margin {
page.margin.left.length
} else if "inside" in page.margin {
page.margin.inside.length
} else if "rest" in page.margin {
page.margin.rest.length
} else { default-margin }
let right-margin = if "right" in page.margin {
page.margin.right.length
} else if "outside" in page.margin {
page.margin.outside.length
} else if "rest" in page.margin {
page.margin.rest.length
} else { default-margin }
return page.width - left-margin - right-margin
}
Thanks for telling us about this package, I’ve been thinking that a function that resolves the current page margins needed to live in a package - turns out that it already does.