Sets column widths as proportions that fill the page or container width.
Widths are converted to Typst fr (fractional) units.
Details
Widths are relative proportions, not absolute values. For example,
tt_widths(tbl, 1, 2, 1) creates columns at 25%, 50%, 25% of the container width.
Examples
# Equal widths
tt(mtcars[1:5, 1:3], rownames = FALSE) |> tt_widths(1, 1, 1)
#> #table(
#> columns: (1fr, 1fr, 1fr),
#> stroke: none,
#> table.hline(stroke: 1pt),
#> [mpg], [cyl], [disp],
#> table.hline(stroke: 0.5pt),
#> [21], [6], [160],
#> [21], [6], [160],
#> [22.8], [4], [108],
#> [21.4], [6], [258],
#> [18.7], [8], [360],
#> table.hline(stroke: 1pt)
#> )
# Proportional widths (25%, 50%, 25%)
tt(mtcars[1:5, 1:3], rownames = FALSE) |> tt_widths(1, 2, 1)
#> #table(
#> columns: (1fr, 2fr, 1fr),
#> stroke: none,
#> table.hline(stroke: 1pt),
#> [mpg], [cyl], [disp],
#> table.hline(stroke: 0.5pt),
#> [21], [6], [160],
#> [21], [6], [160],
#> [22.8], [4], [108],
#> [21.4], [6], [258],
#> [18.7], [8], [360],
#> table.hline(stroke: 1pt)
#> )
# Named columns
tt(mtcars[1:5, 1:3], rownames = FALSE) |> tt_widths(mpg = 1, cyl = 2, disp = 1)
#> #table(
#> columns: (1fr, 2fr, 1fr),
#> stroke: none,
#> table.hline(stroke: 1pt),
#> [mpg], [cyl], [disp],
#> table.hline(stroke: 0.5pt),
#> [21], [6], [160],
#> [21], [6], [160],
#> [22.8], [4], [108],
#> [21.4], [6], [258],
#> [18.7], [8], [360],
#> table.hline(stroke: 1pt)
#> )