1

I am trying to fit a fairly large table on a pdf page using Rmarkdown. The table is too large for one page, but scale_down isn't working. I know from Scale kable table to fit page width that I can scale down the width. How do I force this table to fit on one page. The object m, has 64 rows, and currently only ~50 are being printed.

enter image description here

---
title: "Untitled"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output: 
  pdf_document: default
  html_document: default
---

```{r setup, include=FALSE}

library(knitr)
library(rmarkdown)
library( kableExtra )

m <- rbind( mtcars, mtcars)
m$rows<- 1:nrow( m )


outfinish3 <- knitr::kable( m , format = 'latex',  align = 'c' , booktabs=TRUE) %>% 
 kable_styling(latex_options = c("scale_down")) 

```

`r outfinish3 `
MatthewR
  • 2,660
  • 5
  • 26
  • 37

2 Answers2

1

Not entirely sure how to scale it down, but you could split it into two tables.

[https://stackoverflow.com/a/44490399/10821503][1]

kendalorgera
  • 147
  • 2
  • 11
-1

In order to adjust the table we have to use kable_styling. Although there are few options we must be careful because not all of them works in PDF, for instance bootstrap_options.
My suggestion is to use full_width with column_spec. See below:

kable(myFields, "latex", longtable = F, booktabs = T) %>%
  kable_styling(full_width = T) %>%  
     column_spec(1, width = "5em" ) %>% 
     column_spec(2, width = "10em" ) %>%  
     column_spec(3, width = "15em")