2

I have imported a graphic and stored it as a grayscale tikzfading with the command:

\begin{tikzfadingfrompicture}[name=thefading, inner sep=100]%
  \node [fill={transparent!0}]%
    {\includegraphics[width=8cm,height=8cm]{thegraphic}};%
\end{tikzfadingfrompicture}

I now want to use thefading as a watermark; that is I want to put it at the center and at the back of the page, with the original width and height, and with a level of opacity and colour of my chosing. I have tried the following command with trashy results:

\tikz[remember picture,overlay]%
  \node[%
    path fading=thefading,%
    fit fading=false,%
    fill=blue,%
    fill opacity=.2,%
    minimum width=8cm,%
    minimum height=8cm]%
    at (current page.center) {};%

I hope somebody can help me in this one. Thanks in advance.

PS: By the way, what does exactly inner sep mean? I don't understand the explanation in the manual. Here, I use the value 100 because it has an effect when I double fade the graphic: it removes the coloured line around the final tikzimage. But I discovered this just by playing around with the code. Several other values also work.

lfba
  • 731
  • 4
  • 13

1 Answers1

3

Yes, it seems that fading does not cooperated with a full overlay picture, perhaps because then it is not clear what the dimensions are. One simple possibility to work around this is to store the result in a \savebox, which you can use for your watermark. If you use this watermark on several pages, this method has the advantage of being a bit faster.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\newsavebox\FadeBox
\begin{document}
\begin{tikzfadingfrompicture}[name=thefading]%
\node[transparent!0]{\includegraphics[width=8cm,height=8cm]{example-image-duck}};%
\end{tikzfadingfrompicture}%
\savebox\FadeBox{\tikz{%
\path[path fading=thefading,fit fading=false,fill=blue] 
(-4,-4) rectangle
(4,4);}}%

\tikz[remember picture,overlay]{%
\node[opacity=0.2] at (current page.center){\usebox\FadeBox};}%
\end{document}

enter image description here

BTW, inner sep controls the distance between the node contents and its border. Setting it to 100 is interpreted as 100pt, which is somewhat similar to 4cm, which is why this may have helped you. Nonetheless I feel that the \savebox route is cleaner.