% headfoot.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{headfoot}[1999/12/14 vs2.9 Header and Footer]
%
% 1996/07/12  \headfootwidth=\textwidth pas in \pagestyle zetten
% 1996/08/19  een foutieve optie geeft `warning' i.p.v. `error'
% 1996/09/24  global weg in head/foot definitie, 
%             \ps@plain herdefinitie,
%             \headfootfont toegevoegd
% 1998/02/12  \headfootwidth initialiseren bij inladen
% 1998/03/08  \headfootwidth evt. op \textwidth bij \begin{document}
% 1999/06/03  \pagestyle \let's -> \def's
% 1999/06/12  corrected ps@plain
% 1999/12/14  headfootfont set macro toegevoegd
%---------------------------------------------------------------------
%                   DECLARATIONS AND INITIALIZATIONS
%---------------------------------------------------------------------
% declare length variables
\newdimen\headfootskip      % whitespace above/below rules
\newdimen\headfootwidth     % width of header/footer
\newdimen\headfootstart     % horizontal skip header/footer
\newdimen\headfootrulesize  % thickness of rules
\headfootskip=3pt\relax
\headfootstart=0pt\relax
\headfootrulesize=0.3pt\relax
\AtBeginDocument{% instellen tenzij al expliciet waarde gekregen
  \ifdim\headfootwidth=\z@\relax\headfootwidth=\textwidth\relax\fi}
%.....................................................................
\def\@headstyle{0}				% style selector
\def\@footstyle{0}				% style selector
\def\headfootpattern{\hbox{*}}
%.....................................................................
\def\setheadfootfont#1{\def\headfootfont{#1}}
\setheadfootfont{\rmfamily\mdseries\small}
%---------------------------------------------------------------------
%                            OPTIONS
%---------------------------------------------------------------------
\DeclareOption{headrule}{\def\@headstyle{1}}
\DeclareOption{headrules}{\def\@headstyle{2}}
\DeclareOption{headbox}{\def\@headstyle{3}}
\DeclareOption{headpat}{\def\@headstyle{4}}
%.....................................................................
\DeclareOption{footrule}{\def\@footstyle{1}}
\DeclareOption{footrules}{\def\@footstyle{2}}
\DeclareOption{footbox}{\def\@footstyle{3}}
\DeclareOption{footpat}{\def\@footstyle{4}}
%.....................................................................
\DeclareOption{help}{\PackageWarningNoLine{headfoot}{%
	Following styles head.. or foot..:\MessageBreak
	..rule:\space\space single rule below header/above footer\MessageBreak
	..rules:\space   rule above and below\MessageBreak
	..box:\space\space\space     boxed header/footer\MessageBreak
	..pat:\space\space\space     pattern below header/above footer\MessageBreak
	Parameters:\MessageBreak
	\string\headfootskip\space = space before/after rule (length)\MessageBreak
	\string\headfootwidth\space = width of header/footer (length)\MessageBreak
	\string\headfootstart\space = displacement leftside (length)\MessageBreak
	\string\headfootrulesize\space = thickness of rules (length)\MessageBreak
	\string\headfootpattern\space = fill pattern (command-hbox)\MessageBreak
    Usage:\space\space\space\string\pagestyle{headfoot}}}
