How to style table.header / table.footer?

What is the recommended way to style the table.header and table.footer elements?

2 Likes

I don’t think you can at the moment, see Unable to style `table.header` and `table.footer` · Issue #3640 · typst/typst · GitHub.

Depending on the use case it’s still possible to add some styling, the table header is always the first row, the numerous parameters of table which allow passing functions can easily filter out what a header and footer is.

So this works perfectly fine:

#table(
  columns: 3,
  fill: (x, y) => if y == 0 { gray },
  table.header[A][B][C],
  ..range(9).map(x => [#x])
)

image

Table guide – Typst Documentation goes over a bunch of table formatting options and how to use them effectively.

This works well for the header, but to my knowledge it isn’t possible to style the footer because there’s no (straightforward) way to get the amount of rows of a table, or is there?
Would be handy for a result/sum row to make it stand out.

I think so, the functions don’t carry any totals, nor can they easily without making simple use cases harder.