Chrome 为 xaringan rmarkdown 输出添加了不需要的边距



我正在尝试打印我创建的xaringan降价的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:看起来这曾经是沙林甘 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.

我相信开发版本可以解决您的问题,但是如果您只能访问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"

最新更新