summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/modroman/modroman.dtx
blob: 70952fdeb010ebb4f390a53e19ac8b4787521c31 (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
% \iffalse meta-comment
%
% Copyright (C) 2003, 2004, 2008 by Yvon Henel, 
% dit « le TeXnicien de surface » 
% <le.texnicien.de.surface@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.4}  
%<package>\def\filedate{2008/05/03}
%<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}[2008/05/03]
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,frenchb]{babel}
\IfFileExists{lmodern.sty}{\usepackage{lmodern}}{}%
% commenter 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{101}
%
% \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.} 
% \changes{v0.4}{2008/05/03}{Je me débarrasse des \cs{if}s.}
% \changes{v0.4}{2008/05/03}{Protection par \cs{@ifdefinable} des \cs{def}.}
% \changes{v0.4}{2008/05/03}{J'introduis \cs{modrom@actuelV}.}
%\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.} 
\changes{v0.4}{2008/05/03}{Get rid of the \cs{if}s.}
\changes{v0.4}{2008/05/03}{Creation of \cs{modrom@actuelV}.}
%</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\ 
%              et en est l'édition du cinquantenaire.}}
% \author{Le \TeX nicien de surface\\ \url{Yvon.Henel@orange.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éfinit les deux options, on sélectionne l'option |vpourv| par défaut, on
% charge les options. 
% 
%    \begin{macrocode}
\DeclareOption{vpourv}{%
%    \end{macrocode}
% \begin{macro}{\modrom@actuelV} Cette macro contient la forme effective du
% chiffre romain V: ce sera |u| avec l'option |upourv| et |v| avec |vpourv|,
% l'option par défaut. Dans le 2\ieme \cs{DeclareOption}, qui définit l'option
% |upourv|, la macro \cs{modrom@actuelV} étant déjà définie lors du traitement
% de l'option par défaut, \emph{via} |\ExecuteOptions{vpourv}|, on ne contrôle
% pas la \cs{def} avec \cs{@ifdefinable}, sinon on a une erreur systématique! 
%    \begin{macrocode}
  \@ifdefinable\modrom@actuelV{\def\modrom@actuelV{v}}
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{upourv}{\def\modrom@actuelV{u}}
\ExecuteOptions{vpourv}
\ProcessOptions\relax
%    \end{macrocode}
% \begin{macro}{\romt@mp}
% On commence par créer un nouveau compteur \cs{romt@mp} à la mode \TeX, en
% s'assurant que c'est possible. 
%    \begin{macrocode}
\@ifdefinable\romt@mp{\newcount\romt@mp}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\modromannumeral}
% On poursuit en écrivant la macro principale, définie à la \TeX\ mais en
% ayant pris soin de s'assurer que c'est possible avec \cs{@ifdefinable}. Elle
% 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}
\@ifdefinable\modromannumeral{%
  \def\modromannumeral{\afterassignment\modrom@naux \romt@mp=}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\modrom@naux}
% 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}
\@ifdefinable\modrom@naux{%
  \def\modrom@naux{\ifnum\romt@mp<10 
    \modrom@ni{\romt@mp}\else\modrom@nii{\romt@mp}\fi\relax}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\modrom@ni} Cette macro sert à écrire la version modifiée du
% nombre en chiffre romain quand ce nombre est inférieur à \(10\). Elle fait
% appel à \cs{modrom@actuelV} pour savoir quelle forme du $5$ romain écrire. 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. 
% \changes{v0.4}{2008/05/03}{Réécriture de la définition à l'aide de
% \cs{modrom@actuelV}.}  
%    \begin{macrocode}
\@ifdefinable\modrom@ni{%
  \def\modrom@ni#1{\ifcase#1 \or i\or ij\or iij\or i\modrom@actuelV\or
    \modrom@actuelV\or \modrom@actuelV j\or \modrom@actuelV ij\or
    \modrom@actuelV iij\or ix\fi\relax}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\modrom@nii}
% 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}
\@ifdefinable\modrom@nii{%
  \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}
% \begin{macro}{modrom@nij} La commande \cs{modrom@nij} écrit le dernier
% chiffre romain d'un nombre supérieur à \(10\). Elle admet un argument et
% 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. Elle fait également appel à \cs{modrom@actuelV} pour
% tenir compte de l'option choisie. 
% \changes{v0.4}{2008/05/03}{Réécriture de la définition à l'aide de
% \cs{modrom@actuelV}.} 
%    \begin{macrocode}
\@ifdefinable\modrom@nij{%
  \def\modrom@nij#1{\ifcase#1 \or j\or ij\or iij\or i\modrom@actuelV\or
    \modrom@actuelV\or \modrom@actuelV j\or \modrom@actuelV ij\or
    \modrom@actuelV iij\or ix\fi\relax}}
%    \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: