[NTG-context] How to use layers or other methods for precise positioning of items

Mojca Miklavec mojca.miklavec.lists at gmail.com
Thu Nov 3 20:40:09 CET 2005

Kári Hreinsson wrote:
> Hello,
> I have been trying to use ConTeXt for setting up a book with a list of
> students in my school, with pictures of them, phone numbers, emails
> and such.
> I thought I could use ConTeXt for the job since LaTeX gave me much
> trouble in trying to alter the layout and look of the page.
> I found the "layer" feature in ConTeXt which I found very interesting
> and thought I could use it to position items (such as text info,
> images and the layout) within these layers since they offer very
> precise positioning with a x-y grid like system.
> When I was trying to use this feature for multipage document it cut of
> all of the pages except the first.  I found out that the layers
> weren't thought to be part of the content of the file but more like a
> background and I can't figure out how to use them on many pages
> without placing something like a dot on every page.  Is there any way
> to do this?

If "a dot" is the source of all your problems, you can easily solve
this by placing a \strut instead of a dot at the top of the page.
(Perhaps even \null would do.) \strut is an empty box with width zero
and height of "one line" (generally speaking).

I was confused for a long time since there are at least five different
ways to achieve the desired results, each one with its advantages and
drawbacks, so you may have to be even more specific about the layout.

You can do the whole page with layers if you are sure that you want to
provite all the coordinates by hand. If you use an alternative way (if
you place a figure at the left or right side of text for example),
space will be reserved and text will flow around the figure. If you
place a figure in a layer, you'll have to manually adjust text
width/height/hole, so that it won't overlap with the figure.

Some alternatives to layers that come to my mind in the first moment are:
1. tables (http://wiki.contextgarden.net/Tables_Overview)
with \bTABLE ... \eTABLE you can manully specify widths and heights of
table cells and put photos in the left cell with specified width. The
rest of data can go to the remaining cells on the right with
automatically determined widths and heights.

2. grid typesetting
you can position the stuff on the grid (still precise, but in other
units than centimeters)

3. http://wiki.contextgarden.net/Chromatograms uses \startpositioning
... \stoppositioning, which is probably something similar to layers. I
never used it, but perhaps you can take a look if you find it useful.

4. many other ways for sure (depending on your needs), in worst case
even plain TeX ;)

> I discovered that the layers were "inserted" into the document via
> "\setupbackgrounds[page]" so I understand why it acts like this but I
> am asking if there is some way of getting layers working like I want?

How is that? You can place layers in other ways than on the whole page
(you can say that a layer has to be two centimeters from the bottom
and three centimeters from the left edge or that it has to be 1cm
wider than the text area of the page), you can put them in the
backgrond or on the top of text, but you can't prevent them from being
invisible to the rest of the page content (you can't place a layer and
expect a text portion to flow around that layer).

> Maybe I am going in completely wrong way?  Is there any other good way
> to do this, that is positioning items with x-y coordinates or
> something totally different that I am missing?

see above (tables, grid, ...)

> Another thing I was wondering about is how to make items like images
> bleed (that is to go over the edge of the paper, to avoid white lines
> at the margin).  Can I use negative values for positioning to achive
> that?

You have a couple of examples in the official documentation (page 32
of details.pdf for example). google.com: "bleeding
If you position using frames, you can use negative values, yes. (See
the example below.)

> All help is greatly appreciated since I am not understanding this and
> I haven't found much help on the internet regarding this subject
> (contextgarden had only one example page that had layers).

Patrick already mentioned the new "search engine ;)" through articles.
I often use google.com and "layers site:contextgarden.net" for
example. You can find a lot in old mailing list archives.


		{\bfc Cut the head!}

More information about the ntg-context mailing list