Document layout and layers/Tutorials
Contents
Defining the paper size
Set the page size and its orientation with \setuppapersize.
\setuppapersize[A8] \starttext Hello world ! \stoptext
\setuppapersize[A8,landscape] \starttext Hello world ! \stoptext
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.
- The row and column names are written along the edges of the page.
- The arrows correspond to layout dimensions;
- the more important a dimension is (i.e. the more of the layout is pushed around when you change it), the thicker its arrow and the larger its name.
- From left to right, one encounters
leftedge
,leftmargin
,text
,rightmargin
, andrightedge
. - From top to bottom, the areas are called:
top
,header
,text
,footer
,bottom
.
E.g.
leftmargin
is the margin area to the left of the main text area,{leftmargin,bottom}
is below it, at the same height as thebottom
area,- in between the two lies the area
{leftmargin,footer}
.
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:
- Set the
backspace
andwidth
, and thetopspace
andheight
. Thewidth
is the width of the main typesetting area; thebackspace
is its distance from the left edge of the page. Theheight
is the distance from the top of the header to the bottom of the footer; thetopspace
is the distance from the top edge of the page to the top of the header. - Set the
header
andheaderdistance
, and thefooter
andfooterdistance
. Theheader
is the vertical size of the header area; theheaderdistance
is the distance from the header area to the text area. Thefooter
andfooterdistance
work likewise. - Once the header(distance) and footer(distance) are subtracted from the
height
, what remains is thetextheight
: the height of the main typesetting area. Although it would be very useful, you cannot set this dimension directly. - 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) andtop
(the height of the topmost typesetting area). For typesetting below the footer, definebottomdistance
andbottom
. - 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 theleftmargindistance
; then one sets the widthleftmargin
of the margin typesetting area; then one sets theleftedgedistance
; and then there is theleftedge
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
\setuppapersize[A8] \showframe \setuplayout [backspace=6mm, width=40mm, topspace=2mm, header=4mm, footer=4mm, headerdistance=1mm, footerdistance=1mm, margin=4mm, margindistance=1mm, height=70mm] \starttext Hello world ! \stoptext
- Other examples
- Cover pages: Cover pages (2013, 2019)
- Example of photo page layout (2010)
Adding headers and footers is done with \setupheadertexts and \setupfootertexts. Usually you use these command twice:
- a first time with one argument
[argument]
in order to define what will appear in the middle - a second time with two
[arg1][arg2]
(or four if you work with a double-sided document, see below)
\setuppapersize[A8] \setuppagenumbering[alternative=doublesided] \setupheadertexts[B] \setupheadertexts[A][C] \starttext Hello world ! \stoptext
But usually you need useful information there. There are predefined keywords for popular values, like
[chapter]
[section]
[pagenumber]
[date]
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 amother example:
\setuppapersize[A8] \setupheadertexts [] % To make it empty \setupheadertexts [date] [section] \setupfootertexts [pagenumber] \starttext \startsection[title=Hello] world ! \stopsection \stoptext
You can customize the content, but then pay attention to give a group as argument, i.e. to provide your customization between {}
\setuppapersize[A8] \setupheadertexts [] % To make it empty \setupheadertexts [] [{\tfx\sc\getmarking[section]}] \setupfootertexts [{\star}] \setupfootertexts [{\color[darkred]{page \pagenumber}}] [] \starttext \startsection[title=Hello] world ! \stopsection \stoptext
Double-sided
The principle is the same, but you have
- to declare that you work on a
[alternative=doublesided]
document with \setuppagenumbering - to setup both odd and even pages, so you have to provide four arguments
[arg1][arg2][arg3][arg4]
to \setupheadertexts and \setupfootertexts (see these pages for the details).
\definepapersize[sheet][width=156mm,height=74mm] \setuppapersize[A8][sheet] \setuppaper[nx=3,ny=1] \setuparranging[XY] \showframe[edge] \setupheadertexts [x] \setupheadertexts [C] [D] [B] [A] \setupfootertexts [y] \setupfootertexts [G] [H] [F] [E] \starttext \startsection[title=Hello] world ! \page with \page \ConTeXt \stopsection \stoptext