I am using Quarto, Typst, and R. I'm creating a table with gt. Currently if I create a table that is too long then it gets clipped (see below image)
This is what my R code block looks like. As mentioned above, I am using the typst format in Quarto.
#| echo: false
#| warning: false
#| fig-height: 1
#| fig-cap: ""
# Load the gt library
library(gt)
# Create a sample data frame with 5 rows and 5 columns
data <- data.frame(matrix(rnorm(500), nrow=50))
# Create the gt table and add shading for Column3
gt_table <- gt(data) %>%
tab_style(
style = list(
cell_fill(color = "lightblue")
),
locations = cells_body(columns = vars(X2))
)
# Print the gt table
gt_table
I'd like to be able to create a table that spans multiple pages.
What I usually do is add raw typst code that allows figures to break across pages. Add the below above your table call, it should then print across multiple pages.
You can add this directly to the .qmd file (include the backticks) see https://quarto.org/docs/output-formats/typst.html#raw-typst
`#show figure: set block(breakable: true)`{=typst}
Note, this is a show rule and will apply to all figures below, so if this then messed something else up, you could add the below after the table
`#set block(breakable: false)`{=typst}
Here's an example for clarity
```{r}
library(tidyverse)
```
# Table the runs into bottom of page
```{r}
gt::gt(mpg)
```
# Table that breaks across multiple pages
`#show figure: set block(breakable: true)`{=typst}
```{r}
gt::gt(mpg)
```
# How to end that behavior if needed
`#set block(breakable: false)`{=typst}
```{r}
gt::gt(mpg)
```