Hi, I would like to set the first row in my tables as the table header. This is particularly useful when importing tables from csv files, for example.
Hi and welcome to the forum!
This should achieve what you’re looking for:
#show table: it => {
let fields = it.fields()
let children = fields.remove("children")
if children.at(0, default: none).func() == table.header {
// already has a header
return it
}
let cols = it.columns.len()
let firstrow = children.slice(0, cols)
let rest = children.slice(cols)
table(
..fields,
table.header(..firstrow),
..rest
)
}
(Inspiration taken from here)
3 Likes