title: R markdown pdf output figure with out.width='90%' generating the wrong path with the render function and output_dir used
body: <p>I am generating a pdf from an Rmd file with output = pdf and xelatex.
  Some figures are large and cover the entire page. So the generated pdf creates an empty page. To avoid that I decided to reduce the size of the figure using out.width='90%'. </p>
  
  <p>Here is my .Rmd file:</p>
  
  <pre><code>---
  title: "test out width"
  author: "Courvoisier"
  date: "8 November 2016"
  output:
    pdf_document:
      fig_height: 8
      fig_width: 12
      keep_tex: yes
      latex_engine: xelatex
      number_sections: yes
      toc: yes
  ---
  
  ```{r setup, include=FALSE}
  knitr::opts_chunk$set(echo = TRUE)
  ```
  
  ## Including Plots
  
  ```{r pressure, echo=FALSE}
  plot(pressure)
  ```
  
  ```{r pressure2, echo=FALSE, out.width='90%'}
  plot(pressure)
  ```
  </code></pre>
  
  <p>I used render to create the pdf. Here is the .R code: </p>
  
  <pre><code>rm(list = ls())
  library(knitr)
  library(rmarkdown)
  
  RmdFile = "testoutwidth.Rmd"
  outputpdfFilePathoutPdf = "testoutwidth.pdf"
  renderoutputpdfFilePath = render(input = RmdFile, output_file = outputpdfFilePathoutPdf)
  </code></pre>
  
  <p>This works fine and creates the following .TeX code for the figures:</p>
  
  <pre><code>\includegraphics{testoutwidth_files/figure-latex/pressure-1.pdf}
  
  \includegraphics[width=0.9\linewidth]{testoutwidth_files/figure-latex/pressure2-1}
  </code></pre>
  
  <p>However, when choosing an output_dir in the render function such as:</p>
  
  <pre><code>renderoutputpdfFilePath = render(input = RmdFile, output_dir = "out pdf/", output_file = outputpdfFilePathoutPdf)
  </code></pre>
  
  <p>The includegraphics commands in the .TeX generated become</p>
  
  <pre><code>\includegraphics{C:/work/testRenderRmd/out pdf/testoutwidth_files/figure-latex/pressure-1.pdf}
  
  \includegraphics[width=0.9\linewidth]{C:\work\testRenderRmd\out pdf\testoutwidth_files/figure-latex/pressure2-1}
  </code></pre>
  
  <p>In the second \includegraphics (the one that has [width=0.9\linewidth]) the path separators are "\" instead of "/" and so the latex compilation fails. (it gives C:\work... instead of C:/work/... ).</p>
  
  <p>What should I use to solve this?</p>
  
  <p>thanks</p>
  
  <p>Note: it seems there is an issue open about this on the rmarkdown github :
  <a href="https://github.com/rstudio/rmarkdown/issues/808" rel="nofollow noreferrer">https://github.com/rstudio/rmarkdown/issues/808</a></p>