简体   繁体   中英

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. Sometimes entire sections are missing, hidden off margins.

Also, plots positions go crazy: they are printed anywhere but the right place in the pdf.

using results="asis" in chunk options doesn't help.

Using pander causes the same problems.

If I remove all table captions and use some \\newpage in the .rmd, the pdf margins are fine.

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. Also, the plots are where they want, like if they had proper needs...

github repo

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:

```{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.

That's it: all page bottom margins are ok now that I removed all those var calls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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