diff --git a/src/rust_typeset/pdf/layout.rs b/src/rust_typeset/pdf/layout.rs index f2b06a1..d650ac3 100644 --- a/src/rust_typeset/pdf/layout.rs +++ b/src/rust_typeset/pdf/layout.rs @@ -3016,6 +3016,16 @@ pub(super) fn build_positioned_pages( continue; } + // Keep a table that fits on one page intact instead of + // splitting its rows at the bottom of the current page. + if table_height > 0 && total_height <= page_goal.saturating_sub(top_skip) { + let page_nonempty = pages.last().is_some_and(|page| !page.items.is_empty()); + if page_nonempty && cursor.saturating_add(total_height) > page_goal { + pages.push(PositionedPage::default()); + cursor = top_skip; + } + } + let mut line_index = 0; let mut has_caption_lines = false; for line in caption_lines {