Repository: typst/typst
File: crates/typst/src/math/equation.rs (Rust)

Code before:
    #[borrowed]
    pub numbering: Option<Numbering>,

    /// The alignment of the equation numbering.
    ///
    /// By default, the number is put at the `{end}` of the equation block. Both
    /// `{start}` and `{end}` respects text direction; for absolute positioning,
    /// use `{left}` or `{right}`.
    ///
    /// ```example
    /// #set math.equation(numbering: "(1)", number-align: start)
    ///
    /// With natural units, we know:
    /// $ E^2 = m^2 + p^2 $
    /// ```
    #[default(HAlignment::End)]
    #[parse({
        let option: Option<Spanned<HAlignment>> = args.named("number-align")?;
        if let Some(Spanned { v: align, span }) = option {
            if align == HAlignment::Center {
                bail!(span, "equation number cannot be `center`-aligned");
            }
        }
        option.map(|spanned| spanned.v)
    })]
    pub number_align: HAlignment,

    /// A supplement for the equation.
    ///
    /// For references to equations, this is added before the referenced number.
    ///
    /// If a function is specified, it is passed the referenced equation and
    /// should return content.
    ///
    /// ```example
    /// #set math.equation(numbering: "(1)", supplement: [Eq.])
    ///
    /// We define:
    /// $ phi.alt := (1 + sqrt(5)) / 2 $ <ratio>
    ///
    /// With @ratio, we get:
    /// $ F_n = floor(1 / sqrt(5) phi.alt^n) $
    /// ```
    pub supplement: Smart<Option<Supplement>>,

    /// The contents of the equation.
    #[required]
    pub body: Content,

    /// The size of the glyphs.
    #[internal]

Review comment (suggestion):
Let's wait until the tables PR is merged (shouldn't take long) and then this can be migrated to `OuterHAlignment`: https://github.com/typst/typst/blob/207a3f4f5cebe3e2cfef2b31c52474f09aed7961/crates/typst/src/layout/align.rs#L324-L333

Code after:
    pub numbering: Option<Numbering>,

    /// The alignment of the equation numbering.
    ///
    /// By default, the number is put at the `{end}` of the equation block. Both
    /// `{start}` and `{end}` respects text direction; for absolute positioning,
    /// use `{left}` or `{right}`.
    ///
    /// ```example
    /// #set math.equation(numbering: "(1)", number-align: start)
    ///
    /// With natural units, we know:
    /// $ E^2 = m^2 + p^2 $
    /// ```
    #[default(OuterHAlignment::End)]
    pub number_align: OuterHAlignment,

    /// A supplement for the equation.
    ///
    /// For references to equations, this is added before the referenced number.
    ///
    /// If a function is specified, it is passed the referenced equation and
    /// should return content.
    ///
    /// ```example
    /// #set math.equation(numbering: "(1)", supplement: [Eq.])
    ///
    /// We define:
    /// $ phi.alt := (1 + sqrt(5)) / 2 $ <ratio>
    ///
    /// With @ratio, we get:
    /// $ F_n = floor(1 / sqrt(5) phi.alt^n) $
    /// ```
    pub supplement: Smart<Option<Supplement>>,

    /// The contents of the equation.
    #[required]
    pub body: Content,

    /// The size of the glyphs.
    #[internal]
    #[default(MathSize::Text)]
    #[ghost]
    pub size: MathSize,

    /// The style variant to select.
    #[internal]
    #[ghost]
    pub variant: MathVariant,

    /// Affects the height of exponents.