使用 kableExtra 增加行/行间距 [英] Increase line/row spacing with kableExtra

查看:62
本文介绍了使用 kableExtra 增加行/行间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 kableExtra 增加 r-markdown 或 bookdown 中的 pdf 输出的行距?

Is there a way to increase the line spacing with kableExtra for a pdf output in r-markdown or bookdown?

library(knitr)
library(kableExtra)
kable(
  head(iris, 5), caption = 'Iris Table',
  booktabs = TRUE) %>%
  kable_styling(latex_options = "striped")

推荐答案

你可以使用 LaTeX 命令\arraystretch:

You can just do it using the LaTeX command \arraystretch:

---
output: pdf_document
---

```{r setup, include=FALSE}
library(kableExtra)
library(tidyverse)
```


\renewcommand{\arraystretch}{2}
```{r, echo=FALSE}
library(knitr)
library(kableExtra)
kable(head(iris, 5), caption = 'Iris Table',booktabs = TRUE) %>%
  kable_styling(latex_options = "striped")
```

请注意,以下所有表格都将使用相同的间距.但是你可以使用 \renewcommand{\arraystretch}{1}

Notice that all following tables would use the same spacing. But you could reset it using \renewcommand{\arraystretch}{1}

这篇关于使用 kableExtra 增加行/行间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