Changes

Jump to navigation Jump to search
2,446 bytes added ,  12:37, 19 January 2020
add some hints and links
'''Layers''' are ConTeXt's mechanism for absolute positioning of elements and other advanced techniques like switching elements on and off.
There's There’s still no manual about them.
==My first Layer==
\setupbackgrounds[page][background=mybg]
</texcode>
This command makes the contents of the layer appear only once after the background is activated. If you want to repeat the contents of the layer on each page, use the option <code>repeat=yes</code> in the {{cmd|definelayer}} command. Then the contents of the layer will be shown on every page. You can add to these contents by a new {{cmd|setlayer}}[mybg] command. To clear the accumulated contents use {{cmd|resetlayer}}>[mybg]. To make the layer appear on each page, so that it can be populated with different content, set the option <code>state=repeat</code> in {{cmd|setupbackgrounds}}.
Now you can test the whole thing:
</texcode>
Similarly you can define your own presets.
 
===Understanding "location" and "corner"===
 
The layer is divided into a 2x2 matrix of squares, where 'x' is the center.
This gets you a total of 3x3=9 different corners.
o---o---o
| | |
o---x---o
| | |
o---o---o
 
Now you choose one 'corner' (the reference point) for the placement of the content. The content is placed in relation to this point.
The chosen 'corner' c is our new 'center point' (only for placement) now.
With 'location' you define where (in relation to 'corner') the content is placed.
Again you have nine different corners to choose from.
==== Example: to make this clear ====
Specifications <code>corner={top,right},location={bottom,right}</code> will place content in the area L (outside the original layer).
Think about the 'corner' c as a magnetic grid point, where the content snaps to.
The 'location' defines, from which direction we approach the point c.
* x = layer center point
* c = corner 'top,right'
* d = location 'bottom right'
* L = location (area)
o---o---o
| | |
----o---c---o
| | | L |
----x---o---d
| | |
---------
 
==== Example: placing a logo to the top right corner of the page ====
 
<context source=yes text="gives:">
\definelayer
[Logo]
[location={left,bottom},
x=\paperwidth,y=0mm,
hoffset=-5mm,voffset=5mm,
]
\setlayer[Logo]
{\framed[width=3cm,height=1cm,background=color,backgroundcolor=lightgray]{Logo...}}
\setupbackgrounds[page][background=Logo]
 
\starttext
%\showframe
 
Some text...
\stoptext
</context>
 
Often it makes sense to use a preset (e.g. "lefttop") and move the contents with "hoffset" and "voffset" (positive values move into the page, negative values move into the outer borders).
==State==
* next: layer appears on the following page
* continue: layer appears on all pages except the first
 
==Layers on top==
 
Usually, layers are in the background of your page (or text area). But sometimes you need your layer content on top of the regular content. Then you must set the foreground as one of the backgrounds like this:
 
<texcode>
\setupbackgrounds[page][background={mybacklayer,foreground,myfrontlayer}]
</texcode>
 
The order of backgrounds from left to right is from bottom to top.
==Line breaking and fixed size==
frame=off,
hoffset=0mm, voffset=0mm,
align=right] %You must set align to get multiple lines!
{
PRAGMA Advanced Document Engineering\crlf
== Layers and the delayed font mechanism ==
 
'''TL;DR: Setup your fonts before your layers.'''
Until some years ago the Latin Modern font was always automatically
* Source: [[source:pack-lyr.mkii|pack-lyr.mkii]] or [[source:pack-lyr.mkiv|pack-lyr.mkiv]]
* Example of [[Alternating backgrounds and repeating layers]] and [[Draft Watermark]]
* [http://www.ntg.nl/pipermail/ntg-context/2013/070935.html Layer vs. overlay] by Wolfgang
* {{cmd|setupbackgrounds}}
* {{cmd|definelayer}}, {{cmd|setuplayer}}
* {{cmd|setlayer}}, {{cmd|setlayerframed}}
{{todo|We need a lot of documentation and samples for this complicated subject.}}
 
[[Category:Graphics]] [[Category:Layers]]

Navigation menu