Page setup1

From ConTeXt wiki

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                    %
%  This sample page includes a series of chapters. Each chapter has  %
%  its own unique layout.                                            %
%                                                                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% enable utf
\enableregime[utf]

% turn off automatic page numbering
\setuppagenumbering[state=stop]


\starttext

% show frames so we can debug
\showframe

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                            %
%  Default page layout. This chapter uses all the defaults.  %
%                                                            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% start a page run
\part{}

% input text from another document
Chapter One: use defaults\par
\dorecurse{3}{\input tufte \par \input knuth \par}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                  %
%  Change outermost, non-writeable regions and define paper size.  %
%                                                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% start a page run
\part{}

\definepapersize[chaptTwo][width=8.5in, height=11in]
\setuppapersize[chaptTwo]

% define the laout for the page
\definelayout[chaptTwo][
 topspace=2in, % the space at the very top of the page
 backspace=2in,  % the space in the left hand side of the page 
 cutspace=2in, % the space on the right hand side of the page
 bottomspace=2in, % the space at the very bottome of the page
]

\setuplayout[chapTwo]

Chapter 2: change backspace, cutspace, etc
% input text from another document
\dorecurse{3}{\input tufte \par \input knuth \par}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                   %
%  Add footer and header space, as well as right and left margin.   %
%                                                                   %
%  When we increase the footer and header margins, we decrease the  %
%  areas for our body text. In contrast, increasing the left and    %
%  right margin has no affect on the the text width.                %
%                                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% start a page run
\part{}

\definepapersize[chapThree][width=8.5in, height=11in]
\setuppapersize[chapThree]

% define the laout for the page
\definelayout[chapThree][
 topspace=2in, % the space at the very top of the page
 backspace=2in,  % the space in the left hand side of the page 
 cutspace=2in, % the space on the right hand side of the page
 bottomspace=2in, % the space at the very bottome of the page
 header=1.5in, % the space for headers
 footer=1.5in, % the space for footers
 leftmargin=1.5in, % the space for margin notes
 rightmargin=1.5in, % the space for right margin notes
]

\setuplayout[chapThree]

Chapter 3: Add header space, footer space, right and left margin\par
% input text from another document
\dorecurse{3}{\input tufte \par \input knuth \par}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                     %
%  Changing the default width and height of the body area.            %
%                                                                     %
%  The heigth is equal to the body text plus the footers and          %
%  headers. The width indicates just the body text width.             %
%                                                                     %
%  To control height and width as a percentage of the normal widht    %
%  and height, use the \makeupwidth and \makeupheigth variables. If   %
%  I wanted my width to be 90 percent of the normal width, I use;     %
%  width=.9\makeupwidth If I wanted my height to be 90 percent of my  %
%  normal height, I use height=.9\makeupheight                        %
%                                                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% start a page run
\part{}

\definepapersize[chapFour][width=8.5in, height=11in]
\setuppapersize[chapFour]

% define the laout for the page
\definelayout[chap4][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the left hand side of the page 
 cutspace=1in, % the space on the right hand side of the page
 header=1.5in, % the space for headers
 footer=1.5in, % the space for footers
 %width=.9\makeupwidth,
 width=5.5in, % the width of the body text (one inch narrower than 
 	      % if the value were not set)
 %height=\makeupheight 
 height=8in, % the height of the body text (one inch less than if 
 	     % if the value were not set
 bottomspace=1in,
]

\setuplayout[chap4]

% input text from another document
Chapter 4: Control the width of the body text\par
\dorecurse{3}{\input tufte \par \input knuth \par}


%%%%%%%%%%%%%%%%%%%%%%%%%
%                       %
%  Headers and Footers  %
%                       %
%%%%%%%%%%%%%%%%%%%%%%%%%

% start a page run
\part{}

\definepapersize[chap5][width=8.5in, height=11in]
\setuppapersize[chap5]

% define the laout for the page
\definelayout[chap6][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the left hand side of the page 
 cutspace=1in, % the space on the right hand side of the page
 header=1in, % the space for headers
 footer=1in, % the space for footers
 headerdistance=.25in, % how much distance between header and body
 		       % text
 footerdistance=.25in, % how much distance between foooter and body
 			 % text
 bottomspace=1in, % space at bottom of page
]

\setupheadertexts[header][][][header]
\setupfootertexts[footer][][][footer]

\setuplayout[chap5]

Chapter 5: Add headers and footers\par

% input text from another document
\dorecurse{5}{\input tufte \par \input knuth \par}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                 %
%  Different odd and even pages.  %
%                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% start a page run
\part{}

\definepapersize[chap6][width=8.5in, height=11in]
\setuppapersize[chap6]

\definelayout[odd][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=7.5in % the height of the body text
]

\definelayout[even][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=9in, % the height of the body text
]

\setupheadertexts[even][][][odd]
\setupfootertexts[even][][][odd]

\setuplayout

Chapter 6: Odd and Even Pages\par

% input text from another document
\dorecurse{5}{\input tufte \par \input knuth \par}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                        %
%  Different first, odd and even pages.  %
%                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\definetext[chapStart7][header][Chapter 7]
\setuphead[part][header=chapStart7, footer=empty]

% start a page run
\part{}

\definepapersize[chap7][width=8.5in, height=11in]
\setuppapersize[chap7]

\definelayout[1][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=7.5in % the height of the body text
]

\definelayout[odd][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=7.5in % the height of the body text
]

\definelayout[even][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=9in, % the height of the body text
]

\setupheadertexts[even][][][odd]
\setupfootertexts[even][][][odd]

\setuplayout

Chapter 7: First, Odd and Even Pages\par

% input text from another document
\dorecurse{6}{\input tufte \par \input knuth \par}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                        %
%  Headers and Footers with Formatting.  %
%                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\definetext[chapStart8][header][\vbox{Chapter 8 \vskip5pt Author}]
\definetext[chapStart8Footer][footer][\vbox{ left \hskip2em skip space
\hskip3cm right}]
\setuphead[part][header=chapStart8, footer=chapStart8Footer]

% start a page run
\part{}

\definepapersize[chap8][width=8.5in, height=11in]
\setuppapersize[chap8]

\definelayout[1][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=7.5in % the height of the body text
]

\definelayout[odd][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=7.5in % the height of the body text
]

\definelayout[even][
 topspace=1in, % the space at the very top of the page
 backspace=2in,  % the space in the gutter 
 header=1in, % the space for headers
 footer=1in, % the space for footers
 leftmargin=1in, % the space for margin notes
 rightmargin=1in, % the space for right margin notes
 width=5.5in, % the width of the body text
 height=9in, % the height of the body text
]

\setupheadertexts[author \hfill \pagenumber \hfill title][][][odd]
\setupfootertexts[even][][][odd]

\setuplayout

Chapter 8: Fancy headers and footers\par

% input text from another document
\dorecurse{6}{\input tufte \par \input knuth \par}


\stoptext