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.
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.
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.
Blank Lines To add a single extra line after a paragraph, add two extra spaces at the end of the text. To add an extra line of space between paragraphs, add the HTML code, followed by two extra spaces (e.g.  .. , replacing the periods with spaces).
To insert an image, you can also use an R code chunk. --- title: "R Markdown Tips and Tricks" output: html_document --- You can also insert an image using R code: ```{r} knitr::include_graphics("img/rmarkdown_hex. png") ``` The image looks smaller by default though.
Add Line Breaks in R Markdown To break a line in R Markdown and have it appear in your output, use two trailing spaces and then hit return .
RMarkdown is an extension to markdown which includes the ability to embed code chunks and several other extensions useful for writing technical reports. The rmarkdown package extends the knitr package to, in one step, allow conversion between an RMarkdown file (.Rmd) into PDF, HTML, word document, amongst others.
Try using
header-includes:
- \usepackage{eso-pic,graphicx,transparent}
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}}%
}}
}
}
This should add a rotated DRAFT message (semi-transparent) in the F
oreG
round (over top) of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With