I am currently writing some reports with LaTeX. Due to most of my analysis is made with R, I switched to Rmarkdown, which I am very happy with so far, except one thing, namely when it comes to include figures in the pdf output.
Some of my plots are floating, so they are surrounded by text and the other kinds of output, put some other of my figures take a whole page in the pdf document, although they are not that big. And I have absolutely no clue why it is like that. Does anyone know that problem or a solution?
I would like to switch to Rmarkdown for good, but if that image issue stays like that I can´t use it for more serious reports, where also the form matters.
Example:
---
title: "Multivariate Analysis"
subtitle: "written report"
author: "by XXX"
date: "24.10.2017"
output:
pdf_document:
fig_caption: yes
---
```{r include = FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
```
...
some more R and Latex stuff which works well, approx. 6 pages
...
These eigenvalues determine the proportion of the total variance explained by the i-th component.
```{r, fig.cap="individual and total proportion of total variance explained by the regarding principal components"}
ggplot() + ...
```
```{r}
options(digits=2)
```
So the first principal component contains already `r eig.val[1]/sum(eig.val)*100`% of the information.
more text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text
$$
\begin{aligned}
&Y_1=`r eig.vec[1,1]` ... some latex equations
\end{aligned}
$$
$Y_1$ seems to be text text text text text text text text text text text text text text text text text text text text text text text
text text text text **PAGEBREAK PAGEBREAK** text text text text text text text text text text text text text
In this case I got a pagebreak in the second part of the text where it says PAGEBREAK. On the next page I get my figure from above, which only takes 50% of that pages space but still there´s nothing else on that page. On the next page after the figure the text continous.
That´s like a harsh break in the middle of a sentence separated by a whole page which is half empty.
Why is it like that? To me it seems to be random which images are floating in the text and which not in total, 30-50% have that issue as the one above.
Does anyone have any kind of idea how to solve that? Every hint is welcome I am really desparated...
I also tried to set fig.pos='h' but didn´t change a thing.