% interface=en 

\startcomponent co-pagedesign
\setupexternalfigures[directory={./arranging}]
\startbuffer[fig-layo]

\unprotect

\setuplinewidth[\v!small]

\setupframed[\c!offset=0pt,\c!framecolor=PlusColor]

\framed
  [\c!strut=\v!no,
   \c!background=\v!screen,
   \c!backgroundscreen=1]
  {\hbox
     {\framed
        [\c!height=15cm,\c!width=1.25cm]
        {\translate[nl=rugwit,en=backspace]}%
      \vbox
        {\offinterlineskip
         \setupframed[\c!width=7.5cm]
         \framed
           [\c!height=1.25cm]
           {\translate[nl=kopwit,en=topspace]}
         \framed
           [\c!height=1.00cm,\c!background=\v!screen,\c!backgroundscreen=.85]
           {\translate[nl=hoofd,en=header]}
         \framed
           [\c!height=10.50cm,\c!background=\v!screen,\c!backgroundscreen=.95]
           {\translate[nl=tekst,en=text]}
         \framed
           [\c!height=1.00cm,\c!background=\v!screen,\c!backgroundscreen=.85]
           {\translate[nl=hoofd,en=footer]}
         \framed
           [\c!height=1.25cm]
           {}}%
      \framed[\c!height=15cm,\c!width=1.75cm]{}}}

\vskip.25cm

\hbox to 10.5cm
  {\hskip1.25cm
   \llap{\hbox to 2cm
      {\color[PlusColor]{\vl}\hss
       \translate[nl=marge,en=margin]\hss
       \color[PlusColor]{\vl}}}%
   \hskip7.5cm
   \hbox to 2.00cm
     {\color[PlusColor]{\vl}\hss
      \translate[nl=marge,en=margin]\hss
      \color[PlusColor]{\vl}}%
   \hss}

\protect

\stopbuffer

\startbuffer[pag-16]

\unprotect

\hbox
  {\forgetall
   \offinterlineskip
   \setupframed
     [\c!width=1cm,\c!height=1.5cm,
      \c!background=\v!screen,\c!backgroundscreen=1]%
   \vbox
     {\hbox
        {\framed{8}\framed{9}\framed{12}\framed{5}}
      \rotate[\c!rotation=180]{\hbox
        {\framed{4}\framed{13}\framed{16}\framed{1}}}}%
   \hskip.25cm
   \vbox
     {\hbox
        {\framed{6}\framed{11}\framed{10}\framed{7}}
      \rotate[\c!rotation=180]{\hbox
        {\framed{2}\framed{15}\framed{14}\framed{3}}}}}

\protect

\stopbuffer

\startbuffer[pag-8]

\unprotect

\hbox
  {\forgetall
   \offinterlineskip
   \setupframed
     [\c!width=1cm,\c!height=1.5cm,
      \c!background=\v!screen,\c!backgroundscreen=1]%
   \vbox
     {\hbox
        {\framed{4}\framed{5}}
      \rotate[\c!rotation=180]{\hbox
        {\framed{8}\framed{1}}}}%
   \hskip.25cm
   \vbox
     {\hbox
        {\framed{3}\framed{6}}
      \rotate[\c!rotation=180]{\hbox
        {\framed{2}\framed{7}}}}}

\protect

\stopbuffer

\startbuffer[pag-4]

\unprotect

\hbox
  {\setupframed
     [\c!width=1cm,\c!height=1.5cm,
      \c!background=\v!screen,\c!backgroundscreen=1]%
   \hbox{\framed{1}\framed{4}}%
   \hskip.25cm
   \hbox{\framed{3}\framed{2}}}

\protect

\stopbuffer

\startbuffer[pag-2up]

\unprotect

\hbox
  {\setupframed
     [\c!width=1cm,\c!height=1.5cm,
      \c!background=\v!screen,\c!backgroundscreen=1]%
   \hbox{\framed{1}\framed{8}}%
   \hskip.25cm
   \hbox{\framed{2}\framed{7}}%
   \hskip.25cm
   \hbox{\framed{3}\framed{6}}%
   \hskip.25cm
   \hbox{\framed{4}\framed{5}}}

\protect

\stopbuffer

\startbuffer[pag-2down]

\unprotect

\hbox
  {\forgetall
   \offinterlineskip
   \setupframed
     [\c!width=1.5cm,\c!height=1cm,
      \c!background=\v!screen,\c!backgroundscreen=1]%
   \vbox{\framed{8}\break\framed{1}}%
   \hskip.25cm
   \vbox{\framed{7}\break\framed{2}}%
   \hskip.25cm
   \vbox{\framed{6}\break\framed{3}}%
   \hskip.25cm
   \vbox{\framed{5}\break\framed{4}}}

\protect

\stopbuffer

\startbuffer[grid-1]
  \advance\baselineskip by 0pt plus 1pt
  \hsize.2\hsize
  \def\Alpha{\translate[nl=alfa, en=alpha]}
  \def\Beta {\translate[nl=beta, en=beta]}
  \def\Gamma{\translate[nl=gamma,en=gamma]}
  \startcombination[4]
    {\ruledvbox to 5\baselineskip {\Alpha\par\Beta\par\Gamma\par}}                  {}
    {\ruledvbox to 5\baselineskip {\Alpha\par\Beta\par\Gamma\par\kern-\prevdepth}} {}
    {\ruledvbox to 5\baselineskip {\Alpha\par\Beta\par\Gamma\par\kern0pt}}         {}
    {\ruledvbox to 5\baselineskip {\Alpha\par\Beta\par\Gamma\par\vfill}}           {}
  \stopcombination
\stopbuffer

\startbuffer[grid-2]
  \hsize.2\hsize
  \def\Alpha{\translate[nl=alfa, en=alpha]}
  \def\Beta {\translate[nl=beta, en=beta]}
  \def\Gamma{\translate[nl=gamma,en=gamma]}
  \def\Delta{\translate[nl=delta,en=delta]}
  \startcombination[4]
    {\ruledvbox to 5\baselineskip {\Alpha\par\Beta\blank\Gamma\par\Delta}} {}
    {\ruledvbox to 5\baselineskip {\Alpha\par\Beta\par\Gamma\blank\Delta}} {}
    {\ruledvbox to 5\baselineskip {\Alpha\blank\Beta\blank\Gamma}}        {}
    {\ruledvbox to 5\baselineskip {\Alpha\par\Beta\par\Gamma}}              {}
  \stopcombination
\stopbuffer


\startbuffer[print-1]

\unprotect

\startcombination[4*4]
  {\showprint[][]}
     {\strut}
  {\showprint[][][\c!location=\v!middle]}
     {\tttf\c!location=\v!middle}
  {\showprint[][][\c!location=\v!middle,\c!marking=\v!on]}
     {\tttf\c!marking=\v!on\break\c!location=\v!middle}
  {\showprint[][][\c!location=\v!middle,\c!marking=\v!on,\c!nx=2]}
     {\tttf\c!marking=\v!on\break\c!location=\v!middle\break\c!nx=2}
  {\showprint[][][\c!location=\v!left]}
     {\tttf\c!location=\v!left}
  {\showprint[][][\c!location=\v!right]}
     {\tttf\c!location=\v!right}
  {\showprint[][][\c!location={\v!left,\v!bottom}]}
     {\tttf\c!location={\v!left,\v!bottom}}
  {\showprint[][][\c!location={\v!right,\v!bottom}]}
     {\tttf\c!location={\v!right,\v!bottom}}
  {\showprint[][][\c!nx=2,\c!ny=1]}
     {\tttf\c!nx=2,\c!ny=1}
  {\showprint[][][\c!nx=1,\c!ny=2]}
     {\tttf\c!nx=1,\c!ny=2}
  {\showprint[][][\c!nx=2,\c!ny=2]}
     {\tttf\c!nx=2,\c!ny=2}
  {\showprint[][][\c!nx=2,\c!ny=2,\c!location=\v!middle]}
     {\tttf\c!nx=2,\c!ny=2\break\c!location=\v!middle}
  % {\showprint[][][\c!horoffset=3pt]}
  %    {\tttf\c!horoffset=.5cm}
  % {\showprint[][][\c!veroffset=3pt]}
  %     {\tttf\c!veroffset=.5cm}   
  {\showprint[][][\c!scale=1.5]}
     {\tttf\c!scale=1.5}
  {\showprint[][][\c!scale=0.8]}
     {\tttf\c!scale=0.8}
\stopcombination

\protect

\stopbuffer

\startbuffer[print-2]

\unprotect

