Document layout and layers/Tutorials

Unofficial ConTeXt Wiki mirror

Last modified: 2025-12-26

Defining the paper size

Set the page size and its orientation with \setuppapersize.

Paper setup page provides further important features and options.

Typesetting areas

A ConTeXt page is divided into 5 columns and 5 rows, giving 25 areas. as illustrated by the graphic below, which also shows the associated dimensions.

E.g.

Defining the layout

Positioning the areas is by setting the following dimensions using \setuplayout[backspace=5cm,...]. The dimensions are mentioned in order of how ‘primitive’ they are: e.g. altering the topspace pushes around all other vertical dimensions, but altering the header affects only the headerdistance and the textheight.\

Use \showframe in the setup area to visualize the typesetting areas.

When you define a page layout, it's always a right page that you're defining; if you use a double page layout, 'right' and 'left' values are mirrored on a left page. Doublesided typesetting is activated with \setuppagenumbering[alternative=doublesided].

Now let's proceed in order:

  1. Set the backspace and width , and the topspace and height . The width is the width of the main typesetting area; the backspace is its distance from the left edge of the page. The height is the distance from the top of the header to the bottom of the footer ; the topspace is the distance from the top edge of the page to the top of the header.
  2. Set the header and headerdistance , and the footer and footerdistance . The header is the vertical size of the header area; the headerdistance is the distance from the header area to the text area. The footer and footerdistance work likewise.
  3. Once the header(distance) and footer(distance) are subtracted from the height , what remains is the textheight : the height of the main typesetting area. Although it would be very useful, you cannot set this dimension directly.
  4. If you want to typeset anything above the header, define topdistance (the distance from the top of the header to the bottom of the topmost typesetting area) and top (the height of the topmost typesetting area). For typesetting below the footer, define bottomdistance and bottom .
  5. As for the horizontal dimensions apart from the width : starting at the left edge of the main text area, and moving away from the center, one first sets the leftmargindistance ; then one sets the width leftmargin of the margin typesetting area; then one sets the leftedgedistance ; and then there is the leftedge typesetting area. On the right: rightmargindistance , rightmargin , rightedgedistance , rightedge .

TODO: illustrate the middle and fit options for width and height, Command/setuplayout#Description (See: To-Do List)

Examples layout

Adding headers and footers

Adding headers and footers is done with \setupheadertexts and \setupfootertexts. Usually you use these command twice:

You may also want to use the margin space or other areas. [text] area is the default.

Header and footer content

But usually you need useful information there. There are predefined keywords for popular values, like

By default you have the page number in the middle of the header, like if you would have asked for \setupheadertexts[pagenumber]. If you don't want the pagenumber there, you have to define \setupheadertexts [] in order to let this area empty.

Let's try another example:

You can customize the content, but then pay attention to give a group as argument, i.e. to provide your customization between {}

Vertical and horizontal alignment within header and footer

You may want to tweak the vertical and horizontal alignment of the header and footer content. The usual solution is to insert a \framed and to play with its options width, height, location, align.

For example:

More complex header and footer content with Setups

Double-sided

The principle is the same, but you have