Difference between revisions of "Alternating backgrounds and repeating layers"

From Wiki
Jump to navigation Jump to search
(add link to Draft Watermark)
 
(One intermediate revision by one other user not shown)
Line 3: Line 3:
 
In my final usage of the code below, I changed the preset to bottomleft/bottomright and added hoffset/voffset values to position the text where I wanted it.  The solution below would also allow for placing images in the background instead of text.
 
In my final usage of the code below, I changed the preset to bottomleft/bottomright and added hoffset/voffset values to position the text where I wanted it.  The solution below would also allow for placing images in the background instead of text.
  
<pre>
+
<texcode>
 
\setuppagenumbering
 
\setuppagenumbering
 
  [alternative=doublesided]
 
  [alternative=doublesided]
Line 45: Line 45:
 
   \chapter{first}  \dorecurse{30}{\input tufte  }
 
   \chapter{first}  \dorecurse{30}{\input tufte  }
 
\stoptext
 
\stoptext
</pre>
+
</texcode>
 +
 
 +
For a somewhat different example, see [[Draft Watermark]]
 +
 
 +
[[Category:Layers]]

Latest revision as of 12:01, 19 January 2007

I was in need of adding a watermark to the background of a book. Left and right pages needed a different watermark. I also needed the ability to position the watermark anywhere on the page. Through a nice discussion on mailing list Hans was able to make clear how to go about this.

In my final usage of the code below, I changed the preset to bottomleft/bottomright and added hoffset/voffset values to position the text where I wanted it. The solution below would also allow for placing images in the background instead of text.

\setuppagenumbering
 [alternative=doublesided]

\setupcolors
 [state=start]

\setupbackgrounds
 [leftpage]
 [background=Watermark-Left]

\setupbackgrounds
 [rightpage]
 [background=Watermark-Right]

\definelayer
 [Watermark-Left]
 [repeat=yes,
  width=\paperwidth,
  height=\paperheight]

\definelayer
 [Watermark-Right]
 [repeat=yes,
  width=\paperwidth,
  height=\paperheight]

\setlayerframed
 [Watermark-Left]
 [preset=middle]
 [foregroundcolor=gray]
 {\scale[sx=12,sy=12]{\rotate[rotation=20.0]{left page watermark}}}

\setlayerframed
 [Watermark-Right]
 [preset=middle]
 [foregroundcolor=gray]
 {\scale[sx=12,sy=12]{\rotate[rotation=-20.0]{right page watermark}}}

\starttext
   \chapter{first}  \dorecurse{30}{\input tufte  }
\stoptext

For a somewhat different example, see Draft Watermark