From 247893282b91a068b5d894d721a5e8c0bea06403 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Mon, 19 Oct 2026 18:41:47 +0800 Subject: [PATCH] Match the reference table width for math cells --- README.md | 3 ++- docs/STATUS.md | 3 +++ src/rust_typeset/pdf/layout.rs | 2 +- tests/typeset.rs | 8 ++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44638d9..efba1f7 100644 --- a/README.md +++ b/README.md @@ -376,7 +376,8 @@ by the current PDF dependency. `tabular` rows use natural column widths paragraph (`p{...}`) columns are supported. `\multicolumn{n}{align}{...}` spans columns, `\cmidrule(r){a-b}` and `\cline{a-b}` draw partial rules over a column range, and spanning cells distribute their width over the covered -natural columns. Multi-page table headers are not implemented. Figures honor `[htbp]` +natural columns; the resulting width matches the reference XeLaTeX output. +Multi-page table headers are not implemented. Figures honor `[htbp]` placement hints (`[t]` is deferred to the top of the next page, `[b]` to the page bottom, `[p]` to a float page, `[h]` stays in the flow); tables honor `[t]` by deferring the caption and rows to the next page, `[b]` at the page diff --git a/docs/STATUS.md b/docs/STATUS.md index f031a90..5680f80 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -67,6 +67,9 @@ the source changes; the SVG preview is refreshed per page. metadata, `\paragraph` run-in headings, citations/references, tables/lists/images. - Tables: natural column widths, centered tables, `\multicolumn` spans with per-span alignment, and partial `\cmidrule`/`\cline` rules over a column range. + The arXiv table's full-width rule measures ~61.6mm, matching the XeLaTeX + reference's ~61.2mm; math-containing cells are measured from a character + estimate because inline math is painted as vector paths. - Citations: numeric citations by default; `natbib`/`arxiv.sty` selects author-year `\citet`/`\citep` from `.bib` metadata, formats bibliography entries in plainnat order (`First Last`, `In ...`, `pages`, publisher/year), adds diff --git a/src/rust_typeset/pdf/layout.rs b/src/rust_typeset/pdf/layout.rs index 0e9f5b0..800abde 100644 --- a/src/rust_typeset/pdf/layout.rs +++ b/src/rust_typeset/pdf/layout.rs @@ -626,7 +626,7 @@ fn layout_table( .map(|run| run.text.chars().count()) .sum::() as f64 * f64::from(cell_font_size) - * 0.6 + * 0.45 * 25.4 / 72.27; let mut width = 0.0_f64; diff --git a/tests/typeset.rs b/tests/typeset.rs index 4cf559e..f9847d3 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -1062,6 +1062,14 @@ fn arxiv_table_rules_follow_a_narrow_centered_table() { .all(|(x, width)| *x > 20.0 && *width < 140.0), "table rules should be centered and narrower than the text block: {table_rules:?}" ); + let widest = table_rules + .iter() + .map(|(_, width)| *width) + .fold(0.0_f64, f64::max); + assert!( + (60.5..62.5).contains(&widest), + "natural-width table should match the reference width (~61.2mm), got {widest:.2}mm" + ); } #[test]