Difference between revisions of "Alternating backgrounds and repeating layers"

From ConTeXt wiki
Jump to navigationJump to search
 
Line 1: Line 1:
 +
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 [http://archive.contextgarden.net/message/20061102.165302.c22abc29.en.html 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.
 +
 
<pre>
 
<pre>
 
\setuppagenumbering
 
\setuppagenumbering

Revision as of 13:39, 6 November 2006

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