How to avoid that a large table footer widens the whole table?

It would be cool to have an element that acts as a non-greedy container: don’t request any size, but use everything that’s available once the size is decided, but I don’t think Typst has that currently.

That’s probably the best approach. It’s easy to make two things aligned with a grid or stack:

#let table-with-notes(notes: none, ..args) = layout(size => {
  let tbl = table(..args)
  let w = measure(..size, tbl).width
  stack(dir: ttb, spacing: 0.3em, tbl, block(width: w, notes))
})

#table-with-notes(
  rows: 3,
  columns: 5,
  column-gutter: 0.25em,
  align: (center, center, center, center, center),
  stroke: none,
  table.hline(y: 0, stroke: 1pt),
  [A1], [B1], [C1], [D1], [E1],
  [A2], [B2], [C2], [D2], [E2],
  [A3], [B3], [C3], [D3], [E3],
  table.hline(y: 3, stroke: 1pt),
  notes: [
    #set text(size: 0.8em)
    This is a long footnote. It consists of multiple sentences. Therefore, the table will become very wide.
  ],
)

image

3 Likes