How can I set the font size for the first column excluding the header row inside a table?

Hi!

I’m migrating from the tablex package to typst’s native table function as per the developer’s recommendation as well as improved compile times and performance (especially with tinymist).

Is it possible to format the content of each cell of the first column except the header (the first row) so that it has a bigger font size using table? If so, how can I do that?

Here is a basic example:

#let ktable(..cells) = table(
  stroke: (x: none, y: color.rgb("#DEDEDE")),

  columns: (50pt, 50pt, auto, auto),
  inset: 8pt,

  table.hline(stroke: black),

  table.cell(align: center)[*Character*],
  table.cell(align: center)[*Keyword*],
  table.cell(align: center)[*Index*],
  table.cell(align: center)[*Story*],
  table.hline(stroke: black),

  ..cells,

  table.hline(stroke: black),
)

#ktable(
  [吾], [I], [11], [#lorem(10)],

  [明], [bright], [12], [#lorem(10)],

  [唱], [chant], [13], [#lorem(10)],
)

Here, I would like to have all the cells with Japanese characters in them to be 22pt big.

Hello, it’s fairly simple if you add a show rule to table.cell.

#let ktable(..cells) = {
  show table.cell: c => {
    if c.y == 0 {
      return strong(c)
    }
    if c.y > 0 and c.x == 0 {
      return text(22pt, c)
    }
    c
  }
  table(
    stroke: (
      x: none, 
      y: color.rgb("#DEDEDE")
    ),
    columns: (50pt, 50pt, auto, auto),
    inset: 8pt,
  
    table.hline(stroke: black),
  
    table.cell(align: center)[Character],
    table.cell(align: center)[Keyword],
    table.cell(align: center)[Index],
    table.cell(align: center)[Story],
    table.hline(stroke: black),
  
    ..cells,
  
    table.hline(stroke: black),
  )
}

#ktable(
  [吾], [I], [11], [#lorem(10)],

  [明], [bright], [12], [#lorem(10)],

  [唱], [chant], [13], [#lorem(10)],
)

1 Like