Why does row gutter in a table interrupt the strokes?

Consider:

#let fancy_table(num_headers: 0, num_left: 1, ..sink) = {
  block(stroke: (bottom: 1.5pt + black, top: 1.5pt + black), inset: 3pt)[
    #table(
      stroke: (x, y) => {
        if (y == num_headers - 1) { (bottom: 0.9pt + black) }
        if (x == num_left - 1) { (right: 0.9pt + black) }
      },
      align: (x, y) => (
        if x >= num_left { left } else { right }
      ),
      ..sink,
    )
  ]
}

Works great until I add row-gutter: 5pt. For some reason, the strokes that are drawn don’t extend into the gutter.

Also, the strokes are drawn even if the cell is column span, which I guess is a separate question.

1 Like

You are looking for table.hline and table.vline.

From the table stroke documentation:

[…] stroke the cells

and

If it is necessary to place lines which can cross spacing between cells produced by the gutter option, or to override the stroke between multiple specific cells, consider specifying one or more of table.hline and table.vline alongside your table cells.

#let fancy_table(num_headers: 0, num_left: 1, ..sink) = {
  block(stroke: (bottom: 1.5pt + black, top: 1.5pt + black), inset: 3pt)[
    #table(
      stroke: none,
      align: (x, y) => (
        if x >= num_left { left } else { right }
      ),
      ..if num_headers > 0 {
        (table.hline(y: num_headers - 1, stroke: 0.9pt + black, position: bottom),)
      },
      ..if num_left > 0 {
        (table.vline(x: num_left - 1, stroke: 0.9pt + black, position: right),)
      },
      ..sink,
    )
  ]
}
2 Likes

Very logical solution, thank you!