Closed magaranoriko closed 8 years ago
I was having a similar issue. I think it's to do with latex behaviour, specifically floats.
If you want to override latex's idea of where's best to put it you need to somehow pass the H option to latex. Some people are discussing how to do that in Rmd here. I'm not sure how those solutions worked though or whether they are better than just starting a new page
Yihui's (the creator of knitr) answer is probably the best : http://stackoverflow.com/a/17648350/1705044
That being said. Once you have 'enough text' LaTeX's floating behaviour almost always works better than manual placement. Remember that if figures have informative captions and are sequentially numbered, they don't really need to come at specific points in the text (you'll notice that figures and tables in most academic books and journal articles 'float').
Webpages tend to follow a different convention where figures come after specific pieces of text. But for Rmarkdown with HTML, LaTeX floating isn't involved and this should happen automatically.
Thanks for your helpful advice! I figured it out.
:+1:
Sorry about this beginner-level question... Does anyone know how to place plots and tables on the right page of the PDF document?
I have texts and code chunks to generate plots/tables in my Rmd as I guess you all have. When I knit it into PDF, it seems like the plots/tables are floating around and sometimes they appear on a new page after/in the middle of the next section.
Right now, I'm manually fixing it by inserting page breaks using
\newpage
between chunks and next section. I'd appreciate if you guys know how to fix it in a more sophisticated way! (Or we don't usually care about the placement of the figures in this kind of academic paper? and can we just leave them where R puts them?)Just in case, here's our Rmd and the current version of PDF.