Changes

Jump to navigation Jump to search
1,149 bytes added ,  13:46, 25 April 2012
no edit summary
Define a layer that takes the whole page
<texcode>
\definelayer [mybg] % name of the layer [x=0mm, y=0mm, % from upper left corner of paper width=\paperwidth, height=\paperheight] % let the layer cover the full paper
</texcode>
Now you can put something in that layer:
<texcode>
\setlayer [mybg] % name of the layer [hoffset=1cm, voffset=1cm] % placement (from upper left corner of the layer) {\framed[frame=on, width=3cm, height=2cm]{LAYER}} % the actual contents of the layer
</texcode>
Now you can test the whole thing:
<texcodecontext source=yes>\setuppapersize[A10,portrait][A9,landscape] % A10 = 2.6x3.7cm -- compact example\setuparranging[2SIDE] % show both pages\showframe % So we can see the pages \definelayer [mybg] % name of the layer [x=0mm, y=0mm, % from upper left corner of paper width=\paperwidth, height=\paperheight] , % let the layer cover the full paper state=continue] % on all pages but the first one
\setupbackgrounds[page][background=mybg]
\setlayer [mybg] % name of the layer [hoffset=1cm0.3cm, voffset=1cm0.7cm] % placement (from upper left corner of the layer) {\framed[frame=on, width=3cm2cm, height=2cm]{LAYER}} % the actual contents of the layer 
\starttext
\dorecurse{2}{\page[empty]} % for testing, to get 2 pages, 1st 2nd with layer, 2nd 1st without
\stoptext
 </texcodecontext>
You may experience cases where the defined size of your layer is ignored and you can’t get linebreaking or multiple lines at all.
This is due to <cmd>setlayer</cmd> using <cmd>hbox</cmd> internally. You can work around the problem using <cmd>setlayerframed</cmd>:
This does not work:<texcodecontext source=yes>\showframe \definelayer[AddressBg][ x=20mm0mm,y=30mm0mm, width=65mm,height=30mm, state=start] % size is ignored!\setupbackgrounds[paper][ setups=ALayer, background=AddressBg, state=start]
\starttext
\strut
\startsetups ALayer
\setlayer[AddressBg] % setlayer does not work here
[width=65mm, height=30mm,
frame=off,
hoffset=0mm, voffset=0mm,
align=right]%
{
PRAGMA Advanced Document Engineering\crlf
Mr. Hans Hagen (the wizard who wrote it all, \CONTEXT\ and everything else,
with the help of his little elves)\crlf
Ridderstraat 27\crlf
8061 GH Hasselt\crlf
THE NETHERLANDS
}
\stopsetups
</context>
<context source=yes>\setlayerframeddefinelayer[AddressBg][ x=0mm, y=0mm, width=65mm,height=30mm,frame state=off,hoffset=0mm,voffset=0mm,align=rightstart]%size is ignored!{PRAGMA Advanced Document Engineering\crlfsetupbackgrounds[paper][Mr. Hans Hagen (the wizard who wrote it all setups=ALayer, \CONTEXT\ and everything else background=AddressBg, with the help of his little elves)\crlfRidderstraat 27\crlf8061GH Hasselt\crlfTHE NETHERLANDS} state=start]
\startsetups ALayer
\setlayerframed[AddressBg] % setlayerframed does not work here
[width=65mm, height=30mm,
frame=off,
hoffset=0mm, voffset=0mm,
align=right]%
{
PRAGMA Advanced Document Engineering\crlf
Mr. Hans Hagen (the wizard who wrote it all, \CONTEXT\ and everything else,
with the help of his little elves)\crlf
Ridderstraat 27\crlf
8061 GH Hasselt\crlf
THE NETHERLANDS
}
\stopsetups
 
\page
\stoptext
</texcodecontext>
<context source="yes">
\setupexternalfigures[location={local,default}]
% (necessary for the wiki conTeXt Wiki's ConTeXt live processor)
\definelayer [figure][width=\overlaywidth,height=\overlayheight]

Navigation menu