Debian Codegraph @

texmf-dist/source/latex/romannum/romannum.dtx

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