If you remove the word «Something!» from the following script, once knitting to pdf, the second plot instead of in the new page, is (partially) shown below the same page. If the plots are more than two, only the second has this issue, the other plots are shown normally in the following pages.
title: "Possible bug"
output: pdf_document
knitr::opts_chunk$set(echo = FALSE)
Here is the title. If I remove the word «Something!» from below, once knitting the pdf the second plot will not be shown correctly
Something!
par(mfcol=c(6,3), cex=0.6, mgp = c(0.8,0.6,0.1)
, mai=c(0,0,0,0), omi=c(0.2,0.4,0.3,0.1))
a <- c(1:88)
b <- c(88:1)
d <- cbind(a, b)
# Plot data
for (j in (1:2)){
for (i in (1:18)){
plot.ts(d[j])
}
}
This is expected behavior because of LaTeX, where control of figure placement is very fussy. Something! does not leave sufficient space on the page to complete the figure. You can "fix" this by adjusting the page margins, fonts, etc. to leave extra space, but there can be no assurance that the adjustments will work for all figures on all pages.