Rmarkdown 并排表格间距 [英] Rmarkdown side-by-side tables spacing
问题描述
我正在尝试通过 Rmarkdown 并排打印两个表格,输出为 PDF.
我可以很好地打印表格,但它们最终粘在一起很近,我找不到在它们之间创造更多空间的方法.我在其他帖子中找到的解决方案会返回奇怪的输出或错误,例如从这里开始的第二个只是给出了一个错误 43":你可以做到像这样手动:
```{r, echo = FALSE, results = 'asis', warning = F}图书馆(knitr,安静地= T)t1 <- kable(head(mtcars[,1:2]), format = 'latex')t2 <- kable(head(mtcars[,3:4]), format = 'latex')cat(c("\\begin{table}[h] \\centering",t1,"\\hspace{1cm} \\centering",t2,"\\caption{我的表格} \\end{table}"))``
基本思想是单独创建表格并将它们与普通乳胶对齐.间距由 \\hspace{1cm}
添加.
I'm trying to print two table side-by-side through Rmarkdown, output as PDF.
I can print the tables out fine, but they end up stuck really close together and I cannot find a way to create more space between them. The solutions I find in other posts returns strange output or errors, e.g. the second one from here just gives an 'error 43': Align multiple tables side by side
My code is this:
```{r, echo=FALSE}
library(knitr)
kable(list(head(bymonth),head(bydecade)),align='c')
```
Anyone know how to add some spacing between those two tables?
Incorporating the answer given here you could do it manually like this:
```{r, echo = FALSE, results = 'asis', warning = F}
library(knitr, quietly = T)
t1 <- kable(head(mtcars[,1:2]), format = 'latex')
t2 <- kable(head(mtcars[,3:4]), format = 'latex')
cat(c("\\begin{table}[h] \\centering ",
t1,
"\\hspace{1cm} \\centering ",
t2,
"\\caption{My tables} \\end{table}"))
```
The basic idea is to create the tables individually and align them with plain latex. The spacing is added by \\hspace{1cm}
.
这篇关于Rmarkdown 并排表格间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!