%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Mario Wolczko",
%%%     version         = "2",
%%%     date            = "21 May 1992",
%%%     time            = "21:01:06 BST",
%%%     filename        = "romanneg.sty",
%%%     address         = "Dept of Computer Science
%%%                        The University of Manchester
%%%                        Oxford Road
%%%                        Manchester M13 9PL
%%%                        UK",
%%%     telephone       = "+44-61-275-6146",
%%%     FAX             = "+44-61-275-6236",
%%%     checksum        = "11731 80 341 3482",
%%%     email           = "mario@cs.man.ac.uk (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "LaTeX, output, pagenumbers",
%%%     supported       = "yes",
%%%     docstring       = "Causes the page numbers in the DVI file (as
%%%     defined by \count0) to be negative when roman pagenumbering is
%%%     in effect.",
%%%  }
%%% ====================================================================
%
% This style option should not change the appearance of a document,
% but merely change the page numbers (as defined by \count0) in the
% DVI file to be negative when roman pagenumbering is in use.
%
%
% To do this, the \@steppagecounter macro increments the absolute
% value of \count0
\def\@steppagecounter{% based on \advancepageno, TeXbook, p.362
  \ifnum\c@page<\z@ \global\advance\c@page\m@ne
  \else\global\advance\c@page\@ne \fi} % increase |c@page|

% The output routine is slightly modified so that \@steppagecounter is
% used.  We assume a) that the page counter is only modified in the
% output routine, and by \pagenumbering, and
% b) the output routine below is otherwise identical to that defined
% by LaTeX.  This should be checked before installation.
\def\@outputpage{\begingroup\catcode`\ =10 \if@specialpage
     \global\@specialpagefalse\@nameuse{ps@\@specialstyle}\fi
     \if@twoside
       \ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
            \let\@themargin\oddsidemargin
          \else \let\@thehead\@evenhead
          \let\@thefoot\@evenfoot \let\@themargin\evensidemargin
     \fi\fi
     \shipout
     \vbox{\normalsize \baselineskip\z@ \lineskip\z@
           \vskip \topmargin \moveright\@themargin
           \vbox{\setbox\@tempboxa
                   \vbox to\headheight{\vfil \hbox to\textwidth{\@thehead}}
                 \dp\@tempboxa\z@
                 \box\@tempboxa
                 \vskip \headsep
                 \box\@outputbox
                 \baselineskip\footskip
                 \hbox to\textwidth{\@thefoot}}}\global\@colht\textheight
           \endgroup\@steppagecounter\let\firstmark\botmark} % <-- only
							     % this line changed

% Modified version of the pagenumbering command that sets \count0 (aka
% \c@page) to -1 rather than 1 if roman numbering is specified.
\def\pagenumbering#1{{%
  \def\@tmpa{#1} \def\@tmpb{roman} \def\@tmpc{Roman}
  \ifx\@tmpa\@tmpb % roman option; set -ve page number.
    \global\c@page \m@ne
  \else\ifx\@tmpa\@tmpc
    \global\c@page \m@ne
  \else
    \global\c@page \@ne
  \fi\fi
  \gdef\thepage{\csname @#1\endcsname \c@page}}}

% the modified versions of \@roman and \@Roman deal with negatives
\def\@romannumeral#1{\ifnum#1<0 \romannumeral-#1 \else\romannumeral#1 \fi}
\def\@roman#1{\@romannumeral #1}
\def\@Roman#1{\expandafter\uppercase\expandafter{\@romannumeral #1}}
