How can I adjust line strokes in tables?

Hi everyone!

Im trying to edit my tables to a specific style. I need the outer stroke of the table to be bolder than the lines separating the rows. There must not be vertical lines separating the columns, only horizontal lines between rows (which have to be thinner than the first line on top of the header and last line underneath the last row). In some cases I need to add a vertical line separating the first column from the rest which has to be as bold as first and last line described previously.

Can someone help me here?

Thank you in advance! :grin:

These are two examples of the table style im trying to achieve

Hi, welcome!

You can disable the default stroke and use table.hline and table.vline.

#table(
  columns: 3,
  stroke: none,
  table.hline(),
  table.header([a], [b], [c]),
  table.hline(stroke: 0.5pt),
  [d], [e], [f],
  [g], [h], [i],
  table.hline(),
)

#table(
  columns: 3,
  stroke: none,
  table.hline(),
  table.header([a], [b], [c]),
  table.hline(stroke: 0.5pt),
  [d], table.vline(stroke: 0.5pt), [e], [f],
  [g], [h], [i],
  table.hline(),
)

You might be interested in the Table Guide:

1 Like

This seems similar to the example under table.cell in the docs: Table Function – Typst Documentation

All you need to do is edit the stroke component in the set rule and optionally include a table.vline:

#show table.cell.where(y: 0): strong
#set table(
  stroke: (x, y) => if y == 0 {
    (top: 1pt, bottom: 0.7pt)
  } else if y > 1 {
    (top: 0pt, bottom: 1pt)
  },
  align: (x, y) => (
    if x > 0 { center }
    else { left }
  ),
)

#table(
  columns: 3,
  table.header(
    [Substance],
    table.vline(stroke: 0.7pt),
    [Subcritical °C],
    [Supercritical °C],
  ),
  [Hydrochloric Acid],
  [12.0], [92.1],
  [Sodium Myreth Sulfate],
  [16.6], [104],
)

1 Like