typst_library/layout/
repeat.rs

1use crate::foundations::{Content, elem};
2use crate::introspection::Tagged;
3use crate::layout::Length;
4
5/// Repeats content to the available space.
6///
7/// This can be useful when implementing a custom index, reference, or outline.
8///
9/// Space may be inserted between the instances of the body parameter, so be
10/// sure to adjust the [`justify`]($repeat.justify) parameter accordingly.
11///
12/// Errors if there are no bounds on the available space, as it would create
13/// infinite content.
14///
15/// # Example
16/// ```example
17/// Sign on the dotted line:
18/// #box(width: 1fr, repeat[.])
19///
20/// #set text(10pt)
21/// #v(8pt, weak: true)
22/// #align(right)[
23///   Berlin, the 22nd of December, 2022
24/// ]
25/// ```
26///
27/// # Accessibility
28/// Repeated content is automatically marked as an [artifact]($pdf.artifact) and
29/// hidden from Assistive Technology (AT). Do not use this function to create
30/// content that contributes to the meaning of your document.
31#[elem(Tagged)]
32pub struct RepeatElem {
33    /// The content to repeat.
34    #[required]
35    pub body: Content,
36
37    /// The gap between each instance of the body.
38    #[default]
39    pub gap: Length,
40
41    /// Whether to increase the gap between instances to completely fill the
42    /// available space.
43    #[default(true)]
44    pub justify: bool,
45}