Grid/Table make all the columns 1fr and scale with the data

Hello, when I create a grid in Typst I must specify the width of the columns in the begining of the grid. E.g:

grid(
    columns: (1fr, 1fr, 1fr)
    ...
)

But I want to get an array of people an put them all in a grid of one row. So I would like to do something like this (note the third line):

#let participants(partDict) = {
  grid(
    columns: repeat(partDict.len(), 1fr), // But this doesnt exist
    gutter: 10pt,
    align: center + top,

    ..partDict,
  )
}


#let people = (
  "Adam", "Alice", "Dan"
)


#participants(people)

Any ideas on how that could be done?

Hello. This is used multiple times in Tables – Typst Documentation and documented in Array Type – Typst Documentation.

#let participants(participant-list) = grid(
  columns: (1fr,) * participant-list.len(),
  gutter: 10pt,
  align: center + top,
  ..participant-list,
)

#let people = (
  "Adam",
  "Alice",
  "Dan",
)

#participants(people)
1 Like

Thank you!

1 Like