【问题标题】:Include and size local images from local directory into Xaringan (remark.js) presentation ... (using via Rstudio on mac)将本地目录中的本地图像包含并调整大小到 Xaringan (remark.js) 演示文稿中...(通过 Mac 上的 Rstudio 使用)
【发布时间】:2019-09-25 01:01:12
【问题描述】:

我想将本地目录中的图像/材料包含到 Xaringan remark.js 演示文稿中并调整它们的大小。 我正在通过 Mac 上的 Rmd/Rstudio 执行此操作。我希望能够按照Yihui's docs 中的建议使用宏来自定义大小

用于调整大小的建议宏不适用于我。

添加行:

.center[![trachoma](picsfigs/trachoma.jpg)]

工作正常,但添加 beforeInit:“macros.js” 并将宏添加到该文件 knitting 会产生一个空白演示文稿

---
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 + '" />';
};

【问题讨论】:

    标签: xaringan remarkjs


    【解决方案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"
    ---
    

    【讨论】:

      猜你喜欢
      • 2020-02-23
      • 2017-01-27
      • 2021-04-20
      • 2015-03-17
      • 2014-08-17
      • 2014-01-02
      • 2020-02-03
      • 2015-06-18
      • 2015-10-31
      相关资源
      最近更新 更多