Get numbering of page counter from style chain (#5589)

This commit is contained in:
Eric Biedert 2024-12-16 21:23:13 +01:00 committed by GitHub
parent 75273937f7
commit 51020fcf3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 14 deletions

View File

@ -366,10 +366,9 @@ impl Counter {
.custom() .custom()
.or_else(|| { .or_else(|| {
let styles = styles?; let styles = styles?;
let CounterKey::Selector(Selector::Elem(func, _)) = self.0 else { match self.0 {
return None; CounterKey::Page => PageElem::numbering_in(styles).clone(),
}; CounterKey::Selector(Selector::Elem(func, _)) => {
if func == HeadingElem::elem() { if func == HeadingElem::elem() {
HeadingElem::numbering_in(styles).clone() HeadingElem::numbering_in(styles).clone()
} else if func == FigureElem::elem() { } else if func == FigureElem::elem() {
@ -381,6 +380,9 @@ impl Counter {
} else { } else {
None None
} }
}
_ => None,
}
}) })
.unwrap_or_else(|| NumberingPattern::from_str("1.1").unwrap().into()); .unwrap_or_else(|| NumberingPattern::from_str("1.1").unwrap().into());

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

View File

@ -102,6 +102,14 @@ B
#set page(numbering: "1 / 1", margin: (bottom: 20pt)) #set page(numbering: "1 / 1", margin: (bottom: 20pt))
#counter(page).update(5) #counter(page).update(5)
--- counter-page-display ---
// Counter display should use numbering from style chain.
#set page(
numbering: "A",
margin: (bottom: 20pt),
footer: context align(center, counter(page).display())
)
--- counter-figure --- --- counter-figure ---
// Count figures. // Count figures.
#figure(numbering: "A", caption: [Four 'A's], kind: image, supplement: "Figure")[_AAAA!_] #figure(numbering: "A", caption: [Four 'A's], kind: image, supplement: "Figure")[_AAAA!_]