I have made the bookletic package that splits the page into two smaller ones for ordering as a booklet. And right now I have the overall page size hardcoded so that I can divide it and set the size for the smaller pages but am trying to find a way to use the built in page sizes. Is there a way to ask the user of a function for a page size and use that within a function to get the actual dimensions of a type of paper?
To supplement the previous answer: While layout generally gives the dimensions of the currently surrounding container, page.width and page.height give the page height/width specifically. They are only available within context.
#set page(width: 500pt)
#context page.width
However, page.width will always have the value of width, not of height when flipped: true. Moreover, as of Typst 0.11.1 the retrieval does not work when using an explicit #page(width: ..)[..]. This will be fixed in Typst 0.12.
If it’s for a smaller piece of layout, the layout approach would be more robust in this regard. However, it comes at the cost of all the content within it being wrapped in a block-level container, so you can’t e.g. have pagebreaks within it and it can negatively affect layout of things like footnotes.
I have tried the context approach but have not been able to assign the value to a variable for use throughout the rest of the code. When I assign it like this: let variable = context page.width
The variable ends up having the context function itself assigned rather than the actual value. Am I missing something or is this a bug?
I would like to access the width of the page to calculate the minimum of page width or a given length so that I can make a table that will fit on one page.
The only way to accomplish this is by wrapping the table in a context and then further wrapping the context in a function, and then calling that function? That seems less than ideal.
Hi @Jon, welcome to the Typst forum! Please make a new post for your question. Also please clarify if you want to use the full page width, or only the width of the text area (without margins).