8.1 Embed a Static File

A simple solution is to use the built-in syntax of R Markdown.

![](Path to file){width=100% height=600}

In the above, width=“100%” means the inserted file is as wide as the page contents. The height can be manually adjusted to the desired length. Below is the famous R Markdown cheatsheet.

Alternatively, we can use HTML iframe to attach images or PDF files:

<iframe src="file-name.pdf" width="100%" height="600px">
</iframe>

The advantage of using the HTML iframe directly is that we can add more options. For example, if we add #page= to the end of the PDF file name, src=“file-name.pdf#page=2”, the iframe window will display the second page of the PDF file. The reader can still navigate to other pages using the scroll bar.