\startcombination[3*4]
  {\showprint[\v!landscape][][\c!location=\v!middle]}
     {\tttf\v!landscape}
  {\showprint[][\v!landscape][\c!location=\v!middle]}
     {\tttf\strut\break\v!landscape}
  {\showprint[\v!landscape][\v!landscape][\c!location=\v!middle]}
     {\tttf\v!landscape\break\v!landscape}
  {\showprint[90][][\c!location=\v!middle]}
     {\tttf90}
  {\showprint[][90][\c!location=\v!middle]}
     {\tttf\strut\break90}
  {\showprint[90][90][\c!location=\v!middle]}
     {\tttf90\break90}
  {\showprint[180][][\c!location=\v!middle]}
     {\tttf180}
  {\showprint[][180][\c!location=\v!middle]}
     {\tttf\strut\break180}
  {\showprint[180][180][\c!location=\v!middle]}
     {\tttf180\break180}
  {\showprint[\v!mirrored][][\c!location=\v!middle]}
     {\tttf\v!mirrored}
  {\showprint[][\v!mirrored][\c!location=\v!middle]}
     {\tttf\strut\break\v!mirrored}
  {\showprint[\v!mirrored][\v!mirrored][\c!location=\v!middle]}
     {\tttf\v!mirrored\break\v!mirrored}
\stopcombination

\protect

\stopbuffer


\unprotect

