Difference between revisions of "Layout"

From Wiki
Jump to navigation Jump to search
m (paper sizes)
(→‎Defining the layout: Clarified wording)
Tags: Mobile web edit Mobile edit
 
(86 intermediate revisions by 19 users not shown)
Line 1: Line 1:
< [[Visuals]] | [[Layers]] | [[Columns]] | [[Visual Debugging]] >
+
__TOC__
  
== Location of Areas ==
+
This page focuses on '''Basics of page design and layout'''. It will allow you to continue on [[#Further reading|further topics]] like [[Presentations|Presentations layout]], [[Visual_Debugging|Visual debugging]], [[Floating Objects]], [[Columns]], [[Layers]], [[Grid typesetting]], [[PDF Boxes]]. But first, one needs to understand the basics of page layout by ConTeXt.
  
You can use these design areas in your page:
+
= Typesetting areas =
  
<table>
+
The 25 typesetting areas of a ConTeXt page are divided into 5 columns and 5 rows. From left to right, one encounters {{code|leftedge}}, {{code|leftmargin}}, {{code|text}}, {{code|rightmargin}}, and {{code|rightedge}}. From top to bottom, the areas are called: {{code|top}}, {{code|header}}, {{code|text}}, {{code|footer}}, {{code|bottom}}. E.g. {{code|leftmargin}} is the margin area to the left of the main text area; {{code|{leftmargin,bottom}|}} is below it, at the same height as the {{code|bottom}} area. In between the two lies the area {{code|{leftmargin,footer}|}}.
<tr style="background:#ccccff;">
 
<td style="background:#ffffff;"></td>
 
<td style="text-align:center;">leftedge </td>
 
<td style="text-align:center;width:15%;">leftmargin </td>
 
<td style="text-align:center;width:50%;">text </td>
 
<td style="text-align:center;width:15%;">rightmargin </td>
 
<td style="text-align:center;">rightedge </td>
 
</tr>
 
<tr style="background:#cccccc;">
 
<td style="background:#ccccff;"> top </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">&uarr; topspace &darr;</td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">. </td>
 
</tr>
 
<tr style="background:#cccccc;">
 
<td style="background:#ccccff;"> header </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;background:#DDDDDD;">HEADER<br />&uarr; headerheight &darr;</td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">.  </td>
 
</tr>
 
<tr style="background:#cccccc;">
 
<td style="background:#ccccff;"> text </td>
 
<td style="text-align:center;">&larr;leftedgewidth&rarr;</td>
 
<td style="text-align:center;background:#DDDDDD;">MARGINALS<br />&larr;leftmarginwidth&rarr;</td>
 
<td style="text-align:center;height:20em;background:#EEEEEE;">TEXT<br />&larr;textwidth&rarr;<br />&times;<br />&uarr; textheight &darr;</td>
 
<td style="text-align:center;background:#DDDDDD;">MARGINALS<br />&larr;rightmarginwidth&rarr;</td>
 
<td style="text-align:center;">&larr;rightedgewidth&rarr;</td>
 
</tr>
 
<tr style="background:#cccccc;">
 
<td style="background:#ccccff;"> footer </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;background:#DDDDDD;">FOOTER<br />&uarr; footerheight &darr;</td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">. </td>
 
</tr>
 
<tr style="background:#cccccc;">
 
<td style="background:#ccccff;"> bottom </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">.</td>
 
<td style="text-align:center;">. </td>
 
<td style="text-align:center;">. </td>
 
</tr>
 
</table>
 
  
There's also a "distance" between each of the areas, e.g. <tt>leftedgedistance</tt>, <tt>leftmargindistance</tt> (from the named area to the inner).  
+
The graphic below illustrates the areas and 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.
  
== Table of Parameters ==
+
[[Image:layout.svg||||Diagram of \setuplayout[] dimensions]]
  
<table>
+
= Defining the layout =
<tr style="background:#cccccc;vertical-align=top;"><th>Parameter</th><th>Variable</th><th>Remarks</th>
 
</tr>
 
<tr>
 
<td>paperheight</td>
 
<td><cmd>paperheight</cmd></td>
 
<td>height of paper page</td>
 
</tr>
 
<tr>
 
<td>paperwidth</td>
 
<td><cmd>paperwidth</cmd></td>
 
<td>width of paper page</td>
 
</tr>
 
<tr>
 
<td>printpaperheight</td>
 
<td><cmd>printpaperheight</cmd></td>
 
<td>differs from paperheight when using [[Imposition]] (arranging)</td>
 
</tr>
 
<tr>
 
<td>printpaperwidth</td>
 
<td><cmd>printpaperwidth</cmd></td>
 
<td>differs from paperwidth when using [[Imposition]] (arranging)</td>
 
</tr>
 
<tr>
 
<td>topspace</td>
 
<td><cmd>topspace</cmd></td>
 
<td>above header: from top rim of paper to to top rim of header</td>
 
</tr>
 
<tr>
 
<td>backspace</td>
 
<td><cmd>backspace</cmd></td>
 
<td>from left rim of paper to left rim of text area</td>
 
</tr>
 
<tr>
 
<td>height</td>
 
<td><cmd>makeupheight</cmd></td>
 
<td>sum of heights of text area, header and footer (plus distances)</td>
 
</tr>
 
<tr>
 
<td>width</td>
 
<td><cmd>makeupwidth</cmd></td>
 
<td>normally same as textwidth</td>
 
</tr>
 
<tr>
 
<td>top</td>
 
<td><cmd>topheight</cmd></td>
 
<td>??</td>
 
</tr>
 
<tr>
 
<td>topdistance</td>
 
<td><cmd>topdistance</cmd></td>
 
<td>?? between topspace and header ??</td>
 
</tr>
 
<tr>
 
<td>header</td>
 
<td><cmd>headerheight</cmd></td>
 
<td>height of header area</td>
 
</tr>
 
<tr>
 
<td>headerdistance</td>
 
<td><cmd>headerdistance</cmd></td>
 
<td>between header and text</td>
 
</tr>
 
<tr>
 
<td>textheight</td>
 
<td><cmd>textheight</cmd></td>
 
<td>height of text area</td>
 
</tr>
 
<tr>
 
<td>footerdistance</td>
 
<td><cmd>footerdistance</cmd></td>
 
<td>between text and footer</td>
 
</tr>
 
<tr>
 
<td>footer</td>
 
<td><cmd>footerheight</cmd></td>
 
<td>height of footer area</td>
 
</tr>
 
<tr>
 
<td>bottomdistance</td>
 
<td><cmd>bottomdistance</cmd></td>
 
<td>?? between footer and bottom ??</td>
 
</tr>
 
<tr>
 
<td>bottom</td>
 
<td><cmd>bottomheight</cmd></td>
 
<td>space below footer (but isn't calculated automatically)</td>
 
</tr>
 
<tr>
 
<td>leftedge</td>
 
<td><cmd>leftedgewidth</cmd></td>
 
<td>from left rim of paper to left rim of left margin</td>
 
</tr>
 
<tr>
 
<td>leftedgedistance</td>
 
<td><cmd>leftedgedistance</cmd></td>
 
<td>?? between leftegde and left margin ??</td>
 
</tr>
 
<tr>
 
<td>leftmargin</td>
 
<td><cmd>leftmarginwidth</cmd></td>
 
<td>width of left margin (marginals space)</td>
 
</tr>
 
<tr>
 
<td>leftmargindistance</td>
 
<td><cmd>leftmargindistance</cmd></td>
 
<td>between left margin and text</td>
 
</tr>
 
<tr>
 
<td>textwidth</td>
 
<td><cmd>textwidth</cmd></td>
 
<td>width of text area</td>
 
</tr>
 
<tr>
 
<td>rightmargindistance</td>
 
<td><cmd>rightmargindistance</cmd></td>
 
<td>between text area and right margin</td>
 
</tr>
 
<tr>
 
<td>rightmargin</td>
 
<td><cmd>rightmarginwidth</cmd></td>
 
<td>width of right margin (marginals area)</td>
 
</tr>
 
<tr>
 
<td>rightedgedistance</td>
 
<td><cmd>rightedgedistance</cmd></td>
 
<td>?? between right margin and right edge ??</td>
 
</tr>
 
<tr>
 
<td>rightedge</td>
 
<td><cmd>rightedgewidth</cmd></td>
 
<td>from right margin to right rim of paper</td>
 
</tr>
 
</table>
 
  
== Setup ==
+
Positioning the areas is by setting the following dimensions using {{cmd|setuplayout|[backspace=5cm,...]}}. The dimensions are mentioned in order of how ‘primitive’ they are: e.g. altering the {{code|topspace}} pushes around all other vertical dimensions, but altering the {{code|header}} affects only the {{code|headerdistance}} and the {{code|textheight}}.
  
You define always a right page; if you use a double page layout 'right' and 'left' values are mirrored on a left page.
+
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 {{cmd|setuppagenumbering|[alternative=doublesided]}}.
 +
 
 +
# Set the {{code|backspace}} and {{code|width}}, and the {{code|topspace}} and {{code|height}}. The {{code|width}} is the width of the main typesetting area; the {{code|backspace}} is its distance from the left edge of the page. The {{code|height}} is the distance ''from the top of the header to the bottom of the footer''; the {{code|topspace}} is the distance from the top edge of the page to the top of the header.
 +
# Set the {{code|header}} and {{code|headerdistance}}, and the {{code|footer}} and {{code|footerdistance}}. The {{code|header}} is the vertical size of the header area; the {{code|headerdistance}} is the distance from the header area to the text area. The {{code|footer}} and {{code|footerdistance}} work likewise.
 +
# Once the header(distance) and footer(distance) are subtracted from the {{code|height}}, what remains is the {{code|textheight}}: 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 {{code|topdistance}} (the distance from the top of the header to the bottom of the topmost typesetting area) and {{code|top}} (the height of the topmost typesetting area). For typesetting below the footer, define {{code|bottomdistance}} and {{code|bottom}}.
 +
# As for the horizontal dimensions apart from the {{code|width}}: starting at the left edge of the main text area, and moving away from the center, one first sets the {{code|leftmargindistance}}; then one sets the width {{code|leftmargin}} of the margin typesetting area; then one sets the {{code|leftedgedistance}}; and then there is the {{code|leftedge}} typesetting area. On the right: {{code|rightmargindistance}}, {{code|rightmargin}}, {{code|rightedgedistance}}, {{code|rightedge}}.
 +
 
 +
= Paper size =
 +
 
 +
See the dedicated page [[PaperSetup|Paper setup]], it includes details on:
 +
* {{cmd|setuppapersize}}, to set the page size and paper size
 +
* {{cmd|definepapersize}}, to define a new paper size,
 +
* the [[PaperSetup#Predefined_Paper_Sizes|many paper sizes already defined by name]]. Their actual dimensions in mm are given by [[Paper sizes]] page.
 +
* [[PaperSetup#Changing paper setup mid-document|Changing paper setup mid-document]]
 +
* [[PaperSetup#Setting print size|Setting print size]]
 +
* [[PaperSetup#Fitting pages to their content|Fitting pages to their content]]
 +
 
 +
= Example layout =
  
 
<texcode>
 
<texcode>
\setuppapersize[A4][A4] % this is default and may be omitted
+
\setuppapersize[A4][A4] % this is the default and may be omitted
 
\setuplayout[backspace=20mm,
 
\setuplayout[backspace=20mm,
width=160mm,
+
    width=160mm,
topspace=20mm, top=0mm,
+
    topspace=20mm,
header=0mm, footer=0mm,
+
    header=0mm,
height=250mm]
+
    footer=0mm,
 +
    height=250mm]
 
</texcode>
 
</texcode>
  
You can make all the geometry information visible with <cmd>showlayout</cmd> and the [[Visual Debugging|related commands]].
+
== Let's gather examples here ==
 +
 
 +
; Cover pages
 +
* [[Example MetaFun Cover Page]] (2019) with MetaFun
 +
* [[Simple Cover Page]] (2013)
 +
* [[A Very Simple Cover Page]] (2009)
 +
; Other
 +
* [[Example photo page layout]] (2010)
 +
 
 +
= [[Imposition]] =
 +
 
 +
Imposition is a prepress printing process. It consists of the arrangement of the printed product’s pages on the printer’s sheet, in order to obtain faster printing, simplify binding and reduce paper waste ([https://en.wikipedia.org/wiki/Imposition wikipedia]).
 +
 
 +
We built a dedicated page about '''[[Imposition]]''', because making booklets, to arrange pages in proper order for printing it's a topic in itself. This is where you will use {{cmd|setuppaper}} and {{cmd|setuparranging}}.
 +
 
 +
= Multiple layouts =
 +
 
 +
If you need to use different layouts in some parts of the document, you can set up a global layout, and then define additional named layouts for the deviating parts. You only need to specify the dimensions that differ: unspecified dimensions will be inherited from the global layout.
 +
 
 +
To switch to a different layout, call it up in the appropriate place in the document. To revert back to the global layout, use {{cmd|setuplayout}}|[reset].
 +
 
 +
<texcode>
 +
\setuplayout[...] % global layout
 +
\definelayout[wide][...] % layout of the first page
 +
 
 +
\setuplayout[wide]  % switch to layout called 'wide'
 +
\setuplayout[reset] % switch back to the global layout
 +
</texcode>
 +
 
 +
To specify in advance that you want to change layouts starting from page 4 (e.g.), use {{cmd|definelayout}}|[4][...]. Resetting the layout must be done explicitly; else, the new layout will be used until the end of the document.
 +
 
 +
<texcode>
 +
% different layout for first two pages
 +
\definelayout[1][wide]
 +
\definelayout[3][reset]
 +
</texcode>
 +
 
 +
For the page numbers you can use absolute numbers (as above), relative numbers (like +1, -2) or the keywords odd, even, first and last.
 +
 
 +
<texcode>
 +
\setuplayout[ % default layout (right page)
 +
...
 +
]
 +
\definelayout[even][ % different layout on left pages
 +
...
 +
]
 +
</texcode>
 +
 
 +
If you define additional layouts in a doublepage (duplex) setup, remember to think mirrored: leftmargin defines the right margin, backspace is the distance from the spine to the right edge of the text area etc.
 +
 
 +
.
 +
<div style="border: 3px solid red; background: #ffcccc; padding: 0.4em;">
 +
<div style="font-size: 1.3em; fontweight: bold">Warning!</div>
 +
At the moment a layoutchange (setuplayout) inside a page is not proper working in mkiv duplex mode.
 +
For more details and actual state see mailing list and [http://wiki.contextgarden.net/User_talk:Zenlima Bug Layoutchange inside page while duplexmode].
 +
</div>
 +
 
 +
= Table of Parameters =
 +
 
 +
The first colum is the name by which the variable is set in {{cmd|setuplayout}}. The second column is the name by which TeX stores the variable. This name is usually the same, but sometimes different; knowing it allows you to invoke it with code like <code>The paper's height is \the\paperheight.</code> Any remarks (usually a short description) are given in the third column.
 +
 
 +
{| class=wikitable
 +
! \setuplayout[...] !! dimension !! Remarks
 +
|-
 +
| paperheight
 +
| {{cmd|paperheight}}
 +
| height of paper page
 +
|-
 +
| paperwidth
 +
| {{cmd|paperwidth}}
 +
| width of paper page
 +
|-
 +
| printpaperheight
 +
| {{cmd|printpaperheight}}
 +
| differs from paperheight when using [[Imposition]] (arranging)
 +
|-
 +
| printpaperwidth
 +
| {{cmd|printpaperwidth}}
 +
| differs from paperwidth when using [[Imposition]] (arranging)
 +
|-
 +
| topspace
 +
| {{cmd|topspace}}
 +
| above header: from top rim of paper to to top rim of header
 +
|-
 +
| backspace
 +
| {{cmd|backspace}}
 +
| from left rim of paper to left rim of main text area
 +
|-
 +
| height
 +
| {{cmd|makeupheight}}
 +
| sum of heights of text area, header and footer (plus distances)
 +
|-
 +
| width
 +
| {{cmd|makeupwidth}}
 +
| width of the main text area. {{cmd|makeupwidth}} is normally same as {{cmd|textwidth}}, but it can be different, for example in columns
 +
|-
 +
| top
 +
| {{cmd|topheight}}
 +
| height of the top area
 +
|-
 +
| topdistance
 +
| {{cmd|topdistance}}
 +
| between top and header
 +
|-
 +
| header
 +
| {{cmd|headerheight}}
 +
| height of header area
 +
|-
 +
| headerdistance
 +
| {{cmd|headerdistance}}
 +
| between header and text
 +
|-
 +
| textheight
 +
| {{cmd|textheight}}
 +
| height of text area
 +
|-
 +
| footerdistance
 +
| {{cmd|footerdistance}}
 +
| between text and footer
 +
|-
 +
| footer
 +
| {{cmd|footerheight}}
 +
| height of footer area
 +
|-
 +
| bottomdistance
 +
| {{cmd|bottomdistance}}
 +
| between footer and bottom
 +
|-
 +
| bottom
 +
| {{cmd|bottomheight}}
 +
| space below footer (but isn't calculated automatically)
 +
|-
 +
| bottomspace
 +
| {{cmd|bottomspace}}
 +
| space from bottom footer to bottom rim of paper
 +
|-
 +
| cutspace
 +
| {{cmd|cutspace}}
 +
| from right rim of paper to right rim of main text area
 +
|-
 +
| leftedge
 +
| {{cmd|leftedgewidth}}
 +
| from left rim of paper to left rim of left margin
 +
|-
 +
| leftedgedistance
 +
| {{cmd|leftedgedistance}}
 +
| between leftegde and left margin
 +
|-
 +
| leftmargin
 +
| {{cmd|leftmarginwidth}}
 +
| width of left margin (marginals space)
 +
|-
 +
| leftmargindistance
 +
| {{cmd|leftmargindistance}}
 +
| between left margin and text
 +
|-
 +
| textwidth
 +
| {{cmd|textwidth}}
 +
| width of text area. when columns are used, the value of {{cmd|textwidth}} can differ from {{cmd|makeupwidth}}
 +
|-
 +
| rightmargindistance
 +
| {{cmd|rightmargindistance}}
 +
| between text area and right margin
 +
|-
 +
| rightmargin
 +
| {{cmd|rightmarginwidth}}
 +
| width of right margin (marginals area)
 +
|-
 +
| rightedgedistance
 +
| {{cmd|rightedgedistance}}
 +
| between right margin and right edge
 +
|-
 +
| rightedge
 +
| {{cmd|rightedgewidth}}
 +
| from right margin to right rim of paper
 +
|-
 +
| horoffset
 +
| ?
 +
| bleed from left of paper
 +
|-
 +
| voroffset
 +
| ?
 +
| bleed from top of paper
 +
|}
 +
 
 +
'''Note:'''
 +
 
 +
* width=middle
 +
<texcode>
 +
    if cutspace == 0pt then
 +
        cutspace = backspace
 +
    end
 +
    makeupwidth =  paperwidth- backspace -cutspace
 +
</texcode>
 +
 
 +
* width=fit
 +
<texcode> 
 +
      if cutspace == 0pt then
 +
          cutspace = backspace
 +
      end
 +
      makeupwidth = paperwidth-cutspace
 +
      scratchdimen = backspace - leftedgewidth-leftedgedistance-leftmarginwidth-leftmargindistance
 +
      if scratchdimen< 0pt then
 +
          scratchdimen = 0pt
 +
      end
 +
      makeupwidth = makeupwidth - rightmargindistance-rightmarginwidth- rightedgedistance-rightedgewidth- scratchdimen
 +
</texcode>
 +
 
 +
* otherwise:
 +
<texcode>
 +
      makeupwidth=width
 +
      if cutspace == 0pt then
 +
          cutspace = paperwidth-makeupwidth-backspace
 +
      else
 +
            % A kind of inconsistent specification, but used
 +
            % in for instance s-pre-19.tex; the cutspace is
 +
            % used only for determining some kind of right
 +
            % margin; don't use this in doublesided mode
 +
      pass
 +
      end
 +
</texcode>
 +
(From {{src|page-lay.mkiv}}.)
  
See <cmd>setuplayout</cmd> and <cmd>setuppapersize</cmd> in the manual.
 
  
If you need an unusual paper size, use <cmd>definepapersize</cmd> and have a look at our list of [[PaperSizes|paper sizes]].
+
= Further reading =
  
== Hints ==
 
  
By using [[Layers]], you can also place elements at specific places, as done in the [[BusinessCard]] example.
+
* '''[[Presentations]]''': specifics requirements, specific pages (widgets, multimedia, ...)
 +
* [[Documentation|Manuals about layout]], and noticeably:
 +
** The basics with '''[http://context.aanhet.net/svn/contextman/context-reference/en/co-pagedesign.pdf Page design & Layout chapter]''' from the reference manual (2011)
 +
** The more advance '''[http://www.pragma-ade.com/general/manuals/details.pdf It's in the Details]''' manual (2015), including grid typesetting.
 +
* '''[[Visual Debugging#Layout|Visual Debugging]]''': can greatly facilitate the set up of your layout.
 +
* After the layout, we can usually focus on the following subjects:
 +
** '''[[Floating Objects]]'''
 +
** '''[[Columns]]'''
 +
** '''[[Layers]]''', for absolute positioning of objects on the page, background, foreground etc.)
 +
** '''[[Grid typesetting]]''' (working with fixed distances)
 +
** '''[[Delimiter]]''', master line break and page break
 +
** '''[[Hiding Content]]'''
 +
* About PDF format
 +
** [[PDF Boxes]]: the size of PDF pages can have different meanings – e.g. the visible page, the printed page, the cropped printed page. ConTeXt can define the set of boxes defined by the PDF standard
 +
** [[PDF Print Options]]
 +
** [[Viewer Layers]] PDF has a concept of layers that you can enable and disable (at least in a few viewers). This has nothing to do with ConTeXt’s [[Layers]].
 +
** [[PDF/A]], ConTeXt can create PDF/A compliant outputs
 +
** [[PDFX]], ConTeXt can create PDF/X compliant outputs, the ISO standard.
 +
* For layout from a [[Formatting Objects|XML/FO]] perspective, with some descriptive pictures, see At [http://getfo.sourceforge.net/context_xml/index.html Paul Tremblay's] [[XML]] ConTeXt site.
  
At [http://getfo.sourceforge.net/context_xml/index.html Paul Tremblay's] [[XML]] ConTeXt site, there's a lot about layout from a [[Formatting Objects|XML/FO]] perspective with some descriptive pictures.
 
  
{{todo|Unfortunately it's not that easy to define a layout. We need more documentation about which parameters define which length, what influences what else etc.}}
+
[[Category:Layout]]

Latest revision as of 04:06, 16 June 2020

This page focuses on Basics of page design and layout. It will allow you to continue on further topics like Presentations layout, Visual debugging, Floating Objects, Columns, Layers, Grid typesetting, PDF Boxes. But first, one needs to understand the basics of page layout by ConTeXt.

Typesetting areas

The 25 typesetting areas of a ConTeXt page are divided into 5 columns and 5 rows. From left to right, one encounters leftedge, leftmargin, text, rightmargin, and rightedge. 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 the bottom area. In between the two lies the area {leftmargin,footer}.

The graphic below illustrates the areas and 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.

Diagram of \setuplayout[] dimensions

Defining the layout

Positioning the areas is by setting the following dimensions using \setuplayout. 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.

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.

  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.

Paper size

See the dedicated page Paper setup, it includes details on:

Example layout

\setuppapersize[A4][A4] % this is the default and may be omitted
\setuplayout[backspace=20mm,
    width=160mm,
    topspace=20mm,
    header=0mm,
    footer=0mm,
    height=250mm]

Let's gather examples here

Cover pages
Other

Imposition

Imposition is a prepress printing process. It consists of the arrangement of the printed product’s pages on the printer’s sheet, in order to obtain faster printing, simplify binding and reduce paper waste (wikipedia).

We built a dedicated page about Imposition, because making booklets, to arrange pages in proper order for printing it's a topic in itself. This is where you will use \setuppaper and \setuparranging.

Multiple layouts

If you need to use different layouts in some parts of the document, you can set up a global layout, and then define additional named layouts for the deviating parts. You only need to specify the dimensions that differ: unspecified dimensions will be inherited from the global layout.

To switch to a different layout, call it up in the appropriate place in the document. To revert back to the global layout, use \setuplayout|[reset].

\setuplayout[...] % global layout
\definelayout[wide][...] % layout of the first page

\setuplayout[wide]  % switch to layout called 'wide'
\setuplayout[reset] % switch back to the global layout

To specify in advance that you want to change layouts starting from page 4 (e.g.), use \definelayout|[4][...]. Resetting the layout must be done explicitly; else, the new layout will be used until the end of the document.

% different layout for first two pages
\definelayout[1][wide]
\definelayout[3][reset]

For the page numbers you can use absolute numbers (as above), relative numbers (like +1, -2) or the keywords odd, even, first and last.

\setuplayout[ % default layout (right page)
...
]
\definelayout[even][ % different layout on left pages
...
]

If you define additional layouts in a doublepage (duplex) setup, remember to think mirrored: leftmargin defines the right margin, backspace is the distance from the spine to the right edge of the text area etc.

.

Warning!

At the moment a layoutchange (setuplayout) inside a page is not proper working in mkiv duplex mode. For more details and actual state see mailing list and Bug Layoutchange inside page while duplexmode.

Table of Parameters

The first colum is the name by which the variable is set in \setuplayout. The second column is the name by which TeX stores the variable. This name is usually the same, but sometimes different; knowing it allows you to invoke it with code like The paper's height is \the\paperheight. Any remarks (usually a short description) are given in the third column.

\setuplayout[...] dimension Remarks
paperheight \paperheight height of paper page
paperwidth \paperwidth width of paper page
printpaperheight \printpaperheight differs from paperheight when using Imposition (arranging)
printpaperwidth \printpaperwidth differs from paperwidth when using Imposition (arranging)
topspace \topspace above header: from top rim of paper to to top rim of header
backspace \backspace from left rim of paper to left rim of main text area
height \makeupheight sum of heights of text area, header and footer (plus distances)
width \makeupwidth width of the main text area. \makeupwidth is normally same as \textwidth, but it can be different, for example in columns
top \topheight height of the top area
topdistance \topdistance between top and header
header \headerheight height of header area
headerdistance \headerdistance between header and text
textheight \textheight height of text area
footerdistance \footerdistance between text and footer
footer \footerheight height of footer area
bottomdistance \bottomdistance between footer and bottom
bottom \bottomheight space below footer (but isn't calculated automatically)
bottomspace \bottomspace space from bottom footer to bottom rim of paper
cutspace \cutspace from right rim of paper to right rim of main text area
leftedge \leftedgewidth from left rim of paper to left rim of left margin
leftedgedistance \leftedgedistance between leftegde and left margin
leftmargin \leftmarginwidth width of left margin (marginals space)
leftmargindistance \leftmargindistance between left margin and text
textwidth \textwidth width of text area. when columns are used, the value of \textwidth can differ from \makeupwidth
rightmargindistance \rightmargindistance between text area and right margin
rightmargin \rightmarginwidth width of right margin (marginals area)
rightedgedistance \rightedgedistance between right margin and right edge
rightedge \rightedgewidth from right margin to right rim of paper
horoffset ? bleed from left of paper
voroffset ? bleed from top of paper

Note:

  • width=middle
     if cutspace == 0pt then
        cutspace = backspace
     end
     makeupwidth =  paperwidth- backspace -cutspace
  • width=fit
   
       if cutspace == 0pt then
          cutspace = backspace
       end
       makeupwidth = paperwidth-cutspace
       scratchdimen = backspace - leftedgewidth-leftedgedistance-leftmarginwidth-leftmargindistance
       if scratchdimen< 0pt then
          scratchdimen = 0pt
       end
       makeupwidth = makeupwidth - rightmargindistance-rightmarginwidth- rightedgedistance-rightedgewidth- scratchdimen
  • otherwise:
       makeupwidth=width
       if cutspace == 0pt then
          cutspace = paperwidth-makeupwidth-backspace
       else
            % A kind of inconsistent specification, but used
            % in for instance s-pre-19.tex; the cutspace is
            % used only for determining some kind of right
            % margin; don't use this in doublesided mode
       pass 
       end

(From page-lay.mkiv.)


Further reading

  • Presentations: specifics requirements, specific pages (widgets, multimedia, ...)
  • Manuals about layout, and noticeably:
  • Visual Debugging: can greatly facilitate the set up of your layout.
  • After the layout, we can usually focus on the following subjects:
  • About PDF format
    • PDF Boxes: the size of PDF pages can have different meanings – e.g. the visible page, the printed page, the cropped printed page. ConTeXt can define the set of boxes defined by the PDF standard
    • PDF Print Options
    • Viewer Layers PDF has a concept of layers that you can enable and disable (at least in a few viewers). This has nothing to do with ConTeXt’s Layers.
    • PDF/A, ConTeXt can create PDF/A compliant outputs
    • PDFX, ConTeXt can create PDF/X compliant outputs, the ISO standard.
  • For layout from a XML/FO perspective, with some descriptive pictures, see At Paul Tremblay's XML ConTeXt site.