I have a 120 rows x 2 colunms table to export using knitr::kable()
However, the PDF output gives me a long and thin table, in the center of the page, occuping multiples pages of PDF.
I want to break this long and thin table in shorter and thin tables ocupping the same PDF page, just like breaking clomuns option in Microsoft Word.
Thanks in advance!
CodePudding user response:
It would have been really better if you had given a sample of your table.
---
title: "Wrapping Table"
output:
pdf_document:
keep_tex: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
mtcars_long <- rbind(mtcars, mtcars, mtcars, mtcars)
```
## R Markdown
\newpage
```{r results='asis', echo=FALSE}
cat('\\begin{center}')
cat('\\begin{tabular}{ c c }')
cat('\\fontsize{7}{10}\\selectfont')
print(knitr::kable(mtcars_long[1:60, 1:2], format = 'latex'))
cat('&')
cat('\\fontsize{7}{10}\\selectfont')
print(knitr::kable(mtcars_long[61:120, 1:2], format = 'latex'))
cat('\\end{tabular}')
cat('\\end{center}')
```
rendered Output