I am writing a report on Rmarkdown and knitr using RStudio, and cannot find a way to get figure captions on my document. My code for the chunk where I try to plot is like:
```{r fig1,fig.width=4,fig.height=4,echo=FALSE,message=FALSE,include=TRUE,fig.cap="Caption"}
plot(rnorm(100,2),rnorm(100,8))
```
No caption is added to the pdf output, and a look at the intermediary latex file reveals that the figure environment is not created:
\includegraphics{./Untitled_files/figure-latex/fig.pdf}
Otherwise, the pdf document is created without any problems, it just misses the captions. I have read in the knitr manual and in many other questions about the topic that the chunk option fig.cap will add the figure environment. I tried to add the fig.env=TRUE option, as well, but the results are the same. Is this an issue with rmarkdown in rstudio only or is it that in general it will not work?
.Rmd
to.pdf
? – Adam Liter Sep 19 '14 at 15:50knit()
on an.Rmd
file will produce.md
output, though. How exactly are you going from.Rmd
to a.tex
file? – Adam Liter Sep 19 '14 at 16:56knit2pdf()
only works on.Rnw
files and.Rrst
files. – Adam Liter Sep 19 '14 at 17:04