#Get the page width
26 messages · Page 1 of 1 (latest)
You can try to directly get the page width, but I recommend setting a variable instead that's used to set the width and employed in other calculations:
#let width = 210mm
#let height = 297mm
#set page(width: width, height: height, margin: width / 10)
Otherwise the following is technically possible, but seems to produce an extra page:
#set page(paper: "a4")
#show: doc => context {
set page(margin: page.width / 10)
doc
}
I also suggest reading this
a friend already pointed me to it, thanks :)
I arrived at something somewhat like that, but it tells me I cant do arithmetic with page.width (in my case I cant subtract a length)
what does the code look like
let width = context page.width
let width-trim = width - cbor
let block-size = width-trim / div
set page(margin: (inside: block-size + cbor, outside: 2 * block-size, top: block-size, bottom: block-size * 2))
where cbor is a length and div is an integer
inside the
#let project(
title: "",
authors: (),
date: none,
logo: none,
body,
) = {
...
}
definition that was autogenerated
That's because width is in reality a value of type content, which is what context always returns
Everything that uses a value specific to the current location needs to be embedded in the context call
you can, it just looks ugly
no, if I do that, nothing happens
well, more specifically it would only apply to everything within the block and after the set page
(apart from the empty page that you mentioned)
what exactly are cbor and div?
let cbor = 1.5cm
let div = 13
context {
let width = page.width
let width-trim = width - cbor
let block-size = width-trim / div
set page(margin: (inside: block-size + cbor, outside: 2 * block-size, top: block-size, bottom: block-size * 2))
}
I think you will have to take the approach with the hard coded page sizes then
so I look up the dimensions of a4 and do it manually?
yes
😑
@hallow grove already mentioned the dimensions here
ye
@sour charm you can watch this issue if you like: https://github.com/typst/typst/issues/2326
Note that flipped: true would lead to .height getting used for the x-dimension & v.v.