From ad539ef4ed0551a7eb22f7c9c0ab1c0fd1b59209 Mon Sep 17 00:00:00 2001 From: Andrew Voynov Date: Sat, 10 May 2025 14:19:55 +0300 Subject: [PATCH] Add remaining height example for layout --- crates/typst-library/src/layout/layout.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/typst-library/src/layout/layout.rs b/crates/typst-library/src/layout/layout.rs index 88252e5e3..f8a94b567 100644 --- a/crates/typst-library/src/layout/layout.rs +++ b/crates/typst-library/src/layout/layout.rs @@ -41,6 +41,23 @@ use crate::layout::{BlockElem, Size}; /// receives the page's dimensions minus its margins. This is mostly useful in /// combination with [measurement]($measure). /// +/// If you want to, for example, get the remaining of the page height after some +/// content was already added to the page, wrap the `layout` call in +/// `block(height: 1fr)`. But note that adding multiple blocks with height of +/// `1fr` together will put them all on the same page, which can be fixed with +/// [`pagebreak`]. +/// +/// ```example +/// #lorem(10) +/// #block(height: 1fr, layout(size => { +/// block(..size, stroke: 1pt)[ +/// #align(center + horizon)[ +/// Remaining height: #size.height +/// ] +/// ] +/// })) +/// ``` +/// /// You can also use this function to resolve [`ratio`] to fixed lengths. This /// might come in handy if you're building your own layout abstractions. ///