Compact display-to-heading gaps in Times math
This commit is contained in:
1 parent
13b85b542a
commit
eabebfa687
6 files changed
+52
-12
No files matched your search
@@ -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). 1091 workspace tests are green and no oracle
|
||||
prefer route-D with a v1 fallback). 1092 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.
|
||||
|
||||
@@ -16,7 +16,7 @@ cargo test --workspace --offline
|
||||
|
||||
or run `./scripts/verify-route-d.sh`, which executes both.
|
||||
|
||||
The workspace currently passes **1091 tests**:
|
||||
The workspace currently passes **1092 tests**:
|
||||
|
||||
| Suite | Tests |
|
||||
| --- | --- |
|
||||
@@ -29,7 +29,7 @@ The workspace currently passes **1091 tests**:
|
||||
| engine/core unit | 4 + 1 |
|
||||
|
||||
Latest full run (web trial increment): `./scripts/verify-route-d.sh` passes
|
||||
with fmt clean and **1091 tests** green.
|
||||
with fmt clean and **1092 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
|
||||
|
||||
@@ -124,3 +124,22 @@ the following heading starts at zero. Measured baselines moved:
|
||||
|
||||
The 3.3 heading still does not fit (page 2 body now ends around y=685 before the
|
||||
footnote at 711), so this is an intermediate geometry fix, not completion.
|
||||
|
||||
|
||||
## Display-to-heading compaction
|
||||
|
||||
The gap from the arXiv display equation to 2.1.1 was 46.4 pt vs TeX 32 pt.
|
||||
For ptm display math, the below-display skip is now zero (the formula's own
|
||||
depth carries the separation) and a heading immediately after a display math
|
||||
paragraph loses 15 pt (clamped to zero). Measured baselines:
|
||||
|
||||
```text
|
||||
2.1.1 221.9 -> 206.9 (TeX 206.9)
|
||||
Paragraph 309.4 -> 294.4 (TeX 292.0)
|
||||
3 413.5 -> 389.5 (TeX 373.3)
|
||||
3.1 456.4 -> 422.4 (TeX 397.6)
|
||||
3.2 564.7 -> 530.7 (TeX 503.4)
|
||||
```
|
||||
|
||||
Page 2 body now ends around y=669 before the footnote at 711, but 3.3 still
|
||||
does not fit; roughly 15–20 pt remain.
|
||||
+2
-2
@@ -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 451 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1091 tests (451 core unit, 444 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 67 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 451 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1092 tests (451 core unit, 445 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 67 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 1091 passing tests, with the workspace clean.
|
||||
The suite currently stands at 1092 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
|
||||
|
||||
@@ -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 1091-test suite |
|
||||
| Article/report basics: title, sections, lists, TOC, page numbers | Supported | corpus and 1092-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; PDF XObjects use pixel dimensions and the SVG preview embeds a PNG data URI |
|
||||
|
||||
+27
-6
@@ -13855,6 +13855,14 @@ fn build_document_with_labels(
|
||||
}
|
||||
});
|
||||
let mut paragraphs = expand_maketitle(paragraphs, geometry);
|
||||
if geometry.roman_family.as_deref() == Some("ptm") {
|
||||
for index in 1..paragraphs.len() {
|
||||
if paragraphs[index].heading_level.is_some() && paragraphs[index - 1].math {
|
||||
paragraphs[index].space_before =
|
||||
(paragraphs[index].space_before - 15 * SCALE).max(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(name) = geometry.abstract_name.as_deref() {
|
||||
rename_abstract_heading(&mut paragraphs, name);
|
||||
}
|
||||
@@ -14429,10 +14437,7 @@ fn build_document_with_labels(
|
||||
// builder reserves room for them on the page that mentions them.
|
||||
let (default_above_display, default_below_display) =
|
||||
display_skip_defaults(geometry.base_font_size.unwrap_or(655_360));
|
||||
let times_displays = (
|
||||
(7 * SCALE, 2 * SCALE, 5 * SCALE),
|
||||
(7 * SCALE, 2 * SCALE, 5 * SCALE),
|
||||
);
|
||||
let times_displays = ((7 * SCALE, 2 * SCALE, 5 * SCALE), (0, 0, 0));
|
||||
let (default_above_display, default_below_display) =
|
||||
if geometry.roman_family.as_deref() == Some("ptm") {
|
||||
times_displays
|
||||
@@ -20127,18 +20132,34 @@ left & right \\
|
||||
let (body, geometry) = geometry_and_body(source);
|
||||
let paragraphs = paragraphs(&body).expect("paragraphs");
|
||||
let document = build_document(¶graphs, &geometry);
|
||||
let math = document
|
||||
let math_index = document
|
||||
.units
|
||||
.iter()
|
||||
.find(|unit| {
|
||||
.position(|unit| {
|
||||
unit.items
|
||||
.iter()
|
||||
.any(|item| matches!(item, VerticalItem::Math { .. }))
|
||||
})
|
||||
.expect("display math unit");
|
||||
let math = &document.units[math_index];
|
||||
assert_eq!(math.space_before, 7 * SCALE);
|
||||
assert_eq!(math.space_stretch, 2 * SCALE);
|
||||
assert_eq!(math.space_shrink, 5 * SCALE);
|
||||
assert_eq!(document.units[math_index + 1].space_before, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn times_heading_after_display_math_is_compacted() {
|
||||
let source = "\\renewcommand{\\rmdefault}{ptm}\n\\section{One}\n\nText.\n\n\\[ x \\]\n\n\\subsection{Two}\n\nBody.";
|
||||
let (body, geometry) = geometry_and_body(source);
|
||||
let paragraphs = paragraphs(&body).expect("paragraphs");
|
||||
let document = build_document(¶graphs, &geometry);
|
||||
let heading = document
|
||||
.units
|
||||
.iter()
|
||||
.find(|unit| unit.source.contains("Two"))
|
||||
.expect("subsection unit");
|
||||
assert_eq!(heading.space_before, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user