%REFMAN
% This is REFMAN.STY by H.Partl, TU Wien, Version 0.2 of 30 Sept 1988.
% Document Style Option to `article' and `report',
% for technical reference manuals, users' guides and articles,
% with a design similar to that of the PostScript Reference Manual:
%     All pages have a wide left margin and no right margin, and section
%     headings and other `guiding' material appear in that margin.
% Supports one-column only. REFMAN should be specified as the LAST
% optional argument of the \documentstyle command, e.g.
%     \documentstyle[11pt,twoside,german,refman]{article}
%
% It CAN be used with twoside, fleqn and others.
% It can NOT be used with twocolumn, titlepage, fullpage, a4, a4wide
% and others.
%
% +-----------------------------------------------------------------+
% ! This style file has been designed for reference manuals, users' !
% ! guides, short instants, and related papers at the EDP centre of !
% ! the Technical University of Vienna. It must be re-designed and  !
% ! changed before application at any other institution or for any  !
% ! other purpose.                                                  !
% +-----------------------------------------------------------------+
% Copyright H.Partl TU Wien 1988.

% Process this file only once:
\@ifundefined{leftmarginwidth}{}{\endinput}

\typeout{ TU Wien Refman Style -  Version 0.2 as of 30 Sept 1988}

\newdimen\leftmarginwidth % value of odd & evensidemargin, set below.
\newdimen\fullwidth % = \textwidth + \leftmarginwidth
\newdimen\emptyheadtopmargin % used by some pagestyles
\newdimen\emptyfoottopmargin % dto.

% \longhrule is defined for a \hrule of width \fullwidth

\def\longhrule{\par\hbox to \linewidth{\hss
               \hbox to \fullwidth{\hrulefill}}\par}

% Re-definitions of the \section commands to use \fullwidth and smaller
% vertical skips and smaller fonts.
% (Note that the afterskip must be >zero, not =zero)

\def\secshape{\leftskip=-\leftmarginwidth % use \fullwidth
              \rightskip=\@flushglue % raggedright
              \hyphenpenalty=2000} % no hyphenation

\def\section{\@startsection {section}{1}{\z@}{-2ex plus -1ex minus
    -.2ex}{0.5ex plus .2ex}{\secshape\large\bf}}
\def\subsection{\@startsection{subsection}{2}{\z@}{-1.5ex plus -.5ex minus
   -.2ex}{0.5ex plus .2ex}{\secshape\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{-1.5ex plus
-.5ex minus -.2ex}{0.5ex plus .2ex}{\secshape\normalsize\rm}}
\def\paragraph{\@startsection
     {paragraph}{4}{\z@}{2ex plus 1ex minus .2ex}{-1em}{\normalsize\bf}}
\def\subparagraph{\@startsection
     {subparagraph}{4}{\parindent}{2ex plus 1ex minus
     .2ex}{-1em}{\normalsize\bf}}

% For ARTICLE:
% Re-definitions of \maketitle and \part (\clearpage, \fullwidth, \hrules).
% This \maketitle prints the \title only.
% A \makeauthor command is defined to print the \author (to be used either
% just after \maketitle or at the end of the article, without \thanks).

\def\@redefinemaketitle{

\def\maketitle{\par
 \begingroup
   \if@twocolumn
     \twocolumn[\@maketitle]
     \else \newpage
     \global\@topnum\z@        % Prevents figures from going at top of page.
     \@maketitle \fi\thispagestyle{plain}
 \endgroup
 \setcounter{footnote}{0}}

\def\@maketitle{\clearpage
     \longhrule\bigskip
     {\secshape\parskip\z@\parindent\z@ \Large\bf \@title\par}
     \bigskip\longhrule\bigskip}

\def\makeauthor{\par\nopagebreak\vskip 2ex plus 1ex minus 1ex
     \begin{flushright}\normalsize\sl \@author \end{flushright}\par
     \vskip 2ex plus 1ex minus 1ex\relax }

\def\and{\\*}
\def\thanks{\footnote}

% In \part, only \thepart (the Roman part number) is printed, without
% the word `Part' in front of it, and \markboth is replaced by \@mkboth
% to preserve the marks with the myheadings and myfootings page styles.

\def\part{\par \clearpage \thispagestyle{plain}
          \@afterindentfalse \secdef\@part\@spart}

