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`
entries in plainnat order (`First Last`, `In ...`, `pages`, publisher/year),
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`
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
`\citet`/`\citep` from `.bib` metadata, formats bibliography entries in
plainnat order (`First Last`, `In ...`, `pages`, publisher/year), adds
deterministic `2014a`/`2014b` suffixes for duplicate author-year entries, and
drops numeric bibliography labels.
deterministic `2014a`/`2014b` suffixes for duplicate author-year entries,
indents continuation lines (plainnat hanging style), and drops numeric
bibliography labels.
- Live preview: paragraph cache, page-hash diffing, warm rebuilds in the low
milliseconds for small edits.
+10 -4
View File
@@ -2869,10 +2869,11 @@ pub(super) fn build_positioned_pages(
numbered.extend(runs.clone());
numbered
};
for line in measure_positioned_lines(
let hanging_indent_mm = 7.0;
let entry_lines = measure_positioned_lines(
&numbered,
10,
content_width_mm,
(content_width_mm - hanging_indent_mm).max(10.0),
metrics,
font_cache,
cjk_family,
@@ -2881,7 +2882,8 @@ pub(super) fn build_positioned_pages(
math_metrics,
math_layout,
cache,
) {
);
for (entry_line_index, line) in entry_lines.into_iter().enumerate() {
let anchor = PageAnchor {
block: block_index,
line: line_index,
@@ -2907,7 +2909,11 @@ pub(super) fn build_positioned_pages(
anchor,
content: line.content,
y: cursor,
x: 0,
x: if entry_line_index == 0 {
0
} else {
millimeters_to_scaled(hanging_indent_mm)
},
centered: 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("Hippocampus"), "missing author column");
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]