summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/modroman/modroman.dtx
blob: ea8bc3a3295ce7aa02b0806350096bc33e8ff976 (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
% \iffalse meta-comment
%
% Copyright (C) 2003 by Yvon Henel <Yvon.Henel@wanadoo.fr>
% --------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\def\fileversion{v0.3}  
%<package>\def\filedate{2004/05/19}
%<package>\def\fileinfo{fichier modroman.dtx par Le TeXnicien de surface}
%<package>\ProvidesPackage{modroman}
%<package>   [\filedate\space\fileversion\space\fileinfo] 
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{xspace,url,multicol}
\usepackage{modroman}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,frenchb]{babel}
\IfFileExists{lmodern.sty}{\usepackage{lmodern}}{}%
% commentez la ligne suivante pour avoir un document avec le code
\OnlyDescription
% comment out the preceding line to obtain the full code 
% with explanations in French only, sorry.
\EnableCrossrefs         
\CodelineIndex
\RecordChanges
\GlossaryPrologue{\section*{{Changements}}\markboth{{Changements}}{{Changements}}}
\IndexPrologue{\section*{Index}\markboth{Index}{Index}%
  Les nombres en italique renvoient à la page où l'entrée est décrite ; les
  nombres soulignés renvoient à la ligne de code de la définition ; les
  nombres en caractères romains renvoient à la ligne de code où l'entrée est
  utilisée.}
