% pdcdoc.def 1.2 1995/03/30 -- macros for short documents
%%%@TeX-definition-file {
%%% filename       = "pdcdoc.def",
%%% version        = "1.2",
%%% date           = "1995/03/30",
%%% package        = "pdcmac 1.0",
%%% author         = "P. Damian Cugley",
%%% email          = "damian.cugley@comlab.ox.ac.uk",
%%% address        = "Oxford University Computing Laboratory,
%%%                   Parks Road, Oxford  OX1 3QD, UK",
%%% codetable      = "USASCII",
%%% keywords       = "TeX, plain TeX, style file",
%%% supported      = "Maybe",
%%% abstract       = "Sectioning macros for style files.
%%%                   This macro file was generated by running plain
%%%                   TeX on pdcsty.dtx",
%%% copyright      = "Copyright (c) 1991-1995 P. Damian Cugley",
%%% copying        = "DO NOT DISTRIBUTE THIS FILE.
%%%                   Distribute pdcsty.dtx only as part of the
%%%                   package it came in.",
%%% dependencies   = ""
%%%}

\message{1.2 <pdc 1995/03/30>}

\topmg=297mm \advance\topmg-11in \advance\topmg7mm
\botmg=\topmg
\advance\topmg\ht\strutbox \advance\topmg\headlineskip
\ifdim \topmg<20mm \topmg=20mm \fi
\ifdim \botmg<27mm \botmg=27mm \fi
\setpaper{210mm}{297mm}
\setnkgrid{4}{3}
\colrule=0pt
\leftmargin=\gridwd \advance\leftmargin\colsep
\everypage={\ifdim\leftmargin>0pt
    \setbox\leftbox=\hbox to \gridwd{}\fi}
\everyfootnote={\notefonts}
\everylinenum={\smallfonts}
\everylinenum={\smallfonts}
\everytag={\bf}
\newcount\partno
\def\thepartno{%
    \ifcase\partno O\or I\or II\or III\or IV\or V\else
        \expandafter\uppercase\expandafter{\romannumeral\partno}%
    \fi
}
\newcount\secno \newcount\subsecno \newcount\subsubsecno
\def\thesecno{%
    \n{%
        \number\secno
        \ifnum\subsecno>0
            .\number\subsecno
            \ifnum\subsubsecno>0
         .\number\subsubsecno
            \fi
        \fi
    }%
}
\newtoks\majorheadline
\expandafter\majorheadline
    \expandafter{\expandafter\uppercase\expandafter{\jobname}}
