mirror of
https://github.com/typst/typst
synced 2025-05-20 03:55:29 +08:00
parent
85b1d1d4dd
commit
219c1c9ed0
@ -6,8 +6,8 @@ use crate::foundations::{
|
|||||||
cast, elem, scope, Array, Content, Fold, NativeElement, Smart, StyleChain,
|
cast, elem, scope, Array, Content, Fold, NativeElement, Smart, StyleChain,
|
||||||
};
|
};
|
||||||
use crate::layout::{
|
use crate::layout::{
|
||||||
Axes, BlockElem, Em, Fragment, GridLayouter, HAlign, Layout, Length, Regions, Sizing,
|
Align, Axes, BlockElem, Em, Fragment, GridLayouter, HAlign, Layout, Length, Regions,
|
||||||
Spacing, VAlign,
|
Sizing, Spacing, VAlign,
|
||||||
};
|
};
|
||||||
use crate::model::{Numbering, NumberingPattern, ParElem};
|
use crate::model::{Numbering, NumberingPattern, ParElem};
|
||||||
use crate::text::TextElem;
|
use crate::text::TextElem;
|
||||||
@ -155,18 +155,20 @@ pub struct EnumElem {
|
|||||||
/// If set to `{auto}`, uses the spacing [below blocks]($block.below).
|
/// If set to `{auto}`, uses the spacing [below blocks]($block.below).
|
||||||
pub spacing: Smart<Spacing>,
|
pub spacing: Smart<Spacing>,
|
||||||
|
|
||||||
/// The horizontal alignment that enum numbers should have.
|
/// The alignment that enum numbers should have.
|
||||||
///
|
///
|
||||||
/// By default, this is set to `{end}`, which aligns enum numbers
|
/// By default, this is set to `{end + top}`, which aligns enum numbers
|
||||||
/// towards end of the current text direction (in left-to-right script,
|
/// towards end of the current text direction (in left-to-right script,
|
||||||
/// for example, this is the same as `{right}`). The choice of `{end}`
|
/// for example, this is the same as `{right}`) and at the top of the line.
|
||||||
/// for horizontal alignment of enum numbers is usually preferred over
|
/// The choice of `{end}` for horizontal alignment of enum numbers is
|
||||||
/// `{start}`, as numbers then grow away from the text instead of towards
|
/// usually preferred over `{start}`, as numbers then grow away from the
|
||||||
/// it, avoiding certain visual issues. This option lets you override this
|
/// text instead of towards it, avoiding certain visual issues. This option
|
||||||
/// behavior, however.
|
/// lets you override this behavior, however. (Also to note is that the
|
||||||
|
/// [unordered list]($list) uses a different method for this, by giving the
|
||||||
|
/// `marker` content an alignment directly.).
|
||||||
///
|
///
|
||||||
/// ````example
|
/// ````example
|
||||||
/// #set enum(number-align: start)
|
/// #set enum(number-align: start + bottom)
|
||||||
///
|
///
|
||||||
/// Here are some powers of two:
|
/// Here are some powers of two:
|
||||||
/// 1. One
|
/// 1. One
|
||||||
@ -176,8 +178,8 @@ pub struct EnumElem {
|
|||||||
/// 16. Sixteen
|
/// 16. Sixteen
|
||||||
/// 32. Thirty two
|
/// 32. Thirty two
|
||||||
/// ````
|
/// ````
|
||||||
#[default(HAlign::End)]
|
#[default(HAlign::End + VAlign::Top)]
|
||||||
pub number_align: HAlign,
|
pub number_align: Align,
|
||||||
|
|
||||||
/// The numbered list's items.
|
/// The numbered list's items.
|
||||||
///
|
///
|
||||||
@ -233,7 +235,7 @@ impl Layout for EnumElem {
|
|||||||
// Vertically align to the top to avoid inheriting `horizon` or `bottom`
|
// Vertically align to the top to avoid inheriting `horizon` or `bottom`
|
||||||
// alignment from the context and having the number be displaced in
|
// alignment from the context and having the number be displaced in
|
||||||
// relation to the item it refers to.
|
// relation to the item it refers to.
|
||||||
let number_align = self.number_align(styles) + VAlign::Top;
|
let number_align = self.number_align(styles);
|
||||||
|
|
||||||
for item in self.children() {
|
for item in self.children() {
|
||||||
number = item.number(styles).unwrap_or(number);
|
number = item.number(styles).unwrap_or(number);
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 18 KiB |
@ -20,7 +20,13 @@
|
|||||||
16. c
|
16. c
|
||||||
|
|
||||||
---
|
---
|
||||||
// Number align option should not be affected by the context
|
#set enum(number-align: center + horizon)
|
||||||
|
1. #box(fill: teal, inset: 10pt )[a]
|
||||||
|
8. #box(fill: teal, inset: 10pt )[b]
|
||||||
|
16. #box(fill: teal,inset: 10pt )[c]
|
||||||
|
|
||||||
|
---
|
||||||
|
// Number align option should not be affected by the context.
|
||||||
#set align(center)
|
#set align(center)
|
||||||
#set enum(number-align: start)
|
#set enum(number-align: start)
|
||||||
|
|
||||||
@ -32,13 +38,14 @@
|
|||||||
64. h
|
64. h
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test valid number align values (horizontal)
|
// Test valid number align values (horizontal and vertical)
|
||||||
// Ref: false
|
// Ref: false
|
||||||
#set enum(number-align: start)
|
#set enum(number-align: start)
|
||||||
#set enum(number-align: end)
|
#set enum(number-align: end)
|
||||||
#set enum(number-align: left)
|
#set enum(number-align: left)
|
||||||
|
#set enum(number-align: center)
|
||||||
#set enum(number-align: right)
|
#set enum(number-align: right)
|
||||||
|
|
||||||
---
|
|
||||||
// Error: 25-28 expected `start`, `left`, `center`, `right`, or `end`, found top
|
|
||||||
#set enum(number-align: top)
|
#set enum(number-align: top)
|
||||||
|
#set enum(number-align: horizon)
|
||||||
|
#set enum(number-align: bottom)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user