Decide exact position of figures and plot in knitr R Markdown - r

I had trouble position exactly my plots and figures when knitting to pdf a R Markdown document with knitr.

This question helped me: https://community.rstudio.com/t/cant-control-position-of-tables-and-figures-in-knitted-pdf-document/37364 , where the answerer uses a text file to fit in the latex instructions for the knit.

Related

is there a way to set a title and caption for an image (above and under respectively) in R markdown?

I'm using pdf output.
![title at top^[Font: Own Elaboration (this must be under the image)] \label{fig:VPBFX}](diagram.png)
Or how can i do it with knitr?
Thank you.

R markdown not knitting the equations

I am using R markdown to knit a paper of mine, and R markdown does not knit
\begin{equation}
f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
(\#eq:binom)
\end{equation}
it would knit
$\phi _ { k }$.
In conclusion, it does not recognize \begin..\end
any ideas? Thank you!
I am not getting any error messages, and the code used to work in rnw file.

Show a square plot under chunks in Rstudio

I am programming in Rstudio using markdown files, alternating between Markdown and R chunks of code. If I plot something in a chunk, the plot is shown below the chunk.
Does anybody know how I can make the plot look square instead of rectangular?
use this kind or header of chunk with fig.width = fig.height
<<R_chunk_title,echo=FALSE,warning=FALSE,message=FALSE,fig.width=6,fig.height=6,cache=TRUE>>=

Accents for characters from R Markdown to Microsoft Word

I'm trying to produce a word document with R markdown. Usually i'm creating pdf-files with no problems. I use Latex syntax to create accents for characters for normal text like:
$\'{e}\'{e}$n
And then it produces "één" correctly when i knit my pdf. But this doesn't seem to work when i knit a word document, it will just show "$\'{e}\'{e}$n". So no good. Does anyone know how to solve this problem? Thanks!

LaTeX code in knitr figure caption

I'm trying to insert LaTeX code into a figure caption created by knitr. I have the code below in a .Rnw file and I'm converting it to a .tex file using knitr:
<<my_plot, fig.cap="X is $\leq$1 and Y is $\geq$2">>=
plot(1,2)
#
Code as it stands give an error. How can I use insert the LaTeX code into the figure caption?

Resources