Joh*_*arr 12 latex watermark r knitr r-markdown
我研究并发现了如何在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()
```
Run Code Online (Sandbox Code Playgroud)
如果有人知道解决这个问题,我将不胜感激.
要么让ggplot背景透明(我已经尝试过),或者将水印带到前台并使其透明,就我而言是可以的.
尝试使用
header-includes:
- \usepackage{eso-pic,graphicx,transparent}
Run Code Online (Sandbox Code Playgroud)
然后在文档的第一页(在LaTeX部分中)添加
\AddToShipoutPictureFG{
\AtPageCenter{% or \AtTextCenter
\makebox[0pt]{\rotatebox[origin=c]{45}{%
\scalebox{5}{\texttransparent{0.3}{DRAFT}}%
}}
}
}
Run Code Online (Sandbox Code Playgroud)
这应该在页面的F
矿石G
轮(顶部)中添加旋转的DRAFT消息(半透明).