Place display equation tags at the right margin
Tagged display math used the body width as its box, so the equation number sat immediately after the formula. Add a TaggedWidth atom carrying the line measure: the body is centred in the measure and the tag is painted at its right edge. The arXiv equation number now matches the TeX right-margin placement; the formula body remains approximate. Test count stays 1077.
This commit is contained in:
1 parent
9181bf49fe
commit
764bc18850
5 files changed
+43
-3
No files matched your search
@@ -85,6 +85,12 @@ pub enum MathAtom {
|
||||
body: Box<MathAtom>,
|
||||
tag: String,
|
||||
},
|
||||
/// A display equation tag placed at the right edge of a fixed measure.
|
||||
TaggedWidth {
|
||||
body: Box<MathAtom>,
|
||||
tag: String,
|
||||
width: i64,
|
||||
},
|
||||
Limits {
|
||||
base: Box<MathAtom>,
|
||||
sub: Option<Box<MathAtom>>,
|
||||
@@ -1282,6 +1288,18 @@ pub fn layout_math(atom: &MathAtom, font: &Cmr10Metrics) -> MathBox {
|
||||
depth: body_box.depth.max(2 * 65_536),
|
||||
}
|
||||
}
|
||||
MathAtom::TaggedWidth { body, tag, width } => {
|
||||
let body_box = layout_math(body, font);
|
||||
let tag_width: i64 = tag
|
||||
.chars()
|
||||
.map(|character| Cmr10Metrics::Roman.width(character))
|
||||
.sum();
|
||||
MathBox {
|
||||
width: (*width).max(body_box.width).max(tag_width),
|
||||
height: body_box.height.max(7 * 65_536),
|
||||
depth: body_box.depth.max(2 * 65_536),
|
||||
}
|
||||
}
|
||||
MathAtom::Script { base, sub, sup } => {
|
||||
let base_box = layout_math(base, font);
|
||||
let sub_box = sub.as_deref().map(|atom| layout_math(atom, font));
|
||||
|
||||
@@ -1216,6 +1216,27 @@ impl Page {
|
||||
pen += width;
|
||||
}
|
||||
}
|
||||
MathAtom::TaggedWidth { body, tag, width } => {
|
||||
let body_box = math::layout_math(body, font);
|
||||
let body_x = x + ((*width - body_box.width) / 2).max(0);
|
||||
Self::paint_math(body, font, body_x, baseline, size, list);
|
||||
let tag_width: i64 = tag
|
||||
.chars()
|
||||
.map(|character| Cmr10Metrics::Roman.width(character))
|
||||
.sum();
|
||||
let mut pen = x + (*width).max(tag_width) - tag_width;
|
||||
for character in tag.chars() {
|
||||
let width = Cmr10Metrics::Roman.width(character);
|
||||
list.push(DisplayItem::Text {
|
||||
font: FontFace::Roman,
|
||||
x: pen,
|
||||
y: baseline,
|
||||
size,
|
||||
text: character.to_string(),
|
||||
});
|
||||
pen += width;
|
||||
}
|
||||
}
|
||||
MathAtom::Script { base, sub, sup } => {
|
||||
let base_box = math::layout_math(base, font);
|
||||
Self::paint_math(base, font, x, baseline, size, list);
|
||||
|
||||
@@ -48,7 +48,7 @@ execution is not a goal.
|
||||
- project `.bib` entries now produce author-year labels and natbib-style
|
||||
parenthetical citations; inline `thebibliography` without labels remains
|
||||
numeric, and the full natbib option surface is not implemented;
|
||||
- display math is approximate;
|
||||
- display math is approximate; equation tags now sit at the right margin;
|
||||
- PNG/JPEG/BMP floats now reserve their image height, embed the raster with
|
||||
its real pixel dimensions, centre the image within the float, and emit it
|
||||
into the SVG preview as a PNG data URI. Table floats are centred with their
|
||||
|
||||
@@ -148,7 +148,7 @@ PDF was rendered page-by-page next to the route-D output.
|
||||
| Citations | natbib author-year `(Kour and Saabne, 2014a; …)` | author-year `(Kour and Saabne, 2014a; Keshet et al., 2016)` for `.bib`; numeric for unlabeled inline bibliographies |
|
||||
| Table | booktabs rules, `Size (µm)`, `~100`, `10^6` | centred with rules; `Size (µm)`, `~100`, `10⁶` |
|
||||
| Figure | framed rule box above the caption | centred framed rule body (raster) on page 3 |
|
||||
| Display equation | fully typeset fraction/product/sum | approximate, visibly jumbled |
|
||||
| Display equation | fully typeset fraction/product/sum | approximate body; equation number now at the right margin |
|
||||
| References | author-year, italic venue, DOI link | author-year entries; plain venue text, no DOI |
|
||||
| Float order | figure/table on page 3 with section 3.4 | figure/table on page 3 above 3.3/3.4 |
|
||||
|
||||
|
||||
+2
-1
@@ -13989,9 +13989,10 @@ fn build_document_with_labels(
|
||||
.map(|number| format!("({number})"))
|
||||
});
|
||||
let atom = match tag {
|
||||
Some(tag) => MathAtom::Tagged {
|
||||
Some(tag) => MathAtom::TaggedWidth {
|
||||
body: Box::new(atom),
|
||||
tag,
|
||||
width: line_width,
|
||||
},
|
||||
None => atom,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user