How to have table cells of same height, because of a rowspan in first column?

Hello. I don’t know how abstracted this should be, but I think you would have to use some wrapper either way. The only other way I can think of is similar to How to distribute column widths equally for specific rows in a table? - #4 by Andrew.

#set rotate(reflow: true)

#let even-height(first, ..rest) = {
  if (
    type(first) != content
      or first.func() != table.cell
      or "rowspan" not in first.fields()
  ) {
    return arguments(first, ..rest)
  }
  let height = measure(first).height
  let rows = first.fields().rowspan
  (first,)
  rest.pos().map(block.with(height: height / rows))
}

#context table(
  columns: 9,
  stroke: gray.lighten(65%),
  align: center + horizon,
  table.header(
    table.cell(colspan: 2)[Number of GPUs],
    table.vline(stroke: (paint: black)),
    ..range(7).map(n => [#calc.pow(2, n)]),
  ),
  table.hline(stroke: black),
  ..even-height(
    table.cell(rowspan: 3, rotate(-90deg)[Iteration time (ms)]),
    [Blocking MPI],
    [136.8],
    [69.1],
    [35.9],
    [22.1],
    [14.8],
    [15.1],
    [40.8],

    [Non-blocking MPI],
    [136.8],
    [68.7],
    [34.7],
    [18.2],
    [9.5],
    [5.6],
    [7.2],

    [Masked\ MPI],
    [136.8],
    [68.6],
    [34.3],
    [17.2],
    [8.7],
    [4.4],
    [3.4],
  ),
)

You have to get the height of the first cell somehow, otherwise any ratio or fraction will be against page sizes. You can just specify absolute length to rows, and it will work, but it’s a manual value.

Here is the easiest approach: get the first tall cell, the rest of the cells, measure the total height, get the number of rows spanned, divide one by another and set the height for the rest of the cells to this.

2 Likes