1

I am trying to put two lines of background text over each page. I currently use background with TikZ to put one line of text at the bottom, but I additionally need to put "Confidental" accross every page.

\documentclass{minimal}
\usepackage[a5paper]{geometry}
\usepackage{lipsum}
\usepackage{background}
\backgroundsetup{
    contents={This document contains things which not everybody is supposed to read.},
    scale=1.0,
    placement=bottom,
    angle=0,
    color=red!50,
    pages=all
}
\begin{document}
    \lipsum{10}
\end{document}

current rendering, with line at the bottom

How can I add more material to background? In fact I am not sure what is supposed to go to contents, is it rendered via TikZ's \draw or something similar.

I need to be able to set things up in the preamble, as the rest of the document is generated via Sphinx and I have no chance adding things into document body (without hacks).

1

Something like this? (All I did is paste the example from the pgfmanual in section 17.13.2 in.) NOTE: An arguably much safer answer can be found below. When I wrote the following answer, I ignored the fact that backgrounds uses TikZ, and thus did not realize that I nest tikzpictures. Sorry for that!)

\documentclass{minimal}
\usepackage[a5paper]{geometry}
\usepackage{lipsum}
\usepackage{background}
\usepackage{tikz}
\backgroundsetup{
    contents={This document contains things which not everybody is supposed to read.
    \begin{tikzpicture}[remember picture,overlay] \node [rotate=60,scale=10,text opacity=0.2]
    at (current page.center) {Confidential};
\end{tikzpicture}},
    scale=1.0,
    placement=bottom,
    angle=0,
    color=red!50,
    pages=all
}
\begin{document}
    \lipsum{10}
\end{document}

enter image description here

UPDATE: Actually I think that my above original answer may be somewhat dangerous. Please consider switching to

\documentclass{minimal}
\usepackage[a5paper]{geometry}
\usepackage{lipsum}
%\usepackage{background}
\usepackage{tikz}
\usepackage{eso-pic}
\AddToShipoutPictureBG{
\begin{tikzpicture}[remember picture,overlay,text opacity=0.2,color=red!50] 
\node [rotate=60,scale=10] at (current page.center) {Confidential};
\node [anchor=south] at (current page.south) {This document contains things which not everybody is supposed to read.};
\end{tikzpicture}}
\begin{document}
    \lipsum{10}
\end{document}

The output is practically the same, IMHO it is even easier to customize this, and you are not really using the features which distinguish backgrounds from eso-pic. (Explanation: my original answer nests tikzpictures, which may have side-effects that are hard to control. Even though this does not happen in the above document, it may well happen if you continue customizing the document, or if others use it as a basis for similar documents.)

  • Thanks. Was reading background package docs only. This will make corporate guys very happy. And it is extensible, so I can also add legal disclaimers to the top of each page as well, yay!! – eudoxos Oct 23 '18 at 18:02
  • @eudoxos Yes. You may also use eso-pic for that. backgrounds seems to be a bit "violent" in the sense that the color of the text within the tikzpicture gets affected. So I am not sure if this solution is absolutely safe, perhaps eso-pic might be a safer choice. It also allows you to do the line at the bottom of the page. – user121799 Oct 23 '18 at 18:05
  • 1
    I looked at eso-pic myself now, since the ehm corporate want the CONFIDENTIAL to be in the front so that images are covered and cannot be cut out ;))) (pdfimages, anyone?). This was my solution, very similar to yours: \AddToShipoutPictureFG{ \tikz[color=red,opacity=.5,overlay]{ \node at (current page.south)[above]{This document contains things which not everybody is supposed to read.}; \node at (current page.center)[rotate=60,draw,scale=8]{\textsc{Confidential}}; } } – eudoxos Oct 24 '18 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.