#How do I set the background and text color of the first column in a table?

11 messages · Page 1 of 1 (latest)

fallen tulip
#

I have the table below. How would I set the background color of the first column (Letter) to blue and its text to white? TIA.

#figure(align(center)[#table(
    columns: 2,
    align: (col, row) => (left, right,).at(col),
    table.header(
      table.cell(align: center)[*Letter*],
      table.cell(align: center)[*Number*],
    ),    
    [a], [1],
    [b], [2],
    [c], [3],
  )],
  caption: [My table]
)
worthy prairie
#

use tablex

#

?r

#import "@preview/tablex:0.0.8": tablex, rowspanx, colspanx


#figure(align(center)[#tablex(
    columns: 2,
    map-cells: cell => {
      if cell.x == 0 {
        cell.content = {
          set text(white)
          cell.content
        }
        cell.fill = blue
      }
      cell
    },
    align: (col, row) => (left, right,).at(col),
    [*Letter*], [*Height*],    
    [a], [1],
    [b], [2],
    [c], [3],
  )],
  caption: [My table]
)
tacit chasm
tacit chasm
worthy prairie
#

That's also possible, I just personally don't like using show rules for single elements

tacit chasm
#

:p

#

And have more features, less bugs and so on