[Tex/LaTex] How to set the page layout dimensions in ConTeXt

contextcontext-mkivmargins

Using the instructions found in the page design chapter of the ConTeXt user manual, I have attempted to set my own page dimensions, but have not been able to understand the instructions. For e.g., there are options for leftmargin, leftedge, leftmargindistance, leftedgedistance, but I do not understand how these translate to the page. To further complicate matters, when I compiled any documents, with showframe, \showstruts, and \showgrid options on, lots of red lines appeared in my document, suggesting there were many complex dimensions to set, as illustrated here:

 _____________________ _____________________
|  _   _________   _  |  _   _________   _  |                       
| |_| |         | |_| | |_| |         | |_| |
| |_| |         | |_| | |_| |         | |_| |                     
| | | |         | | | | | | |         | | | |                     
| | | |         | | | | | | |         | | | |                     
| | | |         | | | | | | |         | | | |                     
| | | |         | | | | | | |         | | | |                     
| | | |         | | | | | | |         | | | |                     
| | | |         | | | | | | |         | | | |                     
| | | |         | | | | | | |         | | | |
| |_| |_________| |_| | |_| |_________| |_| |
| |_| |_________| |_| | |_| |_________| |_| |
| |_| |_________| |_| | |_| |_________| |_| |
|_____________________|_____________________|
       (verso)                 (recto)

Generally, my page dimension needs are quite basic. Here is an illustration:

 _____________________ _____________________
|       ^             |             ^       |
|       a             |             a       |
|      _v_____        |        _____v_      |
|     |   ^   |       |       |       |     |
|     |   |   |       |       |       |     |
|<-b->|   c   |<--d-->|<--d-->|<--e-->|<-b->|
|     |   |   |       |       |       |     |
|     |___v___|       |       |_______|     |
|       ^ ^           |           ^ ^       |
|       | f           |           f |       |
|       | v           |           v |       |
|       g #           |           # g       |
|       |             |             |       |
|       |             |             |       |
|_______v_____________|_____________v_______|
       (verso)                 (recto)

a – length of top margin
b – width of outer margin
c – height of text area
d – width of gutter
e – width of text area
f – length of space between text area and page number
g – length of bottom margin

  • The dimensions of the verso pages and recto pages are identical, but mirrored at the gutter.
  • Any footnote text should appear within the text area.
  • Margin notes are not used.
  • The dimensions of c and e need not be set, these can fill the available dimensions left on the page.

How can I set the page layout dimensions in my document in ConTeXt?

Best Answer

The typesetting area in ConTeXt comprises twenty five areas (cutspace is missing in the figure):

context typesetting areas

You only need to set up text area and footer (for the page number):

\setuppagenumbering
  [alternative=doublesided, location=footer]

\setuplayout
  [header=0pt,
   margin=0pt,
   footerdistance=1cm,
   topspace=1cm,
   backspace=1cm,
   cutspace=8cm,
   width=fit,
   % margin bottom of text to paper
   height=\dimexpr
    \paperheight-\topspace+\footerheight+\footerdistance-5cm\relax]

\starttext
  \showlayout
  \null
\stoptext

\setuppagenumbering[alternative=doublesided] switches to the mirrored layout on even pages. When the top area and the header is set to zero, topspace states the distance from the top of the paper to the text area and backspace the distance from the left to the text. cutspace is the distance from the right of the text to the paper. For these to apply correctly, width=fit needs to be set.

The distance from the bottom of the text to the paper cannot be set directly but can be computed. The 5cm in the height= line states the distance from the bottom of the text to the bottom of the paper.

Related Question