pub struct HeadingElem {
pub level: Settable<Self, 0u8>,
pub depth: Settable<Self, 1u8>,
pub offset: Settable<Self, 2u8>,
pub numbering: Settable<Self, 3u8>,
pub supplement: Settable<Self, 4u8>,
pub outlined: Settable<Self, 5u8>,
pub bookmarked: Settable<Self, 6u8>,
pub hanging_indent: Settable<Self, 7u8>,
pub body: Content,
pub numbers: Option<EcoString>,
}Expand description
A section heading.
With headings, you can structure your document into sections. Each heading
has a level, which starts at one and is unbounded upwards. This level
indicates the logical role of the following content (section, subsection,
etc.) A top-level heading indicates a top-level section of the document (not
the document’s title). To insert a title, use the title element
instead.
Typst can automatically number your headings for you. To enable numbering, specify how you want your headings to be numbered with a numbering pattern or function.
Independently of the numbering, Typst can also automatically generate an
[outline] of all headings for you. To exclude one or more headings from this
outline, you can set the outlined parameter to {false}.
When writing a show rule that accesses the
body field to create a completely custom look for
headings, make sure to wrap the content in a block (which is
implicitly sticky for headings through a built-in show-set
rule). This prevents headings from becoming “orphans”, i.e. remaining
at the end of the page with the following content being on the next page.
§Example
#set heading(numbering: "1.a)")
= Introduction
In recent years, ...
== Preliminaries
To start, ...§Syntax
Headings have dedicated syntax: They can be created by starting a line with
one or multiple equals signs, followed by a space. The number of equals
signs determines the heading’s logical nesting depth. The {offset} field
can be set to configure the starting depth.
§Accessibility
Headings are important for accessibility, as they help users of Assistive Technologies (AT) like screen readers to navigate within your document. Screen reader users will be able to skip from heading to heading, or get an overview of all headings in the document.
To make your headings accessible, you should not skip heading levels. This means that you should start with a first-level heading. Also, when the previous heading was of level 3, the next heading should be of level 3 (staying at the same depth), level 4 (going exactly one level deeper), or level 1 or 2 (new hierarchically higher headings).
§HTML export
As mentioned above, a top-level heading indicates a top-level section of
the document rather than its title. This is in contrast to the HTML <h1>
element of which there should be only one per document.
For this reason, in HTML export, a [title] element will turn into an
<h1> and headings turn into <h2> and lower (a level 1 heading thus turns
into <h2>, a level 2 heading into <h3>, etc).
Fields§
§level: Settable<Self, 0u8>§depth: Settable<Self, 1u8>§offset: Settable<Self, 2u8>§numbering: Settable<Self, 3u8>§supplement: Settable<Self, 4u8>§outlined: Settable<Self, 5u8>§bookmarked: Settable<Self, 6u8>§hanging_indent: Settable<Self, 7u8>§body: Content§numbers: Option<EcoString>Implementations§
Source§impl HeadingElem
impl HeadingElem
Sourcepub fn with_level(self, level: Smart<NonZeroUsize>) -> Self
pub fn with_level(self, level: Smart<NonZeroUsize>) -> Self
Builder-style setter for the level field.
Sourcepub fn with_depth(self, depth: NonZeroUsize) -> Self
pub fn with_depth(self, depth: NonZeroUsize) -> Self
Builder-style setter for the depth field.
Sourcepub fn with_offset(self, offset: usize) -> Self
pub fn with_offset(self, offset: usize) -> Self
Builder-style setter for the offset field.
Sourcepub fn with_numbering(self, numbering: Option<Numbering>) -> Self
pub fn with_numbering(self, numbering: Option<Numbering>) -> Self
Builder-style setter for the numbering field.
Sourcepub fn with_supplement(self, supplement: Smart<Option<Supplement>>) -> Self
pub fn with_supplement(self, supplement: Smart<Option<Supplement>>) -> Self
Builder-style setter for the supplement field.
Sourcepub fn with_outlined(self, outlined: bool) -> Self
pub fn with_outlined(self, outlined: bool) -> Self
Builder-style setter for the outlined field.
Sourcepub fn with_bookmarked(self, bookmarked: Smart<bool>) -> Self
pub fn with_bookmarked(self, bookmarked: Smart<bool>) -> Self
Builder-style setter for the bookmarked field.
Sourcepub fn with_hanging_indent(self, hanging_indent: Smart<Length>) -> Self
pub fn with_hanging_indent(self, hanging_indent: Smart<Length>) -> Self
Builder-style setter for the hanging-indent field.
Sourcepub fn with_numbers(self, numbers: EcoString) -> Self
pub fn with_numbers(self, numbers: EcoString) -> Self
Builder-style setter for the numbers field.
Source§impl HeadingElem
impl HeadingElem
pub const level: Field<Self, 0u8>
pub const depth: Field<Self, 1u8>
pub const offset: Field<Self, 2u8>
pub const numbering: Field<Self, 3u8>
pub const supplement: Field<Self, 4u8>
pub const outlined: Field<Self, 5u8>
pub const bookmarked: Field<Self, 6u8>
pub const hanging_indent: Field<Self, 7u8>
pub const body: Field<Self, 8u8>
pub const numbers: Field<Self, 9u8>
Source§impl HeadingElem
impl HeadingElem
pub fn resolve_level(&self, styles: StyleChain<'_>) -> NonZeroUsize
Trait Implementations§
Source§impl Clone for HeadingElem
impl Clone for HeadingElem
Source§fn clone(&self) -> HeadingElem
fn clone(&self) -> HeadingElem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Construct for HeadingElem
impl Construct for HeadingElem
Source§impl Debug for HeadingElem
impl Debug for HeadingElem
Source§impl Hash for HeadingElem
impl Hash for HeadingElem
Source§impl NativeElement for HeadingElem
impl NativeElement for HeadingElem
Source§impl RequiredField<8> for HeadingElem
impl RequiredField<8> for HeadingElem
Source§impl Set for HeadingElem
impl Set for HeadingElem
Source§impl SettableField<0> for HeadingElem
impl SettableField<0> for HeadingElem
Source§impl SettableField<1> for HeadingElem
impl SettableField<1> for HeadingElem
Source§impl SettableField<2> for HeadingElem
impl SettableField<2> for HeadingElem
Source§impl SettableField<3> for HeadingElem
impl SettableField<3> for HeadingElem
Source§impl SettableField<4> for HeadingElem
impl SettableField<4> for HeadingElem
const FIELD: SettableFieldData<Self, 4u8>
type Type = Smart<Option<Supplement>>
Source§impl SettableField<5> for HeadingElem
impl SettableField<5> for HeadingElem
Source§impl SettableField<6> for HeadingElem
impl SettableField<6> for HeadingElem
Source§impl SettableField<7> for HeadingElem
impl SettableField<7> for HeadingElem
Source§impl SynthesizedField<9> for HeadingElem
impl SynthesizedField<9> for HeadingElem
impl RefableProperty<0> for HeadingElem
impl RefableProperty<1> for HeadingElem
impl RefableProperty<2> for HeadingElem
impl RefableProperty<3> for HeadingElem
impl RefableProperty<4> for HeadingElem
impl RefableProperty<5> for HeadingElem
impl RefableProperty<6> for HeadingElem
impl RefableProperty<7> for HeadingElem
Auto Trait Implementations§
impl Freeze for HeadingElem
impl !RefUnwindSafe for HeadingElem
impl Send for HeadingElem
impl Sync for HeadingElem
impl Unpin for HeadingElem
impl !UnwindSafe for HeadingElem
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult for Twhere
T: IntoValue,
impl<T> IntoResult for Twhere
T: IntoValue,
Source§fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
fn into_result(self, _: Span) -> Result<Value, EcoVec<SourceDiagnostic>>
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> IntoValue for Twhere
T: NativeElement,
impl<T> IntoValue for Twhere
T: NativeElement,
Source§fn into_value(self) -> Value
fn into_value(self) -> Value
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T, const I: u8> SettableProperty<I> for Twhere
T: SettableField<I>,
impl<T, const I: u8> SettableProperty<I> for Twhere
T: SettableField<I>,
const FIELD: SettablePropertyData<T, I> = const FIELD: SettablePropertyData<Self, I> = <Self as SettableField::<I>>::FIELD.property;
type Type = <T as SettableField<I>>::Type
const FOLD: Option<FoldFn<Self::Type>> = _
Source§fn default_ref() -> &'static Self::Type
fn default_ref() -> &'static Self::Type
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more