2

How to add image in the center with Xaringan

 7 months ago
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.
neoserver,ios ssh client

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

yihui/xaringan#80

  1. create the following macro as 'macros.js'
remark.macros.scale = function (percentage) {
  var url = this;
  return '<img src="' + url + '" style="width: ' + percentage + '" />';
};
  1. include macro in Xaringan
output:
  xaringan::moon_reader:
    nature:
      beforeInit: "macros.js"
  1. use macro
![:scale 50%](fig/image.jpg)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK