diff --git a/README.md b/README.md index b0c556d..15283cc 100644 --- a/README.md +++ b/README.md @@ -386,7 +386,7 @@ 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; the resulting width matches the reference XeLaTeX output. -In route-D, `\halign`/`\calign` sources support `l`/`c`/`r`/`p{width}` cells, explicit `\tabskip`, `@{}`/`@{\hspace{...}}` column expressions, `\noalign{\vskip ...}` row glue, booktabs rule weights (`\toprule`/`\bottomrule` 0.8pt, `\midrule`/`\cmidrule` 0.5pt) with `\cmidrule(lr){a-b}` trims and ranges, row-level page splitting that repeats the column widths, longtable head/foot sections (`\endfirsthead`/`\endhead`/`\endfoot`/`\endlastfoot`) whose continuation chunks repeat the head rows and paint the foot block once, and LaTeX `tabular` sources mapped onto the same alignment path. Figures honor `[htbp]` +In route-D, `\halign`/`\calign` sources support `l`/`c`/`r`/`p{width}` cells, explicit `\tabskip`, `@{}`/`@{\hspace{...}}` column expressions, `\noalign{\vskip ...}` row glue, booktabs rule weights (`\toprule`/`\bottomrule` 0.8pt, `\midrule`/`\cmidrule` 0.5pt) with `\cmidrule(lr){a-b}` trims and ranges, row-level page splitting that repeats the column widths, longtable head/foot sections (`\endfirsthead`/`\endhead`/`\endfoot`/`\endlastfoot`) whose continuation chunks repeat the head rows and paint the foot block once, and LaTeX `tabular` sources mapped onto the same alignment path, where `\multicolumn{n}{align}{...}` cells span columns with the requested alignment. 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); a standalone `\vspace{...}` between paragraphs becomes vertical glue with its `plus`/`minus` diff --git a/crates/texrra-tex-core/src/lib.rs b/crates/texrra-tex-core/src/lib.rs index b73337e..979fe2c 100644 --- a/crates/texrra-tex-core/src/lib.rs +++ b/crates/texrra-tex-core/src/lib.rs @@ -70,6 +70,43 @@ pub struct HalignRule { pub trim_right: i64, } +fn split_halign_cells(row: &str) -> Vec<&str> { + let mut cells = Vec::new(); + let mut depth = 0usize; + let mut start = 0usize; + for (index, character) in row.char_indices() { + match character { + '{' => depth += 1, + '}' => depth = depth.saturating_sub(1), + '&' if depth == 0 => { + cells.push(&row[start..index]); + start = index + 1; + } + _ => {} + } + } + cells.push(&row[start..]); + cells +} + +fn take_halign_group(text: &str) -> Option<(String, &str)> { + let rest = text.strip_prefix('{')?; + let mut depth = 1usize; + for (index, character) in rest.char_indices() { + match character { + '{' => depth += 1, + '}' => { + depth = depth.saturating_sub(1); + if depth == 0 { + return Some((rest[..index].to_string(), &rest[index + 1..])); + } + } + _ => {} + } + } + None +} + /// A laid-out `\halign` table: natural column widths plus row rules. #[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub struct Halign { @@ -1076,32 +1113,54 @@ impl Unit { continue; } let mut cells = Vec::new(); - for raw_cell in raw_row.split('&') { + for raw_cell in split_halign_cells(raw_row) { let mut text = raw_cell.trim().to_owned(); let mut span = 1; - if let Some(rest) = text.strip_prefix(r"\span") { - span = 2; - text = rest.trim().to_owned(); - } - if let Some(rest) = text.strip_prefix(r"\multispan") { + let mut alignment = None; + if let Some(rest) = text.strip_prefix(r"\multicolumn") { let rest = rest.trim_start(); - if let Some(body) = rest.strip_prefix('{') { - if let Some((count, tail)) = body.split_once('}') { - span = count.trim().parse().unwrap_or(1).max(1); - text = tail.trim().to_owned(); + if let Some((count, rest)) = take_halign_group(rest) { + let rest = rest.trim_start(); + if let Some((spec, rest)) = take_halign_group(rest) { + let rest = rest.trim_start(); + if let Some((body, rest)) = take_halign_group(rest) { + span = count.trim().parse().unwrap_or(1).max(1); + alignment = Some(if spec.contains('r') { + CellAlignment::Right + } else if spec.contains('c') { + CellAlignment::Center + } else { + CellAlignment::Left + }); + text = format!("{}{}", body.trim(), rest); + } } } } - if let Some(rest) = text.strip_prefix(r"\omit") { - text = rest.trim().to_owned(); + if alignment.is_none() { + if let Some(rest) = text.strip_prefix(r"\span") { + span = 2; + text = rest.trim().to_owned(); + } + if let Some(rest) = text.strip_prefix(r"\multispan") { + let rest = rest.trim_start(); + if let Some(body) = rest.strip_prefix('{') { + if let Some((count, tail)) = body.split_once('}') { + span = count.trim().parse().unwrap_or(1).max(1); + text = tail.trim().to_owned(); + } + } + } + if let Some(rest) = text.strip_prefix(r"\omit") { + text = rest.trim().to_owned(); + } } let column: usize = cells.iter().map(|cell: &HalignCell| cell.span.max(1)).sum(); cells.push(HalignCell { text, span, - alignment: alignments - .get(column) - .copied() + alignment: alignment + .or_else(|| alignments.get(column).copied()) .unwrap_or(CellAlignment::Left), }); } @@ -7365,6 +7424,30 @@ mod tests { assert_eq!(halign.rows[1].cells[0].span, 1); assert_eq!(halign.rows[1].cells[1].span, 2); } + #[test] + fn halign_parses_multicolumn_cells() { + let unit = + Unit::halign_from_source(1, r"\multicolumn{2}{c}{Merged} & Tail \\ A & B & C", 3, 10); + let VerticalItem::Halign(halign) = &unit.items[0] else { + panic!("expected halign"); + }; + assert_eq!(halign.rows[0].cells[0].text, "Merged"); + assert_eq!(halign.rows[0].cells[0].span, 2); + assert_eq!(halign.rows[0].cells[0].alignment, CellAlignment::Center); + assert_eq!(halign.rows[0].cells[1].text, "Tail"); + assert_eq!(halign.rows[1].cells.len(), 3); + } + + #[test] + fn halign_keeps_ampersands_inside_groups() { + let unit = Unit::halign_from_source(1, r"{A & B} & C", 2, 10); + let VerticalItem::Halign(halign) = &unit.items[0] else { + panic!("expected halign"); + }; + assert_eq!(halign.rows[0].cells[0].text, "{A & B}"); + assert_eq!(halign.rows[0].cells[1].text, "C"); + } + #[test] fn halign_computes_natural_column_widths() { let rows = vec![ diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index 09ff666..91ffbf9 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`, `\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and -PDF opt-in with `?engine=route-d`). 712 workspace tests are green and no oracle +PDF opt-in with `?engine=route-d`). 715 workspace tests are green and no oracle fixture is ignored. Status after G1 (P0-P2): the paragraph model reproduces TeX's passes, diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 9203820..3101e4e 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -130,7 +130,7 @@ and justification. | M0 | vertical list, page builder, checkpoint, page hash, edit demo | edit on page 2 rebuilds only page 2 | | M1 | TeX box/glue/penalty + paragraph builder (`\par`, `\hsize`, `\parindent`) | **partial**: item stream, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing, `\spaceskip`/`\xspaceskip`, `\raggedright` (infinite `\rightskip`), `\looseness`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfLaTeX oracle matrix 90-240pt plus register, geometry, `\sfcode`, `\parindent`, `\parshape`, `\leftskip`/`\rightskip`, `\hfil`/`\hfill` glue orders, `\prevgraf` in the output routine, and vertical-glue fixtures | | M2 | page builder + `\output`, `\vsize`, `\topskip`, footnotes, floats | **partial**: `\vsize` page goal, `\topskip`, forced penalties, `Insertion` reserve, running `Mark`s, `OutputRoutine` hook, top/bottom `Float` placement; `page::PageBuilder` scores candidate breakpoints with TeX page badness, glue setting (with `\raggedbottom`/`\flushbottom` applied when pages are materialised, and TeX glue orders `\vfil`/`\vfill`/`\vfilll` honoured so only the highest order with stretch is used), `\topskip`/`\maxdepth`, and `Engine::layout_paged` uses it for documents whose units are single vertical items, placing top and bottom floats (with `\floatsep`, a `\bottomfraction` cap and the `\topnumber`/`\bottomnumber`/`\totalnumber` limits, with `\floatpagefraction` deciding when a float-heavy page ships without body) and insertion classes on that path, while in-text floats flow inline as body material; paged layouts replay edits from the edited unit's page and fall back to a full rebuild only when insertions, bottom floats or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset, and `\mark{...}`/`\marks{...}` writes inside the routine are carried to the following page's mark list with their class; `\pageno`, `\outputpenalty` and `\deadcycles` are readable and assignable registers (`\pageno=...` carries into the next page, and an assigned `\vsize` retargets the pages the routine has not seen yet, even when the document raises insertion material; only a document that defers bottom floats keeps its initial goal, because the carried queue cannot be rebuilt after a retarget), `\ht255`, `\dp255` and `\wd255` expose the page box height, depth and width to the routine, and `\hsize` is readable (and assignable for the rest of the run) while `\wd255` tracks it; route-D sets `\hsize` from its 480pt text measure, insertion class registers `\count`/`\dimen`/`\skip` read the configured multiplier, maximum height and skip of class `n` (with `\count0` reading `\pageno`) and accept assignments that outlive the routine (the paged builder runs the routine after each page, so an assigned `\dimen` or `\count` changes the insertion capacity and reservation of later pages); the configured `\skip` also reserves space above its class once per page in the paged builder, and a `\skip` assignment rebuilds the pages the routine has not seen yet with the new reservation, `\deadcycles` accumulates pages the output routine did not ship and resets on the next shipout, `\maxdeadcycles` (default 25, assignable) makes the page builder ship the page itself once that many dead cycles have accumulated, `PageFragment::penalty` carries the break penalty (`\outputpenalty`: the penalty value when the break landed on a penalty, otherwise 10000, as TeX reports for glue breaks, goal overflow and the final page), and `PageFragment::stretches` records glue stretch per TeX order so `\pagefilstretch`/`\pagefillstretch`/`\pagefilllstretch` are readable in the output routine; `\vbadness` reports the badness of the break that produced the page and `\insertpenalties` the number of insertion items held over from it | -| M3 | `\halign`, `\omit`, `\span`, `\multispan`, booktabs/longtable | **partial**: source parsing, natural column widths, spans, rule rows, 10pt display-list painting and row-level page splitting; the paged builder splits a tall alignment into page-sized row chunks that keep the table's column widths, so long tables continue across pages; `p{width}` paragraph columns wrap cell text and grow row heights, wrapped rows participate in row-level splitting, explicit per-column `\tabskip` glue is honoured through layout, painting and page chunks, and booktabs rules carry their own weights and spans (`\toprule`/`\bottomrule` 0.8pt, `\midrule`/`\cmidrule` 0.5pt, with `\cmidrule(lr){a-b}` trimming and column ranges), `@{}` / `@{\hspace{...}}` column expressions override the inter-column glue, and row-boundary `\noalign{\vskip ...}` glue is honoured by layout, painting and page chunks; longtable head/foot sections (`\endfirsthead`/`\endhead`/`\endfoot`/`\endlastfoot`) are parsed, continuation chunks repeat the head rows and the foot block paints once at the end, LaTeX `tabular` environments are captured and laid out through the same `\halign` path (rules are stripped from the column spec, `p{...}`/`m{...}`/`b{...}` become wrapping columns, `@{}` expressions are ignored for spacing), though `\valign`, nested tables and full tabular parity remain open | +| M3 | `\halign`, `\omit`, `\span`, `\multispan`, booktabs/longtable | **partial**: source parsing, natural column widths, spans, rule rows, 10pt display-list painting and row-level page splitting; the paged builder splits a tall alignment into page-sized row chunks that keep the table's column widths, so long tables continue across pages; `p{width}` paragraph columns wrap cell text and grow row heights, wrapped rows participate in row-level splitting, explicit per-column `\tabskip` glue is honoured through layout, painting and page chunks, and booktabs rules carry their own weights and spans (`\toprule`/`\bottomrule` 0.8pt, `\midrule`/`\cmidrule` 0.5pt, with `\cmidrule(lr){a-b}` trimming and column ranges), `@{}` / `@{\hspace{...}}` column expressions override the inter-column glue, and row-boundary `\noalign{\vskip ...}` glue is honoured by layout, painting and page chunks; longtable head/foot sections (`\endfirsthead`/`\endhead`/`\endfoot`/`\endlastfoot`) are parsed, continuation chunks repeat the head rows and the foot block paints once at the end, LaTeX `tabular` environments are captured and laid out through the same `\halign` path (rules are stripped from the column spec, `p{...}`/`m{...}`/`b{...}` become wrapping columns, `@{}` expressions are ignored for spacing), `\multicolumn{n}{align}{...}` cells span columns with the requested alignment, though `\valign`, nested tables and full tabular parity remain open | | M4 | math lists, scripts, fractions, radicals, accents, delimiters | **partial**: token parser, atom boxes with Computer Modern metrics (italic letters from the bundled `cmmi10`, big operators from `cmex10`, symbols such as `\times`/`\leq`/`\infty` from `cmsy10`, with `cmmi10`, `cmsy10` and `cmex10` glyphs embedded as Type1 outlines), `\left...\right` delimiter selection through CMEX size variants using TeX's delimiterfactor and shortfall, accents and a display-list painter; display formulas wider than the measure are split at top-level binary/relation operators into multiple lines (an approximation of TeX's `\split` behaviour; `align`/`align*` displays share column widths and number each row, while `gather`/`gather*` centre every row); CMEX delimiter size variants back `\big`/`\Big`/`\bigg`/`\Bigg`; inter-atom spacing uses TeX's full atom-class table with binary-operator normalisation, with `1mu` = `1/18em` (a thin space is 3mu = 1.67pt at 10pt); `\mid` is a relation while `\colon` is punctuation; `\mskip`, `\mkern`, `\mspace`, `\hskip`, `\kern` and `\hspace` scan TeX dimensions (`mu`, `pt`, `em`, ...) and contribute their natural width, accepting `plus`/`minus` parts even though math boxes are not glue lists; route-D numbers `equation` environments and resolves `\eqref`/`\ref` through their labels; `\tag` overrides the number and `\notag`/`\nonumber` suppress it; math italic letters are embedded as Computer Modern Type1 outlines (`cmmi10`), and math alphabets map `\\mathbf`/`\\mathit`/`\\mathsf`/`\\mathtt` onto the bold, math-italic, sans and mono faces with their TFMs and `\\mathcal` onto the cmsy10 calligraphic capitals; `\mathfrak` maps onto the bundled eufm10 Fraktur letters (embedded as Type1 outlines); infix fractions `\over`, `\atop`, `\choose`, `\brace`, `\brack` and their `withdelims` forms build fractions from the current row, with the bar only for the `\over` forms; `\middle` delimiters are sized with their enclosing `\left`/`\right` group and `\big`/`\Big`/`\bigg`/`\Bigg` paint at their selected CMEX size | | M5 | NFSS/TFM metrics, CM/Latin Modern | **partial**: paragraph-level NFSS declarations and inline run composition over the built-in Roman/Bold/Italic/BoldItalic/Mono/MonoItalic/Sans/SansBold/SansItalic/SmallCaps/Slanted/BoldSlanted faces (CM has no sans bold-italic, so `cmss/bx/it` substitutes `cmss/bx/n`; `\scshape` selects cmcsc10 and a bold small caps request falls back to cmbx10; `\slshape` uses the slanted cmsl10 rather than the italic cmti10 and `\ttfamily\itshape` reaches cmitt10), per-face Computer Modern TFM metrics, and Type1 (PFB) outline embedding for every built-in face plus `cmmi10` math italics, `cmsy10` math symbols and `cmex10` big operators, with Liberation subsets used only as a fallback for characters outside the Type1 encodings; paragraph base sizes from `\fontsize` and the article size commands scale glyph metrics and the default interline glue while the measure and authored skips stay absolute, and a size command in the middle of a paragraph splits a sized run that is shaped and painted at its own type size; full NFSS family/shape state and Type1 coverage for arbitrary Unicode remain open | | M6 | class/package execution (`article`, `sn-jnl`) | **partial**: `\documentclass[...]` options are read and the article `10pt`/`11pt`/`12pt` base size sets the default paragraph font size and `\baselineskip` (13.6pt/14.5pt); the `geometry` package's `margin`/`hmargin`/`vmargin`/`left`/`right`/`top`/`bottom` options (and `\geometry{...}`) adjust the measure and page height; `\title`/`\author`/`\date` are captured, `\today` expands to the UTC calendar date in the title block and the body, and `\maketitle` expands into the centered article title block at the class sizes (with today's date when `\date` is absent and no date for `\date{}`); numbered `\section`/`\subsection`/`\subsubsection`/`\paragraph`/`\subparagraph` headings advance five-level article counters (article's `\setcounter{secnumdepth}` default of 3 numbers through `\subsubsection`, and raising it numbers the two deeper levels) and paint at `\Large`/`\large`/`\normalsize` (the two deepest levels stay bold at the base size), starred headings stay unnumbered, and an optional `[short]` title is dropped; the `abstract` environment expands into a centered bold heading and a 9pt body, `\maketitle` joins `\and` authors and turns `\thanks` notes into title footnotes, and `\label` inside a heading (or on its own line after it) resolves `\ref`/`\eqref` to the section number while unknown references print `??`, and `\appendix` restarts sectioning with letters (`A`, `A.1`), and `\tableofcontents` lists the numbered headings through `\subsubsection` with 12pt per-level indentation (the default article `tocdepth` of 3; `\setcounter{tocdepth}` changes the depth) while `\listoffigures`/`\listoftables` reproduce the numbered figure/table captions; `verbatim` environments keep each source line as a monospaced 9pt paragraph indented by 12pt (leading whitespace is normalised), `\href{url}{text}` keeps its text, and `\url{...}` becomes typewriter text; `\footnote{...}` becomes a numbered 9pt page insertion on the page that mentions it; a `thebibliography` environment is removed from the body, its `\bibitem` entries become numbered `[n]` paragraphs, and `\cite{...}` resolves to `[n]`/`[n, m]` (unknown keys print `[?]`); a `figure` environment becomes a float at its `[t]`/`[b]`/`[h]` placement, its `\caption` numbers as `Figure n:` and resolves `\ref`, and `\includegraphics` embeds the referenced project image (PNG/JPEG/BMP are decoded into a PDF XObject, with a rule placeholder when the file is missing), and a standalone `\includegraphics` paragraph becomes an in-text graphic float, with `width=`/`height=` taking dimensions or fractions of `\textwidth`/`\textheight`, `scale=` a percentage of the natural size, `keepaspectratio` shrinking both dimensions to fit, and `\graphicspath` directories searched with common image extensions when the path has no suffix; a `table` environment becomes a float that carries its captured `tabular` body and a numbered `Table n:` caption whose text sits above the tabular as in LaTeX, while `\caption*` stays unnumbered for either float kind; `theorem`/`lemma`/`corollary`/`proposition`/`definition`/`example`/`remark`/`proof` environments get a bold numbered heading (optionally with `[title]`), italic statements for the theorem group, an unnumbered proof, and `\label`/`\ref` targets; `\newtheorem{env}[shared]{Display}`, `\newtheorem{env}{Display}[section]` and `\newtheorem*{env}{Display}` define custom environments with shared counters and section-scoped numbers; `itemize`/`enumerate`/`description` lists nest with depth-aware bullets (`•`, `–`, `*`), lettered/roman sub-labels and 12pt-per-level indentation, and an optional `\item[label]` overrides the generated marker; `\def\name#1{...}` parameter texts and `\let\alias=\other` aliases are executed as textual definitions; `\newenvironment{name}[n]{begin}{end}` definitions expand their begin/end codes around the environment body, with numbered arguments available in both; `\newif\ifname` flags default to false and `\nametrue`/`\namefalse` assignments, whether in the preamble or the body, select between `\ifname ... \else ... \fi` branches; project previews and PDF exports expand `\input{...}`/`\include{...}` from the project's files (the `.tex` suffix may be omitted) while unknown files stay literal text, and inline a project's own `.sty` files for `\usepackage{name}` and `.cls` files for `\documentclass` (rewritten to `article` with the original options kept), recursively inlining local `\RequirePackage` dependencies (up to eight levels, cycles skipped), inlining local `\input{...}` files inside class/package bodies (unresolved ones are dropped), dropping package/class boilerplate (`\ProvidesPackage`/`\ProvidesClass`, `\NeedsTeXFormat`, `\RequirePackage`) and inlining local base classes requested with `\LoadClass`/`\LoadClassWithOptions` (unknown bases keep LaTeX's article fallback); local class and package files execute their `\DeclareOption`/`\ExecuteOptions`/`\ProcessOptions` subset, so options named on `\documentclass[...]` or `\usepackage[...]` run their declaration code and `\ExecuteOptions` supplies defaults; a full class layout implementation and arbitrary package code remain open | @@ -367,7 +367,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address. `Engine::edit` preserves the face when reflowing an edited paragraph. -The crate currently has 407 unit tests plus eight route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 712 tests (407 route-D unit, 136 engine binary unit, 8 route-D integration, 35 oracle, 71 v1 integration, 50 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path. +The crate currently has 407 unit tests plus eight route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 715 tests (409 route-D unit, 137 engine binary unit, 8 route-D integration, 35 oracle, 71 v1 integration, 50 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path. ### M0 incremental demo diff --git a/src/route_d.rs b/src/route_d.rs index 7f67dcf..a587f9a 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -5255,6 +5255,28 @@ mod source_tests { assert_eq!(second.caption.as_deref(), Some("Figure 1: Numbered")); } + #[test] + fn tabular_multicolumn_cells_span_columns() { + let source = r"\begin{tabular}{|l|c|} +\multicolumn{2}{|c|}{Merged} \\ +A & B \\ +\end{tabular}"; + let (body, geometry) = geometry_and_body(source); + let blocks = paragraphs(&body).unwrap(); + let document = build_document(&blocks, &geometry); + let Some(VerticalItem::Halign(halign)) = document.units[0].items.first() else { + panic!("expected halign"); + }; + assert_eq!(halign.rows[0].cells.len(), 1); + assert_eq!(halign.rows[0].cells[0].text, "Merged"); + assert_eq!(halign.rows[0].cells[0].span, 2); + assert_eq!( + halign.rows[0].cells[0].alignment, + texrra_tex_core::CellAlignment::Center + ); + assert_eq!(halign.rows[1].cells.len(), 2); + } + #[test] fn table_floats_carry_their_tabular() { let source = r"\begin{table}[t]