%% pptfixes.tex [was $Id: pptfixes.doc,v 1.27 1993/09/14 16:02:21 kris Exp $]
%%
%% Fixes for the AMSPPT document style version 2.1 for AMS-TeX.
%% Copyright (c) 1991,1992  Kristoffer H. Rose  <kris@diku.dk>
%%
%% Parts derived from AMSPPT.DOC are
%% Copyright (c) American Mathematical Society, all rights reserved.
%%
%% This file is distributed in the hope that it will be useful, but WITHOUT
%% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
%% FITNESS FOR A PARTICULAR PURPOSE.
%%
%% NOTE: This file is normally distributed along with the XPPT AMS-TeX
%% preprint enhancements but can be used separately.
%%
\ifx\AMSPPTdocument\undefined
 \edef\0{\styname:\styversion}\def\1{AMSPPT:2.1}\ifx\0\1\else
  \errmessage{You can only use PPTFIXES with AMSPPT version 2.1.}\fi
\else \message{[already loaded]}\endinput \fi
\count255=\the\catcode`\@ \catcode`\@=11 \edef\catcode@{\the\count255}
\def\Monograph{\monograph@true \let\headmark\rightheadtext
  \let\varindent@\indent \def\headfont@{\bf}\def\proclaimheadfont@{\smc}%
  \def\demofont@{\smc}}
\def\paper{\makerefbox\paperbox@\paperfont@}
\def\paperfont@{\it}
\newif\ifpaperinquotes@
\def\paperinquotes{\paperinquotes@true\def\paperfont@{}}
\def\book{\makerefbox\bookbox@{\bookfont@\aftergroup\book@true}}
\def\inbook{\makerefbox\bookbox@{\bookfont@\aftergroup\procpaper@true}}
\def\bookfont@{\it}
\newif\ifbookinquotes@
\def\bookinquotes{\bookinquotes@true\def\bookfont@{}}
\def\endref@{%
  \keyhook@
  \def\nofrillscheck##1{%
    \def\do####1{\ifx##1####1\let\frills@\eat@\fi}%
    \let\frills@\identity@ \nofrills@list}%
  \ifvoid\bybox@
    \ifvoid\edbox@
    \else\setbox\bybox@\hbox{\unhbox\edbox@\breakcheck
      \nofrillscheck\edbox@\frills@{\space(\edtext)}\refbreak@}\fi
  \fi
  \ifvoid\keybox@\else\hbox to\refindentwd{%
       \keyformat{\unhbox\keybox@}}\fi 
  \commaunbox@\translbox@
  \ifbook@
    \ifvoid\bybox@
      \ifbookinquotes@ \ppunbox@\empty{``}\bookbox@\endquotes
      \else \ppunbox@\empty\empty\bookbox@\empty \fi
    \else \ppunbox@\empty\empty\bybox@\empty
      \ifbookinquotes@ \ppunbox@,{ ``}\bookbox@\endquotes
      \else \commaunbox@\bookbox@ \fi
    \fi
    \ppunbox@\empty{ (}\procinfobox@)%
    \ppunbox@,{ \voltext~}\volbox@\empty
    \commaunbox@\bookinfobox@
    \commaunbox@\publbox@ \commaunbox@\publaddrbox@
    \commaunbox@\yrbox@
  \else
    \ifvoid\bybox@
      \ifpaperinquotes@ \ppunbox@\empty{``}\paperbox@\endquotes
      \else \ppunbox@\empty\empty\paperbox@\empty \fi
    \else \ppunbox@\empty\empty\bybox@\empty
      \ifpaperinquotes@ \ppunbox@,{ ``}\paperbox@\endquotes
      \else \commaunbox@\paperbox@ \fi
    \fi
    \commaunbox@\paperinfobox@
    \ifprocpaper@
      \ifvoid\edbox@
	\ifbookinquotes@ \ppunbox@,{ in~``}\bookbox@\endquotes
        \else \ppunbox@,{ in~}\bookbox@\empty \fi
      \else
        \ppunbox@,{ in~}\edbox@{ (\edtext)}%
	\ifbookinquotes@ \ppunbox@,{ ``}\bookbox@\endquotes
        \else \commaunbox@\bookbox@ \fi
      \fi
      \ppunbox@\empty{ (}\procinfobox@)%
      \ppunbox@,{ \voltext~}\volbox@\empty
      \commaunbox@\bookinfobox@
      \commaunbox@\publbox@ \commaunbox@\publaddrbox@
      \commaunbox@\yrbox@
      \ppunbox@,{ \pagestext~}\pagesbox@\empty
    \else
      \commaunbox@\jourbox@
      \ppunbox@\empty{ }\volbox@\empty
      \ppunbox@\empty{ (}\yrbox@)%
      \ppunbox@,{ \issuetext~}\issuebox@\empty
      \commaunbox@\publbox@ \commaunbox@\publaddrbox@
      \commaunbox@\pagesbox@ 
    \fi
  \fi
  \commaunbox@\finalinfobox@
  \ppunbox@\empty{ (}\miscnotebox@)%
  \finalpunct\ppunbox@\empty{ (}\langbox@)%
  \defaultreftexts
}
%%% ====================================================================
%%%  @TeX-file{
%%%     author          = "Walter D. Neumann",
%%%     version         = "1.2",
%%%     date            = "22 July 1992",
%%%     time            = "15:57:20 EDT",
%%%     filename        = "newinsert.tex",
%%%     address         = "Department of Mathematics
%%%                        Ohio State University
%%%                        Columbus, OH 43201
%%%                        USA",
%%%     email           = "neumann@mps.ohio-state.edu (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "plain TeX, AMS-TeX, inserts, figures",
%%%     supported       = "yes",
%%%     abstract        = "Bug fixes to plain TeX macros \midinsert and 
%%%                        \topinsert",
%%%  }
%%% ====================================================================
\newskip\insertskipamount\newskip\inserthardskipamount
\insertskipamount 6pt plus2pt
\inserthardskipamount 6pt
\def\insertskip{\vskip\insertskipamount}
\newskip\LastSkip
\def\SaveLastSkip{\LastSkip\lastskip}
\def\RestoreLastSkip{\nobreak\vskip-\LastSkip\vskip\LastSkip}
\newcount\SplitTest%        will be set to -1 if a topinsert has split
\def\SetSplitTest{\SplitTest\insertpenalties
  \insert\topins{\floatingpenalty1}%
  \advance\SplitTest-\insertpenalties}