\def\ShowArrangementA#1#2%
  {\page
   \placefloat
     [\v!figure]
     {#2}
     \startcombination
       {\externalfigure[#1l]
          [\c!width=.4\makeupwidth,
           \c!framecolor=PlusColor,
           \c!background=\v!screen,
           \c!backgroundscreen=1,
           \c!frame=\v!on]}
       {\translate[nl=rechts,en=right]}
       {\externalfigure[#1r]
          [\c!width=.4\makeupwidth,
           \c!framecolor=PlusColor,
           \c!background=\v!screen,
           \c!backgroundscreen=1,
           \c!frame=\v!on]}
       {\translate[nl=links,en=left]}
     \stopcombination
   \typefile{#1q}
   \page}

\def\ShowArrangementB#1#2%
  {\page
   \dimen0=\textheight
   \advance\dimen0 by -15\openlineheight
   \edef\LeftOver{\the\dimen0}%
   \placefloat
     [\v!figure]
     {#2}
     {\externalfigure[#1]
        [\c!height=\LeftOver,
         \c!framecolor=PlusColor,
         \c!background=\v!screen,
         \c!backgroundscreen=1,
         \c!frame=\v!on]}
   \typefile{#1}
   \page}

\protect

\environment contextref-env
\product contextref

\chapter[pagedesign]{Page design}

\section{Introduction}

While processing a text \TEX\ makes use of the actual \type
{\hsize} (width) and \type {\vsize} (height). As soon as
\type {\vsize} is exceeded \TEX's output routine is
launched. The output routine deals with the typeset part
--- most of the time this will be a page. It takes care of
typesetting the headers and footers, the page number, the
backgrounds and footnotes, tables and figures. This rather
complex process makes it obvious that the output routine
actually makes use of more dimensions than \type {\hsize}
and \type {\vsize}.

\section[paperdimension]{Paper dimensions}
\index{page design}
\index{paper dimension}
\macro{\tex{definepapersize}}
\macro{\tex{setuppapersize}}

With the command \type{\setuppapersize} the dimensions of
the paper being used are defined. There is a difference
between the dimensions for typesetting and printing. 

\showsetup{setuppapersize}

The dimensions of \kap{DIN} formats are given in
\in{table}[tab:dindimensions].

\placetable
  [here][tab:dindimensions]
  {Default paper dimensions}
\startcombination[2]
  {\starttable[|c|c|]
   \HL
   \VL \bf format    \VL \bf size in mm \VL\SR
   \HL
   \VL {\type{A0}}   \VL $841 \times 1189$    \VL\FR
   \VL {\type{A1}}   \VL $594 \times ~841$    \VL\MR
   \VL {\type{A2}}   \VL $420 \times ~594$    \VL\MR
   \VL {\type{A3}}   \VL $297 \times ~420$    \VL\MR
   \VL {\type{A4}}   \VL $210 \times ~297$    \VL\LR
   \HL
   \stoptable} {}
  {\starttable[|c|c|]
   \HL
   \VL \bf format \VL \bf size in mm \VL\SR
   \HL
   \VL {\type{A5}}   \VL $148 \times 210$    \VL\FR
   \VL {\type{A6}}   \VL $105 \times 148$    \VL\MR
   \VL {\type{A7}}   \VL $~74 \times 105$    \VL\MR
   \VL {\type{A8}}   \VL $~52 \times ~74$    \VL\MR
   \VL {\type{A9}}   \VL $~37 \times ~52$    \VL\LR
   \HL
   \stoptable} {}
\stopcombination

There are a great number of standardized formats like \type {B0}||\type {B9} and \type
{C0}||\type {C9}. These formats are predefined in\CONTEXT\ as well. You can also use:
\type {letter}, \type {legal}, \type {folio} and \type
{executive}, \type {envelope 9}||\type {14}, \type {monarch},
\type {check}, \type {DL} and \type {CD}.
Another series of predefined formats comprise the \type{RA} and \type{SRA} types of paper sizes.

A new format can be defined by:

\showsetup{definepapersize}

For example \type{CD} was defined as:

\startexample
\starttyping
\definepapersize[CD][width=12cm,height=12cm]
\stoptyping
\stopexample

After defining \type{CD} you can type:

\startexample
\starttyping
\setuppapersize[CD][A4]
\stoptyping
\stopexample

This means that for typesetting \CONTEXT\ will use the
newly defined size \type {CD}. The resulting, rather small
page, is positioned on an \type{A4} paper size. This second
argument is explained in detail later.

\CONTEXT\ can also be used to produce screen documents. For
that purpose a number of screen formats are available that
relate to the screen dimensions. You can use:
\type{S3}||\type{S6}. These generate screens with widths
varying from 300 to 600 pt and a height of $3/4$ of the
width.

When one chooses another paper format than \type{A4}, the
default settings are scaled to fit the new size.

All defined paper sizes can be used either in portrait or landscape orientation. You can tell \CONTEXT\ the orientation of the paper in the \type{\setupapersize} command:

\startexample
\starttyping
\setuppapersize[CD][A4,landscape]
\stoptyping
\stopexample

\section{Page texts}
\index{headers}
\index{footers}
\index{menus}

Page texts are texts that are placed in the headers,
footers, margins and edges of the so called pagebody. This
sentence is for instance typeset in the bodyfont in the
running text. The fonts of the page texts are set up by
means of different commands. The values of the parameters
may be something like \type {style=bold} but
\type {style=\ss\bf} is also allowed. Setups like
\type {style=\ssbf} are less obvious because commands like
\type {\cap} will not behave the way you expect.

Switching to a new font style (\type {\ss}) will cost some
time. Usually this is no problem but in interactive documents
where we may use interactive menus with dozens of
items and related font switches the effect can be
considerable. In that case a more efficient font switching
is:

\startexample
\starttyping
\setuplayout[style=\ss]
\stoptyping
\stopexample

Border texts are setup by its command and the related key.
For example footers may be set up with the key
\type {letter}:

\startexample
\starttyping
\setupfooter[style=bold]
\stoptyping
\stopexample



\section[margins]{Page composition}
\index{margins}
\index{layout}
\index{frames}
\index{set ups}
\index{layout}
\index{topspace}
\index{backspace}
\macro{\tex{setuplayout}}
\macro{\tex{adaptlayout}}
\macro{\tex{showframe}}
\macro{\tex{showsetups}}
\macro{\tex{showlayout}}

In page composition we distinguish the main text area,
headers and footers, and the margins (top, bottom, right and
left). The main text flows inside the main text area. When
defining a layout, one should realize that the header, text
and footer areas are treated as a whole. Their position on
the page is determined by the topspace and backspace
dimensions (see \in {picture} [fig:typesetting area]). 

\startpostponing

\placefigure
  [here]
  [fig:typesetting area]
  {The A4 typesetting area and margins
   ($\hbox{height} = \hbox{header} +
    \hbox{text} + \hbox{footer}$).}
  {\getbuffer[fig-layo]}

\stoppostponing 

\startbuffer
\inleft  {\inframed[background=color,backgroundcolor=GrayColor,framecolor=FrameColor]{left}}%
\inright {\inframed[background=color,backgroundcolor=GrayColor,framecolor=FrameColor]{right}}%
\stopbuffer    

The header is located on top and the
footer below of the main text area. Normally, in the header and footer
page numbers and running titles are placed. The left
and|/|or right margins are often used for structural
components like marginal notes and|/|or chapter and section
numbers. The margins are located in the backspace (along the spine) and in the white space to the right|/|left of the main text area. Their {\getbuffer} width has {\em no} influence on the location
of the typesetting area on the page. 

On the contrary, the height of the header and footer
influences the height of the text area. When talking about
the height, we think of the sum of the header, text and footer
areas. This approach enables you to occasionally hide the header and|/|or footer, 
without introducing inconsistency in the layout. 

The dimensions and location of all those areas are set up
with \type{\setuplayout}. 

\startpostponing
\showsetup{setuplayout}
\stoppostponing 

Setting up the left or right margin has no influence on the
typesetting area. In paper documents this parameter is only
of use when keywords or other text are placed in the margin
(hyphenation).

For paper documents it is sufficient to set up the height,
header, footer, top space and back space. For electronic
and screen documents however we need some extra space for
navigational tools (see \in{chapter}[interaction]). In
screen documents it is common practice to use backgrounds.
Therefore it is also possible to set up the space between
the text area and the header and footer on a page, and
thereby visually separating those areas. 

\starttabulate[|lw(3.5cm)|p(5cm)|p|]
\NC \bf Parameter       \NC \bf Value \NC Comment \NC\NR
\NC width               \NC dimension 
\NC Determines the width of the typesetting area. \type{Middle} sets the white space right to the typesetting area to the value of the backspace. type{Fit} takes values set for margins, edges and margin and edge distances into account. \NC\NR
\NC height              \NC dimension 
\NC The \type{height} is the sum of the text height, header, footer, headerdistance, footerdistance. Middle sets the bottom white space to the value of the topspace. \type{Fit} calculates the text height based on the other vertical height-elements. \NC\NR
\NC backspace           \NC dimension 
\NC \type{Backspace} determines the left boundary of the typesetting area. \NC\NR
\NC topspace            \NC dimension 
\NC \type{Topspace} determines the top boundary of the typesetting area. Together \type{backspace} and \type{topspace} determine the left top corner of the typesetting area.  \NC\NR
\NC margin              \NC dimension 
\NC Setting this parameters makes left and right margin equally large. \NC\NR
\NC leftmargin          \NC dimension 
\NC For documents with different size of the left and right margin, the left margin size is determined.  \NC\NR
\NC rightmargin         \NC dimension 
\NC For documents with different size of the left and right margin, the right margin size is determined. \NC\NR 
\NC header              \NC dimension 
\NC Determines the height of a running header. The header height is part of the \type{height} parameter. \NC\NR
\NC footer              \NC dimension 
\NC Determines the height of the footer. The footer height is part of the \type{height} parameter. \NC\NR
\NC top                 \NC dimension 
\NC Makes space available in the \type{topspace} area. This parameter is not part of the text height. \NC\NR
\NC bottom              \NC dimension 
\NC Makes space available underneath the typesetting area. This parameter is not part of the text height. \NC\NR
\NC leftedge            \NC dimension 
\NC This space located left to the left margin is for screen documents only. \NC\NR
\NC rightedge           \NC dimension 
\NC This space located right to the right margin is for screen documents only. \NC\NR
\NC headerdistance      \NC dimension 
\NC All parameters ending on \dots\type{distance} create white space between adjacent elements. \NC\NR
\NC footerdistance      \NC dimension \NC \NC\NR
\NC leftmargindistance  \NC dimension \NC \NC\NR
\NC rightmargindistance \NC dimension \NC \NC\NR
\NC leftedgedistance    \NC dimension \NC \NC\NR
\NC rightedgedistance   \NC dimension \NC \NC\NR
\NC topdistance         \NC dimension \NC \NC\NR
\NC bottomdistance      \NC dimension \NC \NC\NR
\NC horoffset           \NC dimension 
\NC A horizontal offset moves the complete layout horizontally, starting from the place indicated by the parameter \type{location}. \NC\NR
\NC veroffset           \NC dimension 
\NC A vertical offset moves the complete layout vertically, starting from the place indicated by the parameter \type{location}. \NC\NR
\NC style               \NC normal bold slanted boldslanted type cap small... COMMAND
\NC With the style parameter one can setup the general style of the font(s) used in the document.\NC\NR
\NC marking             \NC on off color screen TEXT
\NC When this parameter is set to \type{on}, then crop marks are placed around the page. \type{Color} displays a color bar, whereas \type{screen} shows a gray-values bar.\NC\NR %TEXT geeft nog in MKII nog in MKIV resultaat. 
\NC location            \NC left middle right bottom top singlesided doublesided duplex %duplex ontbreekt in de paramter lijst
\NC \type{location} determines where the page is placed on the paper. It allows to typeset single and double sided documents and documents for duplex printing (\in{see:}[printing]). \NC\NR
\NC scale               \NC number    
\NC With \type{scale} it is possible to scale a page before placing it on the defined paper. \NC\NR
\NC nx                  \NC number    
\NC In case that a given text should be placed multiple times on a defined paper, \type{nx} gives the number of pages on the x-axis and \type{ny} the number of pages on the y-axis. \NC\NR
\NC ny                  \NC number    \NC  \NC\NR
\NC dx                  \NC dimension 
\NC With \type{dx} and \type{dy} the distances of the pages indicated in \type{nx} and \type{ny} can be manipulated. \NC\NR
\NC dy                  \NC dimension  \NC  \NC\NR
\NC lines               \NC number    
\NC Determines the textheight in terms of the number of lines-heights. \NC\NR
\NC columns             \NC number    \NC \NC\NR % Geen effect nog in MKII nog in MKIV
\NC columndistance      \NC dimension \NC \NC\NR % Geen effect nog in MKII nog in MKIV
\NC grid                \NC yes no    
\NC Typsetting on the grid is activated with grid=on. \NC\NR
\NC bottomspace         \NC dimension
\NC \type{Bottomspace} increases the white space at the bottom of the page without altering the page-layout. \NC\NR 
\NC cutspace            \NC dimension
\NC \type{Cutspace} increases the white space at the right side of the page without altering the page-layout. \NC\NR 
\NC textdistance        \NC dimension  \NC  \NC\NR
\NC textwidth           \NC dimension  \NC  \NC\NR
\NC textmargin          \NC dimension  \NC  \NC\NR
\NC clipoffset          \NC dimension  \NC  \NC\NR
\NC page                \NC identifier \NC  \NC\NR
\NC paper               \NC identifier \NC  \NC\NR
\stoptabulate

In order to get information on the current settings the following
commands can be issued: 

\showsetup{showframe}

The dimensions can be displayed by:

\showsetup{showsetups}

A multi||page combination of both is generated with:

\showsetup{showlayout}

The width of a text is available as \type{\hsize} and the
height as \type{\vsize}. To be on the safe side one can
better use \CONTEXT 's \type{\dimen}||registers \type{\textwidth}
and \type{\textheight}, \type{\makeupwidth} and
\type{\makeupheight}.

When we are typesetting in one column of text
\type{\textwidth} and \type{\makeupwidth} are identical. In
case of a two columned text the \type{\textwidth} is
somewhat less than half the \type{makeupwidth}. The
\type{\textheight} is the \type{\makeupheight} minus the
height of the header and footer.

\placetable{Some \type{\dimen} variables}
\starttable[|l|l|]
\HL
\VL \bf variable         \VL \bf meaning                  \VL\SR
\HL
\VL \type{\makeupwidth}  \VL width of a text              \VL\FR
\VL \type{\makeupheight} \VL height of a text             \VL\MR
\VL \type{\textwidth}    \VL width of a column            \VL\MR
\VL \type{\textheight}   \VL height $-$ header $-$ footer \VL\LR
\HL
\stoptable

There are also other dimensions available like \type
{\leftmarginwidth} and \type {\footerheight}, but be aware
of the fact that you can only use these variables, you can
not set them up. The width of a figure could for instance be
specified as \type {width=.9\leftmarginwidth}. 

Basically documents are typeset automatically. However,
in some cases the output would become much better if a line
would be moved to another page. For these situations you can
adjust the layout temporarily (just for that page) by
typing:

\showsetup{adaptlayout}

The use of this command should be avoided inside a text, because after
altering your document the adjustment could possibly not be necessary
anymore. So, if you use this command, use it at the top of
your document. For example: 

\startexample
\starttyping
\adaptlayout[21,38][height=+.5cm]
\stoptyping
\stopexample

The layout of page~21 and~38 will temporarily be 0.5~cm
higher though the footer will be maintained at the same
height. The numbers to be specified are the page numbers in the
output file.

If the layout is disturbed you can reset the layout by:

\startexample
\starttyping
\setuplayout[reset]
\stoptyping
\stopexample

In some commands you can set up the parameters \type{width}
and \type{height} with the value \type{fit}. In that case
the width and height are calculated automatically.

On the next pages we will show a number of \cap{A5} page
layouts centered on an \cap{A4}. The default setups
(dimensions) are adequate for standard documents like
manuals and papers. The setup adjusts automatically to the
paper size. Note the use of \type{middle} while setting up
the parameters width and height.

%\ShowArrangementA {co-en-1} {The default text||on||page (single sided).}
%\ShowArrangementA {co-en-2} {The default text||on||page (double sided).}
%\ShowArrangementA {co-en-3} {The default text||on||page (single--double sided).}
%\ShowArrangementA {co-en-4} {Automatically centered text||on||page.}
%\ShowArrangementA {co-en-5} {A non symmetric text||on||page.}
%\ShowArrangementA {co-en-6} {A text without \type{footerheight}.}
%\ShowArrangementA {co-en-7} {A text placed on a grid.}

\page

\bgroup

\setuplayout
  [grid=yes]

\showgrid

\setupwhitespace
  [line]

\setupfootnotes
  [location=columns,
   rule=off,
   background=screen,
   frame=off,
   framecolor=blue]

\section[grids]{Grids}
\index{grid}
\index{linespace}
\index{footnotes}
\index{columns}
\index{align}
\macro{\tex{placeongrid}}
\doifmode{mkii}{\macro{\tex{moveongrid}}}
\macro{\tex{showgrid}}

There are many ways to align text on a page. Look at the
example below and notice the vertical alignment of the words
and the white space between the words on the mini pages. 

\placefigure{none}{\getbuffer[grid-1]}

The first three alternatives result in an undesired output.
The fourth alternative will lead to pages with unequal length.
So we rather make the white space between the lines a little
stretchable.\footnote{Hey, watch this. A footnote!}

\placefigure{none}{\getbuffer[grid-2]}

\startcolumns
A stretchable line spacing has the disadvantage that lines of
two pages or two columns that are displayed close to
each other, will seldom align. This is very disturbing for a
reader.\footnote{Here! Another footnote.}

In those situations we prefer to typeset on a grid. The
means to do this in \TEX\ are very limited but \CONTEXT\ has
some features to support grid typesetting.\footnote{Finally,
the last footnote!}
\stopcolumns

During typesetting on a grid the heads, figures, formulas
and the running text are set on a fixed line spacing. If a
typographical component for any reason is not placed on the
grid one can snap this component to the grid with:

\startbuffer
\placeongrid{\framed{This is like a snapshot.}}
\stopbuffer

\startexample
\typebuffer
\stopexample

This will result in:

\startreality
\color[blue]{\getbuffer}
\stopreality

This mechanism can be influenced with an argument:

\startbuffer
\placeongrid[bottom]{\framed{Do you like the snapshot?}}
\stopbuffer

\startexample
\typebuffer
\stopexample

Now an empty line will appear below the framed text.
Other parameters are: \type{top} and \type{both}.
The last parameter divides the linespace between over and
below the framed text.

\startbuffer
\placeongrid[both]{\framed{Now the snapshot looks better.}}
\stopbuffer

\startreality
\color[blue]{\getbuffer}
\stopreality

These examples don't show pretty typesetting. The reason is
that \type{\framed} has no depth because \TEX\ handles
spacing before and after a line in a different way than
text. \CONTEXT\ has a solution to this:

\startbuffer
\startlinecorrection
\framed{This is something for hotshots.}
\stoplinecorrection
\stopbuffer

\startexample
\typebuffer
\stopexample

The command \type{\startlinecorrection} tries to typeset
the lines as good as possible and takes the use of grid in
account.

\startreality
\color[blue]{\getbuffer}
\stopreality

Because line correction takes care of the grid we have to use
yet another command to stretch the framed text:

\startnotmode[mkiv]
\startbuffer
\moveongrid[both]
\startlinecorrection
\framed{Anyhow it is good to know how this works.}
\stoplinecorrection
\stopbuffer
\stopnotmode

\startmode[mkiv]
\startbuffer
\startlinecorrection
\framed{Anyhow it is good to know how this works.}
\stoplinecorrection
\stopbuffer
\stopmode

\startexample
\typebuffer
\stopexample

As you can see this results in somewhat more space:

\startreality
\color[blue]{\getbuffer}
\stopreality

For test purposes one can display the grid with the command
\type{\showgrid}. So grid related commands are:

\showsetup{placeongrid}

\doifmode{mkii}{\showsetup{moveongrid}}

\showsetup{showgrid}

\page
\setuplayout[grid=no]
\egroup


\section[printing]{Printing}
\index{printing}
\doifmode{mkii}{\macro{\tex{showprint}}}

In an earlier section we used page and paper dimensions. In
this section we will discuss how these two can be manipulated
to yield a good output on paper.

% \startnotmode[mkiv]
\startpostponing

\placefigure
  [here][fig:page composition 1]
  {Manipulating the page composition with \type{\setuplayout}.}
  {\switchtobodyfont[7pt]\getbuffer[print-1]}

\placefigure
  [here][fig:page composition 2]
  {Manipulating the page composition with \type{\setuppapersize}.}
  {\switchtobodyfont[7pt]\getbuffer[print-2]}

\stoppostponing
% \stopnotmode



In \in{figure}[fig:page composition 1] \in{and}[fig:page
composition 2] we see some alternatives to manipulate the
page composition by means of \type {\setuppapersize}
and\type {\setuplayout}. So it is possible to put a page in
a corner or in the middle of the paper, to copy a page and
to use cutting marks.

When the parameter paper size is set to \type{landscape}
width and height are interchanged. This is not the same as
rotation! Rotation is done by typing \type{90}, \type{180}
and \type{270} in the first argument of
\type{\setuppapersize}. 

\startexample
\starttyping
\setuppapersize[A5,landscape][A4]
\stoptyping
\stopexample

These examples don't show that we can correct for duplex
printing. For example when we type:

\startexample
\starttyping
\setuppapersize[A5][A4]
\setuplayout[location=middle,marking=on]
\stoptyping
\stopexample

the front and back side will be placed in the middle of the
paper. The markings enable you to cut the paper at the
correct size. If we only want to cut twice, we type:

\starttyping
\setupppapersize[A5][A4]
\setuplayout[location=duplex]
\stoptyping

This has the same meaning as \type{{duplex,left}}. At this
setup \CONTEXT\ will automatically move front and back side
to the correct corner. In \in{figure}[fig:cut paper] we show
both alternatives.

\startbuffer
\startcombination[4]
  {\framed[width=2cm,height=3cm,offset=overlay]
     {\hbox to \hsize
        {\framed[width=1.5cm,height=2cm,background=screen]{}\hss}\vfill}}
  {right}
  {\framed[width=2cm,height=3cm,offset=overlay]
     {\hbox to \hsize
       {\hss\framed[width=1.5cm,height=2cm,background=screen]{}}\vfill}}
  {left}
  {\framed[width=2cm,height=3cm]
     {\framed[width=1.5cm,height=2cm,background=screen]{}}}
  {right}
  {\framed[width=2cm,height=3cm]
     {\framed[width=1.5cm,height=2cm,background=screen]{}}}
  {left}
\stopcombination
\stopbuffer

\placefigure
  [here]
  [fig:cut paper]
  {Positioning the page on paper for cutting.}
  {\getbuffer}

Rotating, mirroring, scaling, duplicating and placing pages
on paper are independent operations. By combining these
operations the desired effects can be reached. Rotating and
mirroring and page and paper size are set up at the same
time. The other operations are set up with
\type{\setuplayout}.

\startmode[mkii]
\showsetup{showprint}

You can use \type{\showprint} to get an idea of how your
print will look. However, it is just a representation of the
real page as is shown in the examples above.

\startexample
\starttyping
\showprint[mirrored][90][location=middle]
\stoptyping
\stopexample
\stopmode

\section{Arranging pages}
\index{arranging}
% \doifmode{mkii}{\macro{\tex{setuparranging}}}
% 
% By means of \type{\setuplayout} one can arrange pages on a
% sheet of paper. A special arrangement for example is that
% for booklets.
% 
% \doifmode{mkii}{\showsetup{setuparranging}}
% 
% We will show some page arrangements on the next pages. If you
% want to understand how it really works you should try this
% yourself one day.
% 
% \startpostponing
% 
% \placefigure {The \type{2*8}   arrangement.} {\getbuffer[pag-16]}
% \placefigure {The \type{2*4}   arrangement.} {\getbuffer[pag-8]}
% \placefigure {The \type{2*2}   arrangement.} {\getbuffer[pag-4]}
% \placefigure {The \type{2UP}   arrangement.} {\getbuffer[pag-2up]}
% \placefigure {The \type{2DOWN} arrangement.} {\getbuffer[pag-2down]}

% \stoppostponing 

Simplified we can say that \TEX\ typesets pages. If the typeset material should become a book, then there are two options. Firstly the book will be produced on multiple sheets carrying only one page either on one or on both sides of the sheet. Second option is to produce arrangements of multiple pages per sheet of paper which will be folded into sections, using imposition schemes.

\CONTEXT\ offers tools to achieve both options.

In the following table an overview is given about all currently available arranging schemes.

\starttabulate[|l|p|]
\NC Key for \type{\setuparranging} \NC Meaning \NC\NR
\HL
\NC \type{[2SIDE]}	       \NC 2 pages next to each other single sided only! \NC\NR
\NC \type{[2TOP]}		   \NC 2 pages above each other, single sided only!  \NC\NR 
\NC \type{[1*8]}           \NC 1 sheet 1 x 8 pages = 8 pages single sided!   \NC\NR
\NC \type{[1*4]}	       \NC 1 sheet 1 x 4 pages = 4 pages single sided!	\NC\NR
\NC \type{[1*2*Conference]} \NC 2 pages on top of each other, 1 page rotated \NC\NR
\NC \type{[1*4*Conference]} \NC 2 odd pages next to each other, even page rotated on top \NC\NR
\NC \type{[XY]}            \NC Arrangement in nx columns and ny rows, uses the setup \type{\setuppaper[dx=,dy=,nx=,ny=]}           \NC\NR
\NC \type{[2UP]}           \NC 2 pages next to each other, n sheets arranged for a single booklet! \NC\NR
\NC \type{[2DOWN]}         \NC 2 pages above each other,  n sheets arranged for a single booklet!  \NC\NR
\NC \type{[2TOPSIDE]}      \NC 2 odd pages on one side, 2 even pages verso, above each other \NC\NR
\NC \type{[2*16]}	       \NC Section: one sheet 2 x 16 pages = 32 pages \NC\NR
\NC \type{[2*8]}	       \NC Section: one sheet 2 x 8 pages = 16 pages \NC\NR
\NC \type{[2*8*Z]}         \NC Section: one sheet 2 x 8 pages = 16 pages, special folding: zig-zag \NC\NR
\NC \type{[2*6*Z]}         \NC Section: one sheet 2 x 6 pages = 12 pages, special folding: zig-zag \NC\NR
\NC \type{[2*4]}	       \NC Section: one sheet 2 x 4 pages = 8 pages \NC\NR
\NC \type{[2*2]}	       \NC Section: one sheet 2 x 2 pages = 4 pages \NC\NR
\NC \type{[2**2]}	       \NC Section: one sheet 2 x 2 pages = 4 pages \NC\NR
\NC \type{[2*4*2]}	       \NC Section of 16 pages: 2 sheets, 4 pages front and backside \NC\NR
\NC \type{[2*2*4]}         \NC Section of 16 pages: 4 sheets, 2 pages front and backside  \NC\NR
\NC \type{[3SIDE]}         \NC 3 odd pages recto, 3 even pages verso \NC\NR
\NC \type{[2*2*2]}	       \NC Section: two sheets 2 x 2 pages = 8 pages \NC\NR
\NC \type{[2*2*3]}	       \NC Section: three sheets 2 x 2 pages = 12 pages \NC\NR
\NC \type{[TRYPTICHON]}    \NC Leaflet: one sheet 2 x 3 pages = 6 pages  \NC\NR
\NC \type{[DOUBLEWINDOW]}  \NC Leaflet: one sheet 2 x 4 pages = 8 pages  \NC\NR
\NC \type{[ZFLYER-8]}    \NC Leaflet: one sheet 2 x 4 pages = 8 pages   \NC\NR
\NC \type{[ZFLYER-10]}   \NC Leaflet: one sheet 2 x 5 pages = 10 pages  \NC\NR
\NC \type{[ZFLYER-12]}   \NC Leaflet: one sheet 2 x 6 pages = 12 pages  \NC\NR
\NC \type{[MAPFLYER-12]} \NC Leaflet: one sheet 2 x 6 pages = 12 pages  \NC\NR
\stoptabulate

When talking about book-printing the industry produces different kinds of sections, consisting commonly out of 32 or 16 pages. Consider, that sections of 32 pages may be quite thick. At binding if the sections are sewn and the spine is rounded the fore edge can become stepped. This is aesthetically less satisfying. Best results are normally obtained with sections of 16 pages.

For special purposes or in case of special papers also less than 16 pages per section are arranged.

The command to arrange pages with \CONTEXT\ is 

\macro{\tex{setuparranging}}

For (standard) sections the following list of schemes is available: 

\setuptabulate[EQ={=}]
\starttabulate[|l|p|p|]
	\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
	\NC \type{\setuparranging[2*16] } \NC section: one sheet $2 \times 16$ pages \EQ 32 pages \NC\NR
	\NC \type{\setuparranging[2*8]  } \NC section: one sheet $2 \times  8$ pages \EQ 16 pages \NC\NR
	\NC \type{\setuparranging[2*4]  } \NC section: one sheet $2 \times  4$ pages \EQ 8 pages \NC\NR
	\NC \type{\setuparranging[2*2]  } \NC section: one sheet $2 \times  2$ pages \EQ 4 pages \NC\NR
	\NC \type{\setuparranging[2**2] } \NC section: one sheet $2 \times  2$ pages \EQ 4 pages \NC\NR 
	\NC \type{\setuparranging[2*8*Z]} \NC section: one sheet $2 \times 8$ pages \EQ 16 pages, special folding: zig-zag \NC\NR
	\NC \type{\setuparranging[2*6*Z]} \NC section: one sheet $2 \times 6$ pages \EQ 12 pages, special folding: zig-zag \NC\NR
	\NC \type{\setuparranging[2*4*2]} \NC section: 2 sheets, 4 pages front and backside \EQ 16 pages\NC\NR
	\NC \type{\setuparranging[2*2*4]} \NC section: 4 sheets, 2 pages front and backside \EQ 16 pages \NC\NR
	\NC \type{\setuparranging[2*2*2]} \NC section: 2 sheets $2 \times 2$ pages          \EQ 8 pages \NC\NR
	\NC \type{\setuparranging[2*2*3]} \NC section: 3 sheets $2 \times 2$ pages          \EQ 12 pages \NC\NR	
 \stoptabulate

On the following pages we show pictures of arranged pages for the mentioned imposition schemes.

\startpostponing
\placefigure
	[middle]
	[]
	{32 pages} %\type{\setuparranging[2*16]}}
	{\startcombination[2*1]
		{\externalfigure[2x16][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x16][page=2,width=.45\textwidth]}{verso}
	\stopcombination}

\placefigure
	[middle]
	[]
	{16 pages} % \type{\setuparranging[2*8]}}
	{\startcombination[2*1]
		{\externalfigure[2x8][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x8][page=2,width=.45\textwidth]}{verso}
	\stopcombination}
	
\stoppostponing

The above mentioned imposition schemes are meant for the professional printing industry. 

But also with an office printer one can produce sections. Sections with less than 16 pages can be produced with the following folding schemes:

\placefigure
	[middle]
	[]
	{8 pages} % \type{\setuparranging[2*4]}}
	{\startcombination[2*1]
		{\externalfigure[2x4][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x4][page=2,width=.45\textwidth]}{verso}
	\stopcombination}

\placefigure
	[middle]
	[fig:2x2]
	{4 pages} % \type{\setuparranging[2*2]}}
	{\startcombination[2*1]
		{\externalfigure[2x2][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x2][page=2,width=.45\textwidth]}{verso}
	\stopcombination}
	
\placefigure
	[middle]
	[fig:2xx2]
	{4 pages} % \type{\setuparranging[2**2]}}
	{\startcombination[2*1]
		{\externalfigure[2xx2][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2xx2][page=2,width=.45\textwidth]}{verso}
	\stopcombination}
	
The last two examples (\in{Figure}[fig:2x2] and \in{}[fig:2xx2]) differ only in the fact, that the verso side carries the two pages in reversed order.

The simplest version of a section is booklet-printing. In this case all pages are arranged in such a way, that with a single fold a booklet is formed.

\starttabulate[|l|p|]
\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
\NC \type{\setuparranging[2UP]}   \NC 2 pages next to each other, n sheets arranged for a single booklet \NC\NR
\NC \type{\setuparranging[2DOWN]} \NC 2 pages above each other,  n sheets arranged for a single booklet  \NC\NR
\stoptabulate

\quote{2UP} results in a booklet with the fold on the long egde of the page. \quote{2DOWN} gives a booklet with a short-edge binding of the pages.

\startpostponing
\placefigure
	[middle]
	[]
	{2 UP booklet: long edge binding} % \type{\setuparranging[2UP]}}
	{\startcombination[2*1]
		{\externalfigure[2UP][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2UP][page=2,width=.45\textwidth]}{verso}
	\stopcombination}

\placefigure
	[middle]
	[]
	{2 DOWN booklet: short edge binding} % \type{\setuparranging[2DOWN]}}
	{\startcombination[2*1]
		{\externalfigure[2DOWN][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2DOWN][page=2,width=.45\textwidth]}{verso}
	\stopcombination}
