diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/ordinalpt/ordinalpt.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/ordinalpt/ordinalpt.dtx | 450 |
1 files changed, 255 insertions, 195 deletions
diff --git a/Master/texmf-dist/source/latex/ordinalpt/ordinalpt.dtx b/Master/texmf-dist/source/latex/ordinalpt/ordinalpt.dtx index e00c9b6c862..01a70f558df 100644 --- a/Master/texmf-dist/source/latex/ordinalpt/ordinalpt.dtx +++ b/Master/texmf-dist/source/latex/ordinalpt/ordinalpt.dtx @@ -1,4 +1,4 @@ -%% \CheckSum{260} +%% \CheckSum{242} % \iffalse % File: ordinalpt.dtx % Copyright (C) 2007 Miguel V. S. Frasson (mvsfrasson@gmail.com) @@ -11,8 +11,11 @@ %<*driver> \documentclass{ltxdoc} \usepackage{doc} +\usepackage[T1]{fontenc} \usepackage{amstext,makeidx} \makeindex +\newcommand{\ordm}{\textordmasculine} +\newcommand{\ordf}{\textordfeminine} \begin{document} \DocInput{ordinalpt.dtx} \end{document} @@ -24,22 +27,27 @@ % \StopEventually % % \changes{1.0}{2007/01/10}{initial version} +% \changes{2.0}{2007/01/27}{reimplemented to make macros freely expandable} +% \changes{3.0}{2007/02/08}{add options for ordinals of 11, 12 and 13; +% changed default behavior for these numbers} % % \MakeShortVerb+ % % \title{\textsf{ordinalpt}: counters as ordinal numbers in Portuguese} % \author{Miguel Vin\'\i cius Santini Frasson} -% \date{2007--01--10 version 1.0} +% \date{2007--02--08 version 3.0} % % \maketitle % +% \tableofcontents +% % \section{Introduction} % -% The package \textsf{ordinalpt} provides a counter style (like -% +\arabic+, +\alph+ and others) but that produces as +% The package \textsf{ordinalpt} provides a counter style like +% +\arabic+, +\alph+, etc., but that produces as % output strings like ``primeiro'' (first in Portuguese), % ``segundo'' (second), ``terceiro'' (third), \ldots, up to -% ``mil\'esimo nongent\'esimo nonag\'esimo nono'' +% ``mil\'esimo noningent\'esimo nonag\'esimo nono'' % (1999$^{\text{th}}$). There are counter commands to output the % text in UPPERCASE, Capitalized or in lowercase, with masculine or % feminine gender. @@ -64,7 +72,7 @@ % + \Ordptfem{+\countername+}+ (capitalized feminine) and\\ % + \ORDPTFEM{+\countername+}+ (uppercase feminine). % -% Example: +% Example: % %\begin{verbatim} %\renewcommand{\thepage}{--- \Ordptfem{page} p\'agina ---} @@ -76,19 +84,59 @@ % % \section{User options} % +% \DescribeEnv{11-12-curtos} +% \DescribeEnv{11-13-curtos} +% \DescribeEnv{11-13-longos} +% For the ordinals of 11, 12 and 13 there are two correct forms each:\par +% \begin{tabular}{cll} +% Number & Shorter & Longer\\\hline +% 11 & und\'ecimo & d\'ecimo primeiro\\ +% 12 & duod\'ecimo & d\'ecimo segundo\\ +% 13 & tred\'ecimo & d\'ecimo terceiro +% \end{tabular}\par\noindent +% It is usual to find the shorter forms for 11\ordm\ and 12\ordm\ in +% texts, including some grammars. The shorter form for 13\ordm\ is +% a bit harder to find. It is kind of strange to see shorter for +% 11\ordm\ and longer for 12\ordm\ and the other way around, so it +% should not happen. If 13\ordm\ is presented in shorter form, +% then definitely the shorter forms should be used for 11\ordm\ and +% 12\ordm. Therefore we provide three package options +% `\texttt{11-12-curtos}', `\texttt{11-13-curtos}' and +% `\texttt{11-13-longos}' with the following results: \par +% \begin{tabular}{llll} +% Option & 11\ordm & 12\ordm & 13\ordm\\\hline +% \texttt{11-12-curtos} (default) & und\'ecimo & duod\'ecimo & d\'ecimo terceiro\\ +% \texttt{11-13-curtos} & und\'ecimo & duod\'ecimo & tred\'ecimo\\ +% \texttt{11-13-longos} & d\'ecimo primeiro & d\'ecimo segundo & d\'ecimo terceiro +% \end{tabular}\par\noindent +% \textit{Nota bene}: These options affect all ordinals that +% finish in 11, 12 and 13. For instance, with option +% \texttt{11-12-curtos}, the ordinal for 112 becomes ``cent\'esimo +% duod\'ecimo''. +% % \DescribeEnv{tricentesimo} % \DescribeEnv{trecentesimo} % The options `\texttt{tricentesimo}' (default; closer to latin % \textit{tricentesimu}) and `\texttt{trecentesimo}' are provided -% to use between ``tricent\'esimo'' and ``trecent\'esimo'', since -% both forms are correct for the ordinal of 300. +% to choose between ``tricent\'esimo'' and ``trecent\'esimo'', since +% both forms are correct for the ordinal of 300.\par +% \begin{tabular}{ll} +% Option & 300\ordm\\\hline +% \texttt{tricentesimo} (default) & tricent\'esimo\\ +% \texttt{trecentesimo} & trecent\'esimo\\ +% \end{tabular} % % \DescribeEnv{sexcentesimo} % \DescribeEnv{seiscentesimo} % The options `\texttt{sexcentesimo}' (default; closer to the latin % \textit{sexcentesimu}) and `\texttt{seiscentesimo}' are provided % to choose between ``sexcent\'esimo'' and ``seiscent\'esimo'', -% since both forms are correct for the ordinal of 600. +% since both forms are correct for the ordinal of 600.\par +% \begin{tabular}{ll} +% Option & 600\ordm\\\hline +% \texttt{sexcentesimo} (default) & sexcent\'esimo\\ +% \texttt{seiscentesimo} & seiscent\'esimo\\ +% \end{tabular} % % \DescribeEnv{noningentesimo} % \DescribeEnv{nongentesimo} @@ -96,15 +144,43 @@ % \textit{noningentesimu}) and `\texttt{nongentesimo} (from latin % \textit{nongentesimu})' are provided to choose between % ``noningent\'esimo'' and ``nongent\'esimo'', since both forms are -% correct for the ordinal of 900. +% correct for the ordinal of 900.\par +% \begin{tabular}{ll} +% Option & 900\ordm\\\hline +% \texttt{noningentesimo} (default) & noningent\'esimo\\ +% \texttt{nongentesimo} & nongent\'esimo\\ +% \end{tabular} % % \section{Code} % -% Identidication of the package and use of the package \textsf{ifthen}. +% Identidication of the package. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ordinalpt}[2007/01/11 v1.0 Ordinal numbers in Portuguese] -\RequirePackage{ifthen} +\ProvidesPackage{ordinalpt}[2007/02/08 v2.1 Ordinal numbers in Portuguese] +% \end{macrocode} +% +% \DescribeEnv{11-12-curtos} +% \DescribeEnv{11-13-curtos} +% \DescribeEnv{11-13-longos} +% Declaring options `\texttt{11-12-curtos}' (default) and +% `\texttt{11-13-curtos}' and +% `\texttt{11-13-longos}', for the various situations for ordinals of +% 11, 12 and 13, as discussed before. +% \begin{macrocode} +\newif\if@ordpt@twelveshort +\newif\if@ordpt@thirteenshort +\@ordpt@twelveshorttrue +\@ordpt@thirteenshortfalse +\DeclareOption{11-12-curtos}{% + \@ordpt@twelveshorttrue + \@ordpt@thirteenshortfalse} +\DeclareOption{11-13-curtos}{% + \@ordpt@twelveshorttrue + \@ordpt@thirteenshorttrue} +\DeclareOption{11-13-longos}{% + \@ordpt@twelveshortfalse + \@ordpt@thirteenshortfalse} +\ExecuteOptions{11-12-curtos} % \end{macrocode} % % \DescribeEnv{tricentesimo} @@ -147,172 +223,174 @@ \ProcessOptions % \end{macrocode} % -% \DescribeEnv{@ordpt@putspace} -% \DescribeEnv{@ordpt@counter} -% \DescribeEnv{@ordpt@alg} -% \DescribeMacro{\@ordpt@case} -% \DescribeMacro{\@ordpt@masc} -% \DescribeMacro{\@ordpt@fem} -% \DescribeMacro{\@ordpt@ul} -% Declaring internals. -% \begin{macrocode} -\newboolean{@ordpt@putspace} -\newcounter{@ordpt@counter} -\newcounter{@ordpt@alg} -\newcommand{\@ordpt@case}{} -\newcommand{\@ordpt@masc}{o} -\newcommand{\@ordpt@fem}{a} -\newcommand{\@ordpt@ul}{o} -% \end{macrocode} -% +% \DescribeMacro{\@ordpt@lowercase} % \DescribeMacro{\@ordpt@capitalize} +% \DescribeMacro{\@ordpt@uppercase} +% Commands that deal with letter case. % \begin{macrocode} -\newcommand{\@ordpt@capitalize}[1]{\MakeUppercase#1} +\newcommand{\@ordpt@lowercase}[2]{#1#2} +\newcommand{\@ordpt@capitalize}[2]{\uppercase{#1}#2} +\newcommand{\@ordpt@uppercase}[2]{\uppercase{#1#2}} % \end{macrocode} % -% \DescribeMacro{\@ordpt@ordunits} -% \DescribeMacro{\@ordpt@ordtens} -% \DescribeMacro{\@ordpt@ordcents} -% These commands take a number between 0 and 9 and return ordinal in -% Portuguese from ``first'' to ``nineth'', ``tenth'' to -% ``ninetieth'' (by 10) and ``one hundredieth'' to ``nine -% hundredieth'' (by 100). Inside the user commands the command -% +\@ordpt@case+ will be redefined to be identity (lowercase), -% +\@ordpt@capitalize+ (capitalized) or +\MakeUppercase+ (uppercase) and -% +\@ordpt@ul+ will be defined as ``o'' (masculine) or ``a'' -% (feminine). +% \DescribeMacro{\@ordpt@printunits} +% \DescribeMacro{\@ordpt@printtens} +% \DescribeMacro{\@ordpt@printhundreds} +% \DescribeMacro{\@ordpt@printthousands} +% These commands take as first and second parameters the command +% that deals with lettercase (commands above) and a letter ``o'' or +% ``a'' for the masculine or feminine genders. The other parameters +% are the digits necessary to print the number: one for numbers less +% than 10, two for numbers between 10 and 99, etc. This commands +% also have to take care of spaces that separate the words. % \begin{macrocode} -\newcommand{\@ordpt@ordunits}[1]{% - \ifcase#1\or - \@ordpt@case{primeir\@ordpt@ul}\or - \@ordpt@case{segund\@ordpt@ul}\or - \@ordpt@case{terceir\@ordpt@ul}\or - \@ordpt@case{quart\@ordpt@ul}\or - \@ordpt@case{quint\@ordpt@ul}\or - \@ordpt@case{sext\@ordpt@ul}\or - \@ordpt@case{s\'etim\@ordpt@ul}\or - \@ordpt@case{oitav\@ordpt@ul}\or - \@ordpt@case{non\@ordpt@ul}% +\newcommand{\@ordpt@printunits}[3]{% + \ifcase#3 \or + #1{p}{rimeir#2}\or + #1{s}{egund#2}\or + #1{t}{erceir#2}\or + #1{q}{uart#2}\or + #1{q}{uint#2}\or + #1{s}{ext#2}\or + #1{s}{\'etim#2}\or + #1{o}{itav#2}\or + #1{n}{on#2}% + \fi} +\newcommand{\@ordpt@printtens}[4]{% + \ifx#31% + \ifx#41% + \if@ordpt@twelveshort + #1{u}{nd\'ecim#2}% + \else + #1{d}{\'ecim#2}\space#1{p}{rimeir#2}% + \fi + \else + \ifx#42% + \if@ordpt@twelveshort + #1{d}{uod\'ecim#2}% + \else + #1{d}{\'ecim#2}\space#1{s}{egund#2}%% + \fi + \else + \ifx#43% + \if@ordpt@thirteenshort + #1{t}{red\'ecim#2}% + \else + #1{d}{\'ecim#2}\space#1{t}{erceir#2}%% + \fi + \else + #1{d}{\'ecim#2}% + \ifx#40% + \else + \space\@ordpt@printunits#1#2#4% + \fi + \fi + \fi + \fi + \else + \ifcase#3 \or\or + #1{v}{ig\'esim#2}\or + #1{t}{rig\'esim#2}\or + #1{q}{uadrag\'esim#2}\or + #1{q}{uinquag\'esim#2}\or + #1{s}{exag\'esim#2}\or + #1{s}{eptuag\'esim#2}\or + #1{o}{ctog\'esim#2}\or + #1{n}{onag\'esim#2}% + \fi + \ifx#40% + \else + \space\@ordpt@printunits#1#2#4% + \fi \fi} -\newcommand{\@ordpt@ordtens}[1]{% - \ifcase#1\or - \@ordpt@case{d\'ecim\@ordpt@ul}\or - \@ordpt@case{vig\'esim\@ordpt@ul}\or - \@ordpt@case{trig\'esim\@ordpt@ul}\or - \@ordpt@case{quadrag\'esim\@ordpt@ul}\or - \@ordpt@case{quinquag\'esim\@ordpt@ul}\or - \@ordpt@case{sexag\'esim\@ordpt@ul}\or - \@ordpt@case{septuag\'esim\@ordpt@ul}\or - \@ordpt@case{octog\'esim\@ordpt@ul}\or - \@ordpt@case{nonag\'esim\@ordpt@ul}% +\newcommand{\@ordpt@printhundreds}[5]{% + \ifcase#3 \or + #1{c}{ent\'esim#2}\or + #1{d}{ucent\'esim#2}\or + #1{t}{r\@ordpt@tricent cent\'esim#2}\or + #1{q}{uadringent\'esim#2}\or + #1{q}{uingent\'esim#2}\or + #1{s}{e\@ordpt@sexcent cent\'esim#2}\or + #1{s}{eptingent\'esim#2}\or + #1{o}{ctingent\'esim#2}\or + #1{n}{on\@ordpt@noningent gent\'esim#2}% + \fi + \ifx#40% + \ifx#50% + \else + \space\@ordpt@printunits#1#2#5% + \fi + \else + \space\@ordpt@printtens#1#2#4#5% \fi} -\newcommand{\@ordpt@ordcents}[1]{% - \ifcase#1\or - \@ordpt@case{cent\'esim\@ordpt@ul}\or - \@ordpt@case{ducent\'esim\@ordpt@ul}\or - \@ordpt@case{tr\@ordpt@tricent cent\'esim\@ordpt@ul}\or - \@ordpt@case{quadringent\'esim\@ordpt@ul}\or - \@ordpt@case{quingent\'esim\@ordpt@ul}\or - \@ordpt@case{se\@ordpt@sexcent cent\'esim\@ordpt@ul}\or - \@ordpt@case{septingent\'esim\@ordpt@ul}\or - \@ordpt@case{octingent\'esim\@ordpt@ul}\or - \@ordpt@case{non\@ordpt@noningent gent\'esim\@ordpt@ul}% +\newcommand{\@ordpt@printthousands}[6]{% + \ifcase#3 \or + #1{m}{il\'esim#2}% + \fi + \ifx#40% + \ifx#50% + \ifx#60% + \else + \space\@ordpt@printunits#1#2#6% + \fi + \else + \space\@ordpt@printtens#1#2#5#6% + \fi + \else + \space\@ordpt@printhundreds#1#2#4#5#6 \fi} % \end{macrocode} % -% \DescribeMacro{\@ordpt@ordinal} -% This command does all the work of mount the words. -% \begin{macrocode} -\newcommand{\@ordpt@ordinal}[1]{% -% \end{macrocode} -% It checks whether the number is between 0 and 1999. -% \begin{macrocode} - \ifthenelse{\value{#1}>0\and\value{#1}<2000} -% \end{macrocode} -% Save original counter to the counter \texttt{@ordpt@counter}. -% \begin{macrocode} - {% - \setcounter{@ordpt@counter}{\value{#1}}% -% \end{macrocode} -% Then, if it is larger than 999, adds ``milesimo(a)'' in front of it. +% \DescribeMacro{\@ordpt@print} +% The command +\@ordpt@print+ is defined with special arguments +% (not possible to be defined with +\newcommand+). The arguments +% are expected as follows:\\ +% + #1+ lettercase command\\ +% + #2+ gender letter o or a\\ +% + #3+ digit\\ +% + #4+ digit or ? (only units)\\ +% + #5+ digit or ? (up to tens)\\ +% + #6+ digit or ? (up to hundreds)\\ +% + #7+ ? (up to thousands) or nothing % \begin{macrocode} - \ifthenelse{\value{@ordpt@counter}>999} - {% - \@ordpt@case{mil\'esim\@ordpt@ul}% -% \end{macrocode} -% Save in the boolean \texttt{@ordpt@putspace} to put a space if -% something else is to be written. -% \begin{macrocode} - \setboolean{@ordpt@putspace}{true}% -% \end{macrocode} -% Subtract 1000 from the counter -% \begin{macrocode} - \addtocounter{@ordpt@counter}{-1000}% - } -% \end{macrocode} -% If counter is less than 1000, set the boolean -% \texttt{@ordpt@putspace} to not put a space if -% something else is to be written. -% \begin{macrocode} - {% - \setboolean{@ordpt@putspace}{false}% - }% -% \end{macrocode} -% Starts to parse the counter. Gets the algarism of cents, reseting -% counter \texttt{@ordpt@alg} and does a loop, steping -% \texttt{@ordpt@alg} and subtracting 100 from -% \texttt{@ordpt@counter} while this counter is larger than 100. -% \begin{macrocode} - \setcounter{@ordpt@alg}{0}% - \whiledo{\value{@ordpt@counter}>99} - {% - \stepcounter{@ordpt@alg}% - \addtocounter{@ordpt@counter}{-100}% - }% -% \end{macrocode} -% If the algarism of the cents is positive, checks if it has to add a -% space, writes with +\@ordpt@ordcents+ and set boolean -% \texttt{@ordpt@putspace} accordingly. -% \begin{macrocode} - \ifthenelse{\value{@ordpt@alg}>0} - {% - \ifthenelse{\boolean{@ordpt@putspace}}{\space}{}% - \@ordpt@ordcents{\value{@ordpt@alg}}% - \setboolean{@ordpt@putspace}{true}% - } - {}% -% \end{macrocode} -% Gets the digits of tens analogously it did before. -% \begin{macrocode} - \setcounter{@ordpt@alg}{0}% - \whiledo{\value{@ordpt@counter}>9} - {% - \stepcounter{@ordpt@alg}% - \addtocounter{@ordpt@counter}{-10}% - }% - \ifthenelse{\value{@ordpt@alg}>0} - {% - \ifthenelse{\boolean{@ordpt@putspace}}{\space}{}% - \@ordpt@ordtens{\value{@ordpt@alg}}% - \setboolean{@ordpt@putspace}{true}% - } - {}% +\newcommand{\@ordpt@print}{} +\def\@ordpt@print#1#2#3#4#5#6#7!{% + \ifx#4?% + \@ordpt@printunits#1#2#3% + \else + \ifx#5?% + \@ordpt@printtens#1#2#3#4% + \else + \ifx#6?% + \@ordpt@printhundreds#1#2#3#4#5% + \else + \@ordpt@printthousands#1#2#3#4#5#6% + \fi + \fi + \fi} % \end{macrocode} -% Now counter \texttt{@ordpt@counter} is left with the units digit. -% Print as before. -% \begin{macrocode} - \ifthenelse{\value{@ordpt@counter}>0} - {% - \ifthenelse{\boolean{@ordpt@putspace}}{\space}{}% - \@ordpt@ordunits{\value{@ordpt@counter}}% - } - {}% - } -% end of the first +\ifthenelse+: sign counter error if argument -% counter is not between 1 and 1999 inclusively. +% +% \DescribeMacro{\@ordpt@ordinal} +% In this command the value of the counter (third argument) is +% expanded, via +\expandafter+, to a list of digits, and four ``?'' +% and a ``!'' are added and expected to be goobled by +% +\@ordpt@print+. We need the ``?'' because of the +\ifx+ on +% detecting how many digits the number has. This command checks if +% the value of the counter is between 1 and 1999 (including both). +% After the expansion of the +\the+, the command +\@ordpt@print+ is +% used. % \begin{macrocode} - {\@ctrerr}% -} +\newcommand{\@ordpt@ordinal}[3]{% + \ifnum\csname c@#3\endcsname<1 + \@ctrerr + \else + \ifnum\csname c@#3\endcsname>1999 + \@ctrerr + \else + \expandafter\@ordpt@print + \expandafter#1\expandafter#2\the\csname c@#3\endcsname????!% + \fi + \fi} % \end{macrocode} % % \DescribeMacro{\ordptmasc} @@ -321,37 +399,19 @@ % \DescribeMacro{\ordptfem} % \DescribeMacro{\Ordptfem} % \DescribeMacro{\ORDPTFEM} -% The end user commands. The diference between them is the +\let+ -% binds of +\@ordpt@case+ to +\@fisrtofone+, +\@ordpt@capitalize+ or -% +\MakeUppercase+, and binds of +\@ordpt@ul+ to +\@ordpt@masc+=``o'' or -% +\@ordpt@fem+=``a''. +% The user commands. The diference between them is that the +% pass to +\@ordpt@ordinal+ the letter case commands as first +% argument and the final gender vowel as second, and the counter +% name as third argument. % \begin{macrocode} -\newcommand{\ordptmasc}[1]{% - \let\@ordpt@case\@firstofone - \let\@ordpt@ul\@ordpt@masc - \@ordpt@ordinal{#1}} -\newcommand{\Ordptmasc}[1]{% - \let\@ordpt@case\@ordpt@capitalize - \let\@ordpt@ul\@ordpt@masc - \@ordpt@ordinal{#1}} -\newcommand{\ORDPTMASC}[1]{% - \let\@ordpt@case\MakeUppercase - \let\@ordpt@ul\@ordpt@masc - \@ordpt@ordinal{#1}} -\newcommand{\ordptfem}[1]{% - \let\@ordpt@case\@firstofone - \let\@ordpt@ul\@ordpt@fem - \@ordpt@ordinal{#1}} -\newcommand{\Ordptfem}[1]{% - \let\@ordpt@case\@ordpt@capitalize - \let\@ordpt@ul\@ordpt@fem - \@ordpt@ordinal{#1}} -\newcommand{\ORDPTFEM}[1]{% - \let\@ordpt@case\MakeUppercase - \let\@ordpt@ul\@ordpt@fem - \@ordpt@ordinal{#1}} +\newcommand{\ordptmasc}[1]{\@ordpt@ordinal\@ordpt@lowercase o{#1}} +\newcommand{\Ordptmasc}[1]{\@ordpt@ordinal\@ordpt@capitalize o{#1}} +\newcommand{\ORDPTMASC}[1]{\@ordpt@ordinal\@ordpt@uppercase o{#1}} +\newcommand{\ordptfem}[1]{\@ordpt@ordinal\@ordpt@lowercase a{#1}} +\newcommand{\Ordptfem}[1]{\@ordpt@ordinal\@ordpt@capitalize a{#1}} +\newcommand{\ORDPTFEM}[1]{\@ordpt@ordinal\@ordpt@uppercase a{#1}} % \end{macrocode} -% \Finale \PrintIndex %\PrintChanges +% \Finale \addcontentsline{toc}{section}{Index}\printindex %\PrintChanges % \endinput % |