我想将本地目录中的图像/素材包含到Xaringan remark.js演示文稿中并调整大小。 我正在通过Mac上的Rmd / Rstudio进行此操作。我希望能够按照Yihui's docs
中的建议使用宏来自定义尺寸建议的宏设置大小对我不起作用。
添加行:
.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 + '" />';
};
答案 0 :(得分:1)
您需要将beforeInit: "macros.js"
放在nature
下,如下所示。
---
title: "A Cool Presentation"
output:
xaringan::moon_reader:
css: [default, metropolis, metropolis-fonts]
seal: true
self_contained: true
yolo: false
nature:
autoplay: 30000
beforeInit: "macros.js"
---