\def\generalname{Général}
\setlength{\columnseprule}{0.5pt}
\setlength{\multicolsep}{6pt plus 2.0pt minus 1.5pt}
\newenvironment{EnAnglais}{\columnbreak\mbox{}\par\begin{otherlanguage}{english}}{\end{otherlanguage}}
\begin{document}
  \DocInput{modroman.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{113}
%
% \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         \~}
%
%
% \changes{v0.1}{2003/04/20}{Version initiale}
% \changes{v0.2}{2004/02/11}{Ajout des options upourv et vpourv}
% \changes{v0.3}{2004/05/18}{Quelques actions cosmétiques sur la documentation}
% \changes{v0.3}{2004/05/18}{Attirail pour *nix et CTAN.} 
%\iffalse
%<*eng>
\changes{v0.1}{2003/04/20}{Initial version}
\changes{v0.2}{2004/02/11}{Two options: upourv (u for v) and vpourv (v for v).}
\changes{v0.3}{2004/05/18}{Some cosmetic actions on the doc.} 
\changes{v0.3}{2004/05/18}{Provides CTAN-ware and *nix tool.} 
\changes{v0.3}{2004/05/18}{Bug corrected: 101 is at last written cj.} 
%</eng>
%\fi
% \GetFileInfo{modroman.sty}
%
% \DoNotIndex{\newcommand,\newenvironment,\fi,\ ,{}}
%
% \title{Le module \textsf{modroman}\thanks{Ce document
%   correspond au fichier \textsf{modroman}~\fileversion, du \filedate.}}
% \author{Le \TeX nicien de surface\\ \url{Yvon.Henel@wanadoo.fr}}
%
% \maketitle
%
% \section{Introduction}
%
% Ce petit module fournit une commande \cs{modromannumeral} pour écrire
% des nombres en chiffres romains minuscules avec une variante que je me
% souviens avoir vu sur des manuscrits : lorsque le nombre est supérieur
% ou égal à 2 et qu'il se termine normalement par un i, on écrit un j à
% la place. Cette commande s'emploie comme la primitive \TeX
% \cs{romannumeral}.
%
% Il fournit également une commande \cs{modroman}\marg{UnCompteur} pour
% écrire la valeur d'un \emph{compteur} de la même manière. Elle s'emploie
% comme la commande \LaTeX{} \cs{roman}.
%
% Il existe désormais à la demande générale d'\textbf{un} contributeur de
% \url{fr.comp.text.tex} deux options qui s'excluent mutuellement : l'option
% par défaut |vpourv| qui conserve le comportement de la version précédente
% et l'option |upourv| qui remplace  \og v \fg par  \og u \fg dans l'écriture
% des chiffres romains. 
%
% \vspace{\stretch{1}}
%
% \hspace*{\stretch{1}}\makebox[0.5\linewidth][c]{\hrulefill} \hspace*{\stretch{1}}
%
% \vspace{\stretch{1}}
%
% \begin{otherlanguage}{english}
% This package provides only two macros viz.\ \cs{modromannumeral} which
% writes the number given as argument in lower case roman numeral with a
% `j' instead of a `i' as the final letter of numbers greater than 1
% such as \modromannumeral 2{} or \modromannumeral 101{} and
% \cs{modroman}\marg{MyCounter} which writes the value of a \emph{counter} in
% the same way. 
%
% You have to use the first as the \TeX{} primitive
% \cs{romannumeral} and the second as \LaTeX{} command \cs{roman}.
% 
% The default option is `vpourv' with which \cs{modromannumeral}| 5| is
% written as v. With the option `upourv' the same \cs{modromannumeral}| 5| is
% written as u. It was a special requirement from \emph{one} person posting on
% \url{fr.comp.text.tex}. \emph{The (almost) French `vpourv' stands for `v for
% v'.}   
% 
% I have not translated the detailed explanations of the code given in French  
% for I wrote them mainly for me and because they are rather low
% level. Moreover all the ideas and technics used here come from  
% \cite{tlachand}.   
% \end{otherlanguage}
% \vspace*{\baselineskip}
% \newpage
% \bgroup \setlength{\parindent}{0pt}
% \section{Utilisation}
% \begin{multicols}{2}
% On écrit |\modromannumeral 123| pour obtenir \modromannumeral 123.
%
% On écrit\\ 
% |\newcounter{moncompt}|\\
% |\setcounter{moncompt}{213}|\\
% |\modroman{moncompt}|\\
% pour obtenir
% \newcounter{moncompt}\setcounter{moncompt}{213} \og \modroman{moncompt} \fg.
%    
% Avec \\
% |\usepackage[upourv]{modroman}|\\
% on passe l'option |upourv| à l'extension et les |v| des chiffres romains
% sont écrits |u|. Sinon, par défaut ou avec l'option |vpourv| on aura bien un
% |v| pour \og traduire \fg  5.
% \begin{EnAnglais}
% One writes |\modromannumeral 123| to obtain \modromannumeral 123.
%
% With \\ 
% |\newcounter{mycount}|\\
% |\setcounter{mycount}{213}|\\
% |\modroman{mycount}|\\
% one obtains `\modroman{moncompt}'.
%    
% With \\
% |\usepackage[upourv]{modroman}|\\
% the option |upourv| is enforced and the
% |v| of the roman numerals are written |u|. By default, or with the explicit
% option |vpourv| one will obtain the more classical |v| as a `translation' of
% 5. 
% \end{EnAnglais}
% \end{multicols}
%
% \DescribeMacro{\modromannumeral} Syntaxe :
% \cs{modromannumeral}\verb*! !\emph{Nbr} 
% \begin{multicols}{2}
% La première macro de ce module, écrite en \TeX. Elle écrit un nombre
% en chiffres romains minuscules et si ce nombre est supérieur à 2 et
% que son écriture habituelle se termine par un \og i \fg, ce \og i \fg
% sera changé en \og j \fg.
%
% Elle s'utilise comme la primitive \TeX{} \cs{romannumeral}, elle peut
% être suivie d'un ou plusieurs espaces suivis, obligatoirement, d'un
% nombre \emph{Nbr} qui \emph{ne doit pas} être entre accolades puis il faut
% assurer, si besoin, l'espace qui suit par \verb*!\ ! ou |{}| car la macro
% mange les espaces qui suivent le nombre.
% \begin{EnAnglais}
% The first macro of the package, written in \TeX. It writes a number in lower
% case roman numerals and if this number is greater than 1 and if its usual
% written form ends with an `i', that `i' is changed into a `j'.
% 
% It is used as the \TeX{} primitive \cs{romannumeral}, it can be followed by
% one or many spaces and then a mandatory number \emph{Nbr} which is
% \emph{not} between curly braces then one has to ensure, if needed, the
% following space with \verb*!\ ! or |{}| for the macro eats the spaces that
% follow the number.
% \end{EnAnglais}
% \end{multicols}
% 
% \DescribeMacro{\modroman} Syntaxe :
% \cs{modroman}\marg{Cptr} 
% \begin{multicols}{2}
% Cette macro dans le mode \LaTeX, prend pour argument un compteur \emph{Cptr}
% comme le font les macros \cs{roman} ou \cs{alph} et écrit la valeur de ce
% compteur  sous la forme indiquée ci-dessus à l'aide de
% \cs{modromannumeral}.
% \begin{EnAnglais}
% This is a \LaTeX-style macro. The mandatory argument is a counter
% \emph{Cptr}. One uses it as the \cs{roman} or \cs{alph} commands. It writes
% the value of \emph{Cptr} in the form explained above via
% \cs{modromannumeral}.  
% \end{EnAnglais}
% \end{multicols}
% \egroup 
% \begin{thebibliography}{9}
% \bibitem{tlachand} T.~\textsc{Lachand-Robert}.
% \emph{La maîtrise de \TeX{} et \LaTeX{}}.
% Masson, Paris, Milan, Barcelone, \oldstylenums{1995}.
% \textsc{isbn} : \texttt{2-225-84832-7}.
% \end{thebibliography}
% \StopEventually{}
%
% \section{Le code}
% Je ne fais que suivre les idées --~nombreuses~-- , les exemples
% --~détaillés~-- et les explications --~claires~-- fournis par
% T.~\textsc{Lachand}-\textsc{Robert} dans~\cite{tlachand}.
% 
% Les erreurs que l'on pourrait trouver dans ce fichier sont entièrement
% de moi.
% 
% On déclare un nouveau \cs{if} et les deux options, on sélectionne l'option
% |vpourv| par défaut, on charge les options. 
%    \begin{macrocode}
\newif\if@upourv
\DeclareOption{upourv}{\@upourvtrue}
\DeclareOption{vpourv}{\@upourvfalse}
\DeclareOption{defaut}{\@upourvfalse}
\ExecuteOptions{defaut}
\ProcessOptions\relax
%    \end{macrocode}
% \begin{macro}{\modromannumeral}
% La première macro, dans le style \TeX, que je décris ci-dessous.
% 
% On commence par créer un nouveau compteur \cs{romt@mp}.
%    \begin{macrocode}
\newcount\romt@mp
%    \end{macrocode}
% On poursuit en écrivant la macro principale qui fait appel à
% \cs{modrom@naux}.  Le \cs{afterassignment} permet de commencer par lire le
% nombre \(N\) qui suit et l'affecter au compteur \cs{romt@mp} puis ensuite de
% lancer \cs{modrom@naux} avec \cs{romt@mp} comme argument. 
%    \begin{macrocode}
\def\modromannumeral{\afterassignment\modrom@naux \romt@mp=}
%    \end{macrocode}
% On continue avec \cs{modrom@naux} qui regarde si \(N\) est strictement
% inférieure à 10. Si c'est le cas on exécute \cs{modrom@ni} avec \cs{romt@mp}
% pour argument. Sinon on exécute \cs{modrom@nii} avec ce même argument. 
%    \begin{macrocode}
\def\modrom@naux{\ifnum\romt@mp<10 
  \modrom@ni{\romt@mp}\else\modrom@nii{\romt@mp}\fi\relax}
%    \end{macrocode}
% La macro \cs{modrom@ni} admet un argument. Elle se contente de réécrire la
% forme souhaitée du nombre à un chiffre \(N\) passé en argument à
% \cs{modromannumeral}.  On utilise un test \cs{ifcase} \cs{or} \texttt{\dots}
% \cs{fi}. On remarquera que le premier \cs{or} suit directement la condition
% puisque ce nombre ne peut être nul. Suivant le choix de l'option on aura
% une définition ou l'autre.  
%    \begin{macrocode}
\if@upourv
\def\modrom@ni#1{\ifcase#1 \or i\or ij\or iij\or iu\or
  u\or uj\or uij\or uiij\or ix\fi\relax}\else