%.....................................................................
\DeclareOption*{\PackageWarning{\filename}{Unknown option `\CurrentOption'}}
\ProcessOptions
%---------------------------------------------------------------------
%                       INTERNAL MACROS
%---------------------------------------------------------------------
%.....................................................................
% put headline
%.....................................................................
\ifcase\@headstyle\relax
\def\@headerline#1#2#3{\hskip\headfootstart
	\vbox to\headheight{\headfootfont
	  \vss\hbox to\headfootwidth
		{\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}}\hss}
\or
\def\@headerline#1#2#3{\hskip\headfootstart
	\vbox to\headheight{\headfootfont
	  \vss\hbox to\headfootwidth
		{%
		\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}%
		\vskip\headfootskip\hrule\@height\headfootrulesize}\hss}
\or
\def\@headerline#1#2#3{\hskip\headfootstart
	\vbox to\headheight{\headfootfont
	  \vss\hrule\@height\headfootrulesize
		\vskip\headfootskip\hbox to\headfootwidth
			{\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}%
		\vskip\headfootskip\hrule\@height\headfootrulesize}\hss}
\or
\def\@headerline#1#2#3{\hskip\headfootstart
	\vbox to\headheight{\headfootfont
	  \vss\vbox{\hrule\@height\headfootrulesize
		\hbox{\vrule\@width\headfootrulesize
			\vbox{\vskip\headfootskip
			\dimen@=\headfootwidth
			\advance\dimen@-\tw@\headfootrulesize
			\hbox to\dimen@{\kern\fboxsep
				\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}%
				\kern\fboxsep}%
			\vskip\headfootskip}%
			\vrule\@width\headfootrulesize}%
		\hrule\@height\headfootrulesize}}\hss}
\or
\def\@headerline#1#2#3{\hskip\headfootstart
	\vbox to\headheight{\headfootfont
	  \vss\hbox to\headfootwidth
		{\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}%
		\nointerlineskip
		\vskip\headfootskip\hbox to \headfootwidth
		{\xleaders\headfootpattern\hfil}}\hss}
\else
\def\@headerline#1#2#3{\hskip\headfootstart
	\vbox to\headheight{\headfootfont
	  \vss\hbox to\headfootwidth
		{\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}}\hss}
\fi
%.....................................................................
% put footline
%.....................................................................
\ifcase\@footstyle\relax
\def\@footerline#1#2#3{\hskip\headfootstart
	\vbox to\footskip{\headfootfont
	  \vss\hbox to\headfootwidth
	  {\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}}\hss}
\or
\def\@footerline#1#2#3{\hskip\headfootstart
	\vbox to\footskip{\headfootfont
	  \vss\hrule\@height\headfootrulesize
		\vskip\headfootskip\hbox to\headfootwidth
		{\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}}\hss}
\or
\def\@footerline#1#2#3{\hskip\headfootstart
	\vbox to\footskip{\headfootfont
	  \vss\hrule\@height\headfootrulesize
		\vskip\headfootskip\hbox to\headfootwidth
			{\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}%
		\vskip\headfootskip\hrule\@height\headfootrulesize}\hss}
\or
\def\@footerline#1#2#3{\hskip\headfootstart
	\vbox to\footskip{\headfootfont
	  \vss\vbox{\hrule\@height\headfootrulesize
		\hbox{\vrule\@width\headfootrulesize
			\vbox{\vskip\headfootskip
			\dimen@=\headfootwidth
			\advance\dimen@-2\headfootrulesize
			\hbox to\dimen@{\kern\fboxsep
				\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}%
				\kern\fboxsep}%
			\vskip\headfootskip}%
			\vrule\@width\headfootrulesize}%
		\hrule\@height\headfootrulesize}}\hss}
\or
\def\@footerline#1#2#3{\hskip\headfootstart
	\vbox to\footskip{\headfootfont
	  \vss\hbox to\headfootwidth
		{\xleaders\headfootpattern\hfil}\nointerlineskip
		\vskip\headfootskip\hbox to\headfootwidth
		{\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}}\hss}
\else
\def\@footerline#1#2#3{\hskip\headfootstart
	\vbox to\footskip{\headfootfont
	  \vss\hbox to\headfootwidth
	  {\rlap{#1\strut}\hss{#2\strut}\hss\llap{#3\strut}}}\hss}
\fi
%.....................................................................
% install the style
\def\ps@headfoot{%
  \def\@oddhead{\hf@oddhead}\def\@evenhead{\hf@evenhead}%
  \def\@oddfoot{\hf@oddfoot}\def\@evenfoot{\hf@evenfoot}%
  \ignorespaces}
% (re)define the plain style
\def\ps@plain{%
  \def\@oddhead{\@empty}\def\@evenhead{\@empty}%
  \def\@oddfoot{\hf@oddfoot}\def\@evenfoot{\hf@evenfoot}%
  \ignorespaces}
% (re)define the empty style
\def\ps@empty{%
  \def\@oddhead{\@empty}\def\@evenhead{\@empty}%
  \def\@oddfoot{\@empty}\def\@evenfoot{\@empty}%
  \ignorespaces}
%---------------------------------------------------------------------
%                         USER INTERFACE
%---------------------------------------------------------------------
% activate the style with "\pagestyle{headfoot}"
%.....................................................................
% set left and right page separately
%   #1 #2 #3 = [left  middle  right]
\def\oddpageheader#1#2#3{%
  \def\hf@oddhead{\@headerline{#1}{#2}{#3}}\ignorespaces}
\def\evenpageheader#1#2#3{%
  \def\hf@evenhead{\@headerline{#1}{#2}{#3}}\ignorespaces}
\def\oddpagefooter#1#2#3{%
  \def\hf@oddfoot{\@footerline{#1}{#2}{#3}}\ignorespaces}
\def\evenpagefooter#1#2#3{%
  \def\hf@evenfoot{\@footerline{#1}{#2}{#3}}\ignorespaces}
%.....................................................................
% set left and right page same
\def\pageheader#1#2#3{%
  \oddpageheader{#1}{#2}{#3}\evenpageheader{#1}{#2}{#3}}
\def\pagefooter#1#2#3{%
  \oddpagefooter{#1}{#2}{#3}\evenpagefooter{#1}{#2}{#3}}
%.....................................................................
% initialisatie
\pageheader{}{}{}%
\pagefooter{}{\thepage}{}%
%---------------------------------------------------------------------
\endinput
