How to wrap long "unbreakable" text in a table cell?

You can use a regex that matches the data in the “Tran ID” column, and use it to put a soft hyphen (if you want a hyphen) or a zero-width space (if you don’t want a hyphen) between each character. You also want to enable hyphenation in general (or scoped to the table), so that “Withdrawals” doesn’t overflow:

#set text(hyphenate: true)
#show regex("(S[0-9]+)+"): it => {
  it.text.codepoints().join(sym.zws) // or .join[-?]
}

#table(
  columns: 8,
  ..txn.flatten()
)

If you can’t use a regex, you could also use a show rule limited to the third column, though you then probably want to scope it to that one table:

#{
  show table.cell.where(x: 2): cell => {
    show regex("\b.+?\b"): it => it.text.codepoints().join(sym.zws)
    cell
  }

  table(
    columns: 8,
    ..txn.flatten()
  )
}
1 Like