Preserve inline emphasis in preprint title runs
This commit is contained in:
1 parent
d211889e93
commit
1da9e0dde9
5 files changed
+26
-7
No files matched your search
@@ -323,7 +323,8 @@ boxes, footnotes, and the default paragraph indent. The article default is
|
||||
`10pt`, matching LaTeX.
|
||||
A document-level `\renewcommand{\maketitle}` replaces the engine title block.
|
||||
When a document loads `arxiv.sty`, the engine switches to a native preprint
|
||||
title style: top/bottom title rules, small-caps title and `\undertitle`,
|
||||
title style: top/bottom title rules, small-caps title with inline emphasis
|
||||
preserved (e.g. the italic `arxiv` in the class example), `\undertitle`,
|
||||
two-column author blocks with affiliations and monospaced e-mail addresses,
|
||||
a long date, and `\thispagestyle{empty}` on the first page. Class and package
|
||||
files that replace `\maketitle` itself are still ignored, so box-level
|
||||
|
||||
@@ -80,6 +80,8 @@ pub struct Footnote {
|
||||
#[derive(Clone)]
|
||||
pub struct DocumentModel {
|
||||
pub title: String,
|
||||
/// Rich title runs, preserving inline emphases such as .
|
||||
pub title_runs: Vec<Run>,
|
||||
pub author: String,
|
||||
pub date: String,
|
||||
/// Style selected by the document's class/package layer.
|
||||
@@ -107,6 +109,7 @@ impl Default for DocumentModel {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
title: String::new(),
|
||||
title_runs: Vec::new(),
|
||||
author: String::new(),
|
||||
date: String::new(),
|
||||
title_style: TitleStyle::default(),
|
||||
|
||||
@@ -725,9 +725,12 @@ impl Parser {
|
||||
self.metadata_capture = Some((active_field, runs));
|
||||
return;
|
||||
}
|
||||
let value = runs.into_iter().map(|run| run.text).collect::<String>();
|
||||
let value = runs.iter().map(|run| run.text.clone()).collect::<String>();
|
||||
match field {
|
||||
expanded::MetadataField::Title => self.document.title = value,
|
||||
expanded::MetadataField::Title => {
|
||||
self.document.title = value;
|
||||
self.document.title_runs = runs;
|
||||
}
|
||||
expanded::MetadataField::Author => self.document.author = value,
|
||||
expanded::MetadataField::Date => self.document.date = value,
|
||||
}
|
||||
|
||||
@@ -1531,9 +1531,17 @@ pub(super) fn build_positioned_pages(
|
||||
TitleStyle::Preprint => {
|
||||
let rule_width = millimeters_to_scaled(content_width_mm);
|
||||
let rule_height = i64::from(scaled_points(2.0).0).max(1);
|
||||
let mut title_run = Run::plain(model.title.clone());
|
||||
title_run.bold = true;
|
||||
title_run.small_caps = true;
|
||||
let mut title_runs = if model.title_runs.is_empty() {
|
||||
vec![Run::plain(model.title.clone())]
|
||||
} else {
|
||||
model.title_runs.clone()
|
||||
};
|
||||
for run in &mut title_runs {
|
||||
run.bold = true;
|
||||
if !run.italic {
|
||||
run.small_caps = true;
|
||||
}
|
||||
}
|
||||
push_title_rule(
|
||||
&mut pages,
|
||||
&mut deferred,
|
||||
@@ -1547,7 +1555,7 @@ pub(super) fn build_positioned_pages(
|
||||
);
|
||||
cursor = cursor.saturating_add(millimeters_to_scaled(6.35));
|
||||
for line in measure_positioned_lines(
|
||||
&[title_run],
|
||||
&title_runs,
|
||||
base_font_size + 7,
|
||||
content_width_mm,
|
||||
metrics,
|
||||
|
||||
@@ -116,6 +116,10 @@ fn arxiv_title_block_uses_rules_and_small_caps() {
|
||||
first_page.contains("font-size=\"4.9389\""),
|
||||
"small-caps title glyphs missing"
|
||||
);
|
||||
assert!(
|
||||
first_page.contains("font-style=\"italic\">arxiv</text>"),
|
||||
"italic emph{{arxiv}} title run missing"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user