diff --git a/docs/src/general/changelog.md b/docs/src/general/changelog.md index be1cdc370..5829cb0e8 100644 --- a/docs/src/general/changelog.md +++ b/docs/src/general/changelog.md @@ -8,6 +8,8 @@ description: | ## Unreleased - **Breaking:** Enumerations now require a space after their marker, that is, `[1.ok]` must now be written as `[1. ok]` +- **Breaking:** Changed default style for [term lists]($func/terms): Does not + include a colon anymore and has a bit more indent - Fixed bibliography ordering in IEEE style - Fixed parsing of decimals in math: `[$1.2/3.4$]` - Fixed parsing of unbalanced delimiters in fractions: `[$1/(2 (x)$]` @@ -21,6 +23,8 @@ description: | - Added support for disabling [matrix]($func/mat) and [vector]($func/vec) delimiters. Generally with `[#set math.mat(delim: none)]` or one-off with `[$mat(delim: #none, 1, 2; 3, 4)$]`. +- Added [`separator`]($func/terms.separator) argument to term lists +- Fixed [`indent`]($func/terms.indent) property of term lists - Added [`round`]($func/round) function for equations - Numberings now allow zeros. To reset a counter, you can write `[#counter(..).update(0)]` diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs index ec4fbc184..ce65b14c4 100644 --- a/library/src/layout/enum.rs +++ b/library/src/layout/enum.rs @@ -118,7 +118,7 @@ pub struct EnumElem { #[default(false)] pub full: bool, - /// The indentation of each item's label. + /// The indentation of each item. #[resolve] pub indent: Length, diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs index 179c93eb9..9f8d5a92e 100644 --- a/library/src/layout/list.rs +++ b/library/src/layout/list.rs @@ -78,7 +78,7 @@ pub struct ListElem { #[default(ListMarker::Content(vec![]))] pub marker: ListMarker, - /// The indent of each item's marker. + /// The indent of each item. #[resolve] pub indent: Length, diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs index 809c7ea7d..6d3e77911 100644 --- a/library/src/layout/table.rs +++ b/library/src/layout/table.rs @@ -87,6 +87,15 @@ pub struct TableElem { /// This can either be a single alignment or a function that returns an /// alignment. The function is passed the cell's column and row index, /// starting at zero. If set to `{auto}`, the outer alignment is used. + /// + /// ```example + /// #table( + /// columns: 3, + /// align: (x, y) => (left, center, right).at(x), + /// [Hello], [Hello], [Hello], + /// [A], [B], [C], + /// ) + /// ``` pub align: Celled>>>, /// How to stroke the cells. diff --git a/library/src/layout/terms.rs b/library/src/layout/terms.rs index 1200076f8..e51280f9d 100644 --- a/library/src/layout/terms.rs +++ b/library/src/layout/terms.rs @@ -1,7 +1,6 @@ use super::{HElem, VElem}; use crate::layout::{BlockElem, ParElem, Spacing}; use crate::prelude::*; -use crate::text::{SpaceElem, TextElem}; /// A list of terms and their descriptions. /// @@ -42,17 +41,33 @@ pub struct TermsElem { #[default(true)] pub tight: bool, - /// The indentation of each item's term. + /// The separator between the item and the description. + /// + /// If you want to just separate them with a certain amount of space, use + /// `{h(2cm, weak: true)}` as the separator and replace `{2cm}` with your + /// desired amount of space. + /// + /// ```example + /// #set terms(separator: [: ]) + /// + /// / Colon: A nice separator symbol. + /// ``` + #[default(HElem::new(Em::new(0.6).into()).with_weak(true).pack())] + pub separator: Content, + + /// The indentation of each item. pub indent: Length, /// The hanging indent of the description. /// + /// This is in addition to the whole item's `indent`. + /// /// ```example /// #set terms(hanging-indent: 0pt) /// / Term: This term list does not /// make use of hanging indents. /// ``` - #[default(Em::new(1.0).into())] + #[default(Em::new(2.0).into())] pub hanging_indent: Length, /// The spacing between the items of a wide (non-tight) term list. @@ -83,6 +98,7 @@ impl Layout for TermsElem { styles: StyleChain, regions: Regions, ) -> SourceResult { + let separator = self.separator(styles); let indent = self.indent(styles); let hanging_indent = self.hanging_indent(styles); let gutter = if self.tight(styles) { @@ -97,11 +113,11 @@ impl Layout for TermsElem { if i > 0 { seq.push(VElem::new(gutter).with_weakness(1).pack()); } - if indent.is_zero() { + if !indent.is_zero() { seq.push(HElem::new(indent.into()).pack()); } - seq.push((child.term() + TextElem::packed(':')).strong()); - seq.push(SpaceElem::new().pack()); + seq.push(child.term().strong()); + seq.push(separator.clone()); seq.push(child.description()); } diff --git a/tests/ref/layout/enum.png b/tests/ref/layout/enum.png index a52ad989e..a03093915 100644 Binary files a/tests/ref/layout/enum.png and b/tests/ref/layout/enum.png differ diff --git a/tests/ref/layout/terms.png b/tests/ref/layout/terms.png index f14781bd1..00531f98c 100644 Binary files a/tests/ref/layout/terms.png and b/tests/ref/layout/terms.png differ