How to Collect Row Indices Based on Table Cell Content?

It’s for a different use case, but the following post could be useful reading:

This effectively what @gezepi has done by defining the countable function.

Btw

You can get around this by splitting the args into the named and positional parts yourself:

#let countable(rowToCount: 0, ..args) = {
  let cells = args.pos()
  let args = args.named()

  //Get the number of columns if given
  let columns = args.named().at("columns", default: 1)
  // in case the columns are given as `(1fr, 1fr)` or similar
  if type(columns) == array { columns = coulumns.len() }
  ...
}

#countable(
  rowToCount: 1,
  columns: 2,
  table.header([a], [b]),
  [1], [],
  [2], [doesn't count],
  [3], [],
)

...

I have also added a small fix regarding counting columns. Feel free to incorporate any or all of this into your answer if you want :slight_smile:

1 Like