A Typst package distributing leftover space of table or grid into auto columns.
Usage
#import "@preview/fittable:0.0.1": fit
#let data = (
[Item], [Description], [Price],
[Notebook], [A notebook with a long description], [12.00],
)
#fit(
columns: (auto, auto, 5em),
table.header([*Item*], [*Description*], [*Price*]),
..data,
)
API
fit
fit(
func: table,
columns: (),
..children,
) -> content
Lays out a table or grid while distributing the available horizontal space among its auto columns. If the content does not fit, the original column specification is used instead.
Parameters
func(table | grid): The layout function to use. Defaults totable.columns(auto | int | relative | fraction | array): The column specification accepted bytableorgrid. An integer creates that manyautocolumns. Eachautocolumn receives an equal share of the remaining width; fractional columns participate according to their fraction.children(arguments): Cells and named arguments forwarded tofunc.
table.header, table.footer, table.hline, and table.vline are recognized when measuring table contents. Cells using colspan or rowspan are not currently supported.
To fit a grid instead of a table:
#fit(
func: grid,
columns: (auto, 2fr, auto),
gutter: 8pt,
[Left],
[Flexible center],
[Right],
)