Here is a hack solution
- We can create a new
table
in the show rule, from the old table- If we just do this, it recurses. So we mark the new table with a label so that it’s not done again
- You can now apply custom styles to tables with headers. But it overwrites any even manually specified styles unfortunately
#show table: it => {
let contains-header = it.fields().children.first().func() == table.header
if not contains-header or (it.has("label") and it.label == <table-style-done>) {
it
} else {
let new-style = (stroke: (x, y) => (
top: if y == 0 or y == 1 { 1pt + red } else { none })
)
let fields = it.fields()
let chld = fields.remove("children")
// note, this overwrites any previous stroke configuration
[#table(..fields, ..new-style, ..chld)<table-style-done>]
}
}
#table(columns: 2, table.header[a][b], ..range(10).map(str))
#table(columns: 3, table.header[a][b][c], ..range(10).map(str))
#table(columns: 3, ..range(10).map(str))