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
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user