How to expand a table's width over the page margins?

I have a margin on the page set to something like - (left: 4cm, bottom: 2cm, top: 2cm, right: 2cm)

How should I increase the width of the table? It looks like this

and here is my code

#figure(
  box(width: 15fr, table(
    stroke: none,
    columns: (auto, 2fr, 2fr, 2fr),
    align: (left, center, center, center),
    table.hline(),
    table.header(
      [header 1], [header 2], [header 3], [header 4],
    ),
    table.hline(),
    [#lorem(4)],[123456789456123456],[0.123456789456123456], [0.123456789456123456],
    [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
    [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
    [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
    table.hline(),
  )),
  caption: [#lorem(10)],
)

I tried adding the box but that does nothing

Update

I tried block instead of box and set it’s width, but it expands only to the left and not to the center or right

Code
#figure(
  block(width: 60em, table(
    stroke: none,
    columns: (auto,) + 3 * (auto,),
    align: (left, center, center, center),
    table.hline(),
    table.header(
      [header 1], [header 2], [header 3], [header 4],
    ),
    table.hline(),
    [#lorem(4)],[123456789456123456],[0.123456789456123456], [0.123456789456123456],
    [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
    [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
    [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
    table.hline(),
  )),
  caption: [#lorem(10)],
)

Wrapping the table in a call to align achieves this:

#figure(
  block(width: 60em,
    align(center, //Align starts here
      table(
        stroke: none,
        columns: (auto,) + 3 * (auto,),
        align: (left, center, center, center),
        table.hline(),
        table.header(
          [header 1], [header 2], [header 3], [header 4],
        ),
        table.hline(),
        [#lorem(4)],[123456789456123456],[0.123456789456123456], [0.123456789456123456],
        [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
        [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
        [#lorem(4)], [0.123456789456123456], [0.123456789456123456], [0.123456789456123456],
        table.hline(),
      )
    ) //Align ends here
  ),
  caption: [#lorem(10)],
)
1 Like

You can use pad with negative lengths to “bypass” the margins:

#set page(margin: (x: 5em))

#lorem(20)

#figure(table(
  columns: (1fr,) * 4,
  ..([abcabcabcabc],)*4*3
), caption: [Short table])

#pad(x: -4em, figure(table(
  columns: (1fr,) * 4,
  ..([abcabcabcabc],)*4*3
), caption: [Long table]))

By the way, I’ve updated your post title to better fit our guidelines: How to post in the Questions category

Please ensure your title is a Typst question you’d ask to a friend. :slight_smile:

1 Like

I tried doing this, but using pad worked. Thanks for the help