From 5185c8bb863b3923d54b8281306721bf06e0f452 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 11 Jan 2006 23:55:13 +0000 Subject: trunk/Master/texmf-dist/source/latex/modroman git-svn-id: svn://tug.org/texlive/trunk@392 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/latex/modroman/modroman.dtx | 342 +++++++++++++++++++++ 1 file changed, 342 insertions(+) create mode 100644 Master/texmf-dist/source/latex/modroman/modroman.dtx (limited to 'Master/texmf-dist/source/latex/modroman/modroman.dtx') diff --git a/Master/texmf-dist/source/latex/modroman/modroman.dtx b/Master/texmf-dist/source/latex/modroman/modroman.dtx new file mode 100644 index 00000000000..ea8bc3a3295 --- /dev/null +++ b/Master/texmf-dist/source/latex/modroman/modroman.dtx @@ -0,0 +1,342 @@ +% \iffalse meta-comment +% +% Copyright (C) 2003 by Yvon Henel +% -------------------------------------------------------- +% +% 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 +%\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%\def\fileversion{v0.3} +%\def\filedate{2004/05/19} +%\def\fileinfo{fichier modroman.dtx par Le TeXnicien de surface} +%\ProvidesPackage{modroman} +% [\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} +% +% \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.} +% +%\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: + + -- cgit v1.2.3