\def\modrom@ni#1{\ifcase#1 \or i\or ij\or iij\or iv\or
  v\or vj\or vij\or viij\or ix\fi\relax}\fi
%    \end{macrocode}
% 
% La macro \cs{modrom@nii} admet un argument.  Elle utilise la macro
% auxiliaire \cs{modrom@nij}. Elle crée dans un groupe ---~notez les doubles
% parenthèses ouvrantes et fermantes~--- deux compteurs temporaires. On
% affecte \(N\) aux deux compteurs.
% 
% Après la 1\iere instruction de la deuxième ligne le compteur 0 |\count0|
% contient le quotient \(q\) de l'argument principal \(N\) dans la division
% euclidienne par \(10\). À la fin de cette ligne il contient \(10q\).
% 
% Après la troisième ligne, le compteur 1 comptient contient \(r\) le reste de
% la division de \(N\) par \(10\). Pour finir, on écrit \(10q\) en chiffres
% romains grâce à la primitive \TeX{} \cs{romannumeral} et on écrit le reste \(r\)
% grâce à \cs{modrom@nij}.
%    \begin{macrocode}
\def\modrom@nii#1{{\count0 =#1\count1 =\count0 % 
    \divide\count0 by 10 \multiply\count0 by 10 %
    \advance \count1 by -\count0 %
    \romannumeral\count0\modrom@nij{\count1}%
  }}
%    \end{macrocode}
% \end{macro}
% La macro \cs{modrom@nij} admet un argument. Elle pratique comme
% \cs{modrom@ni} en tenant compte toutefois que \(N\) est un nombre à au moins
% deux chiffres ce qui entraine que, p. ex., \(101\) s'écrit 
% \modromannumeral 101. Et on a une  \og double \fg définition comme ci-dessus
% pour les mêmes raisons. 
% \begin{macro}{\modrom@nij}
% C'est la macro qui écrit le reste lorsque \(N > 9\).
% \changes{v0.3}{2004/05/18}{Correction d'un bogue : 101 donne enfin \emph{cj}.} 
%    \begin{macrocode}
\if@upourv
\def\modrom@nij#1{\ifcase#1 \or j\or ij\or iij\or iu\or
  u\or uj\or uij\or uiij\or ix\fi\relax}\else
\def\modrom@nij#1{\ifcase#1 \or j\or ij\or iij\or iv\or
  v\or vj\or vij\or viij\or ix\fi\relax}\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\modroman}
% 
% La deuxième macro, dans le style \LaTeX, est bien plus courte. Elle 
% fait appel à \cs{expandafter} pour que \cs{value} passe bien un nombre
% --~la valeur du compteur passé en argument~-- à \cs{modromannumeral}
% et l'histoire finit là.
%    \begin{macrocode}
\newcommand{\modroman}[1]{\expandafter\modromannumeral\value{#1}}
\endinput
%    \end{macrocode}
% \end{macro}
% \Finale \PrintIndex\PrintChanges
\endinput

%%% Local Variables: 
%%% mode: latex
%%% coding: iso-8859-15
%%% TeX-master: t
%%% End: