earnestatistics
earnestatistics

Reputation: 132

Add pdf file in Rmarkdown file

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}

Upvotes: 11

Views: 23998

Answers (3)

FZS
FZS

Reputation: 275

For the record and as suggested in the comments, this works perfectly fine as long as you're knitting to pdf (this is a LaTex command that won't work if you try to knit to HTML or docx though):

\includegraphics[width = \textwidth]{myimage.pdf}

You can change the width with something like

\includegraphics[width = 0.5\textwidth]{myimage.pdf}

Upvotes: 0

ikashnitsky
ikashnitsky

Reputation: 3111

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") 
```

Upvotes: 7

mel
mel

Reputation: 105

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}

Upvotes: 2

Related Questions