Can I make lists appear in two colums?

Can I make a show rule such that lists appear in 2 columns instead of 1?

// some show rule

- this
- list is
- spread
- accross 2 columns
- instead of 1

Currently I’m using the code below, hope this can help you:

/// Arrange the children of a list in a grid with `n` columns and `dir` direction.
/// - `n` (int): The number of columns.
/// - `dir` (ltr | ttb): The direction of the grid.
/// -> The list with the children arranged in a grid.
#let spread-list(n: 2, dir: ltr, it) = {
  let args = it.fields()
  let children = if it.has("children") {
    it.children
  } else {
    ()
  }
  if children.len() <= 1 {
    return it
  }
  args.remove("children")
  let rearrange(arr) = {
    if dir == ltr {
      return arr
    }
    if dir == ttb {
      let rows = calc.ceil(arr.len() / n)
      return range(0, rows).map(i => range(0, n).map(j => arr.at(j * rows + i, default: none))).flatten()
    }
  }
  return grid(
    columns: (100% / n,) * n,
    row-gutter: if args.tight {
      0.65em // Default value of par.leading
    } else {
      1em // Not accurate
    },
    ..rearrange(children).map(x => {
      if x != none {
        list(x, ..args)
      }
    })
  )
  repr(it)
}

#show list: spread-list.with(n: 3, dir: ttb)

- #lorem(1)
  - Sub #lorem(1)
- #lorem(2)
- #lorem(3)
- #lorem(4)
- #lorem(5)
- #lorem(6)
- #lorem(4)

The same function does not work for enum since the it has numbering, which would be painful to handle by re-constructing the enum item.

1 Like

Here’s a crude way to do it:

#show list: it => context {
  let height = measure(it).height / 2
  block(height: height, columns(2, it))
}

This will usually not spread the list in a pleasant way. If you want it to look nice you could try fiddling around with the height calculation, maybe measuring the children individually (it.children).