Polish preprint title details and plainnat bibliography formatting

This commit is contained in:
gloamxun committed 2026-10-19 15:53:47 +08:00
1 parent 7f1f202de1
commit d211889e93
8 files changed
+120 -11

No files matched your search

+2 -2
View File
@@ -453,8 +453,8 @@ const PRELUDE: &str = r#"
\def\And{\texrraauthorseparator}
\def\AND{\texrraauthorseparator}
\def\ifhmode{\iftrue}
\def\paragraph#1{\par\texrraunnumberedheadingstart{3}#1\texrraheadingend\par}
\def\subparagraph#1{\par\texrraunnumberedheadingstart{3}#1\texrraheadingend\par}
\def\paragraph#1{\par\noindent{\bfseries #1}\hspace{1em}}
\def\subparagraph#1{\par\noindent{\itshape #1}\hspace{1em}}
\def\@startsection#1#2#3#4#5#6#7{\par\texrraheadingstart{#2}#7\texrraheadingend\par}
\def\setlength#1#2{#1=#2\relax}
\def\addtolength#1#2{\advance#1#2\relax}
+8 -1
View File
@@ -530,6 +530,10 @@ struct CompilerState {
pending_page_decorations: Vec<PendingPageDecoration>,
#[serde(skip)]
document_started: bool,
/// True when `natbib` (or a class that loads it) is active; controls
/// author-year bibliography formatting and citations.
#[serde(default)]
author_year_bibliography: bool,
}
struct PendingPageDecoration {
@@ -4352,6 +4356,7 @@ fn load_document_class(
token,
FrontendEventKind::PackageLoaded(class.clone()),
);
input.state_mut().author_year_bibliography |= matches!(class.as_str(), "natbib" | "arxiv");
SourceDependency::record(
&mut input.state_mut().dependencies.borrow_mut(),
&path,
@@ -4647,6 +4652,7 @@ fn use_package(
token,
FrontendEventKind::PackageLoaded(package.clone()),
);
input.state_mut().author_year_bibliography |= matches!(package.as_str(), "natbib" | "arxiv");
SourceDependency::record(
&mut input.state_mut().dependencies.borrow_mut(),
&path,
@@ -6215,6 +6221,7 @@ fn bibliography_primitive(
}
.map_err(|message| input.fatal_error(error::SimpleTokenError::new(token, message)))?;
let author_year = input.state().author_year_bibliography;
let mut source = String::from("\\begin{thebibliography}{9}");
for entry in entries {
source.push_str("\\texrrabibmeta{");
@@ -6226,7 +6233,7 @@ fn bibliography_primitive(
source.push_str("}\\bibitem{");
source.push_str(&entry.key);
source.push('}');
source.push_str(&entry.to_latex());
source.push_str(&entry.to_latex(author_year));
}
source.push_str("\\end{thebibliography}");
let generated = lex_generated_tex(input, &source, token)?;