rmarkdown中的水印 [英] Watermark in rmarkdown

查看:217
本文介绍了rmarkdown中的水印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究并发现了如何在rmarkdown文档中创建水印.

I have researched and found how to create a watermark in an rmarkdown document.

它在基本文本上效果很好,但是当您有一个绘图沉重的页面时,它会被隐藏在绘图后面.

It works great on basic text, but when you have a plot heavy page, it gets hidden behind the plot.

显然,这使某人可以轻松对数字进行截图并在PDF之外使用它们.

Obviously, this makes it easy for someone to screencap the figures and use them outside of the PDF.

下面是一些可以清楚地说明问题的代码.

Below is some code that demonstrates the issue clearly.

---
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()
```

如果有人知道解决方法,我将不胜感激.

If anyone is aware of a fix for this, I'd be grateful.

就我而言,要么使ggplot背景透明(我尝试过),要么将水印置于前景并使之透明.

Either making the ggplot backgrounds transparent (which I've tried), or bringing the watermark to the foreground and making it transparent would be ok as far as I'm concerned.

推荐答案

尝试使用

header-includes:
   - \usepackage{eso-pic,graphicx,transparent}

,然后在文档的第一页上(在LaTeX部分内)添加

and then on the first page of your document (within the LaTeX part), add

\AddToShipoutPictureFG{
  \AtPageCenter{% or \AtTextCenter
    \makebox[0pt]{\rotatebox[origin=c]{45}{%
      \scalebox{5}{\texttransparent{0.3}{DRAFT}}%
    }}
  }
}

这应该在页面的F ore G圆(顶部)中添加旋转的DRAFT消息(半透明).

This should add a rotated DRAFT message (semi-transparent) in the ForeGround (over top) of the page.

这篇关于rmarkdown中的水印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