It is worth noting that Typst’s rect
(Rectangle Function – Typst Documentation) and block
(Block Function – Typst Documentation) built-in elements also have a radius
parameter, rendering CeTZ unnecessary here.
This can be used to provide an outer outer stroke to a table, as follows:
#block(
// block will provide stroke with radius around the table
// we have to ensure the table doesn't fight it with its own stroke
stroke: black,
radius: 5pt,
table(
columns: 3,
stroke: (x, y) => (
// Only draw top stroke if we're beyond the first row
// Avoid conflicting with the outer block stroke
top: if y > 0 { black },
// Only draw left stroke if we're beyond the first column
// Avoid conflicting with the outer block stroke
left: if x > 0 { black }
// No bottom or right stroke so that cells at the last row
// or last column don't generate stroke conflicting with
// the block outer stroke
),
table.header([*Name*], [*Amount*], [*Location*]),
[Joseph], [5], [United States],
[Mary], [10], [Germany],
)
)
Note that we have to customize the table stroke to ensure it doesn’t conflict with the block’s outer stroke by disabling top and left stroke from cells at the first row and first column respectively, as well as disabling bottom and right stroke from all cells so that cells at the last row and at the last column respectively don’t override the outer block’s stroke at that position.
If you’d like radius for cells within the table, you’ll have to manually use #rect(radius: ...)
around your cells’ contents, which can be unwieldy at the moment (see How to make each grid cell take up all available space?).