diff --git a/library/src/meta/bibliography.rs b/library/src/meta/bibliography.rs index f35264af0..368a7c397 100644 --- a/library/src/meta/bibliography.rs +++ b/library/src/meta/bibliography.rs @@ -43,7 +43,7 @@ use crate::text::TextElem; /// /// Display: Bibliography /// Category: meta -#[element(Locatable, Synthesize, Show, LocalName)] +#[element(Locatable, Synthesize, Show, Finalize, LocalName)] pub struct BibliographyElem { /// Path to a Hayagriva `.yml` or BibLaTeX `.bib` file. #[required] @@ -66,6 +66,11 @@ pub struct BibliographyElem { /// language]($func/text.lang) will be used. This is the default. /// - When set to `{none}`, the bibliography will not have a title. /// - A custom title can be set by passing content. + /// + /// The bibliography's heading will not be numbered by default, but you can + /// force it to be with a show-set rule: + /// `{show bibliography: set heading(numbering: "1.")}` + /// ``` #[default(Some(Smart::Auto))] pub title: Option>, @@ -152,12 +157,7 @@ impl Show for BibliographyElem { .spanned(self.span()) }); - seq.push( - HeadingElem::new(title) - .with_level(NonZeroUsize::ONE) - .with_numbering(None) - .pack(), - ); + seq.push(HeadingElem::new(title).with_level(NonZeroUsize::ONE).pack()); } if !vt.introspector.init() { @@ -199,6 +199,12 @@ impl Show for BibliographyElem { } } +impl Finalize for BibliographyElem { + fn finalize(&self, realized: Content, _: StyleChain) -> Content { + realized.styled(HeadingElem::set_numbering(None)) + } +} + impl LocalName for BibliographyElem { fn local_name(&self, lang: Lang) -> &'static str { match lang { diff --git a/library/src/meta/outline.rs b/library/src/meta/outline.rs index a5c7a5de4..252111644 100644 --- a/library/src/meta/outline.rs +++ b/library/src/meta/outline.rs @@ -47,7 +47,7 @@ use crate::text::{LinebreakElem, SpaceElem, TextElem}; /// /// Display: Outline /// Category: meta -#[element(Show, LocalName)] +#[element(Show, Finalize, LocalName)] pub struct OutlineElem { /// The title of the outline. /// @@ -55,6 +55,11 @@ pub struct OutlineElem { /// [text language]($func/text.lang) will be used. This is the default. /// - When set to `{none}`, the outline will not have a title. /// - A custom title can be set by passing content. + /// + /// The outline's heading will not be numbered by default, but you can + /// force it to be with a show-set rule: + /// `{show outline: set heading(numbering: "1.")}` + /// ``` #[default(Some(Smart::Auto))] pub title: Option>, @@ -141,13 +146,7 @@ impl Show for OutlineElem { .spanned(self.span()) }); - seq.push( - HeadingElem::new(title) - .with_level(NonZeroUsize::ONE) - .with_numbering(None) - .with_outlined(false) - .pack(), - ); + seq.push(HeadingElem::new(title).with_level(NonZeroUsize::ONE).pack()); } let indent = self.indent(styles); @@ -247,6 +246,14 @@ impl Show for OutlineElem { } } +impl Finalize for OutlineElem { + fn finalize(&self, realized: Content, _: StyleChain) -> Content { + realized + .styled(HeadingElem::set_outlined(false)) + .styled(HeadingElem::set_numbering(None)) + } +} + impl LocalName for OutlineElem { fn local_name(&self, lang: Lang) -> &'static str { match lang { diff --git a/tests/ref/meta/bibliography.png b/tests/ref/meta/bibliography.png index c5a408af2..8e5e18ecd 100644 Binary files a/tests/ref/meta/bibliography.png and b/tests/ref/meta/bibliography.png differ diff --git a/tests/typ/meta/bibliography.typ b/tests/typ/meta/bibliography.typ index e25c54101..94b443467 100644 --- a/tests/typ/meta/bibliography.typ +++ b/tests/typ/meta/bibliography.typ @@ -30,6 +30,9 @@ And quark! @quark --- #set page(width: 200pt) +#set heading(numbering: "1.") +#show bibliography: set heading(numbering: "1.") + = Multiple Bibs Now we have multiple bibliographies containing #cite("glacier-melt", "keshav2007read") #bibliography(("/works.bib", "/works_too.bib"))