summaryrefslogtreecommitdiff
path: root/library/src/layout
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/layout')
-rw-r--r--library/src/layout/enum.rs2
-rw-r--r--library/src/layout/list.rs2
-rw-r--r--library/src/layout/table.rs9
-rw-r--r--library/src/layout/terms.rs28
4 files changed, 33 insertions, 8 deletions
diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs
index ec4fbc18..ce65b14c 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 179c93eb..9f8d5a92 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 809c7ea7..6d3e7791 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<Smart<Axes<Option<GenAlign>>>>,
/// How to stroke the cells.
diff --git a/library/src/layout/terms.rs b/library/src/layout/terms.rs
index 1200076f..e51280f9 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<Fragment> {
+ 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());
}