summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/romanneg/romanneg.sty
blob: 0232bfa438ccbda466ad5e1f747582aceb7fad88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Mario Wolczko",
%%%     version         = "1.03",
%%%     date            = "15 June 1992",
%%%     time            = "18:11:59 BST",
%%%     filename        = "romanneg.sty",
%%%     email           = "mario@acm.org",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "LaTeX, output, pagenumbers",
%%%     supported       = "no",
%%%     docstring       = "Causes the page numbers in the DVI file (as
%%%     defined by \count0) to be negative when roman pagenumbering is
%%%     in effect.",
%%%  }
%%% ====================================================================
%
% This file is in the public domain
%
% 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|

\let\@oldstepcounter\stepcounter
\def\stepcounter#1{{\def\@tmpa{#1}\def\@tmpb{page}%
  \ifx\@tmpa\@tmpb\@steppagecounter\else\@oldstepcounter{#1}\fi}}

% 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}}