glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
627 stars 80 forks source link

knitting to pdf reduces table width #196

Open hughandersen opened 3 years ago

hughandersen commented 3 years ago

Great package, thanks. I can knit to pdf using your package, but the table width is reduced to less than page width. When knitting to html the table is full page width. Is there a fix?

knitr::opts_chunk$set(echo = TRUE)

library(reactable)
library(tidyverse)

reactable(mtcars,
          defaultColDef = colDef(
            align = "center",
            minWidth = 40,
            headerStyle = list(background = "#f7f7f8")
          ),
          style = list(fontFamily = "Work Sans, sans-serif", fontSize = "10px"),
          pagination=FALSE,
          highlight = TRUE,
          bordered = TRUE,
          striped=TRUE,
          compact=TRUE,
          fullWidth = TRUE
)
glin commented 3 years ago

I think this is the same issue as https://github.com/glin/reactable/issues/67#issuecomment-674581250. The problem is that the browser engine in the webshot package is too old, and unfortunately, I don't think there's a good solution yet. The new webshot2 package should support reactable, but it's not on CRAN or supported by knitr/rmarkdown yet.

You could either use webshot2 to take a screenshot of the table and insert it in the PDF, or use another table package for PDFs.

hughandersen commented 3 years ago

Thanks for your reply, I'll make a plan and wait for the webshot2 package to get on CRAN