减少字幕和桌子之间的填充
我正在使用Flextable循环循环,以在列表中的每个元素中生成字幕和表格,以在rmarkDown
文档中生成表。虽然我可以成功地渲染字幕和表格,但字幕和表之间的填充/边距太大,我找不到减少它们的方法。这是我到目前为止所拥有的:
---
title: "Untitled"
output: html_document
date: '2022-05-09'
---
``{r setup, include=FALSE}
library(flextable)
library(magrittr)
``
``{r results='asis', echo=FALSE, ft.align="left"}
my_list<-list()
my_list$ds1<-head(mtcars, 5)
my_list$ds2<-head(mtcars, 10)
for (i in 1:length(my_list)) {
myft <- flextable(my_list[[i]]) %>%
set_caption(paste("Caption ", i))
flextable_to_rmd(myft)
}
``
我认为也许使用Flextable :: Padding()
会有所帮助,但这似乎只能控制表行中的填充,而不是页面上的元素之间的间距。
请注意,我已经在上面的代码示例中删除了一些所需的降压背板,以便可以在Stackoverflow上正确渲染。
I'm using flextable to loop over a list of data, generating captions and tables for each element in the list to generate tables in an rmarkdown
document. While I can successfully render the captions and tables, the padding/margins between captions and tables is too large, and I can't find a way to reduce them. Here's what I have so far:
---
title: "Untitled"
output: html_document
date: '2022-05-09'
---
``{r setup, include=FALSE}
library(flextable)
library(magrittr)
``
``{r results='asis', echo=FALSE, ft.align="left"}
my_list<-list()
my_list$ds1<-head(mtcars, 5)
my_list$ds2<-head(mtcars, 10)
for (i in 1:length(my_list)) {
myft <- flextable(my_list[[i]]) %>%
set_caption(paste("Caption ", i))
flextable_to_rmd(myft)
}
``
I thought that perhaps using flextable::padding()
would help, but this seems to only control the padding within the table rows, rather than the spacing between elements on a page.
Note that I've removed some of the required markdown backticks in the code sample above so that it can render correctly on Stackoverflow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其添加到您的RMD中。不要将其放在代码块中 - 只是将其放置在您可以自由写的地方。
目前,标题是用P标签编写的,周围是标题标签,周围有更多的P标签,所有这些标签都有填充,边距和线条高规格。这为您提供最大的努力(IMO)。
Add this to your RMD. Don't put it in a code chunk—just place it where you might otherwise free-write.
Right now the caption is written in p tags, surrounded by caption tags, surrounded by more p tags, all of which have padding, margin, and line-height specs. This gives you the biggest bang for the least effort (IMO).