Fix auto hanging-indent for centered headings (#6839)
This commit is contained in:
parent
1f41a9f2a1
commit
3d64f7b659
|
|
@ -10,11 +10,11 @@ use typst_library::foundations::{
|
|||
};
|
||||
use typst_library::introspection::{Counter, Locator, LocatorLink};
|
||||
use typst_library::layout::{
|
||||
Abs, AlignElem, Alignment, Axes, BlockBody, BlockElem, ColumnsElem, Em, GridCell,
|
||||
GridChild, GridElem, GridItem, HAlignment, HElem, HideElem, InlineElem, LayoutElem,
|
||||
Length, MoveElem, OuterVAlignment, PadElem, PlaceElem, PlacementScope, Region, Rel,
|
||||
RepeatElem, RotateElem, ScaleElem, Sides, Size, Sizing, SkewElem, Spacing,
|
||||
StackChild, StackElem, TrackSizings, VElem,
|
||||
Abs, AlignElem, Alignment, Axes, BlockBody, BlockElem, ColumnsElem, Em,
|
||||
FixedAlignment, GridCell, GridChild, GridElem, GridItem, HAlignment, HElem, HideElem,
|
||||
InlineElem, LayoutElem, Length, MoveElem, OuterVAlignment, PadElem, PlaceElem,
|
||||
PlacementScope, Region, Rel, RepeatElem, RotateElem, ScaleElem, Sides, Size, Sizing,
|
||||
SkewElem, Spacing, StackChild, StackElem, TrackSizings, VElem,
|
||||
};
|
||||
use typst_library::math::EquationElem;
|
||||
use typst_library::model::{
|
||||
|
|
@ -240,8 +240,9 @@ const HEADING_RULE: ShowFn<HeadingElem> = |elem, engine, styles| {
|
|||
let numbering = Counter::of(HeadingElem::ELEM)
|
||||
.display_at_loc(engine, location, styles, numbering)?
|
||||
.spanned(span);
|
||||
let align = styles.resolve(AlignElem::alignment);
|
||||
|
||||
if hanging_indent.is_auto() {
|
||||
if hanging_indent.is_auto() && align.x == FixedAlignment::Start {
|
||||
let pod = Region::new(Axes::splat(Abs::inf()), Axes::splat(false));
|
||||
|
||||
// We don't have a locator for the numbering here, so we just
|
||||
|
|
|
|||
|
|
@ -177,12 +177,16 @@ pub struct HeadingElem {
|
|||
|
||||
/// The indent all but the first line of a heading should have.
|
||||
///
|
||||
/// The default value of `{auto}` indicates that the subsequent heading
|
||||
/// lines will be indented based on the width of the numbering.
|
||||
/// The default value of `{auto}` uses the width of the numbering as indent
|
||||
/// if the heading is aligned at the [start]($direction.start) of the [text
|
||||
/// direction]($text.dir), and no indent for center and other alignments.
|
||||
///
|
||||
/// ```example
|
||||
/// #set heading(numbering: "1.")
|
||||
/// #heading[A very, very, very, very, very, very long heading]
|
||||
/// = A very, very, very, very, very, very long heading
|
||||
///
|
||||
/// #show heading: set align(center)
|
||||
/// == A very long heading\ with center alignment
|
||||
/// ```
|
||||
#[default(Smart::Auto)]
|
||||
pub hanging_indent: Smart<Length>,
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 860 B |
|
|
@ -101,6 +101,11 @@ comment spans lines
|
|||
#set heading(numbering: "1.1.a.")
|
||||
= State of the Art
|
||||
|
||||
--- heading-hanging-indent-auto-center-align ---
|
||||
#set heading(numbering: "1.1.a.")
|
||||
#show heading: set align(center)
|
||||
= Center aligned
|
||||
|
||||
--- heading-hanging-indent-zero ---
|
||||
#set heading(numbering: "1.1.a.", hanging-indent: 0pt)
|
||||
= State of the Art
|
||||
|
|
|
|||
Loading…
Reference in New Issue