Hang plainnat bibliography continuation lines

This commit is contained in:
gloamxun committed 2026-10-19 18:09:11 +08:00
1 parent 2fca019237
commit 71bd01c82c
4 files changed
+22 -7

No files matched your search

+2 -1
View File
@@ -386,7 +386,8 @@ Manual `thebibliography` entries also work. Documents loading `natbib` or
`arxiv.sty` render `\citet`/`\citep` as author-year citations, format `.bib` `arxiv.sty` render `\citet`/`\citep` as author-year citations, format `.bib`
entries in plainnat order (`First Last`, `In ...`, `pages`, publisher/year), entries in plainnat order (`First Last`, `In ...`, `pages`, publisher/year),
add deterministic year suffixes (`2014a`, `2014b`) when several entries share add deterministic year suffixes (`2014a`, `2014b`) when several entries share
an author and year, and omit numeric bibliography labels; other documents keep an author and year, indent continuation lines in the plainnat hanging style,
and omit numeric bibliography labels; other documents keep
numeric citations. Custom `.bst` numeric citations. Custom `.bst`
sorting/formatting and page-number references (`\pageref`) are not implemented. sorting/formatting and page-number references (`\pageref`) are not implemented.
+3 -2
View File
@@ -70,8 +70,9 @@ the source changes; the SVG preview is refreshed per page.
- Citations: numeric citations by default; `natbib`/`arxiv.sty` selects author-year - Citations: numeric citations by default; `natbib`/`arxiv.sty` selects author-year
`\citet`/`\citep` from `.bib` metadata, formats bibliography entries in `\citet`/`\citep` from `.bib` metadata, formats bibliography entries in
plainnat order (`First Last`, `In ...`, `pages`, publisher/year), adds plainnat order (`First Last`, `In ...`, `pages`, publisher/year), adds
deterministic `2014a`/`2014b` suffixes for duplicate author-year entries, and deterministic `2014a`/`2014b` suffixes for duplicate author-year entries,
drops numeric bibliography labels. indents continuation lines (plainnat hanging style), and drops numeric
bibliography labels.
- Live preview: paragraph cache, page-hash diffing, warm rebuilds in the low - Live preview: paragraph cache, page-hash diffing, warm rebuilds in the low
milliseconds for small edits. milliseconds for small edits.
+10 -4
View File
@@ -2869,10 +2869,11 @@ pub(super) fn build_positioned_pages(
numbered.extend(runs.clone()); numbered.extend(runs.clone());
numbered numbered
}; };
for line in measure_positioned_lines( let hanging_indent_mm = 7.0;
let entry_lines = measure_positioned_lines(
&numbered, &numbered,
10, 10,
content_width_mm, (content_width_mm - hanging_indent_mm).max(10.0),
metrics, metrics,
font_cache, font_cache,
cjk_family, cjk_family,
@@ -2881,7 +2882,8 @@ pub(super) fn build_positioned_pages(
math_metrics, math_metrics,
math_layout, math_layout,
cache, cache,
) { );
for (entry_line_index, line) in entry_lines.into_iter().enumerate() {
let anchor = PageAnchor { let anchor = PageAnchor {
block: block_index, block: block_index,
line: line_index, line: line_index,
@@ -2907,7 +2909,11 @@ pub(super) fn build_positioned_pages(
anchor, anchor,
content: line.content, content: line.content,
y: cursor, y: cursor,
x: 0, x: if entry_line_index == 0 {
0
} else {
millimeters_to_scaled(hanging_indent_mm)
},
centered: false, centered: false,
ragged: false, ragged: false,
})); }));
+7
View File
@@ -98,6 +98,13 @@ fn arxiv_fixture_is_three_letter_pages() {
assert!(first_page.contains("REPRINT"), "missing undertitle"); assert!(first_page.contains("REPRINT"), "missing undertitle");
assert!(first_page.contains("Hippocampus"), "missing author column"); assert!(first_page.contains("Hippocampus"), "missing author column");
assert!(first_page.contains("October"), "missing date"); assert!(first_page.contains("October"), "missing date");
let third_page = page_svg(&value, 2);
let entry_x = text_x(&third_page, "Geor");
let continuation_x = text_x(&third_page, "Recognition");
assert!(
continuation_x - entry_x > 3.0,
"bibliography continuation lines should be indented: {entry_x} vs {continuation_x}"
);
} }
#[test] #[test]