summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/romannum/romannum.dtx
blob: 9baebe78160e9367a386c62eab83caa0d9091966 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
% \iffalse meta-comment
%
% romannum.dtx
% Author: Peter Wilson, Herries Press
% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
% Copyright 1999--2004 Peter R. Wilson
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version: <http://www.latex-project.org/lppl.txt>
%
% This work has the LPPL maintenance status "maintained".
% The Current Maintainer of this work is Will Robertson.
%
% This work consists of the files listed in the README file.
%
% 
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\setcounter{StandardModuleDepth}{1}
\begin{document}
  \DocInput{romannum.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{252}
%
% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
% \DoNotIndex{\@centercr,\@cite}
% \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
% \DoNotIndex{\@input,\@ixpt,\@m}
% \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
% \DoNotIndex{\advance,\Alph,\alph}
% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
% \DoNotIndex{\bullet}
% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
% \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
% \DoNotIndex{\fbox}
% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
% \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
% \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
% \DoNotIndex{\input}
% \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
% \DoNotIndex{\NeedsTeXFormat,\newdimen}
% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
% \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
% \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
% \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
% \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
% \DoNotIndex{\wd,\xiipt,\year,\z@}
%
% \changes{v1.0}{1999/05/08}{First public release}
% \changes{v1.0b}{2009/09/03}{New maintainer (Will Robertson)}
%
% \def\dtxfile{romannum.dtx}
% \def\fileversion{v1.0}  \def\filedate{8 May 1999}
% \def\fileversion{v1.0a} \def\filedate{2004/05/24}
% \def\fileversion{v1.0b} \def\filedate{2009/09/03}
% \newcommand*{\Lpack}[1]{\textsf {#1}}           ^^A typeset a package
% \newcommand*{\Lopt}[1]{\textsf {#1}}            ^^A typeset an option
% \newcommand*{\file}[1]{\texttt {#1}}            ^^A typeset a file
% \newcommand*{\Lcount}[1]{\textsl {\small#1}}    ^^A typeset a counter
% \newcommand*{\pstyle}[1]{\textsl {#1}}          ^^A typeset a pagestyle
% \newcommand*{\Lenv}[1]{\texttt {#1}}            ^^A typeset an environment
%
% \title{The \Lpack{romannum} package\thanks{This
%        file (\texttt{\dtxfile}) has version number \fileversion, last revised
%        \filedate.}}
%
% \author{
%   Author: Peter Wilson, Herries Press \\
%   Maintainer: Will Robertson \\
%   \texttt{will dot robertson at latex-project dot org}
% }
% \date{\filedate}
% \maketitle
% \begin{abstract}
%    The \Lpack{romannum} package changes the numbers generated by
% \LaTeX{} from arabic digits to roman numerals. The package uses
% the \Lpack{stdclsdv} package.
% \end{abstract}
% \tableofcontents
%
% \StopEventually{}
%
% 
%
% \section{Introduction}
%
%     \LaTeX{} generates numbers for things like chapters and sections,
% figure and table captions, and page numbers. Normally these are printed
% using arabic digits. The \Lpack{romannum} package modifies the typesetting
% of such generated numbers so that they are printed as roman numerals.
% 
% This manual is typeset according to the conventions of the
% \LaTeX{} \textsc{docstrip} utility which enables the automatic
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
%
%    Section~\ref{sec:usc} describes the usage of the package.
% Commented source code for the package is in Section~\ref{sec:code}.
%
% \section{The \Lpack{romannum} package} \label{sec:usc}
%
%    Using the \Lpack{romannum} package, numbers that \LaTeX{} generates will 
% be typeset as
% lowercase roman numerals. For example, `iv' instead of 4.
%
%    The following options change the generated numbers from arabic to
% roman:
% \begin{itemize}
% \item[\Lopt{Section}] Sectional numbers in uppercase roman.
% \item[\Lopt{section}] Sectional numbers in lowercase roman.
% \item[\Lopt{Equation}] Equation numbers in uppercase roman.
% \item[\Lopt{equation}] Equation numbers in lowercase roman.
% \item[\Lopt{Caption}] Table and Figure caption numbers in uppercase roman.
% \item[\Lopt{caption}] Table and Figure caption numbers in lowercase roman.
% \item[\Lopt{Footnote}] Footnote numbers in uppercase roman.
% \item[\Lopt{footnote}] Footnote numbers in lowercase roman.
% \item[\Lopt{Enumerate}] First level items in uppercase roman and third
%                         level items in lowercase roman.
% \item[\Lopt{enumerate}] First level items in lowercase roman and third
%                         level items in uppercase roman.
% \item[\Lopt{Year}] The year number from the |\today| command in uppercase 
%                    roman.
% \item[\Lopt{Day}] The year number from the |\today| command in uppercase
%                   roman and the day number in uppercase roman.
% \item[\Lopt{day}] The year number from the |\today| command in uppercase
%                   roman and the day number in uppercase roman.
% \item[\Lopt{Most}] A shorthand option equivalent to using all these options:
%    \Lopt{Section}, \Lopt{Equation}, \Lopt{Caption}, \Lopt{Footnote},
%    \Lopt{Enumerate}; that is, all the uppercasing options except for
%    \Lopt{Year} and \Lopt{Day}.
% \item[\Lopt{most}] A shorthand option equivalent to using all these options:
%    \Lopt{section}, \Lopt{equation}, \Lopt{caption}, \Lopt{footnote},
%    \Lopt{enumerate}; that is, all the lowercasingcasing options except for
%    \Lopt{day}.
% \end{itemize}
%
%    Note that the |\today|-related options are implemented by redefining the
% |\today| command. If any of these options are used together with another
% package that also redefines the |\today| command, then surprising effects
% may occur.
%
%    The package sets the the pagenumbering to be |\pagenumbering{roman}|
% at the start of the document. This can always be changed after the
% |\begin{document}| command.
%
%    Generally speaking, a number typeset using roman numerals requires more
% space than if it was typeset using arabic digits.
%    If roman numbering is used for sectional headings, captions, or page
% numbers, it is probable that the space allowed for numbers in the
% Table of Contents, and the Lists of Figures and Tables, will need to be
% increased. The amount of increase will depend on the longest (not
% necessarily the largest) roman number to be printed. The \Lpack{romannum}
% package makes no such adjustments; I suggest that the \Lpack{tocloft}
% package be used for this~\cite{TOCLOFT}.
%
% \DescribeMacro{\Romannum}
%    The command |\Romannum{|\meta{integer}|}| typesets \meta{integer} using
% uppercase roman numerals. Strictly speaking, the roman numbering system 
% system does not cater for numbers less than 1 (i.e., zero or negative
% numbers), however the command does what might be expected for zero and
% negative numbers. As normal with a \LaTeX{} command it gobbles any following
% space, so if you need a space after the number, use either of
% the forms shown below:
% \begin{verbatim}
% \Romannum{1}{} and \Romannum{2}\ make \Romannum{3}.
% \end{verbatim}
% The \meta{integer} argument must be either arabic digits or a command that
% expands solely to arabic digits (possibly preceeded by a minus sign).
%
% \DescribeMacro{\romannum}
%    The command |\romannum{|\meta{integer}|}| typesets \meta{integer} using
% lowercase roman numerals. It is the analogue of |\Romannum|.
%
% \section{The package code} \label{sec:code}
%
%    Announce the name and version of the package, which requires
% \LaTeXe{} and the \Lpack{stdclsdv} package.
%    \begin{macrocode}
%<*usc>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{romannum}[2009/09/03 v1.0b roman numerals]
\RequirePackage{stdclsdv}
%    \end{macrocode}
%
%    To try and avoid name clashes with other packages, the internal commands
% all contain the character string |rn@m|.
%
% \begin{macro}{\ifrn@mYear}
% \begin{macro}{\ifrn@mDay}
% \begin{macro}{\ifrn@mday}
% We need some booleans for the date related options.
%    \begin{macrocode}
\newif\ifrn@mYear \rn@mYearfalse
\newif\ifrn@mDay \rn@mDayfalse
\newif\ifrn@mday \rn@mdayfalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Do the options. First for changing the sectioning numbers. The Part number
% is already in uppercase roman, so this is left alone.
%    \begin{macrocode}
\DeclareOption{Section}{%
  \ifSCDchapter
    \renewcommand{\thechapter}{\Roman{chapter}}
    \renewcommand{\thesection}{\thechapter.\Roman{section}}
  \else
    \renewcommand{\thesection}{\Roman{section}}
  \fi
  \renewcommand{\thesubsection}{\thesection.\Roman{subsection}}
  \renewcommand{\thesubsubsection}{\thesubsection.\Roman{subsubsection}}
  \renewcommand{\theparagraph}{\thesubsubsection.\Roman{paragraph}}
  \renewcommand{\thesubparagraph}{\theparagraph.\Roman{subparagraph}}
}
\DeclareOption{section}{%
  \ifSCDchapter
    \renewcommand{\thechapter}{\roman{chapter}}
    \renewcommand{\thesection}{\thechapter.\roman{section}}
  \else
    \renewcommand{\thesection}{\roman{section}}
  \fi
  \renewcommand{\thesubsection}{\thesection.\roman{subsection}}
  \renewcommand{\thesubsubsection}{\thesubsection.\roman{subsubsection}}
  \renewcommand{\theparagraph}{\thesubsubsection.\roman{paragraph}}
  \renewcommand{\thesubparagraph}{\theparagraph.\roman{subparagraph}}
}
%    \end{macrocode}
%
% The equation numbering.
%    \begin{macrocode}
\DeclareOption{Equation}{%
  \ifSCDchapter
    \renewcommand{\theequation}%
      {\ifnum \c@chapter>\z@ \thechapter.\fi \Roman{equation}}
  \else
    \renewcommand{\theequation}{\Roman{equation}}
  \fi
}
\DeclareOption{equation}{%
  \ifSCDchapter
    \renewcommand{\theequation}%
      {\ifnum \c@chapter>\z@ \thechapter.\fi \roman{equation}}
  \else
    \renewcommand{\theequation}{\roman{equation}}
  \fi
}
%    \end{macrocode}
%
% The captions.
%    \begin{macrocode}
\DeclareOption{Caption}{%
  \ifSCDchapter
    \renewcommand{\thefigure}%
      {\ifnum \c@chapter>\z@ \thechapter.\fi \Roman{figure}}
    \renewcommand{\thetable}%
      {\ifnum \c@chapter>\z@ \thechapter.\fi \Roman{table}}
  \else
    \renewcommand{\thefigure}{\Roman{figure}}
    \renewcommand{\thetable}{\Roman{table}}
  \fi
}
\DeclareOption{caption}{%
  \ifSCDchapter
    \renewcommand{\thefigure}%
      {\ifnum \c@chapter>\z@ \thechapter.\fi \roman{figure}}
    \renewcommand{\thetable}%
      {\ifnum \c@chapter>\z@ \thechapter.\fi \roman{table}}
  \else
    \renewcommand{\thefigure}{\roman{figure}}
    \renewcommand{\thetable}{\roman{table}}
  \fi
}
%    \end{macrocode}
%
% The footnote.
%    \begin{macrocode}
\DeclareOption{Footnote}{%
  \renewcommand{\thefootnote}{\Roman{footnote}}
}
\DeclareOption{footnote}{%
  \renewcommand{\thefootnote}{\roman{footnote}}
}
%    \end{macrocode}
%
% The enumerate.
%    Two of |enumerate| environment numbers need changing. First level 
% enumerations are normally arabic digits, and the third level are normally
% lowercase roman. These get changed to lowercase and uppercase roman.
%    \begin{macrocode}
\DeclareOption{Enumerate}{%
  \renewcommand{\theenumi}{\Roman{enumi}}
  \renewcommand{\theenumiii}{\roman{enumiii}}
}
\DeclareOption{enumerate}{%
  \renewcommand{\theenumi}{\roman{enumi}}
  \renewcommand{\theenumiii}{\Roman{enumiii}}
}
%    \end{macrocode}
%
% The date related options.
%    \begin{macrocode}
\DeclareOption{Year}{\rn@mYeartrue}
\DeclareOption{Day}{\rn@mDaytrue\rn@mYeartrue\rn@mdayfalse}
\DeclareOption{day}{\rn@mDayfalse\rn@mYeartrue\rn@mdaytrue}
%    \end{macrocode}
%
% The most options.
%    \begin{macrocode}
\DeclareOption{Most}{%
  \ExecuteOptions{Section,Equation,Caption,Footnote,Enumerate}
}
\DeclareOption{most}{%
  \ExecuteOptions{section,equation,caption,footnote,enumerate}
}
%    \end{macrocode}
%
% Now we can process the options.
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
%
%  
%
% \begin{macro}{\theday}
% \begin{macro}{\theyear}
% \begin{macro}{\today}
%    Change the date related numerals, if asked for. This involves redefining
% the |\today| command.
%    \begin{macrocode}
\ifrn@mYear
  \newcommand{\thern@myear}{\@Roman\year}
  \ifrn@mDay
    \newcommand{\thern@mday}{\@Roman\day}
  \else
    \ifrn@mday
      \newcommand{\thern@mday}{\@roman\day}
    \else
      \newcommand{\thern@mday}{\@arabic\day}
    \fi
  \fi
  \edef\today{\ifcase\month\or
    January\or February\or March\or April\or May\or June\or
    July\or August\or September\or October\or November\or December\fi
    \space\thern@mday, \thern@myear}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\romannum}
%    |\romannum{|\meta{integer}|}| typesets \meta{integer} using lowercase
% roman numerals.
%    The basic code for this is in the TEXbook on pages 40--41.
% I have added code to handle the cases of zero and negative integers.
%    \begin{macrocode}
\newcommand{\romannum}[1]{%
  \ifnum#1<1
    \ifnum#1=0
      o%
    \else
      -\romannumeral -#1%
    \fi
  \else
    \romannumeral #1%
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Romannum}
%    Having got |\romannum|, this is easy.
%    \begin{macrocode}
\DeclareRobustCommand{\Romannum}[1]{\MakeUppercase{\romannum{#1}}}
%    \end{macrocode}
% \end{macro}
%
%    Finally, make the default page numbering lowercase roman.
%    \begin{macrocode}
\AtBeginDocument{\pagenumbering{roman}}
%    \end{macrocode}
%
%    The end of this package.
%    \begin{macrocode}
%</usc>
%    \end{macrocode}
%
%
% \bibliographystyle{alpha}
%
% \begin{thebibliography}{GMS94}
%
% \bibitem[GMS94]{GOOSSENS94}
% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
% \newblock {\em The LaTeX Companion}.
% \newblock Addison-Wesley Publishing Company, 1994.
%
% \bibitem[Wil99]{TOCLOFT}
% Peter R.~Wilson.
% \newblock {\em The TOCLOFT package}.
% \newblock 1999. (Available from CTAN in \texttt{macros/latex/contrib/supported})
%
% \end{thebibliography}
%
%
% \Finale
% \PrintIndex
%
\endinput

%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}