24.4 Header and Footer

Instead the noweb page style we define our own header and footer. Up to ALLPROSE version 0.2.3 we have built on the fancyhdr package. Since we do not need so much flexibility and since fancyhdr as well as hyperref use edef (which led to difficulties), it was easier to define a page style for an appropriate header and footer directly.

In the html version, there are no headers and footers. The dvi and pdf versions are hyperlinked in the following way.

Header left:
Section or subsection name.
220apage style allprose header 220a  (222a)  220b
\def\@lhead{\leftmark}
Header right:
Links to the table of contents and the index or (for .as files) name of domain, category, package, function or constant that is defined on the corresponding page. The (temporary) redefinition appears in Section 24.3.3.
220bpage style allprose header 220a+   (222a)  220a
\def\headerhyperlink#1{\hyperlink{sec:#1}{#1}}
\def\rhead#1{\gdef\@rhead{#1}}\rhead{}
\def\rheaddefault{\rhead{\headerhyperlink{Contents} \headerhyperlink{Index}}}

Defines:
rhead, used in chunk 209.
rheaddefault, used in chunk 222.
Footer left:
Name of the project and its version followed by the full filename (currentfile) which links to the starting page of that file.

Note that we use the filename that is active at the bottom of the page (botmark). See also nwfilename.

221apage style allprose footer 221a  (222a)  221b
\def\footerhyperlink#1#2{\hyperlink{s:#2}{\textbf{#2}}}
% Disable \defineterm if \xProject appears in the footer.
\def\uProject{{\def\@@xnamedef##1##2##3{\useterm{##2}}\xProject}}
\def\@lfoot{\uProject{} \LIBRARYVERSION{}:
      \expandafter\footerhyperlink\botmark\@empty\@empty}

Uses LIBRARYVERSION 366.
Footer right:
Date and time of the compilation of the documentation followed by the page number.
221bpage style allprose footer 221a+   (222a)  221a
\def\@rfoot{\hyperlink{sec:Index}{{[\rhxtoday~\CurrentTime]} \thepage}}
\newcount\hours\newcount\minutes
\hours=\time
\divide\hours by 60
\minutes=-\hours \multiply\minutes by 60 \advance\minutes \time
\def\rhx@twodigits#1{\ifnum#1<10 0\fi\number#1}
\newcommand{\CurrentTime}{\the\hours:\rhx@twodigits{\the\minutes}}
\edef\rhxtoday{\rhx@twodigits{\the\day}-\ifcase\month\or
  Jan\or Feb\or Mar\or Apr\or May\or Jun\or
  Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi-\number\year}

By putting everything together, we define the allprose page style.

222apage header/footer 222a  (204)
page style allprose header 220a
page style allprose footer 221a
page style allprose mark 222b
\def\ps@allprose{%
  \def\sectionmark##1{\rhxmark{\z@}{\thesection}{##1}}
  \def\subsectionmark##1{\rhxmark{\@ne}{\thesection}{##1}}
  \let\@mkboth\@gobbletwo
  \rheaddefault
  \def\@oddhead{{\reset@font\footnotesize\@lhead\hfill\@rhead}}%
  \def\@oddfoot{{\reset@font\footnotesize\@lfoot\hfill\@rfoot}}
  \let\@evenhead\@oddhead
  \let\@evenfoot\@oddfoot
}
\pagestyle{allprose}

Uses rheaddefault 220b.

In order to get the right file name at the bottom of the page, we use TEX’s mark command via an abuse of markboth. Instead of marking for even and odd pages, we use the left mark for the section name that appears in the header and the right mark for the current filename.

222bpage style allprose mark 222b  (222a)
\gdef\currentlhead{}%
\def\rhxmark#1#2#3{%
  \markboth{\ifnum \c@secnumdepth>#1#2\hskip 1em\relax\fi#3}{\currentfile}%
  \gdef\currentlhead{\leftmark}%
  \rheaddefault
}

Defines:
currentlhead, used in chunk 229.

Uses currentfile 228a and rheaddefault 220b.