mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Document spacing and breaks
This commit is contained in:
parent
554a0c966a
commit
15cd273c82
@ -144,6 +144,10 @@ impl Layout for ColumnsNode {
|
|||||||
/// # Column Break
|
/// # Column Break
|
||||||
/// A forced column break.
|
/// A forced column break.
|
||||||
///
|
///
|
||||||
|
/// The function will behave like a [page break](@pagebreak) when used in a
|
||||||
|
/// single column layout or the last column on a page. Otherwise, content after
|
||||||
|
/// the column break will be placed in the next column.
|
||||||
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```
|
/// ```
|
||||||
/// #set page(columns: 2)
|
/// #set page(columns: 2)
|
||||||
|
@ -158,6 +158,19 @@ impl Debug for PageNode {
|
|||||||
/// # Page Break
|
/// # Page Break
|
||||||
/// A page break.
|
/// A page break.
|
||||||
///
|
///
|
||||||
|
/// A manually forced page break. It must not be used inside any containers.
|
||||||
|
///
|
||||||
|
/// ## Example
|
||||||
|
/// ```
|
||||||
|
/// The next page contains
|
||||||
|
/// more details on compound theory.
|
||||||
|
/// #pagebreak()
|
||||||
|
///
|
||||||
|
/// // Examples only render the first
|
||||||
|
/// // page, so this is not visible.
|
||||||
|
/// == Compound Theory
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// ## Parameters
|
/// ## Parameters
|
||||||
/// - weak: bool (named)
|
/// - weak: bool (named)
|
||||||
/// If true, the page break is skipped if the current page is already empty.
|
/// If true, the page break is skipped if the current page is already empty.
|
||||||
|
@ -151,6 +151,19 @@ castable! {
|
|||||||
/// # Paragraph Break
|
/// # Paragraph Break
|
||||||
/// A paragraph break.
|
/// A paragraph break.
|
||||||
///
|
///
|
||||||
|
/// This starts a new paragraph. Especially useful when used within code like
|
||||||
|
/// [for loops](/docs/reference/concepts#for-loop). Paragraph breaks in an empty
|
||||||
|
/// paragraph are ignored.
|
||||||
|
///
|
||||||
|
/// ## Example
|
||||||
|
/// ```
|
||||||
|
/// #for i in range(3) {
|
||||||
|
/// [Blind text #i: ]
|
||||||
|
/// lorem(5)
|
||||||
|
/// parbreak()
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// ## Category
|
/// ## Category
|
||||||
/// layout
|
/// layout
|
||||||
#[func]
|
#[func]
|
||||||
|
@ -3,7 +3,20 @@ use std::cmp::Ordering;
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
/// # Spacing (H)
|
/// # Spacing (H)
|
||||||
/// Horizontal spacing in a paragraph.
|
/// Insert horizontal spacing into a paragraph.
|
||||||
|
///
|
||||||
|
/// The spacing can be a length or a `fractional`. In the latter case, the
|
||||||
|
/// remaining space on the line is distributed among all fractional spacings
|
||||||
|
/// according to their relative size.
|
||||||
|
///
|
||||||
|
/// ## Example
|
||||||
|
/// ```
|
||||||
|
/// #circle(fill: red)
|
||||||
|
/// #h(1fr)
|
||||||
|
/// #circle(fill: yellow)
|
||||||
|
/// #h(2fr)
|
||||||
|
/// #circle(fill: green)
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## Parameters
|
/// ## Parameters
|
||||||
/// - amount: Spacing (positional, required)
|
/// - amount: Spacing (positional, required)
|
||||||
@ -14,6 +27,18 @@ use crate::prelude::*;
|
|||||||
/// Moreover, from multiple adjacent weak spacings all but the largest one
|
/// Moreover, from multiple adjacent weak spacings all but the largest one
|
||||||
/// collapse.
|
/// collapse.
|
||||||
///
|
///
|
||||||
|
/// ### Example
|
||||||
|
/// ```
|
||||||
|
/// #h(1cm, weak: true)
|
||||||
|
/// We identified a group of
|
||||||
|
/// _weak_ specimens that fail to
|
||||||
|
/// manifest in most cases. However,
|
||||||
|
/// when #h(8pt, weak: true)
|
||||||
|
/// supported
|
||||||
|
/// #h(8pt, weak: true) on all
|
||||||
|
/// sides, they do show up.
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// ## Category
|
/// ## Category
|
||||||
/// layout
|
/// layout
|
||||||
#[func]
|
#[func]
|
||||||
@ -65,7 +90,29 @@ impl Behave for HNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// # Spacing (V)
|
/// # Spacing (V)
|
||||||
/// Vertical spacing.
|
/// Insert vertical spacing.
|
||||||
|
///
|
||||||
|
/// The spacing can be a length or a `fractional`. In the latter case, the
|
||||||
|
/// remaining space on the page is distributed among all fractional spacings
|
||||||
|
/// according to their relative size.
|
||||||
|
///
|
||||||
|
/// ## Example
|
||||||
|
/// ```
|
||||||
|
/// In this report, we will explore
|
||||||
|
/// the various ethical
|
||||||
|
/// considerations that must be
|
||||||
|
/// taken into account when
|
||||||
|
/// conducting psychological
|
||||||
|
/// research:
|
||||||
|
/// #v(5mm)
|
||||||
|
///
|
||||||
|
/// - Informed consent
|
||||||
|
///
|
||||||
|
/// - Participant confidentiality
|
||||||
|
///
|
||||||
|
/// - The use of
|
||||||
|
/// vulnerable populations.
|
||||||
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## Parameters
|
/// ## Parameters
|
||||||
/// - amount: Spacing (positional, required)
|
/// - amount: Spacing (positional, required)
|
||||||
@ -76,6 +123,19 @@ impl Behave for HNode {
|
|||||||
/// Moreover, from multiple adjacent weak spacings all but the largest one
|
/// Moreover, from multiple adjacent weak spacings all but the largest one
|
||||||
/// collapse.
|
/// collapse.
|
||||||
///
|
///
|
||||||
|
/// ### Example
|
||||||
|
/// ```
|
||||||
|
/// Only paragraph spacing
|
||||||
|
///
|
||||||
|
/// Override paragraph spacing
|
||||||
|
/// with weak space
|
||||||
|
/// #v(7mm, weak: true)
|
||||||
|
///
|
||||||
|
/// Add to paragraph spacing
|
||||||
|
/// #v(7mm, weak: false)
|
||||||
|
///
|
||||||
|
/// A secret, fourth thing
|
||||||
|
/// ```
|
||||||
/// ## Category
|
/// ## Category
|
||||||
/// layout
|
/// layout
|
||||||
#[func]
|
#[func]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user