Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Typst, how can I make my table 100% page width?

Tags:

typst

Currently, my table does not take full page width. In the documentation for typst table, I also cannot find even one mention of "width". How can I make it take up full page width?

#table(
  columns: 2, align: left,
  [Sentence Index], [Text],
  [1549], [A ++], 
  [362], [2000 Carr Futures], 
  [642], [Slope : 0.1171 ( 0.0022 )], 
  [1089], [Canon sx40 or canon s100 ?]
)

(Also, I've included my table template below, even though it might not be relevant to the question)

  // Custom rule: table
  set table(
    stroke: none,
    fill: (x, y) => if calc.even(y) == false { gray.transparentize(80%) },
    inset: (x: 1.0em, y: 0.5em),
    gutter: 0.2em, row-gutter: 0em, column-gutter: 0em
  )
  show table.cell.where(y: 0) : set text(weight: "bold")

enter image description here

like image 451
Hykilpikonna Avatar asked Sep 01 '25 03:09

Hykilpikonna


1 Answers

You can achieve this using fractional units:

#set page(margin: 0.1in)

= Using two fractions
#table(
  columns: (0.25fr, 1fr), align: left,
  [Sentence Index], [Text],
  [1549], [A ++], 
  [362], [2000 Carr Futures], 
  [642], [Slope : 0.1171 ( 0.0022 )], 
  [1089], [Canon sx40 or canon s100 ?]
)

= Using `auto`
#table(
  columns: (auto, 1fr), align: left,
  [Sentence Index], [Text],
  [1549], [A ++], 
  [362], [2000 Carr Futures], 
  [642], [Slope : 0.1171 ( 0.0022 )], 
  [1089], [Canon sx40 or canon s100 ?]
)

Typst will allocate the full available width across your fractions proportionally. So in the example above, column 1 will be 25% the width of column 2, and both together will use the whole page.

You can use auto as the width to take up only as much space as the max cell width for that column. In which case the other fraction column will take up all remaining space.

enter image description here

like image 94
ntjess Avatar answered Sep 03 '25 06:09

ntjess