\stoppostponing

For those who want to print their own book with sections on the office printer \CONTEXT\ offers four schemes which use 2, 3 and 4 sheets of paper respectively to form a section.

\starttabulate[|l|l|r|]
	\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
	\NC \type{\setuparranging[2*4*2]} \NC section: 2 sheets, 4 pages front and backside \EQ 16 pages\NC\NR
	\NC \type{\setuparranging[2*2*4]} \NC section: 4 sheets, 2 pages front and backside \EQ 16 pages \NC\NR
	\NC \type{\setuparranging[2*2*2]} \NC section: 2 sheets $2 \times 2$ pages          \EQ 8 pages \NC\NR
	\NC \type{\setuparranging[2*2*3]} \NC section: 3 sheets $2 \times 2$ pages          \EQ 12 pages \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{16 pages, 2 sheets} % \type{\setuparranging[2*4*2]}}
	{\startcombination[2*2]
		{\externalfigure[2x4x2][page=1,width=.45\textwidth]}{1\high{st} sheet recto}
		{\externalfigure[2x4x2][page=2,width=.45\textwidth]}{1\high{st} sheet verso}
		{\externalfigure[2x4x2][page=3,width=.45\textwidth]}{2\high{nd} sheet recto}
		{\externalfigure[2x4x2][page=4,width=.45\textwidth]}{2\high{nd} sheet verso}
	\stopcombination}