\def\part#1{%
    \global\advance\partno1
    \newpageheading{2\baselineskip}{\headingfonts}
        {}{\thepartno.\quad#1}
    \TOCwrite\TOCentrypart{\thepartno}{#1}
}
\newcount\sectionpenalty
\def\sectionheading#1{
    \par
    \vskip 0pt plus 0.3\vsize
    \penalty\sectionpenalty \sectionpenalty-200
    \vskip 1\bigskipamount plus -0.3\vsize
    \begingroup \advance\leftskip-\leftmargin
        \parskip=0pt \parindent=0pt
        \hyphenpenalty=10000 \exhyphenpenalty=500
        \interlinepenalty=100
        \headingfonts \nointerlineskip
        \hbox{\hskip-\leftmargin
         \vrule height 2pt depth 0pt width \leftmargin
         \vrule height 2pt depth 0pt width \hsize}
       #1\par
        \nobreak\smallskip
    \endgroup
    \global\noindenttrue
}
\newtoks\sectiontoks
\newif\ifsecno \secnotrue
\def\section#1{
    \ifsecno
        \global\advance\secno1 \global\subsecno0 \global\subsubsecno0
    \fi
    \toks0={#1}
    \mark{{\the\sectiontoks}{\ifsecno\S\thesecno\space\fi\the\toks0 }}
    \edef\tmp{\ifsecno\noexpand\S\the\secno\space\fi}
    \global\sectiontoks\expandafter{\tmp#1}
    \sectionheading{\ifsecno\thesecno\quad\fi #1}
    \mark{{\the\sectiontoks}{\the\sectiontoks}}
    \TOCwrite\TOCentrysection{\ifsecno\thesecno\fi}{#1}
}
\def\subsec#1{%
    \ifsecno \global\advance\subsecno1  \global\subsubsecno0 \fi
    \doheading\medskipamount{\subheadingfonts}{}
        {\ifsecno\thesecno\quad\fi#1}
    \TOCwrite\TOCentrysubsec{\ifsecno\thesecno\fi}{#1}
}
\def\subsubsec#1{%
    \ifsecno \global\advance\subsubsecno+1 \fi
    \doheading\smallskipamount{\rm}{}{\ifsecno\thesecno\quad\fi#1}
    \TOCwrite\TOCentrysubsubsec{\ifsecno\thesecno\fi}{#1}
}
\newif\ifnoheadline
\newif\iftwosided
\footline={%
    \ifnoheadline
        \global\noheadlinefalse
        \hfil\bodyfonts\n\folio\hfil
    \else
        \hfil
    \fi
}
\headline={%
    \ifnoheadline
        \hfil
    \else
        \bodyfonts
        \iftwosided
            \ifodd\pageno
         \hfil
         \expandafter\firstoftwo\botmark\quad
         {\bf\n\folio}%
            \else
         {\bf\n\folio}\quad
         \the\majorheadline
         \hfil
            \fi
        \else
            \the\majorheadline
            \hfil
           \expandafter\secondoftwo\topmark\quad
            {\bf\n\folio}%
        \fi
    \fi
}
\def\firstoftwo#1#2{#1}
\def\secondoftwo#1{}
\newwrite\TOCfile
\openout\TOCfile=\jobname.toc
\def\TOCwrite#1#2#3{%
    \begingroup\def\n{\string\n}
    \def\tmp{#3}%
    \edef\tmp{\string#1{#2}{\expandafter\TOCtrim\meaning\tmp}}
    \write\TOCfile\expandafter{\tmp{\folio}}\endgroup
}
\def\TOCtrim#1:->{}
\def\TOCentrypart#1#2#3{
    \smallskip
    \dimen0=\hsize \advance\dimen0\leftmargin
    \moveleft\leftmargin\hbox to\dimen0{\strut\bf #1. #2\hfil}
    \smallskip
}
\def\TOCentrysection#1#2#3{
    \smallskip\noindent\llap{#1\kern1pc}%
        {\bf \ignorespaces #2\quad\rm \n{#3}}\par
}
\def\TOCentrysubsec#1#2#3{
    \ifvmode \noindent \else \quad \fi
    {#1}~{\ignorespaces #2}
}
\def\TOCentrysubsubsec#1#2#3{}
\def\frontmatter{
    \write\TOCfile{\string\endinput}
    \write\TOCfile{\folio}
    \closeout\TOCfile
    \vfill\supereject
    \ifvoid\partialpage\else \null\vfill\eject \fi
    \beginthe{frontmatter}
    \pageno=-1 \secnofalse \noheadlinetrue
    \def\TOCwrite##1##2##3{}
}
\def\endfrontmatter{
    \section{Contents}
    \input\jobname.toc
    \vfill\supereject
    \endthe{frontmatter}
}
\def\titlepage{
    \vfill\eject
    \beginthe{titlepage}
    \noheadlinetrue
    \def\splittitlepage{
        \iftwosided \vfill\eject\null\vfill \else \vfill \fi
    }
}
\def\endtitlepage{
    \eject
    \endthe{titlepage}
}
\def\abstract{
    \smallskip
    \beginthe{abstract}
        \setbox\parbox\hbox to \gridwd{\subheadingfonts Abstract\hfil}
        \noindenttrue \bodyfonts
}
\def\endabstract{
        \smallskip
    \endthe{abstract}
}
\def\pt{\,{\rm pt}}
\def\mm{\,{\rm mm}}
\def\MF{{\ifdim\fontdimen1\font>0pt \mfi \else \mf \fi META}\-%
        {\ifdim\fontdimen1\font>0pt \mfi \else \mf \fi FONT}}
\def\MSDOS{\leavevmode\hbox{MS-DOS}}
\def\TeX{T\kern-0.1em\lower0.5ex\hbox{E}X\spacefactor1000 }
\begingroup\catcode`\|=12 \toks0={\endgroup
    \def\dfn#1{\ifx\index\UNDEFINED\else\index{#1|INDdfn}\fi{\bi #1}}
} \the\toks0
\declareactivechar\* \def*#1*{{\it#1\/}}
\def\|{%
    \relax\ifmmode
        \Vert
    \else
        \begingroup
        \ttb \setupverbatim
        \catcode`\|=13 \let|\endgroup
    \fi
}
\def\inputifexists#1{%
    \openin15=#1
    \ifeof15 \else \input #1 \fi
    \closein15
}
