% /u/sy/beebe/tex/errata/erratum.sty, Fri Oct 18 09:08:51 1991
% Edit by Nelson H. F. Beebe <beebe@magna.math.utah.edu>
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Nelson H. F. Beebe",
%%%     version         = "1.00",
%%%     date            = "18 October 1991",
%%%     filename        = "erratum.sty",
%%%     address         = "Center for Scientific Computing
%%%                        Department of Mathematics
%%%                        South Physics Building
%%%                        University of Utah
%%%                        Salt Lake City, UT 84112
%%%                        USA
%%%                        Tel: (801) 581-5254
%%%                        FAX: (801) 581-4148",
%%%     checksum        = "00314 140 639 6146",
%%%     email           = "beebe@magna.math.utah.edu (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "erratum, LaTeX style",
%%%     supported       = "yes",
%%%     docstring       = "This style file provides macros for the
%%%                        convenient production of errata listings.
%%%
%%%                        An errata list takes the form
%%%
%%%                        \begin{errata}
%%%                        \erritem{p. n, l. m}
%%%                        \erratum{old text}{new text}
%%%                        Discussion.
%%%                        \erritem{p. n, l. m}
%%%                        \erratum{old text}{new text}
%%%                        Discussion.
%%%                        ...
%%%                        \end{errata}
%%%
%%%                        The \erritem{} macro is mandatory for each
%%%                        erratum entry.  It produces a column-wide
%%%                        horizontal rule before each item, and
%%%                        ensures that its argument (the item tag)
%%%                        sits alone on a separate line.
%%%
%%%                        The \erratum{}{} macro need only be used
%%%                        when a correction is made.  It can be
%%%                        preceded, or followed, by discussion.  It
%%%                        puts its arguments in two column-wide
%%%                        framed boxes, separated by the phrase
%%%                        ``should be''.
%%%
%%%                        The checksum field above contains a CRC-16
%%%                        checksum as the first value, followed by the
%%%                        equivalent of the standard UNIX wc (word
%%%                        count) utility output of lines, words, and
%%%                        characters.  This is produced by Robert
%%%                        Solovay's checksum utility.",
%%%  }
%%% ====================================================================
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\if@twocolumn
    % Make page somewhat wider than normal, with smaller margins
    \addtolength{\oddsidemargin}{-30pt}
    \addtolength{\evensidemargin}{-30pt}
    \addtolength{\textwidth}{60pt}
\fi

% Literal backspace
\newcommand{\bs}{{\tt \char`\\}}

\newenvironment{errata}{\begin{trivlist}}{\end{trivlist}}

% \erritem{tag} is an extended \item[tag], with a separating rule
% above the tag line, and a line break before text that follows
% \erritem{tag}.  It can be used in any LaTeX list environment.
\def\erritem#1{%
    \vskip-\lastskip            % remove any pending glue for consistent spacing
    \vspace{\itemsep}           % want spacing before horizontal rule
    {
       \samepage                % keep this group on same page
       \hbox to \columnwidth{\dotfill}% column-wide separator dots
       \labelsep=0pt            % make item tag line up with left margin;
                                % setting it to #pt moves it left by #pt
       \item[{\bf #1}]          % standard item tag
       \leavevmode              % back into horizontal mode for next \newline
       \newline                 % keep item tag on its own line
       \nobreak                 % prevent page break after item tag
    }
}

% \erratum{erroneous text}{corrected text} displays two column-wide
% paragraph boxes containing the arguments, separating them by the
% string ``should be'', then starts a new paragraph.  This makes text
% changes much more obvious, and distinct from commentary text that
% might not flag an erratum, but merely suggest improvements in the
% text.

\newlength{\parboxwidth}        % temporary variable for \erratum

\newcommand{\erratum}[2]{       %\erratum{erroneous text}{corrected text}
  {                             %group here so \hbadness is locally reset
    \parboxwidth=\linewidth     % compute available width for parboxes
    \advance\parboxwidth by -2\fboxsep %make outer box width == parboxwidth
    \advance\parboxwidth by -2\fboxrule
    \hbadness=10000             % suppress underfull box message in fboxes
    \newline\vspace{-1.5\baselineskip}  % want a bit of extra vertical
                                        % space before first box
    \smallskip
    \noindent
    \fbox{\parbox{\parboxwidth}{#1}} % here is the old text
    \par
    \noindent
    should be
    \smallskip
    \par
    \noindent
    \fbox{\parbox{\parboxwidth}{#2}} % and here is the new text
    \vspace{1pt plus 1pt minus 1pt}  % \smallskip is a bit too big here
    \par
  }
}

% LaTeX's default tolerance of 10000 in sloppy and sloppypar
% is unsatisfactory in two-column mode; \emergencystretch
% saves the day
\renewcommand{\sloppy}{\ifx\emergencystretch\undefined
                       \else
                           \emergencystretch=10pt%
                       \fi
                       \tolerance 9000%
                       \hbadness 10000% don't warn about underfull boxes
                       \hfuzz .5pt%
                       \vfuzz .5pt%
                       }

% Change sloppypar to eliminate the initial \par, which gives extra
% vertical space that we don't want here.
\renewenvironment{sloppypar}{\bgroup\sloppy}{\egroup}

\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%[End of erratum.sty]%%%%%%%%%%%%%%%%%%%%%%%%%%