\placefigure
	[middle]
	[]
	{16 pages, 4 sheets} % \type{\setuparranging[2*2*4]}}
	{\startcombination[2*4]
		{\externalfigure[2x2x4][page=1,height=.2\textheight]}{1\high{st} sheet recto}
		{\externalfigure[2x2x4][page=2,height=.2\textheight]}{1\high{st} sheet verso}
		{\externalfigure[2x2x4][page=3,height=.2\textheight]}{2\high{nd} sheet recto}
		{\externalfigure[2x2x4][page=4,height=.2\textheight]}{2\high{nd} sheet verso}
		{\externalfigure[2x2x4][page=5,height=.2\textheight]}{3\high{rd} sheet recto}
		{\externalfigure[2x2x4][page=6,height=.2\textheight]}{3\high{rd} sheet verso}
		{\externalfigure[2x2x4][page=7,height=.2\textheight]}{4\high{th} sheet recto}
		{\externalfigure[2x2x4][page=8,height=.2\textheight]}{4\high{th} sheet verso}
	\stopcombination}

\placefigure
	[middle]
	[]
	{8 pages, 2 sheets} % \type{\setuparranging[2*2*2]}}
	{\startcombination[2*2]
		{\externalfigure[2x2x2][page=1,height=.2\textheight]}{1\high{st} sheet recto}
		{\externalfigure[2x2x2][page=2,height=.2\textheight]}{1\high{st} sheet verso}
		{\externalfigure[2x2x2][page=3,height=.2\textheight]}{2\high{nd} sheet recto}
		{\externalfigure[2x2x2][page=4,height=.2\textheight]}{2\high{nd} sheet verso}
	\stopcombination}

