Flush rightline arguments to the right margin
This commit is contained in:
1 parent
9aa7198aed
commit
3d33ee9dc3
3 files changed
+27
-2
No files matched your search
@@ -9304,6 +9304,12 @@ fn build_document_with_labels(
|
||||
centered = true;
|
||||
text = format!("{}{}", body, &rest.trim_start()[used..]);
|
||||
}
|
||||
if let Some(rest) = text.trim_start().strip_prefix("\\rightline") {
|
||||
if let Some((body, used)) = braced_group(rest.trim_start()) {
|
||||
right_aligned = true;
|
||||
text = format!("{}{}", body, &rest.trim_start()[used..]);
|
||||
}
|
||||
}
|
||||
}
|
||||
let trimmed = text.trim_start();
|
||||
if let Some(rest) = trimmed.strip_prefix("\\centering") {
|
||||
@@ -13402,6 +13408,25 @@ A definition.
|
||||
assert_eq!(blocks[0].text, "See In body.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rightline_flushes_its_argument_right() {
|
||||
let blocks = paragraphs("\\rightline{Short.}").expect("paragraphs");
|
||||
let document = build_document(&blocks, &PageGeometry::default());
|
||||
let engine = Engine::layout(&document);
|
||||
let x = engine
|
||||
.pages()
|
||||
.iter()
|
||||
.flat_map(|page| page.display_list().items)
|
||||
.find_map(|item| match item {
|
||||
texrra_tex_core::render::DisplayItem::Text { text, x, .. } if text == "S" => {
|
||||
Some(x)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.expect("S glyph");
|
||||
assert!(x > 300, "right-flushed text starts at {}", x);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn centerline_centres_its_argument() {
|
||||
let blocks = paragraphs("\\centerline{Short.}").expect("paragraphs");
|
||||
|
||||
Reference in new issue
Block a user