% Copyright (c) 1989 Jan-Simon Pendry
% Copyright (c) 1989 Imperial College of Science, Technology & Medicine
% Copyright (c) 1989 The Regents of the University of California.
% All rights reserved.
%
% This code is derived from software contributed to Berkeley by
% Jan-Simon Pendry at Imperial College, London.
%
% Redistribution and use in source and binary forms are permitted provided
% that: (1) source distributions retain this entire copyright notice and
% comment, and (2) distributions including binaries display the following
% acknowledgement:  ``This product includes software developed by the
% University of California, Berkeley and its contributors'' in the
% documentation or other materials provided with the distribution and in
% all advertising materials mentioning features or use of this software.
% Neither the name of the University nor the names of its contributors may
% be used to endorse or promote products derived from this software without
% specific prior written permission.
% THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
% WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%
%	@(#)nh.sty	5.1 (Berkeley) 7/19/90
%
% Change page size parameters for A4 paper on LaserWriter,
% allowing for headers and footers. Define some new macros for headers
% and footers too.
%
% MJW 9 Jan 1987
\oddsidemargin 16pt % MJW actually get 1/2 inch (=32pt) margin because
                   % of printer offset. was 1pt
\evensidemargin 16pt % was 1pt
\marginparwidth 30pt % these gain 53pt width
\topmargin 5pt      % gains 26pt height (MJW was 16pt)
\headheight 14pt      % gains 11pt height (MJW was 1pt)
\headsep 25pt         % gains 24pt height (MJW was 1pt)
%\footheight 12 pt   % cannot be changed as number must fit
\footskip 24pt       % gains 6pt height
\textheight % 528 + 26 + 11 + 24 + 6 + 55 for luck -16 +32 (heads: -10 -15)
%           650pt
%            666pt
	    641pt
\textwidth % 360 + 53 + 47 for luck -15 +8
           453pt
%\pagestyle{myheadings}
%\markboth{LEFT}{RIGHT}
%left = even, right = odd for two-sided
% everything is right for one-sided
\def\evenheadline{}\def\oddheadline{}
\def\evenfootline{}\def\oddfootline{}
% Use these to set headers and footers for two-sided printing.
\def\setbothheaders#1#2{\def\evenheadline{#1}\def\oddheadline{#2}}
\def\setbothfooters#1#2{\def\evenfootline{#1}\def\oddfootline{#2}}
% Use these for one-sided printing.
\def\setheader#1{\def\oddheadline{#1}}\def\setfooter#1{\def\oddfootline{#1}}
% To set footer on first page of a chapter
\def\setchapterfoot#1{\def\chapterfoot{#1}}
\def\setchapterhead#1{\def\chapterhead{#1}}
% Initialise footers to the page number.
\setbothfooters{\hfil\thepage\hfil}{\hfil\thepage\hfil}
% Initialise chapter footer to page number, header empty.
\setchapterfoot{\hfil\thepage \hfil}
\setchapterhead{}
% My version of \chapter
\def\chapter{\clearpage      % Starts new page.
%  \if@twoside \cleardoublepage
%  \else\clearpage\fi        % Starts new page.
   \thispagestyle{chapterpage}     % Page style of chapter page is 'chapterpage'
   \global\@topnum\z@        % Prevents figures from going at top of page.
   \@afterindentfalse        % Suppresses indent in first paragraph.  Change
   \secdef\@chapter\@schapter}   % to \@afterindenttrue to have indent.
% Style for first page of a chapter
\def\ps@chapterpage{\let\@mkboth\markboth
\def\@evenhead{\chapterhead}\def\@oddhead{\chapterhead}
\def\@evenfoot{\chapterfoot}\def\@oddfoot{\chapterfoot}}
% Style for headers AND footers.
\if@twoside         % If two-sided printing.
\def\ps@footers{\let\@mkboth\markboth
\def\@evenhead{\evenheadline}\def\@oddhead{\oddheadline}
\def\@evenfoot{\evenfootline}\def\@oddfoot{\oddfootline}
% Chapter stuff
\def\chaptermark##1{\markboth{\uppercase{\ifnum \c@secnumdepth >\m@ne
 \@chapapp\ \thechapter. \ \fi ##1}}{}}
\def\sectionmark##1{\markright{\uppercase{\ifnum \c@secnumdepth >\z@
   \thesection. \ \fi ##1}}}
}
\else               % If one-sided printing.
\def\ps@footers{\let\@mkboth\markboth
\def\@evenhead{\evenheadline}\def\@oddhead{\oddheadline}
\def\@evenfoot{\evenfootline}\def\@oddfoot{\oddfootline}
% Chapter stuff
%\def\chaptermark##1{\markright{\uppercase{\ifnum \c@secnumdepth >\m@ne
% \@chapapp\ \thechapter. \ \fi ##1}}}
\def\chaptermark##1{\markright{\sf {\ifnum \c@secnumdepth >\m@ne
 \@chapapp\ \thechapter : \ \fi ##1}}}
}
\fi

% Debugging stuff.
%\let\markbothorig\markboth
%\def\markboth#1#2{\typeout{---Markboth: \#1=#1, \#2=#2\newline}
%  \markbothorig {#1} {#2}}
%  
%\let\markrightorig\markright
%\def\markright#1{\typeout{---Markright: \#1=#1\newline}
%  \markrightorig {#1}}
