%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%  ptexpprt.sty  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	This is a file of macros and definitions for creating a chapter
%	for publication in the ACM/SIAM Preprint Series using Plain TeX.
%	This file may be freely distributed but may not be altered in any way.
%    Any comments or questions regarding these macros should be directed to:

%                 Corey Gray
%                 SIAM
%                 3600 University City Science Center
%                 Philadelphia, PA 19104-2688
%                 USA
%                 Telephone: (215) 382-9800
%                 Fax: (215) 386-7999
%                 e-mail: siampubs@wharton.upenn.edu

%

%    Report the version.
\message{*** ACM/SIAM Plain TeX Preprint Series macro package, version 1.0,
September 24, 1990.***}

% Make the @ sign a letter for internal control sequences.
\catcode`\@=11
%
%
%



%%%  DIMENSIONS  %%%

\newdimen\pagewidth
\hsize=41pc
\pagewidth=\hsize
\newdimen\pageheight
\vsize=50pc
\pageheight=\vsize
\newdimen\ruleht
\ruleht=.5pt
\maxdepth=2.2pt

\parindent=18truept
\def\firstpar{\parindent=0pt\global\everypar{\parindent=18truept}}
\parskip=0pt plus 1pt


%%%  FONTS  %%%

\font\tenrm=cmr10
\font\tenbf=cmbx10
\font\tenit=cmti10
\font\tensmc=cmcsc10
\def\tenpoint{%
   \def\rm{\tenrm}\def\bf{\tenbf}%
   \def\it{\tenit}\def\smc{\tensmc}
        \textfont0=\tenrm \scriptfont0=\sevenrm
	\textfont1=\teni \scriptfont1=\seveni
	\textfont2=\tensy \scriptfont2=\sevensy
	\textfont3=\tenex \scriptfont3=\tenex
\baselineskip=12pt\rm}%

\font\ninerm=cmr9
\font\ninebf=cmbx9
\font\nineit=cmti9
\def\ninepoint{%
   \def\rm{\ninerm}\def\bf{\ninebf}%
   \def\it{\nineit}\baselineskip=11pt\rm}%

\font\eightrm=cmr8
\font\eightbf=cmbx8
\font\eightit=cmti8
\font\eighti=cmmi8
\font\eightsy=cmsy8
\def\eightpoint{%
   \def\rm{\eightrm}\def\bf{\eightbf}%
   \def\it{\eightit}\def\smc{\eightrm}\baselineskip=10pt\rm%
        \textfont0=\eightrm \scriptfont0=\sixrm
	\textfont1=\eighti \scriptfont1=\sixi
	\textfont2=\eightsy \scriptfont2=\sixsy
	\textfont3=\tenex \scriptfont3=\tenex
}

\font\sixrm=cmr6
\font\sixbf=cmbx6
\font\sixi=cmmi6
\font\sixsmc=cmr5
\font\sixsy=cmsy6
\def\sixpoint{%
   \def\rm{\sixrm}\def\bf{\sixbf}%
   \def\smc{\sixsmc}\baselineskip=8pt\rm}%

\fontdimen13\tensy=2.6pt
\fontdimen14\tensy=2.6pt
\fontdimen15\tensy=2.6pt
\fontdimen16\tensy=1.2pt
\fontdimen17\tensy=1.2pt
\fontdimen18\tensy=1.2pt

\font\eightrm=cmr8
\font\ninerm=cmr9
\font\twelverm=cmr10 scaled\magstep1
\font\twelvebf=cmbx10 scaled\magstep 1
\font\sixteenrm=cmr10 scaled\magstep2
\def\titlefont{\sixteenrm}
\def\chapterfont{\twelvebf}
\def\authorfont{\twelverm}
\def\rheadfont{\tenrm}
\def\smc{\tensmc}




%%%  COUNTERS FOR HEADINGS  %%%

\newcount\headcount
\headcount=1
\newcount\seccount
\seccount=1
\newcount\subseccount
\subseccount=1
\def\reset{\global\seccount=1}
\global\headcount=0

%%%  HEADINGS  %%%

\def\headone#1{\global\advance\headcount by 1
\vskip12truept\parindent=0pt{\tenpoint\bf\the\headcount
\hskip11truept #1.}\par\nobreak\firstpar\global\advance\headcount by 0
   %\global\advance\seccount by 1
\reset\vskip2truept}

\def\headtwo#1{%\advance\seccount by -1%
   \vskip12truept\parindent=0pt{\tenpoint\bf\the\headcount.%
   \the\seccount\hskip11truept #1.}\enspace\ignorespaces\firstpar
   \global\advance\headcount by 0\global\advance\seccount by 1}
%   \global\advance\subseccount by 1}


%%%  THEOREMS, PROOFS, DEFINITIONS, etc.  %%%

\def\thm#1{{\smc
#1\enspace}
\begingroup\it\ignorespaces\firstpar}

\let\lem=\thm
\let\cor=\thm
\let\prop=\thm

\def\endthm{\endgroup}
\let\endlem=\endthm
\let\endcor=\endthm
\let\endprop=\endthm

\def\prf#1{{\it #1.}\rm\enspace\ignorespaces}
\let\rem=\prf
\let\case=\prf


\def\dfn#1{{\smc
#1\enspace}
\rm\ignorespaces}



%%%  FIGURES AND CAPTIONS  %%%

\def\caption#1\endcaption{\vskip18pt\ninerm\centerline{#1}\vskip18pt\tenrm}

\newinsert\topins \newif\ifp@ge \newif\if@mid
\def\topinsert{\@midfalse\p@gefalse\@ins}
\def\midinsert{\@midtrue\@ins}
\def\pageinsert{\@midfalse\p@getrue\@ins}
\skip\topins=0pt %no space added when a topinsert is present
\count\topins=1000 %magnification factor (1 to 1)
\dimen\topins=\maxdimen
\def\@ins{\par\begingroup\setbox0=\vbox\bgroup}
\def\endinsert{\egroup
    \if@mid \dimen@=\ht0 \advance\dimen@ by\dp0
       \advance\dimen@ by12\p@ \advance\dimen@ by\pagetotal
       \ifdim\dimen@>\pagegoal \@midfalse\p@gefalse\fi\fi
    \if@mid \bigskip \box0 \bigbreak
    \else\insert\topins{\penalty100
      \splittopskip=0pt \splitmaxdepth=\maxdimen \floatingpenalty=0
      \ifp@ge \dimen@=\dp0
      \vbox to\vsize{\unvbox0 \kern-\dimen@}
    \else \box0 \nobreak\bigskip\fi}\fi\endgroup}


%%%  REFERENCES  %%%

\newdimen\refindent@
\newdimen\refhangindent@
\newbox\refbox@
\setbox\refbox@=\hbox{\ninepoint\rm\baselineskip=11pt [00]}%   Default 2 digits
\refindent@=\wd\refbox@

\def\resetrefindent#1{%
	\setbox\refbox@=\hbox{\ninepoint\rm\baselineskip=11pt [#1]}%
	\refindent@=\wd\refbox@}

\def\Refs{%
	\unskip\vskip1pc
	\leftline{\noindent\tenpoint\bf References}%
	\penalty10000
	\vskip4pt
	\penalty10000
	\refhangindent@=\refindent@
	\global\advance\refhangindent@ by .5em
        \global\everypar{\hangindent\refhangindent@}%
	\parindent=0pt\ninepoint\rm}

\def\sameauthor{\leavevmode\vbox to 1ex{\vskip 0pt plus 100pt
    \hbox to 2em{\leaders\hrule\hfil}\vskip 0pt plus 300pt}}

\def\ref#1\\#2\endref{\leavevmode\hbox to \refindent@{\hfil[#1]}\enspace #2\par}


%%%  OUTPUT  %%%

\newinsert\margin
\dimen\margin=\maxdimen
\count\margin=0 \skip\margin=0pt


\def\footnote#1{\edef\@sf{\spacefactor\the\spacefactor}#1\@sf
  \insert\footins\bgroup\eightpoint\hsize=30pc
  \interlinepenalty100 \let\par=\endgraf
   \leftskip=0pt \rightskip=0pt
   \splittopskip=10pt plus 1pt minus 1pt \floatingpenalty=20000
\smallskip
\item{#1}\bgroup\strut\aftergroup\@foot\let\next}
\skip\footins=6pt plus 2pt minus 4pt
\dimen\footins=30pc

\newif\iftitle


\def\titlepage{\global\titletrue\footline={\hss\ninepoint\rm\folio\hss}}
\def\rhead{\ifodd\pageno CHAPTER TITLE
 \else AUTHORS NAMES\fi}

\def\makefootline{\ifnum\pageno>1\global\footline={\hfill}\fi
   \baselineskip24\p@\vskip12\p@\fullline{\the\footline}}
\def\leftheadline{\hbox to \pagewidth{
  \vbox to 10pt{}
  {\kern-8pt\tenrm\folio\hfill\ninerm\rhead}}}
\def\rightheadline{\hbox to \pagewidth{
  \vbox to 10pt{}
  \kern-8pt\ninerm\rhead\hfil
  {\kern-1pc\tenrm\folio}}}

\def\onepageout#1{\shipout\vbox{
\offinterlineskip
 \vbox to 2.25pc{%
  \iftitle \global\titlefalse
%   \setcornerrules
 \else\ifodd\pageno\rightheadline\else\leftheadline\fi\fi \vfill}
\vbox to \pageheight{
  \ifvoid\margin\else
  \rlap{\kern31pc\vbox to0pt{\kern4pt\box\margin \vss}}\fi
 #1 %
\ifvoid\footins\else
 \vskip\skip\footins \kern 0pt
 \hrule height\ruleht width 2.5pc \kern-\ruleht \kern 0pt
 \unvbox\footins\fi
\boxmaxdepth=\maxdepth}}
\advancepageno}

\def\setcornerrules{\hbox to \pagewidth{
  \vrule width 1pc height\ruleht \hfil \vrule width 1pc}
  \hbox to \pagewidth{\llap{\sevenrm(page \folio)\kern1pc}
  \vrule height1pc width\ruleht depth0pt
  \hfil \vrule width\ruleht depth0pt}}
\output{\onepageout{\unvbox255}}

\newbox\partialpage
\def\begindoublecolumns{\begingroup
  \output={\global\setbox\partialpage=\vbox{\unvbox255\bigskip}}\eject
  \output={\doublecolumnout} \hsize=20pc \vsize=101pc}
\def\enddoublecolumns{\output={\balancecolumns}\eject
  \endgroup \pagegoal=\vsize}

\def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
 \dimen@=50pc \advance\dimen@ by-\ht\partialpage
 \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
 \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
\def\pagesofar{\unvbox\partialpage
 \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
\def\balancecolumns{\setbox0=\vbox{\unvbox255} \dimen@=\ht0
 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
 \divide\dimen@ by2 \splittopskip=\topskip
{\vbadness=10000 \loop \global\setbox3=\copy0
 \global\setbox1=\vsplit3 to\dimen@
 \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
 \setbox0=\vbox to\dimen@{\unvbox1} \setbox2=\vbox to\dimen@{\unvbox 3}
\pagesofar}




%	Turn off @ as being a letter.
%
\catcode`\@=13

% End of ptexpprt.sty
