1

With the help of Schrödinger's cat I've defined a tikz based command for printing an image saved in a box as a watermark:

\newcommand{\tikzwater}[2][]{%
  \tikz[remember picture,overlay]{%
    \node[#1] at (current page.center)%
      {#2};}}

The optional argument #1 allows me to pass key-value options to the node, like opacity. If I want to print the picture saved in \mybox with an opacity of .1, all I have to do is calling:

(1) \tikzwater[opacity=.1]{\usebox\mybox}

at the begining of each page.

Now comes the challenge of making a command that does this automatically.

More precisely, I want a command:

(2) \beginwater{\usebox\mybox}

that calls (1) at the begining of each page of the document, starting at the page where (2) is called. I also want a command:

(3) \endwater{\usebox\mybox}

that stops the calling of (1), again, at the page where (3) is called.

This command would be the last in a series of commands I made only using the packages tikz and pgfkeys. This is why I'm not satisfied by the answers given to previous similar questions, which are based on using other packages such a background, eco-pic, watermark, etc. The closest I know is David Carlisle's answer, but it doesn't let you decide where to begin and end the printing of the watermark.

I hope someone can give me a hand on this one.

lfba
  • 731
  • 4
  • 13
  • 2
    You could do that with the eco-pic package, where \AddToShipoutPictureBG allows you to add a background picture to this and all subsequent pages, and \AddToShipoutPictureBG* adds a picture to this page only. –  Sep 10 '19 at 12:18
  • Thanks @Schrödinger'scat, but I'd rather not use other packages except pgf/tikz. That is, unless you can convince me that there's a good reason for making an exception for eco-pic. – lfba Sep 10 '19 at 12:22
  • 1
    eso-pic allows you to put things really on the background (and so does atbegshi). –  Sep 10 '19 at 12:25
  • 4
    Well you need to add the code to a hook on every page (and remove it at the end). And you can do this either by using a hook provided by someone else (e.g. eso-pic or atbegshi or ...) or by writing the needed code yourself. I would do the first - much less work - but if you have free time you can go for the second. – Ulrike Fischer Sep 10 '19 at 12:25

0 Answers0