r - 从 knitr/rmarkdown 打印裁剪图像并引入换行符
问题描述
我正在创建一个调查问卷,并希望让用户将结果保存为pdf
.
看起来html
不错!但是printing
裁剪图像,到目前为止没有任何效果。
编辑:我添加了关于 pagedown 包的合适引用,可能描述了问题:
“[...] 尝试从您的一个 Rmarkdown 文件生成 PDF,我所说的 PDF 是指那种将图像从一页到另一页分成两半并且书面文本没有在页面末尾完成的文档……(是的,我知道你知道我的意思,但是……)”
# YAML
---
output:
pdf_document: #html?
fig_crop: false # doesn't work
---
---
output:
pagedown::html_paged: # doesn't work
css: ["default-fonts", "default-page", "default"]
---
# CSS line-breaks
<style media="print">
html, body, p, hr, img {
break-after: avoid !important; # doesn't work
break-before: avoid !important; # doesn't work
break-inside: always !important; # doesn't work
}
</style>
# Button
<input type="button" value="Print this page" onClick="window.print()">
# Example Plot
```{r echo=FALSE, message=FALSE}
library(ggplot2)
Plot <- ggplot(mpg, aes(displ, cty)) + geom_point()
Plot + facet_grid(rows = vars(drv))
plot.height <- 45
```
# Calling the plot (with fig.height)
```{r, fig.height=plot.height, strip.white = TRUE} # doesn't work
plot(Plot)
```
这是实现的示例: https ://exampleruntest.formr.org 出于某种原因,示例图没有在图之前引入换行符,而是在之后。
我希望有人有一个想法
解决方案
推荐阅读
- django - 如果在Django中获得带有空字段的参数,如何不将空参数保存在表中
- android - 从android 11的范围存储中删除图像
- php - 如何在 Windows 10 xampp 中为 php 8 安装 memcache
- python - 在 Python 中从 zip 迭代创建字典的更简洁方法
- java - Spring boot Firebase Admin SDK 在部署到 aws EC2 实例时失败
- java - Mockserver 客户端 Java - 使用默认的 JDK 信任库
- javascript - 在Javascript的forEach循环中使用异步等待时没有得到正确的输出
- apache-hudi - [HUDI]在 HUDI 中创建仅附加原始数据
- excel - 通过 Delphi 在 Excel 中构建数据透视表
- r - 如何将一个值除以R中上一年的相同值?(回报计算)