1

I am trying to generate a PDF from Rmarkdown that includes external images (i.e., not figures generated from R code, which has been addressed in other questions, but images from other sources). The problem is that when I generate the PDF, the images don't appear where I placed them in the source code, but rather are moved around, presumably so as not to break the text. To my knowledge, this does not happen with figures generated from R code - those are placed immediately after the R code that generated them. Is there a way to fix this so that images are forced to appear in the text where I place them, as if they were generated from R code?

Some sample Rmd is below. If either of the two images is large, one or the other will be moved until after the text.

---
title: "Untitled"
author: "Me"
date: "December 16, 2016"
output: pdf_document
---

## One image with text

If any of the images are too large, they will be moved elsewhere.

First image goes here:

![Image #1](pictures/image1.jpg)  

First image should be before here.

## Another image

Second image goes here:

![Image #2](pictures/image2.jpg)  

Second image should be before here.
user3004015
  • 617
  • 1
  • 7
  • 14
  • 1
    I think this question has been [asked](http://stackoverflow.com/questions/16626462/figure-position-in-markdown-when-converting-to-pdf-with-knitr-and-pandoc) and [answered](http://stackoverflow.com/a/17648350/3022126) before (from the author of `knitr` himself). – Phil Dec 16 '16 at 15:16
  • If I understand correctly, this question is dealing with images generated from R code and precise positioning of those images, whereas I just want the external images to appear where I placed them in the document. – user3004015 Mar 07 '17 at 15:45
  • @user3004015 I rolled back your edit. If you want to propose a solution to this problem, please post an answer to the linked duplicate – scoa Mar 07 '17 at 17:07
  • But my answer doesn't apply to the linked duplicate (which isn't really a duplicate; I tried to clarify this in my comments and edits to the question). I am talking about external images, whereas they are talking about placement of images generated by R. My answer wouldn't have any relevance for their question. – user3004015 Mar 08 '17 at 18:16

0 Answers0