I am trying to find an easy way to include images in knit pdfs
and html
. It would be nice to write one set of instructions that are easily converted to either format. I read here:
Insert picture/table in R Markdown
that the best way to include graphics is with a code chunk. It seems like it should work both for knitting pdfs as well as html. However, it only includes the graphics in pdf
whereas it is missing from the html
. The following is an MWE.
---
title: "a title"
author: "a"
date: "March 3, 2016"
# header-includes: \usepackage{graphicx}
# output:
# pdf_document:
# toc: true
# toc_depth: 3 # default = 3
# number_sections: true # add section numbering to headers
output:
html_document:
toc: true
toc_float:
collapsed: false
toc_depth: 4
number_sections: true
highlight: tango
theme: simplex
---
### Support Vector Machines (SVMs)
SVM optimal hyperplane:
```{r pressure, echo=FALSE, fig.cap="A caption", out.width = '100%', fig.align = 'center'}
# https://bookdown.org/yihui/bookdown/figures.html
knitr::include_graphics("./All_Figures/Chapter8/8.3.pdf")
```