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