简体   繁体   English

RMarkdown表格标题打破了页面底部边距

[英]RMarkdown table captions breaks page bottom margin

Whenever I use captions in tables, like 每当我在表中使用标题时,比如说

kable(df[1:10, c(7,1:6)], caption = "This is a caption")

the tables and content in the pdf generated by knitr are pushed below the limits of the bottom margin, thus becoming unreadable. 由knitr生成的pdf中的表格和内容被推到底部边距的限制之下,因此变得不可读。 Sometimes entire sections are missing, hidden off margins. 有时整个部分都缺失,隐藏在边缘之外。

Also, plots positions go crazy: they are printed anywhere but the right place in the pdf. 此外,情节位置变得疯狂:它们被打印在PDF格式的正确位置。

using results="asis" in chunk options doesn't help. 在块选项中使用results =“asis”没有帮助。

Using pander causes the same problems. 使用pander会导致同样的问题。

If I remove all table captions and use some \\newpage in the .rmd, the pdf margins are fine. 如果我删除所有表格标题并在.rmd中使用一些\\ newpage,则pdf边距很好。

Is there a safe way to use table captions? 有没有一种安全的方式来使用表格标题?

The pdf in question is here: see page 14 for an entire section missing and table hiding in the bottom margins. 有问题的pdf在这里:有关缺失的整个部分和隐藏在底部边距中的表格,请参见第14页。 Also, the plots are where they want, like if they had proper needs... 此外,情节是他们想要的地方,就像他们有适当的需求...

github repo github回购

this is kind of a anti-climax, 这是一种反高潮,

but as it happens, this problem was being caused by chunks that printed var values to the document, something like: 但实际上,这个问题是由打印var值到文档的块引起的,如:

```{r}
sampled.values <- sample(1:100, 10)
sampled.values
```

when rendered through render(), this code chunk prints the value of sampled.values and this ruins the pdf pagination. 当通过render()渲染时,此代码块打印采样值的值,这会破坏pdf分页。

That's it: all page bottom margins are ok now that I removed all those var calls. 就是这样:所有页面底部边距都可以,因为我删除了所有这些var调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM