Difference between revisions of "Layers"

From ConTeXt wiki
m (todo tag)
(first example for layers)
Line 4: Line 4:
  
 
There's still no manual about them.
 
There's still no manual about them.
 +
 +
=My first Layer=
 +
 +
Define a layer that takes the whole page, but starts with an offset
 +
<texcode>
 +
\definelayer [mybg] % name of the layer
 +
[x=-3mm, y=-3mm, % bleed over the page
 +
width=\paperwidth, height=\paperheight]
 +
</texcode>
 +
 +
Now you can put something on that layer:
 +
<texcode>
 +
\setlayer [mybg] % name of the layer
 +
[x=2cm, y=5cm] % placement (from upper left corner of the layer)
 +
{\framed[frame=on, width=3cm, height=2cm]{LAYER}}
 +
</texcode>
 +
 +
Activate the layer as a background:
 +
<texcode>
 +
\setupbackgrounds [page] [background=mybg]
 +
% switch it off again:
 +
\setupbackgrounds [page] [background=]
 +
</texcode>
 +
 +
You could also typeset the layer once using <cmd>placelayer</cmd> or <cmd>flushlayer</cmd>, but then the location depends from the upper left of the text area! (Bug?)
 +
 +
==Placement==
 +
 +
There are several possibilities for defining the placement of layer content:
 +
* x, y (or hoffset, voffset) : offset from upper left corner
 +
* corner : reference point, something like <code>{left, top}</code>
 +
* location : alignment of the element relative to the corner, something like <code>{right, bottom}</code>
 +
* preset : a named location, see below
 +
 +
There are some "presets" for paper egde placement:
 +
<texcode>
 +
% These four are defined by ConTeXt!
 +
\definelayerpreset [lefttop] [corner={left,top}, location={right,bottom}]
 +
\definelayerpreset [righttop] [corner={right,top}, location={left,bottom}]
 +
\definelayerpreset [leftbottom] [corner={left,bottom}, location={right,top}]
 +
\definelayerpreset [rightbottom] [corner={right,bottom}, location={left,top}]
 +
</texcode>
 +
Similarly you can define your own presets.
  
 
=Links=
 
=Links=

Revision as of 22:12, 14 January 2006

< Layout | Columns | Overlays | Logos >

Layers are ConTeXt's mechanism for absolute positioning of elements and other advanced techniques like switching elements on and off.

There's still no manual about them.

My first Layer

Define a layer that takes the whole page, but starts with an offset

\definelayer	[mybg]	% name of the layer
		[x=-3mm, y=-3mm,	% bleed over the page
		width=\paperwidth, height=\paperheight]

Now you can put something on that layer:

\setlayer	[mybg]	% name of the layer
		[x=2cm, y=5cm]	% placement (from upper left corner of the layer)
		{\framed[frame=on, width=3cm, height=2cm]{LAYER}}

Activate the layer as a background:

\setupbackgrounds	[page]	[background=mybg]
% switch it off again:
\setupbackgrounds	[page]	[background=]

You could also typeset the layer once using \placelayer or \flushlayer, but then the location depends from the upper left of the text area! (Bug?)

Placement

There are several possibilities for defining the placement of layer content:

  • x, y (or hoffset, voffset) : offset from upper left corner
  • corner : reference point, something like {left, top}
  • location : alignment of the element relative to the corner, something like {right, bottom}
  • preset : a named location, see below

There are some "presets" for paper egde placement:

% These four are defined by ConTeXt!
\definelayerpreset	[lefttop]	[corner={left,top}, location={right,bottom}]
\definelayerpreset	[righttop]	[corner={right,top}, location={left,bottom}]
\definelayerpreset	[leftbottom]	[corner={left,bottom}, location={right,top}]
\definelayerpreset	[rightbottom]	[corner={right,bottom}, location={left,top}]

Similarly you can define your own presets.

Links


TODO: We need a lot of documentation and samples for this complicated subject. (See: To-Do List)