How to pass an array of to #grid?

Solution:

#let img_dir = "./"

#let figure_two_images(caption, ..pathes) = figure(
  grid(
    columns: 2,
    gutter: 2mm,
    ..pathes.pos().map(path => image(img_dir + path)),
  ),
  caption: caption,
)

#figure_two_images("Images", "1.png", "2.png", "3.png")

The key concept is using .. to define a function with arbitrary parameters and to spread an array.

For more details, check out my other post and the related Typst documentation page.

1 Like