我希望您能够将本地目录中的图片/素材包含到Xaringan remark.js演示文稿中,并对其进行大小调整。我是通过Mac上的Rmd/Rstudio完成这个过程的。我希望能够使用宏来自定义大小,正如Yihui的文档所建议的那样。
然而,这些推荐的宏对我来说不起作用。
添加以下行:
然而,这些推荐的宏对我来说不起作用。
添加以下行:
.center[![trachoma](picsfigs/trachoma.jpg)]
这个功能正常运行,但添加 beforeInit: "macros.js" 并将宏添加到该文件的编织中会导致演示文稿为空白。
---
title: "A Cool Presentation"
output:
xaringan::moon_reader:
css: [default, metropolis, metropolis-fonts]
seal: true
self_contained: true
yolo: false
beforeInit: "macros.js"
nature:
autoplay: 30000
---
- Hello world
---
---
# new slide??
This works:
.center[![trachoma](picsfigs/trachoma.jpg)]
---
But this does not work:
.center[![:scale 50%](picsfigs/trachoma.jpg)]
Nor this
.center[![trachoma][:scale 50%](picsfigs/trachoma.jpg)]
one more slide
---
宏文件macros.js:
remark.macros.scale = function (percentage) {
var url = this;
return '<img src="' + url + '" style="width: ' + percentage + '" />';
};