\def\@part[##1]##2{\ifnum \c@secnumdepth >\m@ne \refstepcounter{part}
     \addcontentsline{toc}{part}{\thepart \hspace{1em}##1}\else
     \addcontentsline{toc}{part}{##1}\fi
     \longhrule\medskip
     {\secshape\parskip\z@\parindent\z@ \Large\rm
      \ifnum \c@secnumdepth >\m@ne \thepart.\quad \fi ##2\par}
     \medskip\longhrule\bigskip \@mkkboth{}{}\@afterheading }

\def\@spart##1{\longhrule\medskip
     {\secshape\parskip\z@\parindent\z@ \Large\rm ##1\par}
     \medskip\longhrule\bigskip \@afterheading }

} % end of \@redefinemaketitle

% For REPORT:
% Re-definition of \chapter (\clearpage, \fullwidth, \hrules).
% However, \maketitle and \part remain unchanged.

\def\@redefinechapter{

\def\@makechapterhead##1{\longhrule\bigskip
     {\secshape\parskip\z@\parindent\z@ \Large\bf
      \ifnum \c@secnumdepth >\m@ne \@chapapp{} \thechapter:\quad \fi
      ##1\par}
     \bigskip\longhrule\bigskip}

\def\@makeschapterhead##1{\longhrule\bigskip
     {\secshape\parskip\z@\parindent\z@ \Large\bf ##1\par}
     \bigskip\longhrule\bigskip}

% Note that \chapter itself is defined like this:
% \def\chapter{\clearpage \thispagestyle{plain} \global\@topnum\z@
% \@afterindentfalse \secdef\@chapter\@schapter}
% This definition and those of \@chapter and \@schapter remain unchanged.

} % end of \@redefinechapter

% Now, do either the first one or the second one, depending on the main
% document style (article= \chapter undefined, or report= \chapter defined).
% (Note that \par must not appear inside \@ifundefined, therefore this
% indirect approach is taken.)

\@ifundefined{chapter}{\@redefinemaketitle}{\@redefinechapter}

% Re-defintion of the \marginpar command to use always the left margin
% (never the right margin). Be careful that Marginpars do not come to
% near to each other!

\def\@addmarginpar{\@next\@marbox\@currlist{\@cons\@freelist\@marbox
    \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
%-  \if@twocolumn
%-      \if@firstcolumn \@tempcnta\m@ne \fi
%-  \else
%-    \if@mparswitch
%-       \ifodd\c@page \else\@tempcnta\m@ne \fi
%-    \fi
%-    \if@reversemargin \@tempcnta -\@tempcnta \fi
%-  \fi
    \@tempcnta\m@ne % always to left margin <---
    \ifnum\@tempcnta <\z@ \global\setbox\@marbox\box\@currbox \fi
    \@tempdima\@mparbottom \advance\@tempdima -\@pageht
       \advance\@tempdima\ht\@marbox \ifdim\@tempdima >\z@
       \@warning{Marginpar on page \thepage\space moved}\else\@tempdima\z@ \fi
    \global\@mparbottom\@pageht \global\advance\@mparbottom\@tempdima
       \global\advance\@mparbottom\dp\@marbox
       \global\advance\@mparbottom\marginparpush
    \advance\@tempdima -\ht\@marbox
    \global\ht\@marbox\z@ \global\dp\@marbox\z@
    \vskip -\@pagedp \vskip\@tempdima\nointerlineskip
    \hbox to\columnwidth
      {\ifnum \@tempcnta >\z@
          \hskip\columnwidth \hskip\marginparsep
        \else \hskip -\marginparsep \hskip -\marginparwidth \fi
       \box\@marbox \hss}
    \vskip -\@tempdima
    \nointerlineskip
    \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}}

% Special Marginpars:
%   \marginlabel{X} puts X into a flushright Marginpar.
%                   To be used like description-items or short
%                   \subsubsection* headings.
%   \attention      puts ! --> to the left of the text.
%                   To mark an important piece of text.
%   \seealso{X}     puts a small ---> X to the very left.
%                   To mark a reference within the text.
% These three commands start with an empty \mbox, i.e. they can be used
% before the first word of a paragraph and still have the desired
% effect, namely that the marginal stuff appears next to the first
% line of this paragraph, not at the last line of the previous one.
% They end with \ignorespaces, i.e. blanks (spaces) after the argument's
% } are allowed and do NOT appear in the printed text.
% Like all \marginpar's, they cannot be used in math mode or inside boxes.

\def\marginlabel#1{\mbox{}\marginpar{\raggedleft #1}\ignorespaces}
\def\attention{\mbox{}\marginpar{\raggedleft \large\bf ! $\rightarrow$}}
\def\seealso#1{\mbox{}\marginpar{\small $\rightarrow$ #1}\ignorespaces}

% The description environment is redefined such that the item labels use
% the whole left margin (and are in roman, right bound, with colon).
%  \labelwidth = \leftmarginwidth + previous\@totalleftmargin +
%                + new\leftmargin - \labelsep

\def\descriptionlabel#1{\hfil\hss\rm #1:}
\def\description{\list{}{\labelsep=\marginparsep
     \labelwidth=\leftmarginwidth \advance\labelwidth by \@totalleftmargin
     \advance\labelwidth by \leftmargin \advance\labelwidth by -\labelsep
     \let\makelabel=\descriptionlabel}}
\let\enddescription=\endlist

% The maxipage environment is a minipage that uses the \fullwidth,
% with \hrules above and below. Marginpars are not allowed.
% To be used for wide tables, long math equations, and the like.
% It cannot be split across pages.
% It can be used in floats, e.g. like
%    \begin{table}\begin{maxipage}
%    ... a wide table ... \caption{the caption}
%    \end{maxipage}\end{table}

\def\maxipage{\par % (here a \vskip\parskip will happen by the final \par)
              \mbox{}\kern-\leftmarginwidth \kern-\@totalleftmargin
              \begin{minipage}{\fullwidth}
              \medskip\hrule\medskip
              \def\marginpar{\typeout{Marginpar not allowed within Maxipage.}}}
\def\endmaxipage{\par \vskip\parskip \medskip\hrule\medskip
                 \end{minipage}\par}

% The fullpage environment changes the page layout such that normal text
% and all environments use the \fullwidth. Marginpars are not allowed.
% Both \begin{fullpage} and \end{fullpage} start a new page before switching
% to the other layout.
% To be used for one or several special pages where the full line length is
% needed.

\def\fullpage{\clearpage \leftmarginwidth\z@ \textwidth=\fullwidth
              \oddsidemargin=\z@ \evensidemargin\z@
              \hsize=\fullwidth \linewidth=\fullwidth \columnwidth=\fullwidth
              \def\marginpar{\typeout{Marginpar not allowed within Fullpage.}}}
\def\endfullpage{\clearpage}

% The pagestyles plain, headings and myheadings are redefined and new
% pagestyles footings and myfootings are defined, which all use the
% \fullwidth, with \thepage on the outer side of the (odd/even) page
% and some with a \hrule below the head line or above the foot line.
% My favourite is
%    \pagestyle{myfootings}
%    \markboth{the title of the paper}{the title of the paper}
% (Note that the \markboth is not destroyed by the new \part command.)

% The pagestyles headings and myheadings set \topmargin to \emptyfoottopmargin.
% The pagestyles footings and myfootings set \topmargin to \emptyheadtopmargin.
% The pagestyles empty and plain do not change \topmargin.
% Therefore, within one document,
% - you may switch between headings, myheadings, empty, and plain,
% - or you may switch between footings, myfootings, empty, and plain,
% - but you should not mix (my)headings with (my)footings pages.

% As a compromise between article (section+subsection) and report
% (chapter+section), \sectionmark (without uppercase) will be put on
% both side pages in the headings and footings style (neither chapter
% nor subsection).

\def\ps@plain{\let\@mkboth\@gobbletwo
     \def\@oddhead{}\def\@evenhead{}%
     \def\@oddfoot{\rm\hfil\thepage}%
     \def\@evenfoot{\hss \hbox to \fullwidth{\normalsize\rm\thepage\hfil}}}

\if@twoside         % If two-sided printing.
\def\ps@headings{\let\@mkboth\markboth \topmargin\emptyfoottopmargin
\def\@oddfoot{}\def\@evenfoot{}%       No feet.
\def\@evenhead{\hss\vbox{\hsize=\fullwidth
               \hbox to \fullwidth{\normalsize\rm\thepage \hfil
                                   \small\sl \leftmark}%
               \vskip 3pt \hrule}}%
\def\@oddhead{\hss\vbox{\hsize=\fullwidth
               \hbox to \fullwidth{\small\sl \rightmark \hfil
                                   \normalsize\rm\thepage}%
               \vskip 3pt \hrule}}%
\def\sectionmark##1{\markboth
  {{\ifnum \c@secnumdepth >\z@ \thesection\hskip 1em\relax \fi ##1}}%
  {{\ifnum \c@secnumdepth >\z@ \thesection\hskip 1em\relax \fi ##1}}}%
\def\subsectionmark##1{}}
\else               % If one-sided printing.
\def\ps@headings{\let\@mkboth\markboth \topmargin\emptyfoottopmargin
\def\@oddfoot{}\def\@evenfoot{}%     No feet.
\def\@oddhead{\hss\vbox{\hsize=\fullwidth
               \hbox to \fullwidth{\small\sl \rightmark \hfil
                                   \normalsize\rm\thepage}%
               \vskip 3pt \hrule}}%
\def\sectionmark##1{\markright {{\ifnum \c@secnumdepth >\z@
    \thesection\hskip 1em\relax \fi ##1}}}}
\fi

\if@twoside         % If two-sided printing.
\def\ps@footings{\let\@mkboth\markboth \topmargin\emptyheadtopmargin
\def\@oddhead{}\def\@evenhead{}%       No heads.
\def\@evenfoot{\hss\vbox{\hsize=\fullwidth \hrule \vskip 3pt
               \hbox to \fullwidth{\normalsize\rm\thepage \hfil
                                   \small\sl\leftmark}}}%
\def\@oddfoot{\hss\vbox{\hsize=\fullwidth \hrule \vskip 3pt
              \hbox to \fullwidth{\small\sl\rightmark \hfil
                                  \normalsize\rm\thepage}}}%
\def\sectionmark##1{\markboth
 {{\ifnum \c@secnumdepth >\z@ \thesection\hskip 1em\relax \fi ##1}}%
 {{\ifnum \c@secnumdepth >\z@ \thesection\hskip 1em\relax \fi ##1}}}%
\def\subsectionmark##1{}}
\else               % If one-sided printing.
\def\ps@headings{\let\@mkboth\markboth \topmargin\emptyheadtopmargin
\def\@oddhead{}\def\@evenhead{}%     No heads.
\def\@oddfoot{\hss\vbox{\hsize=\fullwidth \hrule \vskip 3pt
              \hbox to \fullwidth{\small\sl\rightmark \hfil
                                  \normalsize\rm\thepage}}}%
\def\sectionmark##1{\markright {{\ifnum \c@secnumdepth >\z@
    \thesection\hskip 1em\relax \fi ##1}}}}
\fi

\def\ps@myheadings{\let\@mkboth\@gobbletwo \topmargin\emptyfoottopmargin
\def\@evenhead{\hss\vbox{\hsize=\fullwidth
               \hbox to \fullwidth{\normalsize\rm\thepage \hfil
                                   \small\sl\leftmark}%
               \vskip 3pt \hrule}}%
\def\@oddhead{\hss\vbox{\hsize=\fullwidth
               \hbox to \fullwidth{\small\sl\rightmark \hfil
                                   \normalsize\rm\thepage}%
               \vskip 3pt \hrule}}%
\def\@oddfoot{}\def\@evenfoot{}\def\sectionmark##1{}\def\subsectionmark##1{}}

\def\ps@myfootings{\let\@mkboth\@gobbletwo \topmargin\emptyheadtopmargin
\def\@evenfoot{\hss\vbox{\hsize=\fullwidth \hrule \vskip 3pt
               \hbox to \fullwidth{\normalsize\rm\thepage \hfil
                                   \small\sl\leftmark}}}%
\def\@oddfoot{\hss\vbox{\hsize=\fullwidth \hrule \vskip 3pt
              \hbox to \fullwidth{\small\sl\rightmark \hfil
                                  \normalsize\rm\thepage}}}%
\def\@oddhead{}\def\@evenhead{}\def\sectionmark##1{}\def\subsectionmark##1{}}

% The \noparskip command is defined to take away the vertical Parskip,
% just like \noindent takes away the horizontal Parindent.

\def\noparskip{\par\vspace{-\parskip}}

% Correction of a LaTeX bug that occurs when marginpars and footnotes
% appear on the same page (by Chris Rowley, TUGboat 9/2 Aug.88)

\def\@specialoutput{\ifnum\outputpenalty > -\@Mii
    \@doclearpage
  \else
    \ifnum \outputpenalty <-\@Miii
       \ifnum\outputpenalty<-\@MM \deadcycles\z@\fi
       \global\setbox\@holdpg\vbox{\unvbox\@cclv}
    \else \setbox\@tempboxa\box\@cclv
        \@pagedp\dp\@holdpg \@pageht\ht\@holdpg
        \unvbox\@holdpg
%-      \ifvoid\footins\else\advance\@pageht\ht\footins
%-        \advance\@pageht\skip\footins \advance\@pagedp\dp\footins
%-        \insert\footins{\unvbox\footins}\fi
        \@next\@currbox\@currlist{\ifnum\count\@currbox >\z@
% moved --->
                \ifvoid\footins\else\advance\@pageht\ht\footins
                  \advance\@pageht\skip\footins \advance\@pagedp\dp\footins
                  \insert\footins{\unvbox\footins}\fi
            \@addtocurcol\else
% moved and changed --->
                \ifvoid\footins\else
                  \insert\footins{\unvbox\footins}\fi
            \@addmarginpar\fi}\@latexbug
    \ifnum \outputpenalty <\z@ \penalty \z@ \fi
  \fi\fi}


% Setting of the Layout Parameters and Dimensions:
% ------------------------------------------------

% Switch to \onecolumn and disable \twocolumn.
\onecolumn
\let\onecolumn=\relax
\def\twocolumn{\typeout{Twocolumn not allowed with Refman.}}

% Horizontal Layout:
%     \fullwidth = \leftmarginwidth + \textwidth
%     \odd&evensidemargin = \leftmarginwidth
%     \marginparwidth = \leftmaginwidth - \marginparsep

% \textwidth, \columnwidth, \linewidth remain unchanged from art10...rep12
\fullwidth=6.5in
\leftmarginwidth=\fullwidth \advance\leftmarginwidth by -\textwidth
\oddsidemargin=\leftmarginwidth
\evensidemargin=\leftmarginwidth
\marginparwidth=\leftmarginwidth \advance\marginparwidth by -\marginparsep

% The horizontal layout can be changed in the preamble with the command
%     \setleftmarginwidth{length}
% This sets \leftmarginwidth=length and \textwidth=\fullwidth-<length> .
% Example: \setleftmarginwidth{2.5in} ---> 2.5 : 4 = 4 : 6.5

\newdimen\templength@
\def\setleftmarginwidth#1{\templength@=#1\relax
\leftmarginwidth=\templength
\textwidth=\fullwidth \advance \textwidth by -\templength
\oddsidemargin=\leftmarginwidth \evensidemargin=\leftmarginwidth
\marginparwidth=\leftmarginwidth \advance\marginparwidth by -\marginparsep
\hsize=\textwidth \linewidth=\textwidth \columnwidth=\textwidth }

% Vertical Layout (for DIN-A4 paper):
%     Top and Bottom Margins are made smaller by 5.5 baselineskips each,
%     Head and Foot separations are increased by 0.5 baselineskips each,
%     Textheight is increased by 10 lines.
%     \raggedbottom is switched on (even for twoside).
% With some pagestyles, the page contents are shifted up or down a bit,
% by using \emptyheadtopmargin or \emptyfoottopmargin, respectively.

\advance\topmargin by -5.5\baselineskip
\advance\headsep by 0.5\baselineskip
\advance\footskip by 0.5\baselineskip
\advance\textheight by 10\baselineskip
\@colht=\textheight \@colroom=\textheight
\emptyheadtopmargin=\topmargin \advance\emptyheadtopmargin by -1\baselineskip
\emptyfoottopmargin=\topmargin \advance\emptyfoottopmargin by 1\baselineskip
\raggedbottom

% Zero minimal vertical separation between Marginpars (because we use a lot
% of them, and all must find room above each other).

\marginparpush=\z@

% Paragraph Layout:
%     Zero Parindent and non-zero Parskip. The stretchable glue in \parskip
%     helps LaTeX in finding the best place for page breaks.

\parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt
\parindent=\z@

% Redefinition of the vertical spacing in the list environments
% to use the same as \parskip in all relevant places (normalsize only):
%   \parsep = \parskip
%   \itemsep = \z@ % add nothing to \parskip between items
%   \topsep = \z@ % add nothing to \parskip before first item

\def\@listI{\leftmargin\leftmargini
   \topsep\z@ \parsep\parskip \itemsep\z@}
\let\@listi\@listI
\@listi

\def\@listii{\leftmargin\leftmarginii
   \labelwidth\leftmarginii\advance\labelwidth-\labelsep
   \topsep\z@ \parsep\parskip \itemsep\z@}

\def\@listiii{\leftmargin\leftmarginiii
    \labelwidth\leftmarginiii\advance\labelwidth-\labelsep
    \topsep\z@ \parsep\parskip \itemsep\z@}

% Note that listiv, listv and listvi don't change vertical parameters.


% Switch on the new version of the plain pagestyle.
\pagestyle{plain}

% This is the end of REFMAN.STY.
\endinput
