Lay out title and author blocks like the class
The title now uses the SmallCaps face, matching the class's \LARGE\sc title. Author metadata is split on \and-row line breaks and \And author groups into separately centred lines instead of one collapsed paragraph, with extra space between author groups. This restores the visible author/affiliation structure in the arXiv template while keeping the generic \and join for article authors. Add a regression test for the title face, author line count and group spacing. The author block is still sequential rather than the class's two-column affiliation layout; title rules, ORCID icons and exact baseline spacing remain open. Test count is 1072 (434 engine).
This commit is contained in:
1 parent
e2e80e8728
commit
86e95881e7
6 files changed
+66
-14
No files matched your search
+56
-6
@@ -12415,6 +12415,29 @@ fn rename_abstract_heading(paragraphs: &mut [SourceParagraph], name: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Split an author block on `\\` and `\And` into separately centred lines.
|
||||
/// The class layouts put each affiliation on its own row; collapsing them to
|
||||
/// one paragraph loses the author/affiliation structure entirely.
|
||||
fn author_lines(author: &str) -> Vec<(String, bool)> {
|
||||
let mut lines = Vec::new();
|
||||
let mut starts_group = false;
|
||||
for row in author.split("\\\\") {
|
||||
let pieces: Vec<&str> = row.split("\\And").collect();
|
||||
for (index, piece) in pieces.iter().enumerate() {
|
||||
let text = clean_title_value(piece);
|
||||
if text.is_empty() {
|
||||
continue;
|
||||
}
|
||||
lines.push((text, starts_group || index > 0));
|
||||
starts_group = false;
|
||||
}
|
||||
if pieces.last().is_some_and(|piece| piece.trim().is_empty()) && pieces.len() > 1 {
|
||||
starts_group = true;
|
||||
}
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
fn expand_maketitle(blocks: &[SourceParagraph], geometry: &PageGeometry) -> Vec<SourceParagraph> {
|
||||
if !blocks
|
||||
.iter()
|
||||
@@ -12434,8 +12457,9 @@ fn expand_maketitle(blocks: &[SourceParagraph], geometry: &PageGeometry) -> Vec<
|
||||
let mut paragraph = title_block(
|
||||
clean_title_value(&expand_today(&thanks_to_footnotes(title), &today)),
|
||||
title_size(base),
|
||||
block.space_before,
|
||||
block.space_before + 18 * SCALE,
|
||||
);
|
||||
paragraph.font = ParagraphFont::SmallCaps;
|
||||
paragraph.page_break = block.page_break;
|
||||
result.push(paragraph);
|
||||
}
|
||||
@@ -12445,11 +12469,18 @@ fn expand_maketitle(blocks: &[SourceParagraph], geometry: &PageGeometry) -> Vec<
|
||||
.as_deref()
|
||||
.filter(|author| !author.is_empty())
|
||||
{
|
||||
result.push(title_block(
|
||||
clean_title_value(&expand_today(&thanks_to_footnotes(author), &today)),
|
||||
title_large_size(base),
|
||||
author_space,
|
||||
));
|
||||
let author = expand_today(&thanks_to_footnotes(author), &today);
|
||||
for (index, (line, starts_group)) in author_lines(&author).into_iter().enumerate() {
|
||||
let mut paragraph = title_block(
|
||||
line,
|
||||
title_large_size(base),
|
||||
if index == 0 { author_space } else { 0 },
|
||||
);
|
||||
if starts_group {
|
||||
paragraph.space_before += 8 * SCALE;
|
||||
}
|
||||
result.push(paragraph);
|
||||
}
|
||||
}
|
||||
let date = match geometry.date.as_deref() {
|
||||
Some(date) if date.trim().is_empty() => None,
|
||||
@@ -20733,6 +20764,25 @@ left & right \\
|
||||
assert!(!expanded[3].centered);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn maketitle_keeps_author_lines_and_small_caps_title() {
|
||||
let source =
|
||||
"\\title{Paper}\n\\author{A \\\\ Dept \\\\ \\And B \\\\ Dept2}\n\n\\maketitle\n\nBody";
|
||||
let (body, geometry) = geometry_and_body(source);
|
||||
let blocks = paragraphs(&body).expect("blocks");
|
||||
let expanded = expand_maketitle(&blocks, &geometry);
|
||||
assert_eq!(expanded[0].text, "Paper");
|
||||
assert_eq!(expanded[0].font, ParagraphFont::SmallCaps);
|
||||
assert_eq!(expanded[1].text, "A");
|
||||
assert_eq!(expanded[2].text, "Dept");
|
||||
assert_eq!(expanded[3].text, "B");
|
||||
assert_eq!(expanded[4].text, "Dept2");
|
||||
assert!(
|
||||
expanded[3].space_before > expanded[2].space_before,
|
||||
"a new \\And group should get extra space"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn maketitle_joins_authors_and_turns_thanks_into_footnotes() {
|
||||
let source = "\\title{Paper}\n\\author{A \\and B \\thanks{Support}}\n\n\\maketitle\n\nBody";
|
||||
|
||||
Reference in new issue
Block a user