0

我正在尝试打印我创建的 xaringan markdown 的 PDF。当我打开由 R markdown 创建的 html 时,它在我的浏览器中呈现得非常好。但是,当我将其打印为 PDF 时(使用“另存为 PDF”选项),它会在幻灯片的底部和右侧添加大的白色边距。

我可以通过使用 pagedown 来避免这种情况,但我的工作场所只允许我使用 chrome 转换为 PDF。为了仔细检查,我从https://bookdown.org/yihui/rmarkdown/xaringan-start.html运行了 hello world 示例,在 chrome 中打开它,尝试打印它并得到相同的结果。

我在两台单独的计算机上执行此操作,以仔细检查它不只是我的机器。

我正在为 R 运行 3.5.2 和 Xaringan 的 0.13(来自 CRAN)。

PS:看起来这曾经是Xaringan的问题https://github.com/yihui/xaringan/issues/65

编辑:从https://bookdown.org/yihui/rmarkdown/xaringan-start.html添加代码

---
title: "Presentation Ninja"
subtitle: "with xaringan"
author: "Yihui Xie"
date: "2016/12/12"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      countIncrementalSlides: false
---

One slide.

---

Another slide.
4

1 回答 1

1

我相信开发版本可以解决您的问题,但如果您只能访问 CRAN 版本,请将以下内容添加到 css 文件中,例如custom.css

@page { margin: 0; }
@media print {
  .remark-slide-scaler {
    width: 100% !important;
    height: 100% !important;
    transform: scale(1) !important;
    top: 0 !important;
    left: 0 !important;
  }
}

然后在 Rmd 的 YAML 中引用这个 css 文件,如下所示

output:
  xaringan::moon_reader:
    css: "custom.css"
于 2019-12-30T06:11:17.790 回答