\placefigure
	[middle]
	[]
	{12 pages, 3 sheets} % \type{\setuparranging[2*2*3]}}
	{\startcombination[2*3]
		{\externalfigure[2x2x3][page=1,height=.2\textheight]}{1\high{st} sheet recto}
		{\externalfigure[2x2x3][page=2,height=.2\textheight]}{1\high{st} sheet verso}
		{\externalfigure[2x2x3][page=3,height=.2\textheight]}{2\high{nd} sheet recto}
		{\externalfigure[2x2x3][page=4,height=.2\textheight]}{2\high{nd} sheet verso}
		{\externalfigure[2x2x3][page=5,height=.2\textheight]}{3\high{rd} sheet recto}
		{\externalfigure[2x2x3][page=6,height=.2\textheight]}{3\high{rd} sheet verso}
	\stopcombination}
\stoppostponing



Yet another way to print sections is to use z-folding, which is a zig-zag folding combined with a single fold in the spine. \CONTEXT\ comes with two types of sections, one with 12 pages and one with 16 pages.

\startpostponing
\placefigure
	[middle]
	[]
	{12 pages z-folding} % \type{\setuparranging[2*6*Z]}}
	{\startcombination[2*1]
		{\externalfigure[2x6xZ][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x6xZ][page=2,width=.45\textwidth]}{verso}
	\stopcombination}

\placefigure
	[middle]
	[]
	{16 pages z-folding} % \type{\setuparranging[2*6*Z]}}
	{\startcombination[2*1]
		{\externalfigure[2x8xZ][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x8xZ][page=2,width=.45\textwidth]}{verso}
	\stopcombination}
\stoppostponing


Next to the imposition schemes involving folding \CONTEXT\ offers possibilities to arrange pages in such a way, that after cutting the pile of sheets book blocks can be assembled. The resulting book block consists of loose sheets of paper and will be glued along the spine to prepare e.g. a paperback.

\CONTEXT\ has an arranging scheme for two odd pages above each other and two even pages on the backside of the sheet. In order to build the book block the sheets need to be cut and the the two piles must be merged.

\starttabulate[|l|p|r|]
	\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
	\NC \type{\setuparranging[2TOPSIDE] } \NC recto 2 odd pages, verso 2 even pages per sheet \EQ 4 pages \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{4 pages, 1 sheet} %\type{\setuparranging[2TOPSIDE]}}
	{\startcombination[2*1]
		{\externalfigure[2TOPSIDE][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2TOPSIDE][page=2,width=.45\textwidth]}{verso} 
	\stopcombination}
\stoppostponing

The following schemes can be used for the preparation of handouts from presentations. They also can be used to assemble book blocks after cutting and merging the piles.

The first scheme arranges 4 pages on the front side of the sheet.

The second scheme puts two pages on the front side of a sheet next to each other.

The third scheme works like the previous one but instead of putting the pages next to each other the pages are placed on top of each other.

