From 86e95881e7a2cb57be77c00b61a50d9375c2b637 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Tue, 27 Oct 2026 21:10:46 +0800 Subject: [PATCH] Lay out title and author blocks like the class The title now uses the SmallCaps face, matching the class's \LARGE\sc title. Author metadata is split on \and-row line breaks and \And author groups into separately centred lines instead of one collapsed paragraph, with extra space between author groups. This restores the visible author/affiliation structure in the arXiv template while keeping the generic \and join for article authors. Add a regression test for the title face, author line count and group spacing. The author block is still sequential rather than the class's two-column affiliation layout; title rules, ORCID icons and exact baseline spacing remain open. Test count is 1072 (434 engine). --- docs/ROUTE_D_PLAN.md | 2 +- docs/ROUTE_D_STATUS.md | 6 ++-- docs/TEX_CORE.md | 4 +-- docs/TEX_FIDELITY_ROADMAP.md | 4 ++- docs/WEB_ROUTE_D_EXPERIMENT.md | 2 +- src/route_d.rs | 62 ++++++++++++++++++++++++++++++---- 6 files changed, 66 insertions(+), 14 deletions(-) diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index 3809d86..10e2dfc 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -51,7 +51,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`, 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`; flat `/preview` and project previews now -prefer route-D with a v1 fallback). 1071 workspace tests are green and no oracle +prefer route-D with a v1 fallback). 1072 workspace tests are green and no oracle fixture is ignored. Preview JSON also carries a `warnings` array naming environments route-D cannot lay out and control words that survived layout, so unsupported source is reported instead of being silently typeset. diff --git a/docs/ROUTE_D_STATUS.md b/docs/ROUTE_D_STATUS.md index 986c410..e3fda45 100755 --- a/docs/ROUTE_D_STATUS.md +++ b/docs/ROUTE_D_STATUS.md @@ -16,12 +16,12 @@ cargo test --workspace --offline or run `./scripts/verify-route-d.sh`, which executes both. -The workspace currently passes **1071 tests**: +The workspace currently passes **1072 tests**: | Suite | Tests | | --- | --- | | route-D unit (engine) | 444 | -| engine binary unit | 433 | +| engine binary unit | 434 | | server integration | 66 | | v1 integration | 71 | | pdfLaTeX oracle | 42 | @@ -29,7 +29,7 @@ The workspace currently passes **1071 tests**: | engine/core unit | 4 + 1 | Latest full run (web trial increment): `./scripts/verify-route-d.sh` passes -with fmt clean and **1071 tests** green. +with fmt clean and **1072 tests** green. Latest live check (2026-10-27): the debug server served `examples/hello.tex` from `target/debug/texrra serve`; `POST /preview` answered 200 with diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 0f1bf63..b596638 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -370,7 +370,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; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph. -The crate currently has 444 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1071 tests (444 core unit, 433 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 66 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; flat and project responses carry `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4. +The crate currently has 444 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1072 tests (444 core unit, 434 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 66 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; flat and project responses carry `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4. ### M0 incremental demo @@ -524,7 +524,7 @@ deliberately open rather than approximated: ## Limits and remaining gaps -The suite currently stands at 1071 passing tests, with the workspace clean. +The suite currently stands at 1072 passing tests, with the workspace clean. Route-D serves both flat `/preview` and project preview/PDF requests by default (automatic v1 fallback; `?engine=v1` or `TEXRRA_ENGINE=v1` opts out). The objective's areas are implemented to the limits below; complex-script shaping is diff --git a/docs/TEX_FIDELITY_ROADMAP.md b/docs/TEX_FIDELITY_ROADMAP.md index 18fbcb9..178868d 100644 --- a/docs/TEX_FIDELITY_ROADMAP.md +++ b/docs/TEX_FIDELITY_ROADMAP.md @@ -40,7 +40,9 @@ execution is not a goal. 6.5in text block and page-2/page-3 headers instead of content at x=0. - Still visibly different from TeX: - body face is CMR/fallback, not Times from `\rmdefault{ptm}`; - - title/author block, small caps and rules are simplified; + - title now uses small caps and author metadata is split onto class-like + lines; title rules, two-column affiliations and ORCID icons are still + missing; - reference style is numeric, not natbib author-year; - display math is approximate; - `\fbox`/rule figures, vector images and float placement differ. diff --git a/docs/WEB_ROUTE_D_EXPERIMENT.md b/docs/WEB_ROUTE_D_EXPERIMENT.md index bf876d5..88800a0 100644 --- a/docs/WEB_ROUTE_D_EXPERIMENT.md +++ b/docs/WEB_ROUTE_D_EXPERIMENT.md @@ -46,7 +46,7 @@ now means route-D. | Area | Route-D | Evidence / impact | | --- | --- | --- | -| Article/report basics: title, sections, lists, TOC, page numbers | Supported | corpus and 1071-test suite | +| Article/report basics: title, sections, lists, TOC, page numbers | Supported | corpus and 1072-test suite | | Inline/display math, equations, tags, cleveref | Supported | math tests, oracle fixtures | | Floats, captions, tables, booktabs | Supported | table/math tests, corpus | | PNG/JPEG/BMP `\includegraphics` | Supported | project image tests | diff --git a/src/route_d.rs b/src/route_d.rs index 7777a67..2d5ca45 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -12415,6 +12415,29 @@ fn rename_abstract_heading(paragraphs: &mut [SourceParagraph], name: &str) { } } +/// Split an author block on `\\` and `\And` into separately centred lines. +/// The class layouts put each affiliation on its own row; collapsing them to +/// one paragraph loses the author/affiliation structure entirely. +fn author_lines(author: &str) -> Vec<(String, bool)> { + let mut lines = Vec::new(); + let mut starts_group = false; + for row in author.split("\\\\") { + let pieces: Vec<&str> = row.split("\\And").collect(); + for (index, piece) in pieces.iter().enumerate() { + let text = clean_title_value(piece); + if text.is_empty() { + continue; + } + lines.push((text, starts_group || index > 0)); + starts_group = false; + } + if pieces.last().is_some_and(|piece| piece.trim().is_empty()) && pieces.len() > 1 { + starts_group = true; + } + } + lines +} + fn expand_maketitle(blocks: &[SourceParagraph], geometry: &PageGeometry) -> Vec { if !blocks .iter() @@ -12434,8 +12457,9 @@ fn expand_maketitle(blocks: &[SourceParagraph], geometry: &PageGeometry) -> Vec< let mut paragraph = title_block( clean_title_value(&expand_today(&thanks_to_footnotes(title), &today)), title_size(base), - block.space_before, + block.space_before + 18 * SCALE, ); + paragraph.font = ParagraphFont::SmallCaps; paragraph.page_break = block.page_break; result.push(paragraph); } @@ -12445,11 +12469,18 @@ fn expand_maketitle(blocks: &[SourceParagraph], geometry: &PageGeometry) -> Vec< .as_deref() .filter(|author| !author.is_empty()) { - result.push(title_block( - clean_title_value(&expand_today(&thanks_to_footnotes(author), &today)), - title_large_size(base), - author_space, - )); + let author = expand_today(&thanks_to_footnotes(author), &today); + for (index, (line, starts_group)) in author_lines(&author).into_iter().enumerate() { + let mut paragraph = title_block( + line, + title_large_size(base), + if index == 0 { author_space } else { 0 }, + ); + if starts_group { + paragraph.space_before += 8 * SCALE; + } + result.push(paragraph); + } } let date = match geometry.date.as_deref() { Some(date) if date.trim().is_empty() => None, @@ -20733,6 +20764,25 @@ left & right \\ assert!(!expanded[3].centered); } + #[test] + fn maketitle_keeps_author_lines_and_small_caps_title() { + let source = + "\\title{Paper}\n\\author{A \\\\ Dept \\\\ \\And B \\\\ Dept2}\n\n\\maketitle\n\nBody"; + let (body, geometry) = geometry_and_body(source); + let blocks = paragraphs(&body).expect("blocks"); + let expanded = expand_maketitle(&blocks, &geometry); + assert_eq!(expanded[0].text, "Paper"); + assert_eq!(expanded[0].font, ParagraphFont::SmallCaps); + assert_eq!(expanded[1].text, "A"); + assert_eq!(expanded[2].text, "Dept"); + assert_eq!(expanded[3].text, "B"); + assert_eq!(expanded[4].text, "Dept2"); + assert!( + expanded[3].space_before > expanded[2].space_before, + "a new \\And group should get extra space" + ); + } + #[test] fn maketitle_joins_authors_and_turns_thanks_into_footnotes() { let source = "\\title{Paper}\n\\author{A \\and B \\thanks{Support}}\n\n\\maketitle\n\nBody";