Sets global styling properties for the entire table including stroke (borders), fill, striped rows, and spacing.
Usage
tt_style(
table,
stroke = NULL,
fill = NULL,
striped = NULL,
inset = NULL,
row_gutter = NULL,
column_gutter = NULL,
position = NULL
)Arguments
- table
A
typst_tableobject.- stroke
Stroke (border) specification:
TRUEfor default 1pt black borders, a color name/hex for 1pt borders in that color, or a Typst stroke specification like"2pt + blue". When stroke is set, separator lines fromtt_header_above()are automatically suppressed.- fill
Fill color for the entire table.
- striped
Logical. If
TRUE, alternates row background colors for readability.- inset
Cell padding. Can be a single value (e.g.,
"5pt") or named vector for different padding on each side.- row_gutter
Vertical spacing between rows.
- column_gutter
Horizontal spacing between columns.
- position
Table position on page:
"auto","left","center","right".
Examples
# Add borders and striped rows
tt(mtcars[1:5, 1:3]) |>
tt_style(stroke = TRUE, striped = TRUE)
#> #table(
#> columns: (auto, auto, auto),
#> stroke: 1pt + black,
#> fill: (_, y) => if calc.odd(y) { rgb("#f5f5f5") },
#> table.header(
#> [mpg], [cyl], [disp]
#> ),
#> [21], [6], [160],
#> [21], [6], [160],
#> [22.8], [4], [108],
#> [21.4], [6], [258],
#> [18.7], [8], [360],
#> )
# Custom border color and padding
tt(mtcars[1:5, 1:3]) |>
tt_style(stroke = "gray", inset = "8pt")
#> #table(
#> columns: (auto, auto, auto),
#> stroke: 1pt + gray,
#> inset: 8pt,
#> table.header(
#> [mpg], [cyl], [disp]
#> ),
#> [21], [6], [160],
#> [21], [6], [160],
#> [22.8], [4], [108],
#> [21.4], [6], [258],
#> [18.7], [8], [360],
#> )