Using out.width with include_graphics()

I am trying to generate a pdf document with Rmarkdown with some images embedded from URLs. The help documentation for include_graphics() seems to suggest I can set the image size with the out.width= and out.height= arguments:

" Chunk options related to graphics output that work for normal R plots also work for these images, such as out.width and out.height ."

However, the code below generates the error

! LaTeX Error: File `https://raw.githubusercontent.com/sjkiss/DMJN328/master/im
ages/chapter_3_rproj' not found.

However, removing the out.witdh and out.height arguments lets me compile the documents fine.

---
title: "Test"
author: "Test"
date: "23/01/2020"
output:
  pdf_document: 
    fig_caption: yes
    pandoc_args: ["--extract-media", "."]
header-includes:
- \usepackage{caption}

---

See \ref{fig:test}. 

```{r test, fig.cap="\\label{fig:test} Finding the .rproj file for Chapter 3", out.width="50%", out.height="50%"}
knitr::include_graphics('https://raw.githubusercontent.com/sjkiss/DMJN328/master/images/chapter_3_rproj.png')

have you tried

![alt text here](path-to-image-here)

you will should be able to edit width of the image as well

1 Like

With Latex output, I think you can include graphics from a url (it is using \includegraphic.) It needs to be a local path. So you need to download the file before rendering.

See this comment

or this recent blogpost https://yongfu.name/2019/03/10/include_graphics2/

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.