End table rows with tabularnewline

This commit is contained in:
gloamxun committed 2026-10-26 20:36:57 +08:00
1 parent 80a5e8272d
commit 7271e2ee12
3 files changed
+21 -2

No files matched your search

+19
View File
@@ -1228,6 +1228,13 @@ impl Unit {
intercolumn: i64,
tabskips: Vec<i64>,
) -> Self {
let normalized;
let source = if source.contains("\\tabularnewline") {
normalized = source.replace("\\tabularnewline", "\\\\");
normalized.as_str()
} else {
source
};
let (alignments, wraps, vertical_rules) = parse_column_template(template);
let column_count = alignments.len().max(1);
let at_glue = parse_at_glues(template);
@@ -6253,6 +6260,18 @@ mod tests {
assert_eq!(layout.pages()[1].insertions.len(), 0);
}
#[test]
fn tabularnewline_ends_a_row() {
let unit =
Unit::halign_from_source_with_template(1, "ll", "a & b \\tabularnewline c & d", 12);
let VerticalItem::Halign(halign) = &unit.items[0] else {
panic!("expected halign");
};
assert_eq!(halign.rows.len(), 2);
assert_eq!(halign.rows[0].cells[1].text, "b");
assert_eq!(halign.rows[1].cells[0].text, "c");
}
#[test]
fn multirow_cells_centre_over_their_rows() {
let source = "\\texrramultirow{3}{Both} & a \\\\ & b \\\\ & c";