12

Is it possible to display a pdf file in an Rmarkdown file? Say, for example, a previously saved image :'myimage.pdf'

What I am aiming is a form of "\includegraphics[width=0.5]{myimage.pdf}"

user2809432
  • 143
  • 1
  • 1
  • 7

2 Answers2

7

An update from the very end of 2017
It is possible to import a PDF image using knitr::include_graphics(), e.g.

{r label, out.width = "85%", fig.cap = "caption"} include_graphics("path-to-your-image.pdf")

ikashnitsky
  • 2,761
  • 23
  • 39
  • 4
    **knitr::include_graphics("path-to-your-image.pdf")** worked for me, but **include_graphics("path-to-your-image.pdf")** did not. Is it possible that you missed to add **knitr::** in your example? – user2809432 Feb 09 '18 at 17:58
  • 2
    Sure. I assume you load knit at the very beginning – ikashnitsky Feb 09 '18 at 18:05
  • Nice that this sorta works now, but the size control does nothing for me in knitr 1.20 – daknowles Aug 27 '18 at 21:11
1

You can insert this directly into your R Markdown. The alternate name will only be displayed if the image does not load.

![Alternate Name](file.pdf){width=500px}
mel
  • 85
  • 1
  • 5