\starttabulate[|l|l|r|]
	\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
	\NC \type{\setuparranging[1*4] }  \NC one sheet recto $4$ pages \EQ  4 pages \NC\NR
	\NC \type{\setuparranging[2SIDE]} \NC one sheet recto $2$ pages \EQ  2 pages \NC\NR
	\NC \type{\setuparranging[2TOP] } \NC one sheet recto $2$ pages \EQ  2 pages \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{4 pages, singlesided, 1 sheet} % \type{\setuparranging[1*4]
		{\externalfigure[1x4][page=1,width=.45\textwidth]}

\placefigure
	[middle]
	[]
	{2 pages, single sided, 1 sheet} % \type{\setuparranging[2Side]} and \type{\setuparranging[2TOP]}
	{\startcombination[2*1]
		{\externalfigure[2SIDE][page=1,width=.45\textwidth]}{\type{\setuparranging[2SIDE]}}
		{\externalfigure[2TOP][page=1,width=.45\textwidth]}{\type{\setuparranging[2TOP]}} 
	\stopcombination}
\stoppostponing


There are a couple of arranging schemes for special purposes. The first one places 8 pages on the recto side of the
paper. It is intentioned for single sided prints only. The arrangement is made in such a way, that it is possible to fold the paper into a booklet, where while turning the pages now empty pages are shown.

\starttabulate[|l|l|r|]
\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
\NC \type{\setuparranging[1*8]}    \NC \quotation{section}: one sheet $1 \times 8$ pages \EQ 8 pages \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{8 pages, single sided, 1 sheet} % \type{\setuparranging[1*8]}
	{\externalfigure[1x8][page=1,width=.45\textwidth]}
\stoppostponing

For those who will have to produce name-card displays for e.g. conferences or for the preparation of menue-displays in a restaurant the following schemes might be of use.

\starttabulate[|l|p|]
\NC \bf Arrangement \NC \bf Result \NC\NR 
\NC \type{\setuparranging[1*2*Conference]} \NC one sheet 2 pages on top of each other, 1 page rotated \NC\NR
\NC \type{\setuparranging[1*4*Conference]} \NC one sheet 2 odd pages next to each other, even page rotated on top \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{Display cards} % \type{\setuparranging[1*2*Conference]} and \type{\setuparranging[1*4*Conference]} 
	{\startcombination[2*1]
		{\externalfigure[1x2xConference][page=1,width=.45\textwidth]}{1 card with 2 pages}
		{\externalfigure[1x4xConference][page=1,width=.45\textwidth]}{1 card with 4 pages}
	\stopcombination}		
\stoppostponing

There are diary systems, where three pages are place next to each other. The following scheme provides this arranging scheme:

\starttabulate[|l|l|r|]
\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR 
\NC \type{\setuparranging[3SIDE]} \NC 3 odd pages recto, 3 even pages verso \EQ 6 pages \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{3 pages per side} % \type{\setuparranging[3SIDE]}
	{\startcombination[2*1]
		{\externalfigure[3SIDE][page=1,width=.45\textwidth]}{3 pages recto}
		{\externalfigure[3SIDE][page=1,width=.45\textwidth]}{3 pages verso}
	\stopcombination}	
\stoppostponing

\CONTEXT\ can also arrange pages for the production of flyers. There is a great variety of such flyers. \CONTEXT\ supports flyers with 6, 8, 10 and 12 pages. It is also possible to make a flyer with 12 pages which is folded like a map.

\starttabulate[|l|l|r|]
\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
\NC \type{\setuparranging[TRYPTICHON]}  \NC Leaflet: one sheet $2 \times 3$ pages \EQ 6 pages  \NC\NR
\NC \type{\setuparranging[DOUBLEWINDOW]}\NC Leaflet: one sheet $2 \times 4$ pages \EQ 8 pages  \NC\NR
\NC \type{\setuparranging[ZFLYER-8]}    \NC Leaflet: one sheet $2 \times 4$ pages \EQ 8 pages   \NC\NR
\NC \type{\setuparranging[ZFLYER-10]}   \NC Leaflet: one sheet $2 \times 5$ pages \EQ 10 pages  \NC\NR
\NC \type{\setuparranging[ZFLYER-12]}   \NC Leaflet: one sheet $2 \times 6$ pages \EQ 12 pages  \NC\NR
\NC \type{\setuparranging[MAPFLYER-12]} \NC Leaflet: one sheet $2 \times 6$ pages \EQ 12 pages  \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{Tryptichon type of flyer} % \type{\setuparranging[TRYPTICHON]}
	{\startcombination[1*2]
		{\externalfigure[Tryptichon][page=1,width=.45\textwidth]}{3 pages recto}
		{\externalfigure[Tryptichon][page=1,width=.45\textwidth]}{3 pages verso}
	\stopcombination}	
	
\placefigure
	[middle]
	[]
	{Double window type of flyer} % \type{\setuparranging[DOUBLEWINDOW]}
	{\startcombination[1*2]
		{\externalfigure[Doublewindow][page=1,width=.45\textwidth]}{4 pages recto}
		{\externalfigure[Doublewindow][page=1,width=.45\textwidth]}{4 pages verso}
	\stopcombination}	
\stoppostponing

As a representative of the Z-folded flyers the flyer with 8 pages is shown.

\startpostponing
\placefigure
	[middle]
	[]
	{Z-folded type of flyer} % \type{\setuparranging[ZFLYER-8]}
	{\startcombination[1*2]
		{\externalfigure[Zflyer-8][page=1,width=.45\textwidth]}{4 pages recto}
		{\externalfigure[Zflyer-8][page=1,width=.45\textwidth]}{4 pages verso}
	\stopcombination}

\placefigure
	[middle]
	[]
	{Map type of flyer} % \type{\setuparranging[3SIDE]}
	{\startcombination[1*2]
		{\externalfigure[Mapflyer-12][page=1,width=.45\textwidth]}{6 pages recto}
		{\externalfigure[Mapflyer-12][page=1,width=.45\textwidth]}{6 pages verso}
	\stopcombination}
\stoppostponing

Last but not least is the X-Y-arrangement of pages.
This scheme is intended for the placement of a number of pages in sequence on a single sided sheet of paper e.g. on sheets carrying labels or for the placement of other information which must return several times on a sheet.

Before issuing the command \type{\setuparranging[XY]} the xy-arrangement must be setup. For this purpose the command
\type{\setuppaper[...]} is used.

\showsetup{setuppaper}

\quote{nx} denominates the number of pages in the x-direction and \quote{ny} determines the number of pages in the y-direction. With \quote{dx} and \quote{dy} the whitespace between the pages in x and y direction can be set.

\starttabulate[|p|l|r|]
	\NC \bf Arrangement \NC \bf Result \NC \bf Number of pages \NC\NR
	\NC \type{\setuparranging[XY]} + \par \type{\setuppaper[dx=,dy=,nx=,ny=]} \NC $nx \times ny$ pages, single sided \EQ n $\times$ m pages \NC\NR
\stoptabulate

\startpostponing
\placefigure
	[middle]
	[]
	{8 pages, singlesided, 1 sheet, XY-arrangement}
	{\externalfigure[XY][page=1,width=.4\textwidth]}
\stoppostponing

There is culprit in arranging pages. If multiple layers of paper are folded, the outermost paper will require more width because it has to turn around the inner paper layers. This effect occurs as well in the spine folds as also in the head folds. How much width is required depends on the number of folds and the thickness of the paper. In professional book printing this effect is accounted for by displacing the pages depending on their position in horizontal and vertical direction. The result is that there will be a perfect look-through registering of all pages. There are no simple rules to indicate the required amount of displacement. Mostly it is a matter of experience to set up the page shift information.

\CONTEXT\ is equipped with a mechanism, which allows to move pages on a sheet apart from each other in horizontal as well as in vertical direction. The mechanism is build on two shift-lists, one for horizontal and one for vertical page shifting. The mechanism works through cycling over the lists which contain a shift amount for each page in a section. For filling in such a shift-list knowledge and understanding the position of a page on the printed sheet is necessary.

In order to use a horizontal shift list this list must be defined and setup.

For a section of 16 pages a horizontal shift list is filled in where for each page the amount of displacement is given. Such a list could look as follows:

\starttyping
\definepageshift[Hor][horizontal]
   [0.25mm, %1
   -0.25mm, %2
   0.15mm,  %3
   -0.15mm, %4
   0.05mm,  %5
   -0.05mm, %6
   0mm,     %7
   0mm,     %8
   0mm,     %9
   0mm,     %10
   0.05mm,  %11
   -0.05mm, %12
   0.15mm,  %13
   -0.15mm, %14
   0.25mm,  %15
   -0.25mm] %16
\stoptyping

For illustration purposes the following list for horizontal page-shift with exaggerated values is used in a Z-folding with 12 pages.

\starttyping
\definepageshift[Hor][horizontal]
    [1mm,   %1
    -1mm,   %2
    0.5mm,  %3
    -0.5mm, %4                                   
    0mm,    %5
    0mm,    %6
    0mm,    %7
    0mm,    %8
    0.5mm,  %9
    -0.5mm, %10
    1mm,    %11
    -1mm]   %12
\stoptyping

\startpostponing
\placefigure
	[middle]
	[]
	{Horizontal page-shift} % \type{\setuparranging[2*6*Z]}}
	{\startcombination[2*1]
		{\externalfigure[2x6xZ-HOR][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x6xZ-HOR][page=2,width=.45\textwidth]}{verso} 
	\stopcombination}
\stoppostponing

In a similar fashion also vertical shift lists can be defined.

\starttyping 
\definepageshift[Vert][vertical]
    [1.5mm, %1
    1.25mm, %2
    0.75mm, %3
    1.0mm,  %4
    1.0mm,  %5
    0.75mm, %6
    1.25mm, %7
    1.5mm,  %8
    1.5mm,  %9
    1.25mm, %10
    0.75mm, %11
    1.0mm,  %12
    1.0mm,  %13
    0.75mm, %14
    1.25mm, %15
    1.5mm]  %16
\stoptyping

For each page in a section the shift amount must be indicated. The above presented list has exaggerated values just for making clear what happens:

\startpostponing
\placefigure
	[middle]
	[]
	{Vertical page-shift} %\type{\setuparranging[2*8]}}
	{\startcombination[2*1]
		{\externalfigure[2x8-VER][page=1,width=.45\textwidth]}{recto}
		{\externalfigure[2x8-VER][page=2,width=.45\textwidth]}{verso} 
	\stopcombination}
\stoppostponing


