Support the appendices environment
The appendices environment was reported as unsupported, so appendix sections
kept main-matter numbering. A body pass now replaces \begin{appendices} with a
blank-line-padded \appendix (so it becomes its own block and the sectioning pass
sees it) and drops \end{appendices}; the environment name counts as supported.
A preview test puts a section inside appendices and checks "1 Main" and
"A Extra" render with no warnings.
This commit is contained in:
1 parent
82c3e24d18
commit
e53ce3b601
4 files changed
+37
-6
No files matched your search
@@ -6421,6 +6421,9 @@ fn geometry_and_body_with_images(
|
||||
body = expand_environments(&body, &geometry.environments);
|
||||
body = expand_keywords(&body);
|
||||
body = expand_acks(&body);
|
||||
body = body
|
||||
.replace("\\begin{appendices}", "\n\n\\appendix\n\n")
|
||||
.replace("\\end{appendices}", "\n\n");
|
||||
body = drop_bibliography_commands(&body);
|
||||
let savebox_base = geometry.base_font_size.unwrap_or(655_360);
|
||||
body = expand_saveboxes(
|
||||
@@ -13821,6 +13824,7 @@ const SUPPORTED_ENVIRONMENTS: &[&str] = &[
|
||||
"flushright",
|
||||
"minipage",
|
||||
"acks",
|
||||
"appendices",
|
||||
"acknowledgments",
|
||||
"acknowledgements",
|
||||
"verbatim",
|
||||
@@ -17242,6 +17246,33 @@ A definition.
|
||||
assert!(text.contains("D"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn appendices_environment_switches_numbering() {
|
||||
let source = "\\documentclass{article}\n\\begin{document}\n\n\\section{Main}\n\nBody.\n\n\\begin{appendices}\n\\section{Extra}\n\\end{appendices}\n\n\\end{document}\n";
|
||||
let json = preview_json(source).expect("preview");
|
||||
let value: serde_json::Value = serde_json::from_str(&json).expect("JSON");
|
||||
assert_eq!(
|
||||
value["warnings"].as_array().map(Vec::len),
|
||||
Some(0),
|
||||
"{}",
|
||||
value["warnings"]
|
||||
);
|
||||
let pages = value["pages"].as_array().expect("pages");
|
||||
let mut text = String::new();
|
||||
for page in pages {
|
||||
if let Some(svg) = page["svg"].as_str() {
|
||||
text.push_str(
|
||||
&svg.split('>')
|
||||
.filter_map(|piece| piece.split('<').next())
|
||||
.collect::<String>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
let text: String = text.split_whitespace().collect();
|
||||
assert!(text.contains("1Main"), "{text}");
|
||||
assert!(text.contains("AExtra"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tagged_equations_add_parentheses() {
|
||||
let source = "\\documentclass{article}\n\\begin{document}\n\n\\begin{equation}\nx = 1 \\tag{A}\n\\end{equation}\n\n\\end{document}\n";
|
||||
|
||||
Reference in new issue
Block a user