% \iffalse
%% File: underlin.dtx Copyright (C) 1987-1997 Rainer Sch"opf
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{underlin}
%<package>         [1997/02/16 v1.01 underlined running head (RmS)]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{underlin}
\pagestyle{underline}
\GetFileInfo{underlin.sty}
\begin{document}
\title{Two {\sf pagestyles} for underlining headers\thanks{This file
       has version number \fileversion, last revised \filedate.}}
\author{Rainer Sch\"opf}
\date{\filedate}
\maketitle
\DocInput{underlin.dtx}
\end{document}
%</driver>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \CheckSum{47}
%
% \changes{1.01}{1997/02/16}{Version 1.0a converted to \LaTeXe
%    documentation format.}
%
% \begin{abstract}
%   This package implements two new {\sf pagestyles}
%   {\tt underline} and {\tt myunderline} that are similar
%   to the standard {\tt headings} and {\tt myheadings}
%   {\sf pagestyles} but provide a horizontal line just below
%   the head line.
% \end{abstract}
%
% The purpose of this package file is to provide a way to
% underline a running head.
% This is done by redefining the \verb+\@evenhead+ and \verb+\@oddhead+
% macros.
% To understand this you must know that whenever a given pagestyle
% (say `xxx') is selected by a \verb+\pagestyle{xxx}+ command the
% macro \verb+\ps@xxx+ is executed.
% Therefore we define a macro \verb+\ps@underline+ which is called
% when you say \verb+\pagestyle{underline}+.
% To provide for a rule with user-defined headings we also define
% the pagestyle `myunderline' , i.e.\ the macro \verb+\ps@myunderline+.
%
% \StopEventually{}
%
% \section{Implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \begin{macro}{\ps@underline}
%    The first thing the macro \verb+\ps@underline+
%    does is to call
%    \verb+\ps@headings+ to set up everything like the `headings'
%    pagestyle does.
%    Here we do not need to distinguish onesided and twosided
%    printing since this is already done correctly by
%    \verb+\ps@headings+.
%    \begin{macrocode}
\def\ps@underline{\ps@headings
%    \end{macrocode}
%    Then we redefine \verb+\@evenhead+. The first part is a copy of
%    the definition in \verb+\ps@headings+.
%    This has the advantage that this style option works with
%    document styles `article', `report', and `book'.
%    \begin{macrocode}
  \def\@evenhead{\thepage\hfil\slshape\leftmark\null
%    \end{macrocode}
%    \verb|\null| is defined to be \verb|\hbox{}| in the \LaTeX{}
%    kernel file \texttt{ltplain.dtx}.
%    Additionally we include a \verb+\vadjust+ primitive. The effect of
%    this primitive is to add its argument after the current
%    \verb+\hbox+ to the enclosing vertical list.
%    \begin{macrocode}
    \vadjust{\vskip .3ex\hrule}}%
%    \end{macrocode}
%    The \verb+\@oddhead+ macro is constructed
%    analogously.
%    \begin{macrocode}
  \def\@oddhead{\null{\slshape \rightmark}\hfil\thepage
    \vadjust{\vskip .3ex\hrule}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@myunderline}
%    The macro \verb+\ps@myunderline+ for underlining user defined
%    running heads is constructed analogously.
%    \begin{macrocode}
\def\ps@myunderline{\ps@myheadings
  \def\@oddhead{\null{\slshape\rightmark}\hfil
    \rm\thepage\vadjust{\vskip .3ex\hrule}}%
  \def\@evenhead{\thepage\hfil\slshape \leftmark \null
    \vadjust{\vskip .3ex\hrule}}}
%    \end{macrocode}
% \end{macro}
%
%
% Well, that's all. Use it and enjoy.
%
% \Finale
%
\endinput