While arranging these lists can be used in the following way:

Only one list is used:     

\startexample
\starttyping
\setuppageshift[paper][Hor]
\stoptyping
\stopexample

or

\startexample
\starttyping
\setuppageshift[paper][Vert]
\stoptyping
\stopexample

Both lists are used:

% \startpostponing
\startexample 
\starttyping
\setuppageshift[paper][Hor][Vert]
\stoptyping
\stopexample
% \stoppostponing

The next examples show the cooperation of the commands
\type{\setuppapersize}, \type{\setuplayout} and
\type{\setuparranging}.


\startexample
\starttyping
\setuppapersize     [A7][A3,mirrored] %negative creates an out of memory error in Acrobat 8.2.2. on the MAc OSX 10.6.3
\setuparranging     [2*8,rotated,doublesided]
\setuppagenumbering [alternative=doublesided]
\stoptyping
\stopexample

With the above shown preamble you get sections of 16 pages of the size of A7, where both sides of the A3 paper carry 8 pages \type{[2*8]}. For two reasons the A7 pages must be rotated on the paper. First in this imposition scheme there will be 4 A7 pages next to each other so they need to be aligned along the long edge of the A3. Secondly and this is important for book-printing, the grain direction of the paper must be in the direction of the spine i.e. in the height of the A7. Since A3 has its grain direction normally along the short edge it is correct to rotate the A7 pages. Further more there is the \quote{doublesided} directive in the \type{\setuparranging} command. This is to rotate the whole content of the verso side of the A3 paper by 180\Degrees in order to enable automatic double sided printing on the printing machine. \type{\setuppagenumbering} tells \CONTEXT\ to use a doublesided lay-out, resulting in left and right pages.

Yet there is inside the \type{\setuppapersize} command the directive \quote{mirrored}. Using this directive, the content of the A3 paper is mirrored along the long edge of the paper, this results in mirrored typeset text.

\startexample
\starttyping
\setuppapersize     [A5][A3]
\setuparranging     [2UP,rotated,doublesided]
\setuppagenumbering [alternative=doublesided]
\stoptyping
\stopexample

What this does is placing two A5 pages side by side on a A3 sheet of paper. Both the page and the paper are in portrait orientation. Because A5 fits better on a A3 when the page is rotated the \type{\setuparranging} command carries the \quote{rotated} directive. The resulting sheet of paper will be printed on an automatic double-sided printing machine. Often these machines require, that the verso side of the paper is printed reversed, this is achieved with \quote{doublesided} in the \type{\setuparranging} command.

Instead of using the \quote{rotated} directive in \type{\setuparanging} you can also say:

\startexample
\starttyping
\setuppapersize     [A7][A3,landscape]
\setuparranging     [2*8,doublesided]
\setuppagenumbering [alternative=doublesided]
\stoptyping
\stopexample

You rotate the A3 paper by means of the \quote{rotated} directive in \type{\setuppapersize}.

%\ShowArrangementB {co-en-1p} {Arranging: 16.}
%\ShowArrangementB {co-en-2p} {Arranging: negative mirrored 16.}
%\ShowArrangementB {co-en-3p} {Arranging: 8.}
%\ShowArrangementB {co-en-4p} {Arranging: 4.}
%\ShowArrangementB {co-en-5p} {Arranging: 2UP (1).}
%\ShowArrangementB {co-en-6p} {Arranging: 2UP (2).}
%\ShowArrangementB {co-en-7p} {Arranging: 2DOWN.}

There is one thing which should be kept in mind when using \type{\setuparranging}: \TEX\ compilations with \CONTEXT\ are most of the time multi-pass runs. If there is a table of content or other lists, this information is stored in auxiliary files or tables in \LUATEX. In order not to loose the content of those lists it is important to run the file first without the \type{\setuparranging} command enabled. If all went well, run the file a single time with the \type{\setuparranging} command enabled.

\section[logo types]{Logo types}
\index{logo types}
\index{letter heads}
\doifmode{mkii}{\macro{\tex{definelogo}}}
\macro{\tex{placelogos}}

\doifmode{mkiv}{Logos were removed in mkiv.}

\startnotmode[mkiv]
It is possible to place for example company logos at the top
or the bottom of a page. We show some examples on the next
pages. It is advisable to define a command for typesetting a
logo type.

The location of a logo type is defined by:

\start \showframe

\showsetup{definelogo}

All logo types with \type{state=start} are automatically
typeset on the page. A logo can also be recalled by:

\showsetup{placelogos}

In that case only the listed logos are typeset.

\startbuffer
\definelogo
  [logo a] [bottom] [left]
  [command=left bottom]
\definelogo
  [logo d] [top] [left]
  [command=left top]
\definelogo
  [logo g] [footer]  [left]
  [command=left footer]
\definelogo
  [logo j] [header] [left]
  [command=left header]

\placelogos[logo a,logo b,logo c,logo d]
\stopbuffer

\getbuffer

\definelogo
  [logo b] [bottom] [middle]
  [command=middle bottom]
\definelogo
  [logo e] [top] [middle]
  [command=middle top]
\definelogo
  [logo h] [footer] [middle]
  [command=middle footer]
\definelogo
  [logo k] [header] [middle]
  [command=middle header]

\definelogo
  [logo c] [bottom] [right]
  [command=right bottom]
\definelogo
  [logo f] [top] [right]
  [command=right top]
\definelogo
  [logo i] [footer] [right]
  [command=right footer]
\definelogo
  [logo l] [header] [right]
  [command=right header]

\placelogos
  [logo a,logo b,logo c,logo d,logo e,logo f,
   logo g,logo h,logo i,logo j,logo k,logo l]

\setuppagenumbering
  [location=inmargin,
   state=stop]

\setupfootertexts
\setupheadertexts

On this page a few potential locations of logos are shown.
Temporarily headers and footers of this manual are
suppressed. For example the left logo types are defined by
means of:

\startexample
\typebuffer
\stopexample

Instead of \type{command} we could have chosen \type{text}.
We define the logo with \type{command} because it is evident
that we will use the logo more than once. The example is
discussed below.

First we define a command that generates a small logo.

\startbuffer[a]
\def\ContextLogo%
  {\externalfigure[mp-cont.502][height=24pt,method=mps]}
\stopbuffer

\startbuffer[b]
\definelogo
  [small logo] [bottom] [middle]
  [command=\ContextLogo,state=start]
\stopbuffer

\getbuffer[a]
\getbuffer[b]

\startexample
\typebuffer[a]
\stopexample

If we want to set this logo at the bottom of every page
we type:

\startexample
\typebuffer[b]
\stopexample

This logo is placed at the bottom of every page. In letters
however the logos are located on different positions on the
paper. Again, we define the bigger logo including all
address information. Watch the use of \type{\framed}.

\startbuffer
\def\ContextLetterhead%
  {\hbox
     {\definefont[ContextFont][RegularBold sa 1.5]%
      \ContextFont \setupinterlinespace
      \setupframed
        [align=middle,top=\vfill,bottom=\vfill,
         height=10\bodyfontsize,offset=overlay,frame=off]%
      \framed
        {The\\Con\TeX t\\Chronicle}%
      \externalfigure
        [mp-cont.502][height=10\bodyfontsize]%
      \framed
        {Ridderstraat 27\\8061GH Hasselt NL\\pragma@wxs.nl}}}
\stopbuffer

\getbuffer

\startexample
\typebuffer
\stopexample

We also define the position on the paper:

\startbuffer
\definelogo
  [big logo] [header] [right]
  [command=\ContextLetterhead]
\stopbuffer

\getbuffer

\startexample
\typebuffer
\stopexample

This letterhead logo should appear only on the first page. So
we simply say: 

\startbuffer
\placelogos[big logo]
\stopbuffer

\startexample
\typebuffer
\stopexample

% \page \writestatus{CHECK}{TOP OF PAGE \the \realpageno} 

\getbuffer

\dorecurse{8}{\line{\strut}} % en of andere interferentie 

You will notice that the smaller logo is not placed at the
bottom of the page because the command \type {\placelogos}
typesets only the listed logos and suppresses all other
logos. 

The big logo needs some space on this page so the content of
the letter should be moved to a somewhat lower location. We
do this with the command:

\startexample
\starttyping
\blank[force,8\bodyfontsize]
\stoptyping
\stopexample

\page
\stop
\setuplayout

\placefigure
  {The location of header, footer, bottom and top logos on a page.}
  {\externalfigure[cont-yy][factor=broad,background=raster,
     backgroundraster=1,frame=on,framecolor=PlusColor]}

\chardef\logostatus=0 % make logos go away again

\stopnotmode

\stopcomponent
