有没有一种方法来增加kableExtra的行间距,用于r标记或预订中的pdf输出?
library(knitr)
library(kableExtra)
kable(
head(iris, 5), caption = 'Iris Table',
booktabs = TRUE) %>%
kable_styling(latex_options = "striped")

发布于 2018-12-15 15:52:21
您可以使用LaTeX命令\arraystretch来完成它。
---
output: pdf_document
---
```{r setup, include=FALSE}图书馆(KableExtra)
图书馆(Tidyverse)
\renewcommand{\arraystretch}{2}
```{r, echo=FALSE}图书馆(针织品)
图书馆(KableExtra)
(头(虹膜,5),标题=‘虹膜表’,书签=真) %>%
kable_styling(latex_options =“条带”)
请注意,以下所有表都将使用相同的间距。但是你可以用\renewcommand{\arraystretch}{1}重置它

发布于 2019-08-13 00:47:48
在CL.的答案here的基础上,您还可以使用kable的linesep参数和'\addlinespace‘(或来自Latex’booktabs的类似参数)。就像这样:
linesep = "\\addlinespace"
你的例子:
kable(head(iris, 5),
"latex",
caption = 'Iris Table',
booktabs = T,
linesep = "\\addlinespace") %>%
kable_styling(latex_options = "striped")我认为\arraystretch更改整个表的行距,包括标头、注释等,而linesep只控制表主体的行空间。这样,您也不必在Rmarkdown文档中引入自定义Latex代码。
发布于 2019-07-16 09:06:46
除了Martin的回答之外,您还可以将标签\更新命令{\arraystretch}{2}放入类似于so的save_kable函数(如果您像我一样,只想导出一个pdf表而不使用R):
save_kable(tableName, file="FileName.pdf", latex_header_includes = c("\\renewcommand{\\arraystretch}{2}"))https://stackoverflow.com/questions/53794142
复制相似问题