\def\midinsert{\par
 \SaveLastSkip\penalty-150\SetSplitTest\RestoreLastSkip
 \ifnum\SplitTest=-1
  \@midfalse\else\@midtrue\fi\@ins}
\def\@ins{\par\begingroup\setbox\z@\vbox\bgroup%
  \vglue\inserthardskipamount}
\def\endinsert{\egroup
  \if@mid \dimen@\ht\z@ \advance\dimen@\dp\z@
    \advance\dimen@\insertskipamount%            was 12pt (wn)
    \advance\dimen@\pagetotal\advance\dimen@-\pageshrink
    \ifdim\dimen@>\pagegoal\@midfalse\p@gefalse\fi\fi
  \if@mid%
    \ifdim\lastskip<\insertskipamount\removelastskip\insertskip\fi
    \nointerlineskip\box\z@\penalty-200\insertskip
  \else%
    \SaveLastSkip%                                  added (wn)
    \insert\topins{\penalty100
    \splittopskip\z@skip
    \splitmaxdepth\maxdimen \floatingpenalty\z@
    \ifp@ge \dimen@\dp\z@
    \vbox to\vsize{\unvbox\z@\kern-\dimen@}% depth is zero
    \else \box\z@\nobreak\insertskip\fi}% was \bigskip\fi (wn)
    \RestoreLastSkip%                               added (wn)
   \fi\endgroup}
\def\@ins{\par\begingroup\def\vspace##1{\vskip##1\relax}%
  \def\captionwidth##1{\captionwidth@##1\relax}%
  \setbox\z@\vbox\bgroup%
  \vglue\inserthardskipamount}
\catcode`\@=\catcode@ \endinput
