mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
parent
0804a9e25d
commit
7b61d722dd
@ -114,8 +114,27 @@ pub struct TableElem {
|
|||||||
pub stroke: Option<Stroke>,
|
pub stroke: Option<Stroke>,
|
||||||
|
|
||||||
/// How much to pad the cells' content.
|
/// How much to pad the cells' content.
|
||||||
#[default(Abs::pt(5.0).into())]
|
///
|
||||||
pub inset: Rel<Length>,
|
/// ```example
|
||||||
|
/// #table(
|
||||||
|
/// inset: 10pt,
|
||||||
|
/// [Hello],
|
||||||
|
/// [World],
|
||||||
|
/// )
|
||||||
|
///
|
||||||
|
/// #table(
|
||||||
|
/// columns: 2,
|
||||||
|
/// inset: (
|
||||||
|
/// x: 20pt,
|
||||||
|
/// y: 10pt,
|
||||||
|
/// ),
|
||||||
|
/// [Hello],
|
||||||
|
/// [World],
|
||||||
|
/// )
|
||||||
|
/// ```
|
||||||
|
#[fold]
|
||||||
|
#[default(Sides::splat(Abs::pt(5.0).into()))]
|
||||||
|
pub inset: Sides<Option<Rel<Length>>>,
|
||||||
|
|
||||||
/// The contents of the table cells.
|
/// The contents of the table cells.
|
||||||
#[variadic]
|
#[variadic]
|
||||||
@ -141,7 +160,7 @@ impl Layout for TableElem {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, child)| {
|
.map(|(i, child)| {
|
||||||
let mut child = child.padded(Sides::splat(inset));
|
let mut child = child.padded(inset);
|
||||||
|
|
||||||
let x = i % cols;
|
let x = i % cols;
|
||||||
let y = i / cols;
|
let y = i / cols;
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 12 KiB |
@ -29,6 +29,38 @@
|
|||||||
[A], [B], [C]
|
[A], [B], [C]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
---
|
||||||
|
// Test inset.
|
||||||
|
#table(
|
||||||
|
columns: 3,
|
||||||
|
inset: 10pt,
|
||||||
|
[A], [B], [C]
|
||||||
|
)
|
||||||
|
|
||||||
|
#table(
|
||||||
|
columns: 3,
|
||||||
|
inset: (y: 10pt),
|
||||||
|
[A], [B], [C]
|
||||||
|
)
|
||||||
|
|
||||||
|
#table(
|
||||||
|
columns: 3,
|
||||||
|
inset: (left: 20pt, rest: 10pt),
|
||||||
|
[A], [B], [C]
|
||||||
|
)
|
||||||
|
|
||||||
|
#table(
|
||||||
|
columns: 2,
|
||||||
|
inset: (
|
||||||
|
left: 20pt,
|
||||||
|
right: 5pt,
|
||||||
|
top: 10pt,
|
||||||
|
bottom: 3pt,
|
||||||
|
),
|
||||||
|
[A],
|
||||||
|
[B],
|
||||||
|
)
|
||||||
|
|
||||||
---
|
---
|
||||||
// Ref: false
|
// Ref: false
|
||||||
#table()
|
#table()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user