I have a table in my r markdown pdf.
kable(df, "latex", longtable = F, booktabs = T) %>%
kable_styling(latex_options = c("hold_position",
"scale_down"),
fixed_thead = T)
this give a nice table centered in the page, but it is too long for the height of the page. so I added
kable(df, "latex", longtable = T, booktabs = T) %>%
kable_styling(latex_options = c("repeat_header"))
as suggested by many posts. My table now is split across several pages but now wider so that it does not fit within the width of the paper.
How can I keep the original width while still using longtable.
I run the same code suggested here
When you add the command full_width = T
to the kable_styling
, it looks more scaled than before. Check this output:
CodePudding user response:
You could try using kable_styling( full_width = TRUE)
which fits a wide (10 column version of iris data across one page). You may need to tweek the column headings so they are legible. Without seeing your actual data it's difficult to suggest anything else.
---
output:
pdf_document
---
```{r}
library(kableExtra)
cbind(iris, iris) |>
kbl("latex", longtable = T, booktabs = T) %>%
kable_styling(latex_options = c("repeat_header"), full_width = TRUE)
```