rmarkdown 中的水印
Watermark in rmarkdown
我研究并找到了如何在 rmarkdown 文档中创建水印。
它在基本文本上效果很好,但是当你有一个情节繁重的页面时,它会隐藏在情节后面。
显然,这使得有人可以很容易地截屏图形并在 PDF 之外使用它们。
下面是一些代码,清楚地演示了这个问题。
---
title: "Testing Watermark"
author: "John"
date: "September 18, 2015"
header-includes:
- \usepackage{draftwatermark}
output:
pdf_document
---
This is some basic text.
Note the watermark on this page, and the hidden watermark on the next page.
\newpage
\SetWatermarkText{DRAFT}
```{r echo=FALSE, warning=FALSE, message=FALSE, fig.height=7}
library(ggplot2)
ggplot(mtcars) +
geom_point(aes(mtcars$mpg, mtcars$cyl)) +
facet_wrap(~carb, ncol=1) +
theme_bw()
```
如果有人知道此问题的解决方法,我将不胜感激。
就我而言,要么使 ggplot 背景透明(我已经尝试过),要么将水印带到前景并使其透明。
尝试使用
header-includes:
- \usepackage{eso-pic,graphicx,transparent}
然后在文档的第一页(在 LaTeX 部分)添加
\AddToShipoutPictureFG{
\AtPageCenter{% or \AtTextCenter
\makebox[0pt]{\rotatebox[origin=c]{45}{%
\scalebox{5}{\texttransparent{0.3}{DRAFT}}%
}}
}
}
这应该在页面的 F
oreG
圆形(顶部)中添加旋转的 DRAFT 消息(半透明)。
我研究并找到了如何在 rmarkdown 文档中创建水印。
它在基本文本上效果很好,但是当你有一个情节繁重的页面时,它会隐藏在情节后面。
显然,这使得有人可以很容易地截屏图形并在 PDF 之外使用它们。
下面是一些代码,清楚地演示了这个问题。
---
title: "Testing Watermark"
author: "John"
date: "September 18, 2015"
header-includes:
- \usepackage{draftwatermark}
output:
pdf_document
---
This is some basic text.
Note the watermark on this page, and the hidden watermark on the next page.
\newpage
\SetWatermarkText{DRAFT}
```{r echo=FALSE, warning=FALSE, message=FALSE, fig.height=7}
library(ggplot2)
ggplot(mtcars) +
geom_point(aes(mtcars$mpg, mtcars$cyl)) +
facet_wrap(~carb, ncol=1) +
theme_bw()
```
如果有人知道此问题的解决方法,我将不胜感激。
就我而言,要么使 ggplot 背景透明(我已经尝试过),要么将水印带到前景并使其透明。
尝试使用
header-includes:
- \usepackage{eso-pic,graphicx,transparent}
然后在文档的第一页(在 LaTeX 部分)添加
\AddToShipoutPictureFG{
\AtPageCenter{% or \AtTextCenter
\makebox[0pt]{\rotatebox[origin=c]{45}{%
\scalebox{5}{\texttransparent{0.3}{DRAFT}}%
}}
}
}
这应该在页面的 F
oreG
圆形(顶部)中添加旋转的 DRAFT 消息(半透明)。