使用 R Markdown 输出 pdf。kable() 效果很好,但是当我添加longtable=T
标题时不再扩展表格的整个宽度。我似乎无法在这里找到一个可以控制标题细节的论点。我可以移动要为每个代码块输出的标题,但如果可能的话,我宁愿使用 kable 中的内置功能。
谢谢!
---
title: "test"
author: ""
date: "September 6, 2017"
output:
pdf_document:
latex_engine: xelatex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(kableExtra)
library(knitr)
library(dplyr)
```
```{r table1}
test <- data.frame(col1=rep("MyLongWordsareLong",5),
col2=rep("MyLongWordsareLong",5),
col3=rep("MyLongWordsareLong",5),
col4=rep("MyLongWordsareLong",5),
col5=rep("MyLongWordsareLong",5),
col6=rep("MyLongWordsareLong",5))
kable(test,format='latex',booktabs=TRUE,
caption="This is my example caption. See how, when I don't use
longtable, it extends the full width of the table, but when I use the
longtable option, it compresses down to only a portion of the table's wdith.
Is this weird or is it just me?") %>%
landscape()
kable(test,longtable=TRUE,format='latex',booktabs=TRUE,caption="This is my
example caption. See how, when I don't use longtable, it extends the full
width of the table, but when I use the longtable option, it compresses down
to only a portion of the table's wdith. Is this weird or is it just me?")
%>%
landscape()
```