I need help splitting a table horizontally

I haven’t been able to find a good solution to this seemingly pretty trivial problem

There’s a post similar to this one
here
but I don’t know if it’s because I’m not very familiar with Typst syntax but none of the solutions under that post worked for me

for reference this is what I have

#table(
  columns: 2,
  align: (x, y) => if x == 0 or y == 0 { left } else { center },
  stroke: (x, y) => (
    left: if y == 0 and x > 0 { white } else { black },
    rest: black,
  ),
  fill: (_, y) => if y == 0 { black } else if y >= 1 { white } else { none },

  table.header([$y$], [$y = sin theta$]),
  [$0º = 0$], [$0$],
  [$30º = pi / 6$], [$.5$],
  [$45º = pi / 4$], [$.70711$],
  [$60º = pi / 3$], [$.86603$],
  [$90º = pi / 2$], [$1$],
  [$120º = 2 pi / 3$], [$.86603$],
  [$135º = 3 pi / 4$], [$.70711$],
  [$150º = 5 pi / 6$], [$.5$],
  [$180º = pi$], [$0$],

  [$210º = 7 pi / 6$], [$-.5$],
  [$225º = 5 pi / 4$], [$-.70711$],
  [$240º = 4 pi / 3$], [$-.86603$],
  [$270º = 3 pi / 2$], [$-1$],
  [$300º = 5 pi / 3$], [$-.86603$],
  [$315º = 7 pi / 4$], [$-.70711$],
  [$330º = 11 pi / 6$], [$-.5$],
  [$360º = 2 pi$], [$0$],
)

Right now this is what it looks like

And this is what I want

I tried adding columns but I didn’t get the result I wanted, is there not a #colbreak() equivalent for tables specifically?

If you want two tables, use two tables ? No ? If the problem is to place your tables side-by side, you can use grid to place them as you wish:

#align(center, grid(
  columns: 2,
  gutter: 2cm,
  table(
    columns: 2,
    align: (x, y) => if x == 0 or y == 0 { left } else { center },
    stroke: (x, y) => (
      left: if y == 0 and x > 0 { white } else { black },
      rest: black,
    ),
    fill: (_, y) => if y == 0 { black } else if y >= 1 { white } else { none },
  
    table.header(text(white,$y$), text(white,$y = sin theta$)),
    $0º = 0$, $0$,
    $30º = pi / 6$, $.5$,
    $45º = pi / 4$, $.70711$,
    $60º = pi / 3$, $.86603$,
    $90º = pi / 2$, $1$,
    $120º = 2 pi / 3$, $.86603$,
    $135º = 3 pi / 4$, $.70711$,
    $150º = 5 pi / 6$, $.5$,
    $180º = pi$, $0$,
  ),
  table(
    columns: 2,
    align: (x, y) => if x == 0 or y == 0 { left } else { center },
    stroke: (x, y) => (
      left: if y == 0 and x > 0 { white } else { black },
      rest: black,
    ),
    fill: (_, y) => if y == 0 { black } else if y >= 1 { white } else { none },
  
    table.header(text(white,$y$), text(white,$y = sin theta$)),
    $210º = 7 pi / 6$, $-.5$,
    $225º = 5 pi / 4$, $-.70711$,
    $240º = 4 pi / 3$, $-.86603$,
    $270º = 3 pi / 2$, $-1$,
    $300º = 5 pi / 3$, $-.86603$,
    $315º = 7 pi / 4$, $-.70711$,
    $330º = 11 pi / 6$, $-.5$,
    $360º = 2 pi$, $0$,
  )
))

You can follow the guidance in the post you have identified, which is :

and

It works well if you set the good height for the surrounding block or page height.

// Needed to see the header content
#show table.cell.where(y: 0): set text(
  fill: white,
  weight: "bold",
)

#block(
  height: 26%, //adjust depending on page size
  width: 75%, //adjust depending on page size
  stroke: red + 0.5pt, // to see the block temporarily
  columns(2, align(center, table(
    columns: 2,
    align: (x, y) => if x == 0 or y == 0 { left } else { center },
    stroke: (x, y) => (
      left: if y == 0 and x > 0 { white } else { black },
      rest: black,
    ),
    fill: (_, y) => if y == 0 { black } else if y >= 1 { white } else { none },

    table.header([$y$], [$y = sin theta$]),
    [$0º = 0$], [$0$],
    [$30º = pi / 6$], [$.5$],
    [$45º = pi / 4$], [$.70711$],
    [$60º = pi / 3$], [$.86603$],
    [$90º = pi / 2$], [$1$],
    [$120º = 2 pi / 3$], [$.86603$],
    [$135º = 3 pi / 4$], [$.70711$],
    [$150º = 5 pi / 6$], [$.5$],
    [$180º = pi$], [$0$],

    [$210º = 7 pi / 6$], [$-.5$],
    [$225º = 5 pi / 4$], [$-.70711$],
    [$240º = 4 pi / 3$], [$-.86603$],
    [$270º = 3 pi / 2$], [$-1$],
    [$300º = 5 pi / 3$], [$-.86603$],
    [$315º = 7 pi / 4$], [$-.70711$],
    [$330º = 11 pi / 6$], [$-.5$],
    [$360º = 2 pi$], [$0$],
  ))),
)

3 Likes

this worked, thanks a lot

1 Like