2
How to add image in the center with Xaringan
source link: https://gist.github.com/taekyunk/aad6ff2df1cf536ac3fc68f569054303
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
includgraphics()
```{r, echo=FALSE, out.width="45%", fig.cap="Caption"}
knitr::include_graphics("fig/image.png")
```
With html tag
<center>
<img src="fig/code_comment.jpg" width="200" height="200" />
</center>
Using .center[]
.center[<img src="fig/code_comment.jpg" width="200" height="200" />]
With macro
- create the following macro as 'macros.js'
remark.macros.scale = function (percentage) {
var url = this;
return '<img src="' + url + '" style="width: ' + percentage + '" />';
};
- include macro in Xaringan
output:
xaringan::moon_reader:
nature:
beforeInit: "macros.js"
- use macro
![:scale 50%](fig/image.jpg)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK