#Stylistic recommendations for tables

19 messages · Page 1 of 1 (latest)

mossy osprey
#

?r

#let rule_table(..children) = table(
  stroke: gray + 0.2pt, columns: (1fr, 1fr, 1fr, 1fr), table.cell([Rules], colspan: 4), [Name], [Default], [Type], [Valid], ..children,
)
#rule_table(
  [Class names], [ PASCAL_CASE ], [ enum ], [["FLAT_CASE","PASCAL_CASE","SNAKE_CASE","KEBAB_CASE","UPPERCASE","SCREAMING_SNAKE_CASE","CAMEL_SNAKE_CASE","PASCAL_SNAKE_CASE","SCREAMING_KEBAB_CASE","TRAIN_CASE","CAMEL_CASE","UNKNOWN","ANY"]], [Method names], [ CAMEL_CASE ], [enum], [["FLAT_CASE","PASCAL_CASE","SNAKE_CASE","KEBAB_CASE","UPPERCASE","SCREAMING_SNAKE_CASE","CAMEL_SNAKE_CASE","PASCAL_SNAKE_CASE","SCREAMING_KEBAB_CASE","TRAIN_CASE","CAMEL_CASE","UNKNOWN","ANY"]], [Variable names], [ ANY ], [enum], [["FLAT_CASE","PASCAL_CASE","SNAKE_CASE","KEBAB_CASE","UPPERCASE","SCREAMING_SNAKE_CASE","CAMEL_SNAKE_CASE","PASCAL_SNAKE_CASE","SCREAMING_KEBAB_CASE","TRAIN_CASE","CAMEL_CASE","UNKNOWN","ANY"]],
)

I have the above table and am looking for some references or sudgestions on how to make it look better, thanks

raw ravine
#

Just to be clear: you are asking for ideas to make the table look prettier, not the Typst syntax, right?

mossy osprey
#

yes yes

cerulean ivy
#

Small Guide to Making Nice Tables, by Markus Püschel

cerulean ivy
#

the details are for LaTeX but the actual rendered tables are good

#

in general, less is more when you're rendering tables: separate the headers from the body; minimize the number of lines you use, especially vertical lines; it's usually better to increase the spacing between rows than to insert lines or zebra-stripe the rows

#

following those tips I'd go with something like this

#

?r

#let rule_table(..children) = {
  show table.cell.where(y: 0): set text(weight: "bold", size: 14pt)
  show table.cell.where(y: 1): set text(weight: "bold")
  show table.cell.where(x: 3): set text(size:10pt)
  table(
    stroke: none,
    columns: (auto, auto, auto, auto),
    table.hline(stroke: 2pt),
    table.cell([Rules], colspan: 4),
    [Name],
    [Default],
    [Type],
    [Valid],
    table.hline(),
    ..children,
    table.hline(stroke: 2pt),
  )
}
#rule_table(
  [Class names],
  [ `PASCAL_CASE` ],
  [ enum ],
  [`["FLAT_CASE", "PASCAL_CASE", "SNAKE_CASE", "KEBAB_CASE", "UPPERCASE", "SCREAMING_SNAKE_CASE", "CAMEL_SNAKE_CASE", "PASCAL_SNAKE_CASE", "SCREAMING_KEBAB_CASE", "TRAIN_CASE", "CAMEL_CASE", "UNKNOWN", "ANY"]`],
  [Method names],
  [ `CAMEL_CASE` ],
  [enum],
  [`["FLAT_CASE", "PASCAL_CASE", "SNAKE_CASE", "KEBAB_CASE", "UPPERCASE", "SCREAMING_SNAKE_CASE", "CAMEL_SNAKE_CASE", "PASCAL_SNAKE_CASE", "SCREAMING_KEBAB_CASE", "TRAIN_CASE", "CAMEL_CASE", "UNKNOWN", "ANY"]`],
  [Variable names],
  [ `ANY` ],
  [enum],
  [`["FLAT_CASE", "PASCAL_CASE", "SNAKE_CASE", "KEBAB_CASE", "UPPERCASE", "SCREAMING_SNAKE_CASE", "CAMEL_SNAKE_CASE", "PASCAL_SNAKE_CASE", "SCREAMING_KEBAB_CASE", "TRAIN_CASE", "CAMEL_CASE", "UNKNOWN", "ANY"]`],
)
mossy osprey
#

thank you very much, i will iterate on what you have provided as well as studying the presentations given

raw ravine
#

That suggestion is very much in line with what I'd have suggested. Just three small caveats on my side:

  • If Rules is a header that applies to all columns, it would probably work best as a table caption or section heading.
  • If the content of Valid is not supposed to be the array itself but the collection of values, you could consider presenting them differently, like in a bullet list.
  • Valid is, by far, the column with the most content. To avoid wasting a lot of empty space in the other columns, I'd make that column much wider than the others (by how much, it would be a question of trial and error)
mossy forge
#

i'd also suggest using table.header([each], [cell], [at], [the], [top])

mossy osprey
#

Also i noticed no changes from header to no header, don't really know what it does

mossy forge
mossy forge