Repository navigation
Description
Description
If a block has its breakable property set to true, it may be broken across multiple pages in what are called “frames”. When an element in a block is too big to fit on the current page, it creates a new frame on the next one and the block continues there. If the first frame of a block is empty (typically, because the first element of the block was too big to fit on the first page), it is not displayed (unless there is no other frame).
typst/crates/typst-library/src/layout/container.rs
Lines 423 to 426 in cf9bde3
| let mut skip = false; | |
| if let [first, rest @ ..] = frames.as_slice() { | |
| skip = first.is_empty() && rest.iter().any(|frame| !frame.is_empty()); | |
| } |
However, if the first frame of a block contains elements that have no visible content (like a counter update), it is still displayed, even though it has no visible content.
This issue should not be too hard to fix, as a similar problem was already solved in #1929, although there is something more to this one: out-of-flow elements (typically, place) should be treated as “basically empty”, and they may also have to move across frames. Indeed, if the element that causes the first frame to be displayed is an out-of-flow element, I think it is safe to assume you would want it to (1) not cause the first frame to be displayed, and (2) be laid out as part of the first displayed frame.
Reproduction
#set page(height: 10cm, margin: 1cm)
Not enough space on this page to fit the rectangle, so the whole block is moved to the next page.
#block(breakable: true, stroke: 1pt, inset: 0.5cm)[
#rect(height: 7cm, fill: gray)
]
Not enough space for the rectangle on this page either, but this time there is an invisible element (a counter update) before the rectangle within the block.
#block(breakable: true, stroke: 1pt, inset: 0.5cm)[
#counter("dummy").step()
#rect(height: 7cm, fill: gray)
]
Not enough place again, but this time, the element that's causing the first frame to be displayed _has_ visual content, but it is out-of-flow, so we might want it to belong to the next frame instead.
#v(0.5cm)
#block(breakable: true, stroke: 1pt, inset: 0.5cm)[
#place(dx: -0.5cm, dy: -1cm, box(width: 200%)[Out of flow title])
#rect(height: 7cm, fill: gray)
]Operating system
No response
Typst version
- I am using the latest version of Typst
Activity
MDLC01 commentedon Oct 2, 2023
I realise now that I may not have been very clear in the original message: the main question here is how to treat out-of-flow elements.
Fix typst#2297
Fix typst#2297
laurmaedje commentedon Nov 27, 2023
Example: