From b5d732b5920ac3f1cf3a2d53344c03d540559b4a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 3 Oct 2009 18:49:59 +0000 Subject: interim fmtcount update git-svn-id: svn://tug.org/texlive/trunk@15620 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/latex/fmtcount/fmtcount.dtx | 10056 +++++++++++-------- .../texmf-dist/source/latex/fmtcount/fmtcount.ins | 18 +- .../texmf-dist/source/latex/fmtcount/fmtcount.perl | 2670 +++++ 3 files changed, 8298 insertions(+), 4446 deletions(-) create mode 100644 Master/texmf-dist/source/latex/fmtcount/fmtcount.perl (limited to 'Master/texmf-dist/source') diff --git a/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx b/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx index 2bb59106fea..0fbf2f94beb 100644 --- a/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx +++ b/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx @@ -1,17 +1,19 @@ %\iffalse % fmtcount.dtx generated using makedtx version 0.94b (c) Nicola Talbot % Command line args: +% -macrocode ".*\.tex" % -macrocode "fmtcount.perl" % -setambles "fmtcount.perl=>\nopreamble\nopostamble" % -comment "fmtcount.perl" -% -src "(.+)\.(def)=>\1.\2" % -src "(.+)\.(sty)=>\1.\2" +% -src "(.+)\.(def)=>\1.\2" % -src "(fmtcount\.perl)=>\1" -% -doc "manual.tex" +% -src "(fc-.+\.tex\Z)=>\1" +% -doc "fmtcount-manual.tex" % -author "Nicola Talbot" % -dir "source" % fmtcount -% Created on 2007/8/20 12:28 +% Created on 2009/10/2 18:35 %\fi %\iffalse %<*package> @@ -34,7 +36,7 @@ %\fi % \iffalse % Doc-Source file to use with LaTeX2e -% Copyright (C) 2007 Nicola Talbot, all rights reserved. +% Copyright (C) 2009 Nicola Talbot, all rights reserved. % \fi % \iffalse %<*driver> @@ -66,19 +68,20 @@ \fcolorbox{black}{defbackground}{\usebox\defsbox}% \vskip10pt } -\OnlyDescription \newcommand{\sty}[1]{\textsf{#1}}\newcommand{\cls}[1]{\textsf{#1}} +\CheckSum{9371} +\OnlyDescription + \begin{document} \DocInput{fmtcount.dtx} \end{document} % %\fi %\RecordChanges -%\CheckSum{7745} % -% \title{fmtcount.sty v1.3: Displaying the Values of +% \title{fmtcount.sty v1.31: Displaying the Values of %\LaTeX\ Counters} % \author{Nicola L.C. Talbot\\[10pt] % School of Computing Sciences\\ @@ -86,7 +89,7 @@ % Norwich. NR4 7TJ.\\ % United Kingdom.\\ % \url{http://theoval.cmp.uea.ac.uk/~nlct/}} -% \date{20 Aug 2007} +% \date{2nd October 2009} % \maketitle % \tableofcontents % \section{Introduction} @@ -95,7 +98,8 @@ %provides equivalent commands for actual numbers rather than %counter names. Limited multilingual support is available. %Currently, there is only support for English, French (including -%Belgian and Swiss variations), Spanish, Portuguese and German. +%Belgian and Swiss variations), Spanish, Portuguese, German and +%Italian. % %\section{Installation} % @@ -489,8 +493,8 @@ %The following options can be passed to this package: % %\begin{tabular}{ll} -% raise & make ordinal st,nd,rd,th appear as superscript\\ -% level & make ordinal st,nd,rd,th appear level with rest of +% \texttt{raise} & make ordinal st,nd,rd,th appear as superscript\\ +% \texttt{level} & make ordinal st,nd,rd,th appear level with rest of %text %\end{tabular} % @@ -509,7 +513,9 @@ %limited multilingual support. The following languages are %implemented: English, Spanish, Portuguese, French, French (Swiss) %and French (Belgian). German support was added in version -%1.1\footnote{Thanks to K. H. Fricke for supplying the information}. +%1.1.\footnote{Thanks to K. H. Fricke for supplying the information.} +%Italian support was added in version 1.31.\footnote{Thanks to +%Edoardo Pasca for supplying the information.} % %The package checks to see if the command \cs{l@}\meta{language} is %defined\footnote{this will be true if you have loaded \sty{babel}}, @@ -594,7 +600,8 @@ %I would like to thank my mother for the French and Portuguese %support and my Spanish dictionary for the Spanish support. %Thank you to K. H. Fricke for providing me with the German -%translations. +%translations and to Edoardo Pasca for providing me with the +%Italian translations. % %\section{Troubleshooting} % @@ -607,3791 +614,4125 @@ %\section{The Code} %\iffalse % \begin{macrocode} -%<*fc-british.def> +%<*fmtcount.sty> % \end{macrocode} %\fi -% \subsection{fc-british.def} -% British definitions +%\subsection{fmtcount.sty} +% This section deals with the code for |fmtcount.sty| % \begin{macrocode} -\ProvidesFile{fc-british}[2007/06/14] +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{fmtcount}[2009/10/02 v1.31] +\RequirePackage{ifthen} +\RequirePackage{keyval} % \end{macrocode} -% Check that fc-english.def has been loaded +% \changes{1.3}{2007/7/19}{no +%longer using xspace package} +%\changes{1.31}{2009/10/02}{amsgen now loaded (\cs{new@ifnextchar} +% needed)} +% Need to use \cs{new@ifnextchar} instead of \cs{@ifnextchar} in +% commands that have a final optional argument (such as \cs{gls}) +% so require \sty{amsgen}. % \begin{macrocode} -\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} +\RequirePackage{amsgen} % \end{macrocode} -% These are all just synonyms for the commands provided by -% fc-english.def. +% These commands need to be defined before the +% configuration file is loaded. +% +% Define the macro to format the |st|, |nd|, |rd| or |th| of an +% ordinal. +%\begin{macro}{\fmtord} % \begin{macrocode} -\let\@ordinalMbritish\@ordinalMenglish -\let\@ordinalFbritish\@ordinalMenglish -\let\@ordinalNbritish\@ordinalMenglish -\let\@numberstringMbritish\@numberstringMenglish -\let\@numberstringFbritish\@numberstringMenglish -\let\@numberstringNbritish\@numberstringMenglish -\let\@NumberstringMbritish\@NumberstringMenglish -\let\@NumberstringFbritish\@NumberstringMenglish -\let\@NumberstringNbritish\@NumberstringMenglish -\let\@ordinalstringMbritish\@ordinalstringMenglish -\let\@ordinalstringFbritish\@ordinalstringMenglish -\let\@ordinalstringNbritish\@ordinalstringMenglish -\let\@OrdinalstringMbritish\@OrdinalstringMenglish -\let\@OrdinalstringFbritish\@OrdinalstringMenglish -\let\@OrdinalstringNbritish\@OrdinalstringMenglish +\providecommand*{\fmtord}[1]{\textsuperscript{#1}} % \end{macrocode} -%\iffalse +%\end{macro} +%\begin{macro}{\padzeroes} +%\begin{definition} +%\cs{padzeroes}\oarg{n} +%\end{definition} +% Specifies how many digits should be displayed for commands such as +% \cs{decimal} and \cs{binary}. % \begin{macrocode} -% +\newcount\c@padzeroesN +\c@padzeroesN=1\relax +\providecommand*{\padzeroes}[1][17]{\c@padzeroesN=#1} % \end{macrocode} -%\fi -%\iffalse +%\end{macro} +% Load appropriate language definition files: +%\changes{v1.1}{14 June 2007}{added check for UKenglish, +% british and USenglish babel settings} % \begin{macrocode} -%<*fc-english.def> +\@ifundefined{l@english}{}{\input{fc-english.def}} +\@ifundefined{l@UKenglish}{}{\input{fc-UKenglish.def}} +\@ifundefined{l@british}{}{\input{fc-british.def}} +\@ifundefined{l@USenglish}{}{\input{fc-USenglish.def}} +\@ifundefined{l@spanish}{}{\input{fc-spanish.def}} +\@ifundefined{l@portuges}{}{\input{fc-portuges.def}} +\@ifundefined{l@french}{}{\input{fc-french.def}} +\@ifundefined{l@german}{% +\@ifundefined{l@ngerman}{}{\input{fc-german.def}}}{% +\input{fc-german.def}} +\@ifundefined{l@italian}{}{\input{fc-italian.def}} % \end{macrocode} -%\fi -% \subsection{fc-english.def} -% English definitions +%\begin{macro}{\fmtcount@french} +% Define keys for use with |\fmtcountsetoptions|. +% Key to switch French dialects (Does babel store +%this kind of information?) % \begin{macrocode} -\ProvidesFile{fc-english}[2007/05/26] +\def\fmtcount@french{france} +\define@key{fmtcount}{french}[france]{% +\@ifundefined{datefrench}{% +\PackageError{fmtcount}{Language `french' not defined}{You need +to load babel before loading fmtcount}}{ +\ifthenelse{\equal{#1}{france} + \or\equal{#1}{swiss} + \or\equal{#1}{belgian}}{% + \def\fmtcount@french{#1}}{% +\PackageError{fmtcount}{Invalid value `#1' to french key} +{Option `french' can only take the values `france', +`belgian' or `swiss'}} +}} % \end{macrocode} -% Define macro that converts a number or count register (first -% argument) to an ordinal, and stores the result in the -% second argument, which should be a control sequence. +%\end{macro} +% Key to determine how to display the ordinal % \begin{macrocode} -\newcommand*{\@ordinalMenglish}[2]{% -\def\@fc@ord{}% -\@orgargctr=#1\relax -\@ordinalctr=#1% -\@modulo{\@ordinalctr}{100}% -\ifnum\@ordinalctr=11\relax - \def\@fc@ord{th}% -\else - \ifnum\@ordinalctr=12\relax - \def\@fc@ord{th}% - \else - \ifnum\@ordinalctr=13\relax - \def\@fc@ord{th}% - \else - \@modulo{\@ordinalctr}{10}% - \ifcase\@ordinalctr - \def\@fc@ord{th}% case 0 - \or \def\@fc@ord{st}% case 1 - \or \def\@fc@ord{nd}% case 2 - \or \def\@fc@ord{rd}% case 3 - \else - \def\@fc@ord{th}% default case - \fi - \fi - \fi -\fi -\edef#2{\number#1\relax\noexpand\fmtord{\@fc@ord}}% -} +\define@key{fmtcount}{fmtord}{% +\ifthenelse{\equal{#1}{level} + \or\equal{#1}{raise} + \or\equal{#1}{user}}{ + \def\fmtcount@fmtord{#1}}{% +\PackageError{fmtcount}{Invalid value `#1' to fmtord key} +{Option `fmtord' can only take the values `level', `raise' +or `user'}}} % \end{macrocode} -% There is no gender difference in English, so make feminine and -% neuter the same as the masculine. +%\begin{macro}{\iffmtord@abbrv} +% Key to determine whether the ordinal should be abbreviated +% (language dependent, currently only affects French ordinals.) % \begin{macrocode} -\let\@ordinalFenglish=\@ordinalMenglish -\let\@ordinalNenglish=\@ordinalMenglish +\newif\iffmtord@abbrv +\fmtord@abbrvfalse +\define@key{fmtcount}{abbrv}[true]{% +\ifthenelse{\equal{#1}{true}\or\equal{#1}{false}}{ + \csname fmtord@abbrv#1\endcsname}{% +\PackageError{fmtcount}{Invalid value `#1' to fmtord key} +{Option `fmtord' can only take the values `true' or +`false'}}} % \end{macrocode} -% Define the macro that prints the value of a \TeX\ count register -% as text. To make it easier, break it up into units, teens and -% tens. First, the units: the argument should be between 0 and 9 -% inclusive. +%\end{macro} +%\begin{macro}{\fmtcountsetoptions} +% Define command to set options. % \begin{macrocode} -\newcommand*{\@@unitstringenglish}[1]{% -\ifcase#1\relax -zero% -\or one% -\or two% -\or three% -\or four% -\or five% -\or six% -\or seven% -\or eight% -\or nine% -\fi +\newcommand*{\fmtcountsetoptions}[1]{% +\def\fmtcount@fmtord{}% +\setkeys{fmtcount}{#1}% +\@ifundefined{datefrench}{}{% +\edef\@ordinalstringMfrench{\noexpand +\csname @ordinalstringMfrench\fmtcount@french\noexpand\endcsname}% +\edef\@ordinalstringFfrench{\noexpand +\csname @ordinalstringFfrench\fmtcount@french\noexpand\endcsname}% +\edef\@OrdinalstringMfrench{\noexpand +\csname @OrdinalstringMfrench\fmtcount@french\noexpand\endcsname}% +\edef\@OrdinalstringFfrench{\noexpand +\csname @OrdinalstringFfrench\fmtcount@french\noexpand\endcsname}% +\edef\@numberstringMfrench{\noexpand +\csname @numberstringMfrench\fmtcount@french\noexpand\endcsname}% +\edef\@numberstringFfrench{\noexpand +\csname @numberstringFfrench\fmtcount@french\noexpand\endcsname}% +\edef\@NumberstringMfrench{\noexpand +\csname @NumberstringMfrench\fmtcount@french\noexpand\endcsname}% +\edef\@NumberstringFfrench{\noexpand +\csname @NumberstringFfrench\fmtcount@french\noexpand\endcsname}% +}% +% +\ifthenelse{\equal{\fmtcount@fmtord}{level}}{% +\renewcommand{\fmtord}[1]{##1}}{% +\ifthenelse{\equal{\fmtcount@fmtord}{raise}}{% +\renewcommand{\fmtord}[1]{\textsuperscript{##1}}}{% +}} } % \end{macrocode} -% Next the tens, again the argument should be between 0 and 9 -% inclusive. +%\end{macro} +% Load confguration file if it exists. This needs to be done +% before the package options, to allow the user to override +% the settings in the configuration file. % \begin{macrocode} -\newcommand*{\@@tenstringenglish}[1]{% -\ifcase#1\relax -\or ten% -\or twenty% -\or thirty% -\or forty% -\or fifty% -\or sixty% -\or seventy% -\or eighty% -\or ninety% -\fi -} +\InputIfFileExists{fmtcount.cfg}{% +\typeout{Using configuration file fmtcount.cfg}}{% +\typeout{No configuration file fmtcount.cfg found.}} % \end{macrocode} -% Finally the teens, again the argument should be between 0 and 9 -% inclusive. +%Declare options % \begin{macrocode} -\newcommand*{\@@teenstringenglish}[1]{% -\ifcase#1\relax -ten% -\or eleven% -\or twelve% -\or thirteen% -\or fourteen% -\or fifteen% -\or sixteen% -\or seventeen% -\or eighteen% -\or nineteen% -\fi -} +\DeclareOption{level}{\def\fmtcount@fmtord{level}% +\def\fmtord#1{#1}} +\DeclareOption{raise}{\def\fmtcount@fmtord{raise}% +\def\fmtord#1{\textsuperscript{#1}}} % \end{macrocode} -% As above, but with the initial letter in uppercase. The units: +% Process package options % \begin{macrocode} -\newcommand*{\@@Unitstringenglish}[1]{% -\ifcase#1\relax -Zero% -\or One% -\or Two% -\or Three% -\or Four% -\or Five% -\or Six% -\or Seven% -\or Eight% -\or Nine% -\fi -} +\ProcessOptions % \end{macrocode} -% The tens: -% \begin{macrocode} -\newcommand*{\@@Tenstringenglish}[1]{% -\ifcase#1\relax -\or Ten% -\or Twenty% -\or Thirty% -\or Forty% -\or Fifty% -\or Sixty% -\or Seventy% -\or Eighty% -\or Ninety% -\fi -} -% \end{macrocode} -% The teens: +%\begin{macro}{\@modulo} +%\begin{definition} +%\cs{@modulo}\marg{count reg}\marg{n} +%\end{definition} +% Sets the count register to be its value modulo \meta{n}. +% This is used for the +% date, time, ordinal and numberstring commands. (The fmtcount +% package was originally part of the datetime package.) % \begin{macrocode} -\newcommand*{\@@Teenstringenglish}[1]{% -\ifcase#1\relax -Ten% -\or Eleven% -\or Twelve% -\or Thirteen% -\or Fourteen% -\or Fifteen% -\or Sixteen% -\or Seventeen% -\or Eighteen% -\or Nineteen% -\fi -} +\newcount\@DT@modctr +\def\@modulo#1#2{% +\@DT@modctr=#1\relax +\divide \@DT@modctr by #2\relax +\multiply \@DT@modctr by #2\relax +\advance #1 by -\@DT@modctr} % \end{macrocode} -% This has changed in version 1.09, so that it now stores -% the result in the second argument, but doesn't display anything. -% Since it only affects internal macros, it shouldn't affect -% documents created with older versions. (These internal macros are -% not meant for use in documents.) +%\end{macro} +% The following registers are needed by |\@ordinal| etc % \begin{macrocode} -\newcommand*{\@@numberstringenglish}[2]{% -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000}% -\else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% -\fi -\fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>9 -% #1 is greater or equal to 10000 - \divide\@strctr by 10 - \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1 \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr-\@unitstring{\@strctr}}% - \fi - \else - \@strctr=#1\relax - \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@thousand}% -\else - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ \@thousand}% - \fi -\fi -\@strctr=#1\relax \@modulo{\@strctr}{1000}% -\divide\@strctr by 100 -\ifnum\@strctr>0\relax - \ifnum#1>1000\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ }% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ \@hundred}% -\fi -\@strctr=#1\relax \@modulo{\@strctr}{100}% -\ifnum#1>100\relax - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@andname\ }% - \fi -\fi -\ifnum\@strctr>19\relax - \divide\@strctr by 10\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1\relax \@modulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr-\@unitstring{\@strctr}}% - \fi -\else - \ifnum\@strctr<10\relax - \ifnum\@strctr=0\relax - \ifnum#1<100\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% - \fi - \else - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% - \fi - \else - \@modulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% - \fi -\fi -} +\newcount\@ordinalctr +\newcount\@orgargctr +\newcount\@strctr +\newcount\@tmpstrctr % \end{macrocode} -% All lower case version, the second argument must be a -% control sequence. +%Define commands that display numbers in different bases. +% Define counters and conditionals needed. % \begin{macrocode} -\DeclareRobustCommand{\@numberstringMenglish}[2]{% -\let\@unitstring=\@@unitstringenglish -\let\@teenstring=\@@teenstringenglish -\let\@tenstring=\@@tenstringenglish -\def\@hundred{hundred}\def\@thousand{thousand}% -\def\@andname{and}% -\@@numberstringenglish{#1}{#2}% -} +\newif\if@DT@padzeroes +\newcount\@DT@loopN +\newcount\@DT@X % \end{macrocode} -% There is no gender in English, so make feminine and neuter the same -% as the masculine. +%\begin{macro}{\binarynum} +% Converts a decimal number to binary, and display. % \begin{macrocode} -\let\@numberstringFenglish=\@numberstringMenglish -\let\@numberstringNenglish=\@numberstringMenglish +\newcommand*{\@binary}[1]{% +\@DT@padzeroestrue +\@DT@loopN=17\relax +\@strctr=\@DT@loopN +\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% +\@strctr=65536\relax +\@DT@X=#1\relax +\loop +\@DT@modctr=\@DT@X +\divide\@DT@modctr by \@strctr +\ifthenelse{\boolean{@DT@padzeroes} \and \(\@DT@modctr=0\) \and \(\@DT@loopN>\c@padzeroesN\)}{}{\the\@DT@modctr}% +\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi +\multiply\@DT@modctr by \@strctr +\advance\@DT@X by -\@DT@modctr +\divide\@strctr by 2\relax +\advance\@DT@loopN by -1\relax +\ifnum\@strctr>1 +\repeat +\the\@DT@X} + +\let\binarynum=\@binary % \end{macrocode} -% This version makes the first letter of each word an uppercase -% character (except ``and''). The second argument must be a control -% sequence. +%\end{macro} +%\begin{macro}{\octalnum} +% Converts a decimal number to octal, and displays. % \begin{macrocode} -\newcommand*{\@NumberstringMenglish}[2]{% -\let\@unitstring=\@@Unitstringenglish -\let\@teenstring=\@@Teenstringenglish -\let\@tenstring=\@@Tenstringenglish -\def\@hundred{Hundred}\def\@thousand{Thousand}% -\def\@andname{and}% -\@@numberstringenglish{#1}{#2}} +\newcommand*{\@octal}[1]{% +\ifnum#1>32768 +\PackageError{fmtcount}{Value of counter too large for \protect\@octal}{Maximum value 32768} +\else +\@DT@padzeroestrue +\@DT@loopN=6\relax +\@strctr=\@DT@loopN +\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% +\@strctr=32768\relax +\@DT@X=#1\relax +\loop +\@DT@modctr=\@DT@X +\divide\@DT@modctr by \@strctr +\ifthenelse{\boolean{@DT@padzeroes} \and \(\@DT@modctr=0\) \and \(\@DT@loopN>\c@padzeroesN\)}{}{\the\@DT@modctr}% +\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi +\multiply\@DT@modctr by \@strctr +\advance\@DT@X by -\@DT@modctr +\divide\@strctr by 8\relax +\advance\@DT@loopN by -1\relax +\ifnum\@strctr>1 +\repeat +\the\@DT@X +\fi} +\let\octalnum=\@octal % \end{macrocode} -% There is no gender in English, so make feminine and neuter the same -% as the masculine. +%\end{macro} +%\begin{macro}{\hexadecimalnum} +% Converts a decimal number to a lowercase hexadecimal number, +% and displays it. % \begin{macrocode} -\let\@NumberstringFenglish=\@NumberstringMenglish -\let\@NumberstringNenglish=\@NumberstringMenglish +\newcommand*{\@@hexadecimal}[1]{\ifcase#10\or1\or2\or3\or4\or5\or +6\or7\or8\or9\or a\or b\or c\or d\or e\or f\fi} + +\newcommand*{\@hexadecimal}[1]{% +\@DT@padzeroestrue +\@DT@loopN=5\relax +\@strctr=\@DT@loopN +\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% +\@strctr=65536\relax +\@DT@X=#1\relax +\loop +\@DT@modctr=\@DT@X +\divide\@DT@modctr by \@strctr +\ifthenelse{\boolean{@DT@padzeroes}\and\(\@DT@modctr=0\)\and +\(\@DT@loopN>\c@padzeroesN\)}{}{\@@hexadecimal\@DT@modctr}% +\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi +\multiply\@DT@modctr by \@strctr +\advance\@DT@X by -\@DT@modctr +\divide\@strctr by 16\relax +\advance\@DT@loopN by -1\relax +\ifnum\@strctr>1 +\repeat +\@@hexadecimal\@DT@X} + +\let\hexadecimalnum=\@hexadecimal % \end{macrocode} -% Define a macro that produces an ordinal as a string. Again, break -% it up into units, teens and tens. First the units: +%\end{macro} +%\begin{macro}{\Hexadecimalnum} +% Uppercase hexadecimal % \begin{macrocode} -\newcommand*{\@@unitthstringenglish}[1]{% -\ifcase#1\relax -zeroth% -\or first% -\or second% -\or third% -\or fourth% -\or fifth% -\or sixth% -\or seventh% -\or eighth% -\or ninth% -\fi -} +\newcommand*{\@@Hexadecimal}[1]{\ifcase#10\or1\or2\or3\or4\or5\or6\or +7\or8\or9\or A\or B\or C\or D\or E\or F\fi} + +\newcommand*{\@Hexadecimal}[1]{% +\@DT@padzeroestrue +\@DT@loopN=5\relax +\@strctr=\@DT@loopN +\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% +\@strctr=65536\relax +\@DT@X=#1\relax +\loop +\@DT@modctr=\@DT@X +\divide\@DT@modctr by \@strctr +\ifthenelse{\boolean{@DT@padzeroes} \and \(\@DT@modctr=0\) \and \(\@DT@loopN>\c@padzeroesN\)}{}{\@@Hexadecimal\@DT@modctr}% +\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi +\multiply\@DT@modctr by \@strctr +\advance\@DT@X by -\@DT@modctr +\divide\@strctr by 16\relax +\advance\@DT@loopN by -1\relax +\ifnum\@strctr>1 +\repeat +\@@Hexadecimal\@DT@X} + +\let\Hexadecimalnum=\@Hexadecimal % \end{macrocode} -% Next the tens: +%\end{macro} +%\begin{macro}{\aaalphnum} +% Lowercase alphabetical representation (a \ldots\ z aa \ldots\ zz) % \begin{macrocode} -\newcommand*{\@@tenthstringenglish}[1]{% -\ifcase#1\relax -\or tenth% -\or twentieth% -\or thirtieth% -\or fortieth% -\or fiftieth% -\or sixtieth% -\or seventieth% -\or eightieth% -\or ninetieth% -\fi -} -% \end{macrocode} -% The teens: -% \begin{macrocode} -\newcommand*{\@@teenthstringenglish}[1]{% -\ifcase#1\relax -tenth% -\or eleventh% -\or twelfth% -\or thirteenth% -\or fourteenth% -\or fifteenth% -\or sixteenth% -\or seventeenth% -\or eighteenth% -\or nineteenth% -\fi -} -% \end{macrocode} -% As before, but with the first letter in upper case. The units: -% \begin{macrocode} -\newcommand*{\@@Unitthstringenglish}[1]{% -\ifcase#1\relax -Zeroth% -\or First% -\or Second% -\or Third% -\or Fourth% -\or Fifth% -\or Sixth% -\or Seventh% -\or Eighth% -\or Ninth% -\fi +\newcommand*{\@aaalph}[1]{% +\@DT@loopN=#1\relax +\advance\@DT@loopN by -1\relax +\divide\@DT@loopN by 26\relax +\@DT@modctr=\@DT@loopN +\multiply\@DT@modctr by 26\relax +\@DT@X=#1\relax +\advance\@DT@X by -1\relax +\advance\@DT@X by -\@DT@modctr +\advance\@DT@loopN by 1\relax +\advance\@DT@X by 1\relax +\loop +\@alph\@DT@X +\advance\@DT@loopN by -1\relax +\ifnum\@DT@loopN>0 +\repeat } + +\let\aaalphnum=\@aaalph % \end{macrocode} -% The tens: +%\end{macro} +%\begin{macro}{\AAAlphnum} +% Uppercase alphabetical representation (a \ldots\ z aa \ldots\ zz) % \begin{macrocode} -\newcommand*{\@@Tenthstringenglish}[1]{% -\ifcase#1\relax -\or Tenth% -\or Twentieth% -\or Thirtieth% -\or Fortieth% -\or Fiftieth% -\or Sixtieth% -\or Seventieth% -\or Eightieth% -\or Ninetieth% -\fi +\newcommand*{\@AAAlph}[1]{% +\@DT@loopN=#1\relax +\advance\@DT@loopN by -1\relax +\divide\@DT@loopN by 26\relax +\@DT@modctr=\@DT@loopN +\multiply\@DT@modctr by 26\relax +\@DT@X=#1\relax +\advance\@DT@X by -1\relax +\advance\@DT@X by -\@DT@modctr +\advance\@DT@loopN by 1\relax +\advance\@DT@X by 1\relax +\loop +\@Alph\@DT@X +\advance\@DT@loopN by -1\relax +\ifnum\@DT@loopN>0 +\repeat } + +\let\AAAlphnum=\@AAAlph % \end{macrocode} -% The teens: +%\end{macro} +%\begin{macro}{\abalphnum} +% Lowercase alphabetical representation % \begin{macrocode} -\newcommand*{\@@Teenthstringenglish}[1]{% -\ifcase#1\relax -Tenth% -\or Eleventh% -\or Twelfth% -\or Thirteenth% -\or Fourteenth% -\or Fifteenth% -\or Sixteenth% -\or Seventeenth% -\or Eighteenth% -\or Nineteenth% -\fi -} +\newcommand*{\@abalph}[1]{% +\ifnum#1>17576\relax +\PackageError{fmtcount}{Value of counter too large for +\protect\@abalph}{Maximum value 17576}% +\else +\@DT@padzeroestrue +\@strctr=17576\relax +\@DT@X=#1\relax +\advance\@DT@X by -1\relax +\loop +\@DT@modctr=\@DT@X +\divide\@DT@modctr by \@strctr +\ifthenelse{\boolean{@DT@padzeroes}\and +\(\@DT@modctr=1\)}{}{\@alph\@DT@modctr}% +\ifnum\@DT@modctr=1\else\@DT@padzeroesfalse\fi +\multiply\@DT@modctr by \@strctr +\advance\@DT@X by -\@DT@modctr +\divide\@strctr by 26\relax +\ifnum\@strctr>1 +\repeat +\advance\@DT@X by 1\relax +\@alph\@DT@X +\fi} + +\let\abalphnum=\@abalph % \end{macrocode} -% Again, as from version 1.09, this has been changed to take two -% arguments, where the second argument is a control sequence. -% The resulting text is stored in the control sequence, and nothing -% is displayed. +%\end{macro} +%\begin{macro}{\ABAlphnum} +% Uppercase alphabetical representation % \begin{macrocode} -\newcommand*{\@@ordinalstringenglish}[2]{% -\@strctr=#1\relax -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000 (value given: \number\@strctr)}% +\newcommand*{\@ABAlph}[1]{% +\ifnum#1>17576\relax +\PackageError{fmtcount}{Value of counter too large for +\protect\@ABAlph}{Maximum value 17576}% \else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% -\fi -\def#2{}% -\fi -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>9\relax -% #1 is greater or equal to 10000 - \divide\@strctr by 10 - \ifnum\@strctr>1\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% - \@strctr=#1\relax - \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr-\@unitstring{\@strctr}}% - \fi - \else - \@strctr=#1\relax \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenstring{\@strctr}}% - \fi - \@strctr=#1\relax \@modulo{\@strctr}{1000}% - \ifnum\@strctr=0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@thousandth}% - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@thousand}% - \fi -\else - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \@strctr=#1\relax \@modulo{\@strctr}{1000}% - \let\@@fc@ordstr#2\relax - \ifnum\@strctr=0\relax - \edef#2{\@@fc@ordstr\ \@thousandth}% - \else - \edef#2{\@@fc@ordstr\ \@thousand}% - \fi - \fi -\fi -\@strctr=#1\relax \@modulo{\@strctr}{1000}% -\divide\@strctr by 100 -\ifnum\@strctr>0\relax - \ifnum#1>1000\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ }% - \fi - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \@strctr=#1\relax \@modulo{\@strctr}{100}% - \let\@@fc@ordstr#2\relax - \ifnum\@strctr=0\relax - \edef#2{\@@fc@ordstr\ \@hundredth}% - \else - \edef#2{\@@fc@ordstr\ \@hundred}% - \fi -\fi -\@strctr=#1\relax \@modulo{\@strctr}{100}% -\ifnum#1>100\relax - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@andname\ }% - \fi -\fi -\ifnum\@strctr>19\relax - \@tmpstrctr=\@strctr - \divide\@strctr by 10\relax - \@modulo{\@tmpstrctr}{10}% - \let\@@fc@ordstr#2\relax - \ifnum\@tmpstrctr=0\relax - \edef#2{\@@fc@ordstr\@tenthstring{\@strctr}}% - \else - \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% - \fi - \@strctr=#1\relax \@modulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr-\@unitthstring{\@strctr}}% - \fi -\else - \ifnum\@strctr<10\relax - \ifnum\@strctr=0\relax - \ifnum#1<100\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% - \fi - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% - \fi - \else - \@modulo{\@strctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% - \fi +\@DT@padzeroestrue +\@strctr=17576\relax +\@DT@X=#1\relax +\advance\@DT@X by -1\relax +\loop +\@DT@modctr=\@DT@X +\divide\@DT@modctr by \@strctr +\ifthenelse{\boolean{@DT@padzeroes}\and +\(\@DT@modctr=1\)}{}{\@Alph\@DT@modctr}% +\ifnum\@DT@modctr=1\else\@DT@padzeroesfalse\fi +\multiply\@DT@modctr by \@strctr +\advance\@DT@X by -\@DT@modctr +\divide\@strctr by 26\relax +\ifnum\@strctr>1 +\repeat +\advance\@DT@X by 1\relax +\@Alph\@DT@X +\fi} + +\let\ABAlphnum=\@ABAlph +% \end{macrocode} +%\end{macro} +%\begin{macro}{\@fmtc@count} +% Recursive command to count number of characters in argument. +% |\@strctr| should be set to zero before calling it. +% \begin{macrocode} +\def\@fmtc@count#1#2\relax{% +\if\relax#1 +\else +\advance\@strctr by 1\relax +\@fmtc@count#2\relax +\fi} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\@decimal} +%\changes{1.31}{2009/10/02}{fixed unwanted space.} +% Format number as a decimal, possibly padded with zeroes in front. +% \begin{macrocode} +\newcommand{\@decimal}[1]{% +\@strctr=0\relax +\expandafter\@fmtc@count\number#1\relax +\@DT@loopN=\c@padzeroesN +\advance\@DT@loopN by -\@strctr +\ifnum\@DT@loopN>0\relax +\@strctr=0\relax +\whiledo{\@strctr < \@DT@loopN}{0\advance\@strctr by 1\relax}% \fi +\number#1\relax } + +\let\decimalnum=\@decimal % \end{macrocode} -% All lower case version. Again, the second argument must be a -% control sequence in which the resulting text is stored. +%\end{macro} +%\begin{macro}{\FCordinal} +%\begin{definition} +%\cs{FCordinal}\marg{number} +%\end{definition} +% This is a bit cumbersome. Previously \cs{@ordinal} +% was defined in a similar way to \cs{abalph} etc. +% This ensured that the actual value of the counter was +% written in the new label stuff in the .aux file. However +% adding in an optional argument to determine the gender +% for multilingual compatibility messed things up somewhat. +% This was the only work around I could get to keep the +% the cross-referencing stuff working, which is why +% the optional argument comes \emph{after} the compulsory +% argument, instead of the usual manner of placing it before. +% Note however, that putting the optional argument means that +% any spaces will be ignored after the command if the optional +% argument is omitted. +% Version 1.04 changed \cs{ordinal} to \cs{FCordinal} +% to prevent it clashing with the memoir class. % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringMenglish}[2]{% -\let\@unitthstring=\@@unitthstringenglish -\let\@teenthstring=\@@teenthstringenglish -\let\@tenthstring=\@@tenthstringenglish -\let\@unitstring=\@@unitstringenglish -\let\@teenstring=\@@teenstringenglish -\let\@tenstring=\@@tenstringenglish -\def\@andname{and}% -\def\@hundred{hundred}\def\@thousand{thousand}% -\def\@hundredth{hundredth}\def\@thousandth{thousandth}% -\@@ordinalstringenglish{#1}{#2}} +\newcommand{\FCordinal}[1]{% +\expandafter\protect\expandafter\ordinalnum{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% No gender in English, so make feminine and neuter same as masculine: +%\end{macro} +%\begin{macro}{\ordinal} +% If \cs{ordinal} isn't defined make \cs{ordinal} a synonym +% for \cs{FCordinal} to maintain compatibility with previous +% versions. % \begin{macrocode} -\let\@ordinalstringFenglish=\@ordinalstringMenglish -\let\@ordinalstringNenglish=\@ordinalstringMenglish +\@ifundefined{ordinal}{\let\ordinal\FCordinal}{% +\PackageWarning{fmtcount}{\string\ordinal +\space already defined use \string\FCordinal \space instead.}} % \end{macrocode} -% First letter of each word in upper case: +%\end{macro} +%\begin{macro}{\ordinalnum} +% Display ordinal where value is given as a number or +% count register instead of a counter: +%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with +%\cs{new@ifnextchar}} % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMenglish}[2]{% -\let\@unitthstring=\@@Unitthstringenglish -\let\@teenthstring=\@@Teenthstringenglish -\let\@tenthstring=\@@Tenthstringenglish -\let\@unitstring=\@@Unitstringenglish -\let\@teenstring=\@@Teenstringenglish -\let\@tenstring=\@@Tenstringenglish -\def\@andname{and}% -\def\@hundred{Hundred}\def\@thousand{Thousand}% -\def\@hundredth{Hundredth}\def\@thousandth{Thousandth}% -\@@ordinalstringenglish{#1}{#2}} +\newcommand*{\ordinalnum}[1]{\new@ifnextchar[{\@ordinalnum{#1}}{% +\@ordinalnum{#1}[m]}} % \end{macrocode} -% No gender in English, so make feminine and neuter same as masculine: +%\end{macro} +%\begin{macro}{\@ordinalnum} +% Display ordinal according to gender (neuter added in v1.1, +% \cs{xspace} added in v1.2, and removed in v1.3\footnote{I +%couldn't get it to work consistently both with and without the +%optional argument}): % \begin{macrocode} -\let\@OrdinalstringFenglish=\@OrdinalstringMenglish -\let\@OrdinalstringNenglish=\@OrdinalstringMenglish +\def\@ordinalnum#1[#2]{{% +\ifthenelse{\equal{#2}{f}}{% + \protect\@ordinalF{#1}{\@fc@ordstr}% + }{% + \ifthenelse{\equal{#2}{n}}{% + \protect\@ordinalN{#1}{\@fc@ordstr}% + }{% + \ifthenelse{\equal{#2}{m}}{}{% + \PackageError{fmtcount}{Invalid gender option `#2'}{% + Available options are m, f or n}% + }% + \protect\@ordinalM{#1}{\@fc@ordstr}% + }% + }% +\@fc@ordstr +}} % \end{macrocode} -%\iffalse +%\end{macro} +%\begin{macro}{\storeordinal} +% Store the ordinal (first argument +% is identifying name, second argument is a counter.) % \begin{macrocode} -% +\newcommand*{\storeordinal}[2]{% +\expandafter\protect\expandafter\storeordinalnum{#1}{% +\expandafter\the\csname c@#2\endcsname}} % \end{macrocode} -%\fi -%\iffalse +%\end{macro} +%\begin{macro}{\storeordinalnum} +% Store ordinal (first argument +% is identifying name, second argument is a number or +% count register.) % \begin{macrocode} -%<*fc-french.def> +\newcommand*{\storeordinalnum}[2]{% +\@ifnextchar[{\@storeordinalnum{#1}{#2}}{% +\@storeordinalnum{#1}{#2}[m]}} % \end{macrocode} -%\fi -% \subsection{fc-french.def} -% French definitions +%\end{macro} +%\begin{macro}{\@storeordinalnum} +% Store ordinal according to gender: % \begin{macrocode} -\ProvidesFile{fc-french.def}[2007/05/26] +\def\@storeordinalnum#1#2[#3]{% +\ifthenelse{\equal{#3}{f}}{% +\protect\@ordinalF{#2}{\@fc@ord}}{% +\ifthenelse{\equal{#3}{n}}{% +\protect\@ordinalN{#2}{\@fc@ord}}{% +\ifthenelse{\equal{#3}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#3'}{% +Available options are m or f}}% +\protect\@ordinalM{#2}{\@fc@ord}}}% +\expandafter\let\csname @fcs@#1\endcsname\@fc@ord} % \end{macrocode} -% Define macro that converts a number or count register (first -% argument) to an ordinal, and store the result in the second -% argument, which must be a control sequence. Masculine: +%\end{macro} +%\begin{macro}{\FMCuse} +% Get stored information: % \begin{macrocode} -\newcommand*{\@ordinalMfrench}[2]{% -\iffmtord@abbrv - \edef#2{\number#1\relax\noexpand\fmtord{e}}% -\else - \ifnum#1=1\relax - \edef#2{\number#1\relax\noexpand\fmtord{er}}% - \else - \edef#2{\number#1\relax\noexpand\fmtord{eme}}% - \fi -\fi} +\newcommand*{\FMCuse}[1]{\csname @fcs@#1\endcsname} % \end{macrocode} -% Feminine: +%\end{macro} +%\begin{macro}{\ordinalstring} +% Display ordinal as a string (argument is a counter) % \begin{macrocode} -\newcommand*{\@ordinalFfrench}[2]{% -\iffmtord@abbrv - \edef#2{\number#1\relax\noexpand\fmtord{e}}% -\else - \ifnum#1=1\relax - \edef#2{\number#1\relax\noexpand\fmtord{ere}}% - \else - \edef#2{\number#1\relax\noexpand\fmtord{eme}}% - \fi -\fi} +\newcommand*{\ordinalstring}[1]{% +\expandafter\protect\expandafter\ordinalstringnum{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Make neuter same as masculine: +%\end{macro} +%\begin{macro}{\ordinalstringnum} +% Display ordinal as a string (argument is a count register or +% number.) +%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with +%\cs{new@ifnextchar}} % \begin{macrocode} -\let\@ordinalNfrench\@ordinalMfrench -% \end{macrocode} -% Textual representation of a number. To make it easier break it -% into units, tens and teens. First the units: -% \begin{macrocode} -\newcommand*{\@@unitstringfrench}[1]{% -\ifcase#1\relax -zero% -\or un% -\or deux% -\or trois% -\or quatre% -\or cinq% -\or six% -\or sept% -\or huit% -\or neuf% -\fi -} +\newcommand{\ordinalstringnum}[1]{% +\new@ifnextchar[{\@ordinal@string{#1}}{\@ordinal@string{#1}[m]}} % \end{macrocode} -% Feminine only changes for 1: +%\end{macro} +%\begin{macro}{\@ordinal@string} +% Display ordinal as a string according to gender. % \begin{macrocode} -\newcommand*{\@@unitstringFfrench}[1]{% -\ifnum#1=1\relax -une% -\else\@@unitstringfrench{#1}% -\fi -} +\def\@ordinal@string#1[#2]{{% +\ifthenelse{\equal{#2}{f}}{% +\protect\@ordinalstringF{#1}{\@fc@ordstr}}{% +\ifthenelse{\equal{#2}{n}}{% +\protect\@ordinalstringN{#1}{\@fc@ordstr}}{% +\ifthenelse{\equal{#2}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#2' to +\string\ordinalstring}{Available options are m, f or f}}% +\protect\@ordinalstringM{#1}{\@fc@ordstr}}}\@fc@ordstr}} % \end{macrocode} -% Tens (this includes the Belgian and Swiss variants, special -% cases employed lower down.) +%\end{macro} +%\begin{macro}{\storeordinalstring} +% Store textual representation of number. First argument is +% identifying name, second argument is the counter set to the +% required number. % \begin{macrocode} -\newcommand*{\@@tenstringfrench}[1]{% -\ifcase#1\relax -\or dix% -\or vingt% -\or trente% -\or quarante% -\or cinquante% -\or soixante% -\or septente% -\or huitante% -\or nonente% -\or cent% -\fi -} +\newcommand*{\storeordinalstring}[2]{% +\expandafter\protect\expandafter\storeordinalstringnum{#1}{% +\expandafter\the\csname c@#2\endcsname}} % \end{macrocode} -% Teens: +%\end{macro} +%\begin{macro}{\storeordinalstringnum} +% Store textual representation of number. First argument is +% identifying name, second argument is a count register or number. % \begin{macrocode} -\newcommand*{\@@teenstringfrench}[1]{% -\ifcase#1\relax -dix% -\or onze% -\or douze% -\or treize% -\or quatorze% -\or quinze% -\or seize% -\or dix-sept% -\or dix-huit% -\or dix-neuf% -\fi -} +\newcommand*{\storeordinalstringnum}[2]{% +\@ifnextchar[{\@store@ordinal@string{#1}{#2}}{% +\@store@ordinal@string{#1}{#2}[m]}} % \end{macrocode} -% Seventies are a special case, depending on dialect: +%\end{macro} +%\begin{macro}{\@store@ordinal@string} +% Store textual representation of number according to gender. % \begin{macrocode} -\newcommand*{\@@seventiesfrench}[1]{% -\@tenstring{6}% -\ifnum#1=1\relax -\ \@andname\ -\else --% -\fi -\@teenstring{#1}% -} +\def\@store@ordinal@string#1#2[#3]{% +\ifthenelse{\equal{#3}{f}}{% +\protect\@ordinalstringF{#2}{\@fc@ordstr}}{% +\ifthenelse{\equal{#3}{n}}{% +\protect\@ordinalstringN{#2}{\@fc@ordstr}}{% +\ifthenelse{\equal{#3}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#3' to +\string\ordinalstring}{Available options are m, f or n}}% +\protect\@ordinalstringM{#2}{\@fc@ordstr}}}% +\expandafter\let\csname @fcs@#1\endcsname\@fc@ordstr} % \end{macrocode} -% Eighties are a special case, depending on dialect: +%\end{macro} +%\begin{macro}{\Ordinalstring} +% Display ordinal as a string with initial letters in upper case +% (argument is a counter) % \begin{macrocode} -\newcommand*{\@@eightiesfrench}[1]{% -\@unitstring{4}-\@tenstring{2}% -\ifnum#1>0 --\@unitstring{#1}% -\else -s% -\fi -} +\newcommand*{\Ordinalstring}[1]{% +\expandafter\protect\expandafter\Ordinalstringnum{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Nineties are a special case, depending on dialect: +%\end{macro} +%\begin{macro}{\Ordinalstringnum} +% Display ordinal as a string with initial letters in upper case +% (argument is a number or count register) +%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with +%\cs{new@ifnextchar}} % \begin{macrocode} -\newcommand*{\@@ninetiesfrench}[1]{% -\@unitstring{4}-\@tenstring{2}-\@teenstring{#1}% -} +\newcommand*{\Ordinalstringnum}[1]{% +\new@ifnextchar[{\@Ordinal@string{#1}}{\@Ordinal@string{#1}[m]}} % \end{macrocode} -% Swiss seventies: +%\end{macro} +%\begin{macro}{\@Ordinal@string} +% Display ordinal as a string with initial letters in upper case +% according to gender % \begin{macrocode} -\newcommand*{\@@seventiesfrenchswiss}[1]{% -\@tenstring{7}% -\ifnum#1=1\ \@andname\ \fi -\ifnum#1>1-\fi -\ifnum#1>0\@unitstring{#1}\fi -} +\def\@Ordinal@string#1[#2]{{% +\ifthenelse{\equal{#2}{f}}{% +\protect\@OrdinalstringF{#1}{\@fc@ordstr}}{% +\ifthenelse{\equal{#2}{n}}{% +\protect\@OrdinalstringN{#1}{\@fc@ordstr}}{% +\ifthenelse{\equal{#2}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#2'}{% +Available options are m, f or n}}% +\protect\@OrdinalstringM{#1}{\@fc@ordstr}}}\@fc@ordstr}} % \end{macrocode} -% Swiss eighties: +%\end{macro} +%\begin{macro}{\storeOrdinalstring} +% Store textual representation of number, with initial letters in +% upper case. First argument is identifying name, second argument +% is the counter set to the +% required number. % \begin{macrocode} -\newcommand*{\@@eightiesfrenchswiss}[1]{% -\@tenstring{8}% -\ifnum#1=1\ \@andname\ \fi -\ifnum#1>1-\fi -\ifnum#1>0\@unitstring{#1}\fi -} +\newcommand*{\storeOrdinalstring}[2]{% +\expandafter\protect\expandafter\storeOrdinalstringnum{#1}{% +\expandafter\the\csname c@#2\endcsname}} % \end{macrocode} -% Swiss nineties: +%\end{macro} +%\begin{macro}{\storeOrdinalstringnum} +% Store textual representation of number, with initial letters in +% upper case. First argument is identifying name, second argument +% is a count register or number. % \begin{macrocode} -\newcommand*{\@@ninetiesfrenchswiss}[1]{% -\@tenstring{9}% -\ifnum#1=1\ \@andname\ \fi -\ifnum#1>1-\fi -\ifnum#1>0\@unitstring{#1}\fi -} +\newcommand*{\storeOrdinalstringnum}[2]{% +\@ifnextchar[{\@store@Ordinal@string{#1}{#2}}{% +\@store@Ordinal@string{#1}{#2}[m]}} % \end{macrocode} -% Units with initial letter in upper case: +%\end{macro} +%\begin{macro}{\@store@Ordinal@string} +% Store textual representation of number according to gender, +% with initial letters in upper case. % \begin{macrocode} -\newcommand*{\@@Unitstringfrench}[1]{% -\ifcase#1\relax -Zero% -\or Un% -\or Deux% -\or Trois% -\or Quatre% -\or Cinq% -\or Six% -\or Sept% -\or Huit% -\or Neuf% -\fi -} +\def\@store@Ordinal@string#1#2[#3]{% +\ifthenelse{\equal{#3}{f}}{% +\protect\@OrdinalstringF{#2}{\@fc@ordstr}}{% +\ifthenelse{\equal{#3}{n}}{% +\protect\@OrdinalstringN{#2}{\@fc@ordstr}}{% +\ifthenelse{\equal{#3}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#3'}{% +Available options are m or f}}% +\protect\@OrdinalstringM{#2}{\@fc@ordstr}}}% +\expandafter\let\csname @fcs@#1\endcsname\@fc@ordstr} % \end{macrocode} -% As above, but feminine: +%\end{macro} +% +%\begin{macro}{\storeORDINALstring} +% Store upper case textual representation of ordinal. The first +% argument is identifying name, the second argument is a counter. % \begin{macrocode} -\newcommand*{\@@UnitstringFfrench}[1]{% -\ifnum#1=1\relax -Une% -\else \@@Unitstringfrench{#1}% -\fi -} +\newcommand*{\storeORDINALstring}[2]{% +\expandafter\protect\expandafter\storeORDINALstringnum{#1}{% +\expandafter\the\csname c@#2\endcsname}} % \end{macrocode} -% Tens, with initial letter in upper case (includes Swiss and -% Belgian variants): +%\end{macro} +%\begin{macro}{\storeORDINALstringnum} +% As above, but the second argument is a count register or a +% number. % \begin{macrocode} -\newcommand*{\@@Tenstringfrench}[1]{% -\ifcase#1\relax -\or Dix% -\or Vingt% -\or Trente% -\or Quarante% -\or Cinquante% -\or Soixante% -\or Septente% -\or Huitante% -\or Nonente% -\or Cent% -\fi -} +\newcommand*{\storeORDINALstringnum}[2]{% +\@ifnextchar[{\@store@ORDINAL@string{#1}{#2}}{% +\@store@ORDINAL@string{#1}{#2}[m]}} % \end{macrocode} -% Teens, with initial letter in upper case: +%\end{macro} +%\begin{macro}{\@store@ORDINAL@string} +% Gender is specified as an optional argument at the end. % \begin{macrocode} -\newcommand*{\@@Teenstringfrench}[1]{% -\ifcase#1\relax -Dix% -\or Onze% -\or Douze% -\or Treize% -\or Quatorze% -\or Quinze% -\or Seize% -\or Dix-Sept% -\or Dix-Huit% -\or Dix-Neuf% -\fi -} +\def\@store@ORDINAL@string#1#2[#3]{% +\ifthenelse{\equal{#3}{f}}{% +\protect\@ordinalstringF{#2}{\@fc@ordstr}}{% +\ifthenelse{\equal{#3}{n}}{% +\protect\@ordinalstringN{#2}{\@fc@ordstr}}{% +\ifthenelse{\equal{#3}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#3'}{% +Available options are m or f}}% +\protect\@ordinalstringM{#2}{\@fc@ordstr}}}% +\expandafter\edef\csname @fcs@#1\endcsname{% +\noexpand\MakeUppercase{\@fc@ordstr}}} % \end{macrocode} -% This has changed in version 1.09, so that it now stores the -% result in the second argument, but doesn't display anything. -% Since it only affects internal macros, it shouldn't affect -% documents created with older versions. (These internal macros -% are not defined for use in documents.) Firstly, the Swiss -% version: +%\end{macro} +%\begin{macro}{\ORDINALstring} +% Display upper case textual representation of an ordinal. The +% argument must be a counter. % \begin{macrocode} -\DeclareRobustCommand{\@numberstringMfrenchswiss}[2]{% -\let\@unitstring=\@@unitstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundred{cent}\def\@thousand{mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand*{\ORDINALstring}[1]{% +\expandafter\protect\expandafter\ORDINALstringnum{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Same as above, but for French as spoken in France: +%\end{macro} +%\begin{macro}{\ORDINALstringnum} +% As above, but the argument is a count register or a number. +%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with +%\cs{new@ifnextchar}} % \begin{macrocode} -\DeclareRobustCommand{\@numberstringMfrenchfrance}[2]{% -\let\@unitstring=\@@unitstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{cent}\def\@thousand{mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand*{\ORDINALstringnum}[1]{% +\new@ifnextchar[{\@ORDINAL@string{#1}}{\@ORDINAL@string{#1}[m]}} % \end{macrocode} -% Same as above, but for Belgian dialect: +%\end{macro} +%\begin{macro}{\@ORDINAL@string} +% Gender is specified as an optional argument at the end. % \begin{macrocode} -\DeclareRobustCommand{\@numberstringMfrenchbelgian}[2]{% -\let\@unitstring=\@@unitstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{cent}\def\@thousand{mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\def\@ORDINAL@string#1[#2]{{% +\ifthenelse{\equal{#2}{f}}{% +\protect\@ordinalstringF{#1}{\@fc@ordstr}}{% +\ifthenelse{\equal{#2}{n}}{% +\protect\@ordinalstringN{#1}{\@fc@ordstr}}{% +\ifthenelse{\equal{#2}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#2'}{% +Available options are m, f or n}}% +\protect\@ordinalstringM{#1}{\@fc@ordstr}}}% +\MakeUppercase{\@fc@ordstr}}} % \end{macrocode} -% Set default dialect: +%\end{macro} +%\begin{macro}{\storenumberstring} +% Convert number to textual respresentation, and store. First +% argument is the identifying name, second argument is a counter +% containing the number. % \begin{macrocode} -\let\@numberstringMfrench=\@numberstringMfrenchfrance +\newcommand*{\storenumberstring}[2]{% +\expandafter\protect\expandafter\storenumberstringnum{#1}{% +\expandafter\the\csname c@#2\endcsname}} % \end{macrocode} -% As above, but for feminine version. Swiss: +%\end{macro} +%\begin{macro}{\storenumberstringnum} +% As above, but second argument is a number or count register. % \begin{macrocode} -\DeclareRobustCommand{\@numberstringFfrenchswiss}[2]{% -\let\@unitstring=\@@unitstringFfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundred{cent}\def\@thousand{mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand{\storenumberstringnum}[2]{% +\@ifnextchar[{\@store@number@string{#1}{#2}}{% +\@store@number@string{#1}{#2}[m]}} % \end{macrocode} -% French: +%\end{macro} +%\begin{macro}{\@store@number@string} +% Gender is given as optional argument, \emph{at the end}. % \begin{macrocode} -\DeclareRobustCommand{\@numberstringFfrenchfrance}[2]{% -\let\@unitstring=\@@unitstringFfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{cent}\def\@thousand{mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\def\@store@number@string#1#2[#3]{% +\ifthenelse{\equal{#3}{f}}{% +\protect\@numberstringF{#2}{\@fc@numstr}}{% +\ifthenelse{\equal{#3}{n}}{% +\protect\@numberstringN{#2}{\@fc@numstr}}{% +\ifthenelse{\equal{#3}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#3'}{% +Available options are m, f or n}}% +\protect\@numberstringM{#2}{\@fc@numstr}}}% +\expandafter\let\csname @fcs@#1\endcsname\@fc@numstr} % \end{macrocode} -% Belgian: +%\end{macro} +%\begin{macro}{\numberstring} +% Display textual representation of a number. The argument +% must be a counter. % \begin{macrocode} -\DeclareRobustCommand{\@numberstringFfrenchbelgian}[2]{% -\let\@unitstring=\@@unitstringFfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{cent}\def\@thousand{mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand*{\numberstring}[1]{% +\expandafter\protect\expandafter\numberstringnum{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Set default dialect: +%\end{macro} +%\begin{macro}{\numberstringnum} +% As above, but the argument is a count register or a number. +%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with +%\cs{new@ifnextchar}} % \begin{macrocode} -\let\@numberstringFfrench=\@numberstringFfrenchfrance +\newcommand*{\numberstringnum}[1]{% +\new@ifnextchar[{\@number@string{#1}}{\@number@string{#1}[m]}% +} % \end{macrocode} -% Make neuter same as masculine: +%\end{macro} +% +%\begin{macro}{\@number@string} +% Gender is specified as an optional argument \emph{at the end}. % \begin{macrocode} -\let\@ordinalstringNfrench\@ordinalstringMfrench +\def\@number@string#1[#2]{{% +\ifthenelse{\equal{#2}{f}}{% +\protect\@numberstringF{#1}{\@fc@numstr}}{% +\ifthenelse{\equal{#2}{n}}{% +\protect\@numberstringN{#1}{\@fc@numstr}}{% +\ifthenelse{\equal{#2}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#2'}{% +Available options are m, f or n}}% +\protect\@numberstringM{#1}{\@fc@numstr}}}\@fc@numstr}} % \end{macrocode} -% As above, but with initial letter in upper case. Swiss (masculine): +%\end{macro} +%\begin{macro}{\storeNumberstring} +% Store textual representation of number. First argument is +% identifying name, second argument is a counter. % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringMfrenchswiss}[2]{% -\let\@unitstring=\@@Unitstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundred{Cent}\def\@thousand{Mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand*{\storeNumberstring}[2]{% +\expandafter\protect\expandafter\storeNumberstringnum{#1}{% +\expandafter\the\csname c@#2\endcsname}} % \end{macrocode} -% French: +%\end{macro} +%\begin{macro}{\storeNumberstringnum} +% As above, but second argument is a count register or number. % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringMfrenchfrance}[2]{% -\let\@unitstring=\@@Unitstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{Cent}\def\@thousand{Mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand{\storeNumberstringnum}[2]{% +\@ifnextchar[{\@store@Number@string{#1}{#2}}{% +\@store@Number@string{#1}{#2}[m]}} % \end{macrocode} -% Belgian: +%\end{macro} +%\begin{macro}{\@store@Number@string} +% Gender is specified as an optional argument \emph{at the end}: % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringMfrenchbelgian}[2]{% -\let\@unitstring=\@@Unitstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{Cent}\def\@thousand{Mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\def\@store@Number@string#1#2[#3]{% +\ifthenelse{\equal{#3}{f}}{% +\protect\@NumberstringF{#2}{\@fc@numstr}}{% +\ifthenelse{\equal{#3}{n}}{% +\protect\@NumberstringN{#2}{\@fc@numstr}}{% +\ifthenelse{\equal{#3}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#3'}{% +Available options are m, f or n}}% +\protect\@NumberstringM{#2}{\@fc@numstr}}}% +\expandafter\let\csname @fcs@#1\endcsname\@fc@numstr} % \end{macrocode} -% Set default dialect: +%\end{macro} +%\begin{macro}{\Numberstring} +% Display textual representation of number. The argument must be +% a counter. % \begin{macrocode} -\let\@NumberstringMfrench=\@NumberstringMfrenchfrance +\newcommand*{\Numberstring}[1]{% +\expandafter\protect\expandafter\Numberstringnum{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% As above, but feminine. Swiss: +%\end{macro} +%\begin{macro}{\Numberstringnum} +% As above, but the argument is a count register or number. +%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with +%\cs{new@ifnextchar}} % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringFfrenchswiss}[2]{% -\let\@unitstring=\@@UnitstringFfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundred{Cent}\def\@thousand{Mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand*{\Numberstringnum}[1]{% +\new@ifnextchar[{\@Number@string{#1}}{\@Number@string{#1}[m]}} % \end{macrocode} -% French (feminine): +%\end{macro} +%\begin{macro}{\@Number@string} +% Gender is specified as an optional argument at the end. % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringFfrenchfrance}[2]{% -\let\@unitstring=\@@UnitstringFfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{Cent}\def\@thousand{Mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\def\@Number@string#1[#2]{{% +\ifthenelse{\equal{#2}{f}}{% +\protect\@NumberstringF{#1}{\@fc@numstr}}{% +\ifthenelse{\equal{#2}{n}}{% +\protect\@NumberstringN{#1}{\@fc@numstr}}{% +\ifthenelse{\equal{#2}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#2'}{% +Available options are m, f or n}}% +\protect\@NumberstringM{#1}{\@fc@numstr}}}\@fc@numstr}} % \end{macrocode} -% Belgian (feminine): +%\end{macro} +%\begin{macro}{\storeNUMBERstring} +% Store upper case textual representation of number. The first +% argument is identifying name, the second argument is a counter. % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringFfrenchbelgian}[2]{% -\let\@unitstring=\@@UnitstringFfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\def\@hundred{Cent}\def\@thousand{Mille}% -\def\@andname{et}% -\@@numberstringfrench{#1}{#2}} +\newcommand{\storeNUMBERstring}[2]{% +\expandafter\protect\expandafter\storeNUMBERstringnum{#1}{% +\expandafter\the\csname c@#2\endcsname}} % \end{macrocode} -% Set default dialect: +%\end{macro} +%\begin{macro}{\storeNUMBERstringnum} +% As above, but the second argument is a count register or a +% number. % \begin{macrocode} -\let\@NumberstringFfrench=\@NumberstringFfrenchfrance +\newcommand{\storeNUMBERstringnum}[2]{% +\@ifnextchar[{\@store@NUMBER@string{#1}{#2}}{% +\@store@NUMBER@string{#1}{#2}[m]}} % \end{macrocode} -% Make neuter same as masculine: +%\end{macro} +%\begin{macro}{\@store@NUMBER@string} +% Gender is specified as an optional argument at the end. % \begin{macrocode} -\let\@NumberstringNfrench\@NumberstringMfrench +\def\@store@NUMBER@string#1#2[#3]{% +\ifthenelse{\equal{#3}{f}}{% +\protect\@numberstringF{#2}{\@fc@numstr}}{% +\ifthenelse{\equal{#3}{n}}{% +\protect\@numberstringN{#2}{\@fc@numstr}}{% +\ifthenelse{\equal{#3}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#3'}{% +Available options are m or f}}% +\protect\@numberstringM{#2}{\@fc@numstr}}}% +\expandafter\edef\csname @fcs@#1\endcsname{% +\noexpand\MakeUppercase{\@fc@numstr}}} % \end{macrocode} -% Again, as from version 1.09, this has been changed to take -% two arguments, where the second argument is a control -% sequence, and nothing is displayed. Store textual representation -% of an ordinal in the given control sequence. Swiss dialect (masculine): +%\end{macro} +%\begin{macro}{\NUMBERstring} +% Display upper case textual representation of a number. The +% argument must be a counter. % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringMfrenchswiss}[2]{% -\ifnum#1=1\relax -\def#2{premier}% -\else -\let\@unitthstring=\@@unitthstringfrench -\let\@unitstring=\@@unitstringfrench -\let\@teenthstring=\@@teenthstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenthstring=\@@tenthstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrenchswiss -\let\@ninetieths=\@@ninetiethsfrenchswiss -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundredth{centi\`eme}\def\@hundred{cent}% -\def\@thousandth{mili\`eme}\def\@thousand{mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\newcommand*{\NUMBERstring}[1]{% +\expandafter\protect\expandafter\NUMBERstringnum{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% French (masculine): +%\end{macro} +%\begin{macro}{\NUMBERstringnum} +% As above, but the argument is a count register or a number. +%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with +%\cs{new@ifnextchar}} % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringMfrenchfrance}[2]{% -\ifnum#1=1\relax -\def#2{premier}% -\else -\let\@unitthstring=\@@unitthstringfrench -\let\@unitstring=\@@unitstringfrench -\let\@teenthstring=\@@teenthstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenthstring=\@@tenthstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventieths=\@@seventiethsfrench -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@teenstringfrench -\def\@hundredth{centi\`eme}\def\@hundred{cent}% -\def\@thousandth{mili\`eme}\def\@thousand{mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\newcommand*{\NUMBERstringnum}[1]{% +\new@ifnextchar[{\@NUMBER@string{#1}}{\@NUMBER@string{#1}[m]}} % \end{macrocode} -% Belgian dialect (masculine): +%\end{macro} +%\begin{macro}{\@NUMBER@string} +% Gender is specified as an optional argument at the end. % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringMfrenchbelgian}[2]{% -\ifnum#1=1\relax -\def#2{premier}% -\else -\let\@unitthstring=\@@unitthstringfrench -\let\@unitstring=\@@unitstringfrench -\let\@teenthstring=\@@teenthstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenthstring=\@@tenthstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrenchswiss -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@teenstringfrench -\def\@hundredth{centi\`eme}\def\@hundred{cent}% -\def\@thousandth{mili\`eme}\def\@thousand{mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\def\@NUMBER@string#1[#2]{{% +\ifthenelse{\equal{#2}{f}}{% +\protect\@numberstringF{#1}{\@fc@numstr}}{% +\ifthenelse{\equal{#2}{n}}{% +\protect\@numberstringN{#1}{\@fc@numstr}}{% +\ifthenelse{\equal{#2}{m}}{}{% +\PackageError{fmtcount}{Invalid gender option `#2'}{% +Available options are m, f or n}}% +\protect\@numberstringM{#1}{\@fc@numstr}}}% +\MakeUppercase{\@fc@numstr}}} % \end{macrocode} -% Set up default dialect: +%\end{macro} +%\begin{macro}{\binary} +% Number representations in other bases. Binary: % \begin{macrocode} -\let\@ordinalstringMfrench=\@ordinalstringMfrenchfrance +\providecommand*{\binary}[1]{% +\expandafter\protect\expandafter\@binary{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% As above, but feminine. Swiss: +%\end{macro} +%\begin{macro}{\aaalph} +% Like \verb"\alph", but goes beyond 26. +% (a \ldots\ z aa \ldots zz \ldots) % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringFfrenchswiss}[2]{% -\ifnum#1=1\relax -\def#2{premi\`ere}% -\else -\let\@unitthstring=\@@unitthstringfrench -\let\@unitstring=\@@unitstringFfrench -\let\@teenthstring=\@@teenthstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenthstring=\@@tenthstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrenchswiss -\let\@ninetieths=\@@ninetiethsfrenchswiss -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundredth{centi\`eme}\def\@hundred{cent}% -\def\@thousandth{mili\`eme}\def\@thousand{mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\providecommand*{\aaalph}[1]{% +\expandafter\protect\expandafter\@aaalph{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% French (feminine): +%\end{macro} +%\begin{macro}{\AAAlph} +% As before, but upper case. % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringFfrenchfrance}[2]{% -\ifnum#1=1\relax -\def#2{premi\`ere}% -\else -\let\@unitthstring=\@@unitthstringfrench -\let\@unitstring=\@@unitstringFfrench -\let\@teenthstring=\@@teenthstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenthstring=\@@tenthstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventieths=\@@seventiethsfrench -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@teenstringfrench -\def\@hundredth{centi\`eme}\def\@hundred{cent}% -\def\@thousandth{mili\`eme}\def\@thousand{mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\providecommand*{\AAAlph}[1]{% +\expandafter\protect\expandafter\@AAAlph{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Belgian (feminine): +%\end{macro} +%\begin{macro}{\abalph} +% Like \verb"\alph", but goes beyond 26. +% (a \ldots\ z ab \ldots az \ldots) % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringFfrenchbelgian}[2]{% -\ifnum#1=1\relax -\def#2{premi\`ere}% -\else -\let\@unitthstring=\@@unitthstringfrench -\let\@unitstring=\@@unitstringFfrench -\let\@teenthstring=\@@teenthstringfrench -\let\@teenstring=\@@teenstringfrench -\let\@tenthstring=\@@tenthstringfrench -\let\@tenstring=\@@tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@teenstringfrench -\def\@hundredth{centi\`eme}\def\@hundred{cent}% -\def\@thousandth{mili\`eme}\def\@thousand{mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\providecommand*{\abalph}[1]{% +\expandafter\protect\expandafter\@abalph{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Set up default dialect: +%\end{macro} +%\begin{macro}{\ABAlph} +% As above, but upper case. % \begin{macrocode} -\let\@ordinalstringFfrench=\@ordinalstringFfrenchfrance +\providecommand*{\ABAlph}[1]{% +\expandafter\protect\expandafter\@ABAlph{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Make neuter same as masculine: +%\end{macro} +%\begin{macro}{\hexadecimal} +% Hexadecimal: % \begin{macrocode} -\let\@ordinalstringNfrench\@ordinalstringMfrench +\providecommand*{\hexadecimal}[1]{% +\expandafter\protect\expandafter\@hexadecimal{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% As above, but with initial letters in upper case. Swiss (masculine): +%\end{macro} +%\begin{macro}{\Hexadecimal} +% As above, but in upper case. % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMfrenchswiss}[2]{% -\ifnum#1=1\relax -\def#2{Premi\`ere}% -\else -\let\@unitthstring=\@@Unitthstringfrench -\let\@unitstring=\@@Unitstringfrench -\let\@teenthstring=\@@Teenthstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenthstring=\@@Tenthstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrenchswiss -\let\@ninetieths=\@@ninetiethsfrenchswiss -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% -\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\providecommand*{\Hexadecimal}[1]{% +\expandafter\protect\expandafter\@Hexadecimal{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% French (masculine): +%\end{macro} +%\begin{macro}{\octal} +% Octal: % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMfrenchfrance}[2]{% -\ifnum#1=1\relax -\def#2{Premi\`ere}% -\else -\let\@unitthstring=\@@Unitthstringfrench -\let\@unitstring=\@@Unitstringfrench -\let\@teenthstring=\@@Teenthstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenthstring=\@@Tenthstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventieths=\@@seventiethsfrench -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@Teenstringfrench -\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% -\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\providecommand*{\octal}[1]{% +\expandafter\protect\expandafter\@octal{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Belgian (masculine): +%\end{macro} +%\begin{macro}{\decimal} +% Decimal: % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMfrenchbelgian}[2]{% -\ifnum#1=1\relax -\def#2{Premi\`ere}% -\else -\let\@unitthstring=\@@Unitthstringfrench -\let\@unitstring=\@@Unitstringfrench -\let\@teenthstring=\@@Teenthstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenthstring=\@@Tenthstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@Teenstringfrench -\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% -\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\providecommand*{\decimal}[1]{% +\expandafter\protect\expandafter\@decimal{% +\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -% Set up default dialect: +%\end{macro} +% +%\subsection{Multilinguage Definitions} +%\begin{macro}{\@setdef@ultfmtcount} +% If multilingual support is provided, make \verb"\@numberstring" +% etc use the correct language (if defined). +% Otherwise use English definitions. "\@setdef@ultfmtcount" +% sets the macros to use English. % \begin{macrocode} -\let\@OrdinalstringMfrench=\@OrdinalstringMfrenchfrance +\def\@setdef@ultfmtcount{ +\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} +\def\@ordinalstringM{\@ordinalstringMenglish} +\let\@ordinalstringF=\@ordinalstringMenglish +\let\@ordinalstringN=\@ordinalstringMenglish +\def\@OrdinalstringM{\@OrdinalstringMenglish} +\let\@OrdinalstringF=\@OrdinalstringMenglish +\let\@OrdinalstringN=\@OrdinalstringMenglish +\def\@numberstringM{\@numberstringMenglish} +\let\@numberstringF=\@numberstringMenglish +\let\@numberstringN=\@numberstringMenglish +\def\@NumberstringM{\@NumberstringMenglish} +\let\@NumberstringF=\@NumberstringMenglish +\let\@NumberstringN=\@NumberstringMenglish +\def\@ordinalM{\@ordinalMenglish} +\let\@ordinalF=\@ordinalM +\let\@ordinalN=\@ordinalM +} % \end{macrocode} -% As above, but feminine form. Swiss: +%\end{macro} +%\begin{macro}{\@set@mulitling@fmtcount} +% This defines the number and ordinal string macros to use +% \cs{languagename}: % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringFfrenchswiss}[2]{% -\ifnum#1=1\relax -\def#2{Premi\`ere}% -\else -\let\@unitthstring=\@@Unitthstringfrench -\let\@unitstring=\@@UnitstringFfrench -\let\@teenthstring=\@@Teenthstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenthstring=\@@Tenthstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrenchswiss -\let\@ninetieths=\@@ninetiethsfrenchswiss -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% -\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\def\@set@mulitling@fmtcount{% % \end{macrocode} -% French (feminine): +% The masculine version of \cs{numberstring}: % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringFfrenchfrance}[2]{% -\ifnum#1=1\relax -\def#2{Premi\`ere}% -\else -\let\@unitthstring=\@@Unitthstringfrench -\let\@unitstring=\@@UnitstringFfrench -\let\@teenthstring=\@@Teenthstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenthstring=\@@Tenthstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventieths=\@@seventiethsfrench -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@Teenstringfrench -\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% -\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\def\@numberstringM{\@ifundefined{@numberstringM\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@numberstringM}}{% +\csname @numberstringM\languagename\endcsname}}% % \end{macrocode} -% Belgian (feminine): +% The feminine version of \cs{numberstring}: % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringFfrenchbelgian}[2]{% -\ifnum#1=1\relax -\def#2{Premi\`ere}% -\else -\let\@unitthstring=\@@Unitthstringfrench -\let\@unitstring=\@@UnitstringFfrench -\let\@teenthstring=\@@Teenthstringfrench -\let\@teenstring=\@@Teenstringfrench -\let\@tenthstring=\@@Tenthstringfrench -\let\@tenstring=\@@Tenstringfrench -\let\@seventieths=\@@seventiethsfrenchswiss -\let\@eightieths=\@@eightiethsfrench -\let\@ninetieths=\@@ninetiethsfrench -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\@teenstring=\@@Teenstringfrench -\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% -\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% -\def\@andname{et}% -\@@ordinalstringfrench{#1}{#2}% -\fi} +\def\@numberstringF{\@ifundefined{@numberstringF\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@numberstringF}}{% +\csname @numberstringF\languagename\endcsname}}% % \end{macrocode} -% Set up default dialect: +% The neuter version of \cs{numberstring}: % \begin{macrocode} -\let\@OrdinalstringFfrench=\@OrdinalstringFfrenchfrance +\def\@numberstringN{\@ifundefined{@numberstringN\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@numberstringN}}{% +\csname @numberstringN\languagename\endcsname}}% % \end{macrocode} -% Make neuter same as masculine: +% The masculine version of \cs{Numberstring}: % \begin{macrocode} -\let\@OrdinalstringNfrench\@OrdinalstringMfrench +\def\@NumberstringM{\@ifundefined{@NumberstringM\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@NumberstringM}}{% +\csname @NumberstringM\languagename\endcsname}}% % \end{macrocode} -% In order to convert numbers into textual ordinals, need -% to break it up into units, tens and teens. First the units. -% The argument must be a number or count register between 0 -% and 9. +% The feminine version of \cs{Numberstring}: % \begin{macrocode} -\newcommand*{\@@unitthstringfrench}[1]{% -\ifcase#1\relax -zero% -\or uni\`eme% -\or deuxi\`eme% -\or troisi\`eme% -\or quatri\`eme% -\or cinqui\`eme% -\or sixi\`eme% -\or septi\`eme% -\or huiti\`eme% -\or neuvi\`eme% -\fi -} -% \end{macrocode} -% Tens (includes Swiss and Belgian variants, special cases are -% dealt with later.) +\def\@NumberstringF{\@ifundefined{@NumberstringF\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@NumberstringF}}{% +\csname @NumberstringF\languagename\endcsname}}% +% \end{macrocode} +% The neuter version of \cs{Numberstring}: % \begin{macrocode} -\newcommand*{\@@tenthstringfrench}[1]{% -\ifcase#1\relax -\or dixi\`eme% -\or vingti\`eme% -\or trentri\`eme% -\or quaranti\`eme% -\or cinquanti\`eme% -\or soixanti\`eme% -\or septenti\`eme% -\or huitanti\`eme% -\or nonenti\`eme% -\fi -} +\def\@NumberstringN{\@ifundefined{@NumberstringN\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@NumberstringN}}{% +\csname @NumberstringN\languagename\endcsname}}% % \end{macrocode} -% Teens: +% The masculine version of \cs{ordinal}: % \begin{macrocode} -\newcommand*{\@@teenthstringfrench}[1]{% -\ifcase#1\relax -dixi\`eme% -\or onzi\`eme% -\or douzi\`eme% -\or treizi\`eme% -\or quatorzi\`eme% -\or quinzi\`eme% -\or seizi\`eme% -\or dix-septi\`eme% -\or dix-huiti\`eme% -\or dix-neuvi\`eme% -\fi -} +\def\@ordinalM{\@ifundefined{@ordinalM\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@ordinalM}}{% +\csname @ordinalM\languagename\endcsname}}% % \end{macrocode} -% Seventies vary depending on dialect. Swiss: +% The feminine version of \cs{ordinal}: % \begin{macrocode} -\newcommand*{\@@seventiethsfrenchswiss}[1]{% -\ifcase#1\relax -\@tenthstring{7}% -\or -\@tenstring{7} \@andname\ \@unitthstring{1}% -\else -\@tenstring{7}-\@unitthstring{#1}% -\fi} +\def\@ordinalF{\@ifundefined{@ordinalF\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@ordinalF}}{% +\csname @ordinalF\languagename\endcsname}}% % \end{macrocode} -% Eighties vary depending on dialect. Swiss: +% The neuter version of \cs{ordinal}: % \begin{macrocode} -\newcommand*{\@@eightiethsfrenchswiss}[1]{% -\ifcase#1\relax -\@tenthstring{8}% -\or -\@tenstring{8} \@andname\ \@unitthstring{1}% -\else -\@tenstring{8}-\@unitthstring{#1}% -\fi} +\def\@ordinalN{\@ifundefined{@ordinalN\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@ordinalN}}{% +\csname @ordinalN\languagename\endcsname}}% % \end{macrocode} -% Nineties vary depending on dialect. Swiss: +% The masculine version of \cs{ordinalstring}: % \begin{macrocode} -\newcommand*{\@@ninetiethsfrenchswiss}[1]{% -\ifcase#1\relax -\@tenthstring{9}% -\or -\@tenstring{9} \@andname\ \@unitthstring{1}% -\else -\@tenstring{9}-\@unitthstring{#1}% -\fi} +\def\@ordinalstringM{\@ifundefined{@ordinalstringM\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@ordinalstringM}}{% +\csname @ordinalstringM\languagename\endcsname}}% % \end{macrocode} -% French (as spoken in France) version: +% The feminine version of \cs{ordinalstring}: % \begin{macrocode} -\newcommand*{\@@seventiethsfrench}[1]{% -\ifnum#1=0\relax -\@tenstring{6}% --% -\else -\@tenstring{6}% -\ \@andname\ -\fi -\@teenthstring{#1}% -} +\def\@ordinalstringF{\@ifundefined{@ordinalstringF\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@ordinalstringF}}{% +\csname @ordinalstringF\languagename\endcsname}}% % \end{macrocode} -% Eighties (as spoken in France): +% The neuter version of \cs{ordinalstring}: % \begin{macrocode} -\newcommand*{\@@eightiethsfrench}[1]{% -\ifnum#1>0\relax -\@unitstring{4}-\@tenstring{2}% --\@unitthstring{#1}% -\else -\@unitstring{4}-\@tenthstring{2}% -\fi -} +\def\@ordinalstringN{\@ifundefined{@ordinalstringN\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@ordinalstringN}}{% +\csname @ordinalstringN\languagename\endcsname}}% % \end{macrocode} -% Nineties (as spoken in France): +% The masculine version of \cs{Ordinalstring}: % \begin{macrocode} -\newcommand*{\@@ninetiethsfrench}[1]{% -\@unitstring{4}-\@tenstring{2}-\@teenthstring{#1}% -} +\def\@OrdinalstringM{\@ifundefined{@OrdinalstringM\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@OrdinalstringM}}{% +\csname @OrdinalstringM\languagename\endcsname}}% % \end{macrocode} -% As above, but with initial letter in upper case. Units: +% The feminine version of \cs{Ordinalstring}: % \begin{macrocode} -\newcommand*{\@@Unitthstringfrench}[1]{% -\ifcase#1\relax -Zero% -\or Uni\`eme% -\or Deuxi\`eme% -\or Troisi\`eme% -\or Quatri\`eme% -\or Cinqui\`eme% -\or Sixi\`eme% -\or Septi\`eme% -\or Huiti\`eme% -\or Neuvi\`eme% -\fi -} +\def\@OrdinalstringF{\@ifundefined{@OrdinalstringF\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@OrdinalstringF}}{% +\csname @OrdinalstringF\languagename\endcsname}}% % \end{macrocode} -% Tens (includes Belgian and Swiss variants): +% The neuter version of \cs{Ordinalstring}: % \begin{macrocode} -\newcommand*{\@@Tenthstringfrench}[1]{% -\ifcase#1\relax -\or Dixi\`eme% -\or Vingti\`eme% -\or Trentri\`eme% -\or Quaranti\`eme% -\or Cinquanti\`eme% -\or Soixanti\`eme% -\or Septenti\`eme% -\or Huitanti\`eme% -\or Nonenti\`eme% -\fi +\def\@OrdinalstringN{\@ifundefined{@OrdinalstringN\languagename}{% +\PackageError{fmtcount}{No support for language '\languagename'}{% +The fmtcount package currently does not support language +'\languagename' for command \string\@OrdinalstringN}}{% +\csname @OrdinalstringN\languagename\endcsname}} } % \end{macrocode} -% Teens: +%\end{macro} +% Check to see if babel or ngerman packages have been loaded. % \begin{macrocode} -\newcommand*{\@@Teenthstringfrench}[1]{% -\ifcase#1\relax -Dixi\`eme% -\or Onzi\`eme% -\or Douzi\`eme% -\or Treizi\`eme% -\or Quatorzi\`eme% -\or Quinzi\`eme% -\or Seizi\`eme% -\or Dix-Septi\`eme% -\or Dix-Huiti\`eme% -\or Dix-Neuvi\`eme% -\fi -} +\@ifpackageloaded{babel}{% +\ifthenelse{\equal{\languagename}{nohyphenation}\or +\equal{languagename}{english}}{\@setdef@ultfmtcount}{% +\@set@mulitling@fmtcount} +}{% +\@ifpackageloaded{ngerman}{% +\@ifundefined{@numberstringMgerman}{% +\input{fc-german.def}}{}\@set@mulitling@fmtcount}{% +\@setdef@ultfmtcount}} % \end{macrocode} -% Store textual representation of number (first argument) in given control -% sequence (second argument). +% Backwards compatibility: % \begin{macrocode} -\newcommand*{\@@numberstringfrench}[2]{% -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000}% -\else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% -\fi -\fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>9\relax -% #1 is greater or equal to 10000 - \@tmpstrctr=\@strctr - \divide\@strctr by 10\relax - \ifnum\@strctr>1\relax - \ifthenelse{\(\@strctr>6\)\and\(\@strctr<10\)}{% - \@modulo{\@tmpstrctr}{10}% - \ifnum\@strctr<8\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@seventies{\@tmpstrctr}}% - \else - \ifnum\@strctr<9\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@eighties{\@tmpstrctr}}% - \else - \ifnum\@strctr<10\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@nineties{\@tmpstrctr}}% - \fi - \fi - \fi - }{% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1\relax - \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% - \fi - }% - \else - \@strctr=#1\relax - \divide\@strctr by 1000 - \@modulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@thousand}% +\let\@ordinal=\@ordinalM +\let\@ordinalstring=\@ordinalstringM +\let\@Ordinalstring=\@OrdinalstringM +\let\@numberstring=\@numberstringM +\let\@Numberstring=\@NumberstringM +% \end{macrocode} +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*fc-british.def> +% \end{macrocode} +%\fi +% \subsubsection{fc-british.def} +% British definitions +% \begin{macrocode} +\ProvidesFile{fc-british}[2007/06/14] +% \end{macrocode} +% Check that fc-english.def has been loaded +% \begin{macrocode} +\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} +% \end{macrocode} +% These are all just synonyms for the commands provided by +% fc-english.def. +% \begin{macrocode} +\let\@ordinalMbritish\@ordinalMenglish +\let\@ordinalFbritish\@ordinalMenglish +\let\@ordinalNbritish\@ordinalMenglish +\let\@numberstringMbritish\@numberstringMenglish +\let\@numberstringFbritish\@numberstringMenglish +\let\@numberstringNbritish\@numberstringMenglish +\let\@NumberstringMbritish\@NumberstringMenglish +\let\@NumberstringFbritish\@NumberstringMenglish +\let\@NumberstringNbritish\@NumberstringMenglish +\let\@ordinalstringMbritish\@ordinalstringMenglish +\let\@ordinalstringFbritish\@ordinalstringMenglish +\let\@ordinalstringNbritish\@ordinalstringMenglish +\let\@OrdinalstringMbritish\@OrdinalstringMenglish +\let\@OrdinalstringFbritish\@OrdinalstringMenglish +\let\@OrdinalstringNbritish\@OrdinalstringMenglish +% \end{macrocode} +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*fc-english.def> +% \end{macrocode} +%\fi +% \subsubsection{fc-english.def} +% English definitions +% \begin{macrocode} +\ProvidesFile{fc-english}[2007/05/26] +% \end{macrocode} +% Define macro that converts a number or count register (first +% argument) to an ordinal, and stores the result in the +% second argument, which should be a control sequence. +% \begin{macrocode} +\newcommand*{\@ordinalMenglish}[2]{% +\def\@fc@ord{}% +\@orgargctr=#1\relax +\@ordinalctr=#1% +\@modulo{\@ordinalctr}{100}% +\ifnum\@ordinalctr=11\relax + \def\@fc@ord{th}% \else - \ifnum\@strctr>0\relax - \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@thousand}% - \fi -\fi -\@strctr=#1\relax \@modulo{\@strctr}{1000}% -\divide\@strctr by 100 -\ifnum\@strctr>0\relax - \ifnum#1>1000\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ }% - \fi - \@tmpstrctr=#1\relax - \@modulo{\@tmpstrctr}{1000}\relax - \ifnum\@tmpstrctr=100\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{10}}% - \else - \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@hundred}% - \fi -\fi -\@strctr=#1\relax \@modulo{\@strctr}{100}% -%\@tmpstrctr=#1\relax -%\divide\@tmpstrctr by 100\relax -\ifnum#1>100\relax - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ }% + \ifnum\@ordinalctr=12\relax + \def\@fc@ord{th}% \else - \ifnum\@tmpstrctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr s}% - \fi% - \fi -\fi -\ifnum\@strctr>19\relax - \@tmpstrctr=\@strctr - \divide\@strctr by 10\relax - \ifthenelse{\@strctr>6}{% - \@modulo{\@tmpstrctr}{10}% - \ifnum\@strctr<8\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@seventies{\@tmpstrctr}}% + \ifnum\@ordinalctr=13\relax + \def\@fc@ord{th}% \else - \ifnum\@strctr<9\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@eighties{\@tmpstrctr}}% - \else - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@nineties{\@tmpstrctr}}% - \fi - \fi - }{% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1\relax \@modulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \ifnum\@strctr=1\relax - \edef#2{\@@fc@numstr\ \@andname\ }% + \@modulo{\@ordinalctr}{10}% + \ifcase\@ordinalctr + \def\@fc@ord{th}% case 0 + \or \def\@fc@ord{st}% case 1 + \or \def\@fc@ord{nd}% case 2 + \or \def\@fc@ord{rd}% case 3 \else - \edef#2{\@@fc@numstr-}% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% - \fi - }% -\else - \ifnum\@strctr<10\relax - \ifnum\@strctr=0\relax - \ifnum#1<100\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \def\@fc@ord{th}% default case \fi - \else%(>0,<10) - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% \fi - \else%>10 - \@modulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% \fi \fi +\edef#2{\number#1\relax\noexpand\fmtord{\@fc@ord}}% } % \end{macrocode} -% Store textual representation of an ordinal (from number -% specified in first argument) in given control -% sequence (second argument). +% There is no gender difference in English, so make feminine and +% neuter the same as the masculine. % \begin{macrocode} -\newcommand*{\@@ordinalstringfrench}[2]{% -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000}% -\else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% +\let\@ordinalFenglish=\@ordinalMenglish +\let\@ordinalNenglish=\@ordinalMenglish +% \end{macrocode} +% Define the macro that prints the value of a \TeX\ count register +% as text. To make it easier, break it up into units, teens and +% tens. First, the units: the argument should be between 0 and 9 +% inclusive. +% \begin{macrocode} +\newcommand*{\@@unitstringenglish}[1]{% +\ifcase#1\relax +zero% +\or one% +\or two% +\or three% +\or four% +\or five% +\or six% +\or seven% +\or eight% +\or nine% \fi +} +% \end{macrocode} +% Next the tens, again the argument should be between 0 and 9 +% inclusive. +% \begin{macrocode} +\newcommand*{\@@tenstringenglish}[1]{% +\ifcase#1\relax +\or ten% +\or twenty% +\or thirty% +\or forty% +\or fifty% +\or sixty% +\or seventy% +\or eighty% +\or ninety% \fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>9 -% #1 is greater or equal to 10000 - \@tmpstrctr=\@strctr - \divide\@strctr by 10\relax - \ifnum\@strctr>1\relax - \ifthenelse{\@strctr>6}{% - \@modulo{\@tmpstrctr}{10}% - \ifnum\@strctr=7\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@seventies{\@tmpstrctr}}% - \else - \ifnum\@strctr=8\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@eighties{\@tmpstrctr}}% - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@nineties{\@tmpstrctr}}% - \fi - \fi - }{% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% - \@strctr=#1\relax - \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \ifnum\@strctr=1\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@andname}% - \fi - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@unitstring{\@strctr}}% - \fi - }% - \else - \@strctr=#1\relax - \divide\@strctr by 1000\relax +} +% \end{macrocode} +% Finally the teens, again the argument should be between 0 and 9 +% inclusive. +% \begin{macrocode} +\newcommand*{\@@teenstringenglish}[1]{% +\ifcase#1\relax +ten% +\or eleven% +\or twelve% +\or thirteen% +\or fourteen% +\or fifteen% +\or sixteen% +\or seventeen% +\or eighteen% +\or nineteen% +\fi +} +% \end{macrocode} +% As above, but with the initial letter in uppercase. The units: +% \begin{macrocode} +\newcommand*{\@@Unitstringenglish}[1]{% +\ifcase#1\relax +Zero% +\or One% +\or Two% +\or Three% +\or Four% +\or Five% +\or Six% +\or Seven% +\or Eight% +\or Nine% +\fi +} +% \end{macrocode} +% The tens: +% \begin{macrocode} +\newcommand*{\@@Tenstringenglish}[1]{% +\ifcase#1\relax +\or Ten% +\or Twenty% +\or Thirty% +\or Forty% +\or Fifty% +\or Sixty% +\or Seventy% +\or Eighty% +\or Ninety% +\fi +} +% \end{macrocode} +% The teens: +% \begin{macrocode} +\newcommand*{\@@Teenstringenglish}[1]{% +\ifcase#1\relax +Ten% +\or Eleven% +\or Twelve% +\or Thirteen% +\or Fourteen% +\or Fifteen% +\or Sixteen% +\or Seventeen% +\or Eighteen% +\or Nineteen% +\fi +} +% \end{macrocode} +% This has changed in version 1.09, so that it now stores +% the result in the second argument, but doesn't display anything. +% Since it only affects internal macros, it shouldn't affect +% documents created with older versions. (These internal macros are +% not meant for use in documents.) +% \begin{macrocode} +\newcommand*{\@@numberstringenglish}[2]{% +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\fi +\fi +\def#2{}% +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>9 +% #1 is greater or equal to 10000 + \divide\@strctr by 10 + \ifnum\@strctr>1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1 \divide\@strctr by 1000\relax \@modulo{\@strctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenstring{\@strctr}}% - \fi - \@strctr=#1\relax \@modulo{\@strctr}{1000}% - \ifnum\@strctr=0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@thousandth}% + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr-\@unitstring{\@strctr}}% + \fi \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@thousand}% + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@thousand}% \else \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \@strctr=#1\relax \@modulo{\@strctr}{1000}% - \ifnum\@strctr=0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@thousandth}% - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@thousand}% - \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ \@thousand}% \fi \fi \@strctr=#1\relax \@modulo{\@strctr}{1000}% -\divide\@strctr by 100\relax +\divide\@strctr by 100 \ifnum\@strctr>0\relax - \ifnum#1>1000\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ }% - \fi - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \@strctr=#1\relax \@modulo{\@strctr}{100}% - \let\@@fc@ordstr#2\relax - \ifnum\@strctr=0\relax - \edef#2{\@@fc@ordstr\ \@hundredth}% - \else - \edef#2{\@@fc@ordstr\ \@hundred}% - \fi + \ifnum#1>1000\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ }% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ \@hundred}% \fi -\@tmpstrctr=\@strctr \@strctr=#1\relax \@modulo{\@strctr}{100}% \ifnum#1>100\relax \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@andname\ }% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname\ }% \fi \fi \ifnum\@strctr>19\relax - \@tmpstrctr=\@strctr \divide\@strctr by 10\relax - \@modulo{\@tmpstrctr}{10}% - \ifthenelse{\@strctr>6}{% - \ifnum\@strctr=7\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@seventieths{\@tmpstrctr}}% - \else - \ifnum\@strctr=8\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@eightieths{\@tmpstrctr}}% - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@ninetieths{\@tmpstrctr}}% - \fi - \fi - }{% - \ifnum\@tmpstrctr=0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenthstring{\@strctr}}% - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% - \fi - \@strctr=#1\relax \@modulo{\@strctr}{10}% - \ifnum\@strctr=1\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@andname}% - \fi - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@unitthstring{\@strctr}}% - \fi - }% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr-\@unitstring{\@strctr}}% + \fi \else \ifnum\@strctr<10\relax \ifnum\@strctr=0\relax - \ifnum#1<100\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% - \fi + \ifnum#1<100\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% \fi \else \@modulo{\@strctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% \fi \fi } % \end{macrocode} -%\iffalse +% All lower case version, the second argument must be a +% control sequence. % \begin{macrocode} -% +\DeclareRobustCommand{\@numberstringMenglish}[2]{% +\let\@unitstring=\@@unitstringenglish +\let\@teenstring=\@@teenstringenglish +\let\@tenstring=\@@tenstringenglish +\def\@hundred{hundred}\def\@thousand{thousand}% +\def\@andname{and}% +\@@numberstringenglish{#1}{#2}% +} % \end{macrocode} -%\fi -%\iffalse +% There is no gender in English, so make feminine and neuter the same +% as the masculine. % \begin{macrocode} -%<*fc-german.def> +\let\@numberstringFenglish=\@numberstringMenglish +\let\@numberstringNenglish=\@numberstringMenglish % \end{macrocode} -%\fi -% \subsection{fc-german.def} -% German definitions (thank you to K. H. Fricke for supplying -% this information) +% This version makes the first letter of each word an uppercase +% character (except ``and''). The second argument must be a control +% sequence. % \begin{macrocode} -\ProvidesFile{fc-german.def}[2007/06/14] +\newcommand*{\@NumberstringMenglish}[2]{% +\let\@unitstring=\@@Unitstringenglish +\let\@teenstring=\@@Teenstringenglish +\let\@tenstring=\@@Tenstringenglish +\def\@hundred{Hundred}\def\@thousand{Thousand}% +\def\@andname{and}% +\@@numberstringenglish{#1}{#2}} % \end{macrocode} -% Define macro that converts a number or count register (first -% argument) to an ordinal, and stores the result in the -% second argument, which must be a control sequence. -% Masculine: +% There is no gender in English, so make feminine and neuter the same +% as the masculine. % \begin{macrocode} -\newcommand{\@ordinalMgerman}[2]{% -\edef#2{\number#1\relax.}} +\let\@NumberstringFenglish=\@NumberstringMenglish +\let\@NumberstringNenglish=\@NumberstringMenglish % \end{macrocode} -% Feminine: -% \begin{macrocode} -\newcommand{\@ordinalFgerman}[2]{% -\edef#2{\number#1\relax.}} -% \end{macrocode} -% Neuter: -% \begin{macrocode} -\newcommand{\@ordinalNgerman}[2]{% -\edef#2{\number#1\relax.}} -% \end{macrocode} -% Convert a number to text. The easiest way to do this is to -% break it up into units, tens and teens. -% Units (argument must be a number from 0 to 9, 1 on its own (eins) -% is dealt with separately): +% Define a macro that produces an ordinal as a string. Again, break +% it up into units, teens and tens. First the units: % \begin{macrocode} -\newcommand{\@@unitstringgerman}[1]{% -\ifcase#1% -null% -\or ein% -\or zwei% -\or drei% -\or vier% -\or f\"unf% -\or sechs% -\or sieben% -\or acht% -\or neun% +\newcommand*{\@@unitthstringenglish}[1]{% +\ifcase#1\relax +zeroth% +\or first% +\or second% +\or third% +\or fourth% +\or fifth% +\or sixth% +\or seventh% +\or eighth% +\or ninth% \fi } % \end{macrocode} -% Tens (argument must go from 1 to 10): +% Next the tens: % \begin{macrocode} -\newcommand{\@@tenstringgerman}[1]{% -\ifcase#1% -\or zehn% -\or zwanzig% -\or drei{\ss}ig% -\or vierzig% -\or f\"unfzig% -\or sechzig% -\or siebzig% -\or achtzig% -\or neunzig% -\or einhundert% +\newcommand*{\@@tenthstringenglish}[1]{% +\ifcase#1\relax +\or tenth% +\or twentieth% +\or thirtieth% +\or fortieth% +\or fiftieth% +\or sixtieth% +\or seventieth% +\or eightieth% +\or ninetieth% \fi } -% \end{macrocode} -% |\einhundert| is set to |einhundert| by default, user can -% redefine this command to just |hundert| if required, similarly -% for |\eintausend|. -% \begin{macrocode} -\providecommand*{\einhundert}{einhundert} -\providecommand*{\eintausend}{eintausend} -% \end{macrocode} -% Teens: -% \begin{macrocode} -\newcommand{\@@teenstringgerman}[1]{% -\ifcase#1% -zehn% -\or elf% -\or zw\"olf% -\or dreizehn% -\or vierzehn% -\or f\"unfzehn% -\or sechzehn% -\or siebzehn% -\or achtzehn% -\or neunzehn% +% \end{macrocode} +% The teens: +% \begin{macrocode} +\newcommand*{\@@teenthstringenglish}[1]{% +\ifcase#1\relax +tenth% +\or eleventh% +\or twelfth% +\or thirteenth% +\or fourteenth% +\or fifteenth% +\or sixteenth% +\or seventeenth% +\or eighteenth% +\or nineteenth% +\fi +} +% \end{macrocode} +% As before, but with the first letter in upper case. The units: +% \begin{macrocode} +\newcommand*{\@@Unitthstringenglish}[1]{% +\ifcase#1\relax +Zeroth% +\or First% +\or Second% +\or Third% +\or Fourth% +\or Fifth% +\or Sixth% +\or Seventh% +\or Eighth% +\or Ninth% \fi } % \end{macrocode} -% The results are stored in the second argument, but doesn't -% display anything. -% \begin{macrocode} -\DeclareRobustCommand{\@numberstringMgerman}[2]{% -\let\@unitstring=\@@unitstringgerman -\let\@teenstring=\@@teenstringgerman -\let\@tenstring=\@@tenstringgerman -\@@numberstringgerman{#1}{#2}} -% \end{macrocode} -% Feminine and neuter forms: -% \begin{macrocode} -\let\@numberstringFgerman=\@numberstringMgerman -\let\@numberstringNgerman=\@numberstringMgerman -% \end{macrocode} -% As above, but initial letters in upper case: -% \begin{macrocode} -\DeclareRobustCommand{\@NumberstringMgerman}[2]{% -\@numberstringMgerman{#1}{\@@num@str}% -\edef#2{\noexpand\MakeUppercase\@@num@str}} -% \end{macrocode} -% Feminine and neuter form: -% \begin{macrocode} -\let\@NumberstringFgerman=\@NumberstringMgerman -\let\@NumberstringNgerman=\@NumberstringMgerman -% \end{macrocode} -% As above, but for ordinals. -% \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringMgerman}[2]{% -\let\@unitthstring=\@@unitthstringMgerman -\let\@teenthstring=\@@teenthstringMgerman -\let\@tenthstring=\@@tenthstringMgerman -\let\@unitstring=\@@unitstringgerman -\let\@teenstring=\@@teenstringgerman -\let\@tenstring=\@@tenstringgerman -\def\@thousandth{tausendster}% -\def\@hundredth{hundertster}% -\@@ordinalstringgerman{#1}{#2}} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringFgerman}[2]{% -\let\@unitthstring=\@@unitthstringFgerman -\let\@teenthstring=\@@teenthstringFgerman -\let\@tenthstring=\@@tenthstringFgerman -\let\@unitstring=\@@unitstringgerman -\let\@teenstring=\@@teenstringgerman -\let\@tenstring=\@@tenstringgerman -\def\@thousandth{tausendste}% -\def\@hundredth{hundertste}% -\@@ordinalstringgerman{#1}{#2}} -% \end{macrocode} -% Neuter form: -% \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringNgerman}[2]{% -\let\@unitthstring=\@@unitthstringNgerman -\let\@teenthstring=\@@teenthstringNgerman -\let\@tenthstring=\@@tenthstringNgerman -\let\@unitstring=\@@unitstringgerman -\let\@teenstring=\@@teenstringgerman -\let\@tenstring=\@@tenstringgerman -\def\@thousandth{tausendstes}% -\def\@hundredth{hunderstes}% -\@@ordinalstringgerman{#1}{#2}} -% \end{macrocode} -% As above, but with initial letters in upper case. -% \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMgerman}[2]{% -\@ordinalstringMgerman{#1}{\@@num@str}% -\edef#2{\protect\MakeUppercase\@@num@str}} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringFgerman}[2]{% -\@ordinalstringFgerman{#1}{\@@num@str}% -\edef#2{\protect\MakeUppercase\@@num@str}} -% \end{macrocode} -% Neuter form: -% \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringNgerman}[2]{% -\@ordinalstringNgerman{#1}{\@@num@str}% -\edef#2{\protect\MakeUppercase\@@num@str}} -% \end{macrocode} -% Code for converting numbers into textual ordinals. As before, -% it is easier to split it into units, tens and teens. -% Units: +% The tens: % \begin{macrocode} -\newcommand{\@@unitthstringMgerman}[1]{% -\ifcase#1% -nullter% -\or erster% -\or zweiter% -\or dritter% -\or vierter% -\or f\"unter% -\or sechster% -\or siebter% -\or achter% -\or neunter% +\newcommand*{\@@Tenthstringenglish}[1]{% +\ifcase#1\relax +\or Tenth% +\or Twentieth% +\or Thirtieth% +\or Fortieth% +\or Fiftieth% +\or Sixtieth% +\or Seventieth% +\or Eightieth% +\or Ninetieth% \fi } % \end{macrocode} -% Tens: +% The teens: % \begin{macrocode} -\newcommand{\@@tenthstringMgerman}[1]{% -\ifcase#1% -\or zehnter% -\or zwanzigster% -\or drei{\ss}igster% -\or vierzigster% -\or f\"unfzigster% -\or sechzigster% -\or siebzigster% -\or achtzigster% -\or neunzigster% +\newcommand*{\@@Teenthstringenglish}[1]{% +\ifcase#1\relax +Tenth% +\or Eleventh% +\or Twelfth% +\or Thirteenth% +\or Fourteenth% +\or Fifteenth% +\or Sixteenth% +\or Seventeenth% +\or Eighteenth% +\or Nineteenth% \fi } % \end{macrocode} -% Teens: -% \begin{macrocode} -\newcommand{\@@teenthstringMgerman}[1]{% -\ifcase#1% -zehnter% -\or elfter% -\or zw\"olfter% -\or dreizehnter% -\or vierzehnter% -\or f\"unfzehnter% -\or sechzehnter% -\or siebzehnter% -\or achtzehnter% -\or neunzehnter% +% Again, as from version 1.09, this has been changed to take two +% arguments, where the second argument is a control sequence. +% The resulting text is stored in the control sequence, and nothing +% is displayed. +% \begin{macrocode} +\newcommand*{\@@ordinalstringenglish}[2]{% +\@strctr=#1\relax +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000 (value given: \number\@strctr)}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\fi +\def#2{}% +\fi +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>9\relax +% #1 is greater or equal to 10000 + \divide\@strctr by 10 + \ifnum\@strctr>1\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr-\@unitstring{\@strctr}}% + \fi + \else + \@strctr=#1\relax \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenstring{\@strctr}}% + \fi + \@strctr=#1\relax \@modulo{\@strctr}{1000}% + \ifnum\@strctr=0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@thousandth}% + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@thousand}% + \fi +\else + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{1000}% + \let\@@fc@ordstr#2\relax + \ifnum\@strctr=0\relax + \edef#2{\@@fc@ordstr\ \@thousandth}% + \else + \edef#2{\@@fc@ordstr\ \@thousand}% + \fi + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{1000}% +\divide\@strctr by 100 +\ifnum\@strctr>0\relax + \ifnum#1>1000\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ }% + \fi + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{100}% + \let\@@fc@ordstr#2\relax + \ifnum\@strctr=0\relax + \edef#2{\@@fc@ordstr\ \@hundredth}% + \else + \edef#2{\@@fc@ordstr\ \@hundred}% + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{100}% +\ifnum#1>100\relax + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@andname\ }% + \fi +\fi +\ifnum\@strctr>19\relax + \@tmpstrctr=\@strctr + \divide\@strctr by 10\relax + \@modulo{\@tmpstrctr}{10}% + \let\@@fc@ordstr#2\relax + \ifnum\@tmpstrctr=0\relax + \edef#2{\@@fc@ordstr\@tenthstring{\@strctr}}% + \else + \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% + \fi + \@strctr=#1\relax \@modulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr-\@unitthstring{\@strctr}}% + \fi +\else + \ifnum\@strctr<10\relax + \ifnum\@strctr=0\relax + \ifnum#1<100\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi + \else + \@modulo{\@strctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% + \fi \fi } % \end{macrocode} -% Units (feminine): +% All lower case version. Again, the second argument must be a +% control sequence in which the resulting text is stored. % \begin{macrocode} -\newcommand{\@@unitthstringFgerman}[1]{% -\ifcase#1% -nullte% -\or erste% -\or zweite% -\or dritte% -\or vierte% -\or f\"unfte% -\or sechste% -\or siebte% -\or achte% -\or neunte% -\fi -} +\DeclareRobustCommand{\@ordinalstringMenglish}[2]{% +\let\@unitthstring=\@@unitthstringenglish +\let\@teenthstring=\@@teenthstringenglish +\let\@tenthstring=\@@tenthstringenglish +\let\@unitstring=\@@unitstringenglish +\let\@teenstring=\@@teenstringenglish +\let\@tenstring=\@@tenstringenglish +\def\@andname{and}% +\def\@hundred{hundred}\def\@thousand{thousand}% +\def\@hundredth{hundredth}\def\@thousandth{thousandth}% +\@@ordinalstringenglish{#1}{#2}} % \end{macrocode} -% Tens (feminine): +% No gender in English, so make feminine and neuter same as masculine: % \begin{macrocode} -\newcommand{\@@tenthstringFgerman}[1]{% -\ifcase#1% -\or zehnte% -\or zwanzigste% -\or drei{\ss}igste% -\or vierzigste% -\or f\"unfzigste% -\or sechzigste% -\or siebzigste% -\or achtzigste% -\or neunzigste% -\fi -} +\let\@ordinalstringFenglish=\@ordinalstringMenglish +\let\@ordinalstringNenglish=\@ordinalstringMenglish % \end{macrocode} -% Teens (feminine) +% First letter of each word in upper case: % \begin{macrocode} -\newcommand{\@@teenthstringFgerman}[1]{% -\ifcase#1% -zehnte% -\or elfte% -\or zw\"olfte% -\or dreizehnte% -\or vierzehnte% -\or f\"unfzehnte% -\or sechzehnte% -\or siebzehnte% -\or achtzehnte% -\or neunzehnte% -\fi -} +\DeclareRobustCommand{\@OrdinalstringMenglish}[2]{% +\let\@unitthstring=\@@Unitthstringenglish +\let\@teenthstring=\@@Teenthstringenglish +\let\@tenthstring=\@@Tenthstringenglish +\let\@unitstring=\@@Unitstringenglish +\let\@teenstring=\@@Teenstringenglish +\let\@tenstring=\@@Tenstringenglish +\def\@andname{and}% +\def\@hundred{Hundred}\def\@thousand{Thousand}% +\def\@hundredth{Hundredth}\def\@thousandth{Thousandth}% +\@@ordinalstringenglish{#1}{#2}} % \end{macrocode} -% Units (neuter): +% No gender in English, so make feminine and neuter same as masculine: % \begin{macrocode} -\newcommand{\@@unitthstringNgerman}[1]{% -\ifcase#1% -nulltes% -\or erstes% -\or zweites% -\or drittes% -\or viertes% -\or f\"unte% -\or sechstes% -\or siebtes% -\or achtes% -\or neuntes% -\fi -} +\let\@OrdinalstringFenglish=\@OrdinalstringMenglish +\let\@OrdinalstringNenglish=\@OrdinalstringMenglish % \end{macrocode} -% Tens (neuter): +%\iffalse % \begin{macrocode} -\newcommand{\@@tenthstringNgerman}[1]{% -\ifcase#1% -\or zehntes% -\or zwanzigstes% -\or drei{\ss}igstes% -\or vierzigstes% -\or f\"unfzigstes% -\or sechzigstes% -\or siebzigstes% -\or achtzigstes% -\or neunzigstes% -\fi -} +% % \end{macrocode} -% Teens (neuter) +%\fi +%\iffalse % \begin{macrocode} -\newcommand{\@@teenthstringNgerman}[1]{% -\ifcase#1% -zehntes% -\or elftes% -\or zw\"olftes% -\or dreizehntes% -\or vierzehntes% -\or f\"unfzehntes% -\or sechzehntes% -\or siebzehntes% -\or achtzehntes% -\or neunzehntes% -\fi -} +%<*fc-french.def> % \end{macrocode} -% This appends the results to |#2| for number |#2| (in range 0 to 100.) -% null and eins are dealt with separately in |\@@numberstringgerman|. +%\fi +% \subsubsection{fc-french.def} +% French definitions % \begin{macrocode} -\newcommand{\@@numberunderhundredgerman}[2]{% -\ifnum#1<10\relax - \ifnum#1>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{#1}}% +\ProvidesFile{fc-french.def}[2007/05/26] +% \end{macrocode} +% Define macro that converts a number or count register (first +% argument) to an ordinal, and store the result in the second +% argument, which must be a control sequence. Masculine: +% \begin{macrocode} +\newcommand*{\@ordinalMfrench}[2]{% +\iffmtord@abbrv + \edef#2{\number#1\relax\noexpand\fmtord{e}}% +\else + \ifnum#1=1\relax + \edef#2{\number#1\relax\noexpand\fmtord{er}}% + \else + \edef#2{\number#1\relax\noexpand\fmtord{eme}}% \fi +\fi} +% \end{macrocode} +% Feminine: +% \begin{macrocode} +\newcommand*{\@ordinalFfrench}[2]{% +\iffmtord@abbrv + \edef#2{\number#1\relax\noexpand\fmtord{e}}% \else - \@tmpstrctr=#1\relax - \@modulo{\@tmpstrctr}{10}% - \ifnum#1<20\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@tmpstrctr}}% + \ifnum#1=1\relax + \edef#2{\number#1\relax\noexpand\fmtord{ere}}% \else - \ifnum\@tmpstrctr=0\relax - \else - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@tmpstrctr}und}% - \fi - \@tmpstrctr=#1\relax - \divide\@tmpstrctr by 10\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@tmpstrctr}}% + \edef#2{\number#1\relax\noexpand\fmtord{eme}}% \fi +\fi} +% \end{macrocode} +% Make neuter same as masculine: +% \begin{macrocode} +\let\@ordinalNfrench\@ordinalMfrench +% \end{macrocode} +% Textual representation of a number. To make it easier break it +% into units, tens and teens. First the units: +% \begin{macrocode} +\newcommand*{\@@unitstringfrench}[1]{% +\ifcase#1\relax +zero% +\or un% +\or deux% +\or trois% +\or quatre% +\or cinq% +\or six% +\or sept% +\or huit% +\or neuf% \fi } % \end{macrocode} -% This stores the results in the second argument -% (which must be a control -% sequence), but it doesn't display anything. +% Feminine only changes for 1: % \begin{macrocode} -\newcommand{\@@numberstringgerman}[2]{% -\ifnum#1>99999\relax - \PackageError{fmtcount}{Out of range}% - {This macro only works for values less than 100000}% -\else - \ifnum#1<0\relax - \PackageError{fmtcount}{Negative numbers not permitted}% - {This macro does not work for negative numbers, however - you can try typing "minus" first, and then pass the modulus of - this number}% - \fi +\newcommand*{\@@unitstringFfrench}[1]{% +\ifnum#1=1\relax +une% +\else\@@unitstringfrench{#1}% \fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>1\relax -% #1 is >= 2000, \@strctr now contains the number of thousands -\@@numberunderhundredgerman{\@strctr}{#2}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr tausend}% -\else -% #1 lies in range [1000,1999] - \ifnum\@strctr=1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\eintausend}% - \fi +} +% \end{macrocode} +% Tens (this includes the Belgian and Swiss variants, special +% cases employed lower down.) +% \begin{macrocode} +\newcommand*{\@@tenstringfrench}[1]{% +\ifcase#1\relax +\or dix% +\or vingt% +\or trente% +\or quarante% +\or cinquante% +\or soixante% +\or septente% +\or huitante% +\or nonente% +\or cent% \fi -\@strctr=#1\relax -\@modulo{\@strctr}{1000}% -\divide\@strctr by 100\relax -\ifnum\@strctr>1\relax -% now dealing with number in range [200,999] - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}hundert}% -\else - \ifnum\@strctr=1\relax -% dealing with number in range [100,199] - \ifnum#1>1000\relax -% if orginal number > 1000, use einhundert - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr einhundert}% - \else -% otherwise use \einhundert - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\einhundert}% - \fi - \fi +} +% \end{macrocode} +% Teens: +% \begin{macrocode} +\newcommand*{\@@teenstringfrench}[1]{% +\ifcase#1\relax +dix% +\or onze% +\or douze% +\or treize% +\or quatorze% +\or quinze% +\or seize% +\or dix-sept% +\or dix-huit% +\or dix-neuf% \fi -\@strctr=#1\relax -\@modulo{\@strctr}{100}% -\ifnum#1=0\relax - \def#2{null}% +} +% \end{macrocode} +% Seventies are a special case, depending on dialect: +% \begin{macrocode} +\newcommand*{\@@seventiesfrench}[1]{% +\@tenstring{6}% +\ifnum#1=1\relax +\ \@andname\ \else - \ifnum\@strctr=1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr eins}% - \else - \@@numberunderhundredgerman{\@strctr}{#2}% - \fi +-% \fi +\@teenstring{#1}% } % \end{macrocode} -% As above, but for ordinals +% Eighties are a special case, depending on dialect: % \begin{macrocode} -\newcommand{\@@numberunderhundredthgerman}[2]{% -\ifnum#1<10\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitthstring{#1}}% +\newcommand*{\@@eightiesfrench}[1]{% +\@unitstring{4}-\@tenstring{2}% +\ifnum#1>0 +-\@unitstring{#1}% \else - \@tmpstrctr=#1\relax - \@modulo{\@tmpstrctr}{10}% - \ifnum#1<20\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenthstring{\@tmpstrctr}}% - \else - \ifnum\@tmpstrctr=0\relax - \else - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@tmpstrctr}und}% - \fi - \@tmpstrctr=#1\relax - \divide\@tmpstrctr by 10\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenthstring{\@tmpstrctr}}% - \fi +s% \fi } % \end{macrocode} +% Nineties are a special case, depending on dialect: % \begin{macrocode} -\newcommand{\@@ordinalstringgerman}[2]{% -\ifnum#1>99999\relax - \PackageError{fmtcount}{Out of range}% - {This macro only works for values less than 100000}% -\else - \ifnum#1<0\relax - \PackageError{fmtcount}{Negative numbers not permitted}% - {This macro does not work for negative numbers, however - you can try typing "minus" first, and then pass the modulus of - this number}% - \fi +\newcommand*{\@@ninetiesfrench}[1]{% +\@unitstring{4}-\@tenstring{2}-\@teenstring{#1}% +} +% \end{macrocode} +% Swiss seventies: +% \begin{macrocode} +\newcommand*{\@@seventiesfrenchswiss}[1]{% +\@tenstring{7}% +\ifnum#1=1\ \@andname\ \fi +\ifnum#1>1-\fi +\ifnum#1>0\@unitstring{#1}\fi +} +% \end{macrocode} +% Swiss eighties: +% \begin{macrocode} +\newcommand*{\@@eightiesfrenchswiss}[1]{% +\@tenstring{8}% +\ifnum#1=1\ \@andname\ \fi +\ifnum#1>1-\fi +\ifnum#1>0\@unitstring{#1}\fi +} +% \end{macrocode} +% Swiss nineties: +% \begin{macrocode} +\newcommand*{\@@ninetiesfrenchswiss}[1]{% +\@tenstring{9}% +\ifnum#1=1\ \@andname\ \fi +\ifnum#1>1-\fi +\ifnum#1>0\@unitstring{#1}\fi +} +% \end{macrocode} +% Units with initial letter in upper case: +% \begin{macrocode} +\newcommand*{\@@Unitstringfrench}[1]{% +\ifcase#1\relax +Zero% +\or Un% +\or Deux% +\or Trois% +\or Quatre% +\or Cinq% +\or Six% +\or Sept% +\or Huit% +\or Neuf% \fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>1\relax -% #1 is >= 2000, \@strctr now contains the number of thousands -\@@numberunderhundredgerman{\@strctr}{#2}% - \let\@@fc@numstr#2\relax - % is that it, or is there more? - \@tmpstrctr=#1\relax \@modulo{\@tmpstrctr}{1000}% - \ifnum\@tmpstrctr=0\relax - \edef#2{\@@fc@numstr\@thousandth}% - \else - \edef#2{\@@fc@numstr tausend}% - \fi -\else -% #1 lies in range [1000,1999] - \ifnum\@strctr=1\relax - \ifnum#1=1000\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@thousandth}% - \else - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\eintausend}% - \fi - \fi -\fi -\@strctr=#1\relax -\@modulo{\@strctr}{1000}% -\divide\@strctr by 100\relax -\ifnum\@strctr>1\relax -% now dealing with number in range [200,999] - \let\@@fc@numstr#2\relax - % is that it, or is there more? - \@tmpstrctr=#1\relax \@modulo{\@tmpstrctr}{100}% - \ifnum\@tmpstrctr=0\relax - \ifnum\@strctr=1\relax - \edef#2{\@@fc@numstr\@hundredth}% - \else - \edef#2{\@@fc@numstr\@unitstring{\@strctr}\@hundredth}% - \fi - \else - \edef#2{\@@fc@numstr\@unitstring{\@strctr}hundert}% - \fi -\else - \ifnum\@strctr=1\relax -% dealing with number in range [100,199] -% is that it, or is there more? - \@tmpstrctr=#1\relax \@modulo{\@tmpstrctr}{100}% - \ifnum\@tmpstrctr=0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@hundredth}% - \else - \ifnum#1>1000\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr einhundert}% - \else - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\einhundert}% - \fi - \fi - \fi -\fi -\@strctr=#1\relax -\@modulo{\@strctr}{100}% -\ifthenelse{\@strctr=0 \and #1>0}{}{% -\@@numberunderhundredthgerman{\@strctr}{#2}% -}% } % \end{macrocode} -% Set |ngerman| to be equivalent to |german|. Is it okay to do -% this? (I don't know the difference between the two.) +% As above, but feminine: % \begin{macrocode} -\let\@ordinalMngerman=\@ordinalMgerman -\let\@ordinalFngerman=\@ordinalFgerman -\let\@ordinalNngerman=\@ordinalNgerman -\let\@numberstringMngerman=\@numberstringMgerman -\let\@numberstringFngerman=\@numberstringFgerman -\let\@numberstringNngerman=\@numberstringNgerman -\let\@NumberstringMngerman=\@NumberstringMgerman -\let\@NumberstringFngerman=\@NumberstringFgerman -\let\@NumberstringNngerman=\@NumberstringNgerman -\let\@ordinalstringMngerman=\@ordinalstringMgerman -\let\@ordinalstringFngerman=\@ordinalstringFgerman -\let\@ordinalstringNngerman=\@ordinalstringNgerman -\let\@OrdinalstringMngerman=\@OrdinalstringMgerman -\let\@OrdinalstringFngerman=\@OrdinalstringFgerman -\let\@OrdinalstringNngerman=\@OrdinalstringNgerman +\newcommand*{\@@UnitstringFfrench}[1]{% +\ifnum#1=1\relax +Une% +\else \@@Unitstringfrench{#1}% +\fi +} % \end{macrocode} -%\iffalse +% Tens, with initial letter in upper case (includes Swiss and +% Belgian variants): % \begin{macrocode} -% +\newcommand*{\@@Tenstringfrench}[1]{% +\ifcase#1\relax +\or Dix% +\or Vingt% +\or Trente% +\or Quarante% +\or Cinquante% +\or Soixante% +\or Septente% +\or Huitante% +\or Nonente% +\or Cent% +\fi +} % \end{macrocode} -%\fi -%\iffalse +% Teens, with initial letter in upper case: % \begin{macrocode} -%<*fc-portuges.def> +\newcommand*{\@@Teenstringfrench}[1]{% +\ifcase#1\relax +Dix% +\or Onze% +\or Douze% +\or Treize% +\or Quatorze% +\or Quinze% +\or Seize% +\or Dix-Sept% +\or Dix-Huit% +\or Dix-Neuf% +\fi +} % \end{macrocode} -%\fi -% \subsection{fc-portuges.def} -% Portuguse definitions +% This has changed in version 1.09, so that it now stores the +% result in the second argument, but doesn't display anything. +% Since it only affects internal macros, it shouldn't affect +% documents created with older versions. (These internal macros +% are not defined for use in documents.) Firstly, the Swiss +% version: % \begin{macrocode} -\ProvidesFile{fc-portuges.def}[2007/05/26] +\DeclareRobustCommand{\@numberstringMfrenchswiss}[2]{% +\let\@unitstring=\@@unitstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundred{cent}\def\@thousand{mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Define macro that converts a number or count register (first -% argument) to an ordinal, and stores the result in the second -% argument, which should be a control sequence. Masculine: +% Same as above, but for French as spoken in France: % \begin{macrocode} -\newcommand*{\@ordinalMportuges}[2]{% -\ifnum#1=0\relax - \edef#2{\number#1}% -\else - \edef#2{\number#1\relax\noexpand\fmtord{o}}% -\fi} +\DeclareRobustCommand{\@numberstringMfrenchfrance}[2]{% +\let\@unitstring=\@@unitstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{cent}\def\@thousand{mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Feminine: +% Same as above, but for Belgian dialect: % \begin{macrocode} -\newcommand*{\@ordinalFportuges}[2]{% -\ifnum#1=0\relax - \edef#2{\number#1}% -\else - \edef#2{\number#1\relax\noexpand\fmtord{a}}% -\fi} +\DeclareRobustCommand{\@numberstringMfrenchbelgian}[2]{% +\let\@unitstring=\@@unitstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{cent}\def\@thousand{mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Make neuter same as masculine: +% Set default dialect: % \begin{macrocode} -\let\@ordinalNportuges\@ordinalMportuges +\let\@numberstringMfrench=\@numberstringMfrenchfrance % \end{macrocode} -% Convert a number to a textual representation. To make it easier, -% split it up into units, tens, teens and hundreds. Units (argument must -% be a number from 0 to 9): +% As above, but for feminine version. Swiss: % \begin{macrocode} -\newcommand*{\@@unitstringportuges}[1]{% -\ifcase#1\relax -zero% -\or um% -\or dois% -\or tr\^es% -\or quatro% -\or cinco% -\or seis% -\or sete% -\or oito% -\or nove% -\fi -} -% \end{macrocode} -% As above, but for feminine: -% \begin{macrocode} -\newcommand*{\@@unitstringFportuges}[1]{% -\ifcase#1\relax -zero% -\or uma% -\or duas% -\or tr\^es% -\or quatro% -\or cinco% -\or seis% -\or sete% -\or oito% -\or nove% -\fi -} +\DeclareRobustCommand{\@numberstringFfrenchswiss}[2]{% +\let\@unitstring=\@@unitstringFfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundred{cent}\def\@thousand{mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Tens (argument must be a number from 0 to 10): +% French: % \begin{macrocode} -\newcommand*{\@@tenstringportuges}[1]{% -\ifcase#1\relax -\or dez% -\or vinte% -\or trinta% -\or quarenta% -\or cinq\"uenta% -\or sessenta% -\or setenta% -\or oitenta% -\or noventa% -\or cem% -\fi -} +\DeclareRobustCommand{\@numberstringFfrenchfrance}[2]{% +\let\@unitstring=\@@unitstringFfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{cent}\def\@thousand{mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Teens (argument must be a number from 0 to 9): +% Belgian: % \begin{macrocode} -\newcommand*{\@@teenstringportuges}[1]{% -\ifcase#1\relax -dez% -\or onze% -\or doze% -\or treze% -\or quatorze% -\or quinze% -\or dezesseis% -\or dezessete% -\or dezoito% -\or dezenove% -\fi -} +\DeclareRobustCommand{\@numberstringFfrenchbelgian}[2]{% +\let\@unitstring=\@@unitstringFfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{cent}\def\@thousand{mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Hundreds: +% Set default dialect: % \begin{macrocode} -\newcommand*{\@@hundredstringportuges}[1]{% -\ifcase#1\relax -\or cento% -\or duzentos% -\or trezentos% -\or quatrocentos% -\or quinhentos% -\or seiscentos% -\or setecentos% -\or oitocentos% -\or novecentos% -\fi} +\let\@numberstringFfrench=\@numberstringFfrenchfrance % \end{macrocode} -% Hundreds (feminine): +% Make neuter same as masculine: % \begin{macrocode} -\newcommand*{\@@hundredstringFportuges}[1]{% -\ifcase#1\relax -\or cento% -\or duzentas% -\or trezentas% -\or quatrocentas% -\or quinhentas% -\or seiscentas% -\or setecentas% -\or oitocentas% -\or novecentas% -\fi} +\let\@ordinalstringNfrench\@ordinalstringMfrench % \end{macrocode} -% Units (initial letter in upper case): +% As above, but with initial letter in upper case. Swiss (masculine): % \begin{macrocode} -\newcommand*{\@@Unitstringportuges}[1]{% -\ifcase#1\relax -Zero% -\or Um% -\or Dois% -\or Tr\^es% -\or Quatro% -\or Cinco% -\or Seis% -\or Sete% -\or Oito% -\or Nove% -\fi -} +\DeclareRobustCommand{\@NumberstringMfrenchswiss}[2]{% +\let\@unitstring=\@@Unitstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundred{Cent}\def\@thousand{Mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% As above, but feminine: +% French: % \begin{macrocode} -\newcommand*{\@@UnitstringFportuges}[1]{% -\ifcase#1\relax -Zera% -\or Uma% -\or Duas% -\or Tr\^es% -\or Quatro% -\or Cinco% -\or Seis% -\or Sete% -\or Oito% -\or Nove% -\fi -} +\DeclareRobustCommand{\@NumberstringMfrenchfrance}[2]{% +\let\@unitstring=\@@Unitstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{Cent}\def\@thousand{Mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Tens (with initial letter in upper case): +% Belgian: % \begin{macrocode} -\newcommand*{\@@Tenstringportuges}[1]{% -\ifcase#1\relax -\or Dez% -\or Vinte% -\or Trinta% -\or Quarenta% -\or Cinq\"uenta% -\or Sessenta% -\or Setenta% -\or Oitenta% -\or Noventa% -\or Cem% -\fi -} +\DeclareRobustCommand{\@NumberstringMfrenchbelgian}[2]{% +\let\@unitstring=\@@Unitstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{Cent}\def\@thousand{Mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% Teens (with initial letter in upper case): +% Set default dialect: % \begin{macrocode} -\newcommand*{\@@Teenstringportuges}[1]{% -\ifcase#1\relax -Dez% -\or Onze% -\or Doze% -\or Treze% -\or Quatorze% -\or Quinze% -\or Dezesseis% -\or Dezessete% -\or Dezoito% -\or Dezenove% -\fi -} +\let\@NumberstringMfrench=\@NumberstringMfrenchfrance % \end{macrocode} -% Hundreds (with initial letter in upper case): +% As above, but feminine. Swiss: % \begin{macrocode} -\newcommand*{\@@Hundredstringportuges}[1]{% -\ifcase#1\relax -\or Cento% -\or Duzentos% -\or Trezentos% -\or Quatrocentos% -\or Quinhentos% -\or Seiscentos% -\or Setecentos% -\or Oitocentos% -\or Novecentos% -\fi} +\DeclareRobustCommand{\@NumberstringFfrenchswiss}[2]{% +\let\@unitstring=\@@UnitstringFfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundred{Cent}\def\@thousand{Mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% As above, but feminine: +% French (feminine): % \begin{macrocode} -\newcommand*{\@@HundredstringFportuges}[1]{% -\ifcase#1\relax -\or Cento% -\or Duzentas% -\or Trezentas% -\or Quatrocentas% -\or Quinhentas% -\or Seiscentas% -\or Setecentas% -\or Oitocentas% -\or Novecentas% -\fi} +\DeclareRobustCommand{\@NumberstringFfrenchfrance}[2]{% +\let\@unitstring=\@@UnitstringFfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{Cent}\def\@thousand{Mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% This has changed in version 1.08, so that it now stores -% the result in the second argument, but doesn't display -% anything. Since it only affects internal macros, it shouldn't -% affect documents created with older versions. (These internal -% macros are not meant for use in documents.) +% Belgian (feminine): % \begin{macrocode} -\DeclareRobustCommand{\@numberstringMportuges}[2]{% -\let\@unitstring=\@@unitstringportuges -\let\@teenstring=\@@teenstringportuges -\let\@tenstring=\@@tenstringportuges -\let\@hundredstring=\@@hundredstringportuges -\def\@hundred{cem}\def\@thousand{mil}% -\def\@andname{e}% -\@@numberstringportuges{#1}{#2}} +\DeclareRobustCommand{\@NumberstringFfrenchbelgian}[2]{% +\let\@unitstring=\@@UnitstringFfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\def\@hundred{Cent}\def\@thousand{Mille}% +\def\@andname{et}% +\@@numberstringfrench{#1}{#2}} % \end{macrocode} -% As above, but feminine form: +% Set default dialect: % \begin{macrocode} -\DeclareRobustCommand{\@numberstringFportuges}[2]{% -\let\@unitstring=\@@unitstringFportuges -\let\@teenstring=\@@teenstringportuges -\let\@tenstring=\@@tenstringportuges -\let\@hundredstring=\@@hundredstringFportuges -\def\@hundred{cem}\def\@thousand{mil}% -\def\@andname{e}% -\@@numberstringportuges{#1}{#2}} +\let\@NumberstringFfrench=\@NumberstringFfrenchfrance % \end{macrocode} % Make neuter same as masculine: % \begin{macrocode} -\let\@numberstringNportuges\@numberstringMportuges +\let\@NumberstringNfrench\@NumberstringMfrench +% \end{macrocode} +% Again, as from version 1.09, this has been changed to take +% two arguments, where the second argument is a control +% sequence, and nothing is displayed. Store textual representation +% of an ordinal in the given control sequence. Swiss dialect (masculine): +% \begin{macrocode} +\DeclareRobustCommand{\@ordinalstringMfrenchswiss}[2]{% +\ifnum#1=1\relax +\def#2{premier}% +\else +\let\@unitthstring=\@@unitthstringfrench +\let\@unitstring=\@@unitstringfrench +\let\@teenthstring=\@@teenthstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenthstring=\@@tenthstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrenchswiss +\let\@ninetieths=\@@ninetiethsfrenchswiss +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundredth{centi\`eme}\def\@hundred{cent}% +\def\@thousandth{mili\`eme}\def\@thousand{mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% French (masculine): +% \begin{macrocode} +\DeclareRobustCommand{\@ordinalstringMfrenchfrance}[2]{% +\ifnum#1=1\relax +\def#2{premier}% +\else +\let\@unitthstring=\@@unitthstringfrench +\let\@unitstring=\@@unitstringfrench +\let\@teenthstring=\@@teenthstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenthstring=\@@tenthstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventieths=\@@seventiethsfrench +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@teenstringfrench +\def\@hundredth{centi\`eme}\def\@hundred{cent}% +\def\@thousandth{mili\`eme}\def\@thousand{mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Belgian dialect (masculine): +% \begin{macrocode} +\DeclareRobustCommand{\@ordinalstringMfrenchbelgian}[2]{% +\ifnum#1=1\relax +\def#2{premier}% +\else +\let\@unitthstring=\@@unitthstringfrench +\let\@unitstring=\@@unitstringfrench +\let\@teenthstring=\@@teenthstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenthstring=\@@tenthstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrenchswiss +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@teenstringfrench +\def\@hundredth{centi\`eme}\def\@hundred{cent}% +\def\@thousandth{mili\`eme}\def\@thousand{mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Set up default dialect: +% \begin{macrocode} +\let\@ordinalstringMfrench=\@ordinalstringMfrenchfrance +% \end{macrocode} +% As above, but feminine. Swiss: +% \begin{macrocode} +\DeclareRobustCommand{\@ordinalstringFfrenchswiss}[2]{% +\ifnum#1=1\relax +\def#2{premi\`ere}% +\else +\let\@unitthstring=\@@unitthstringfrench +\let\@unitstring=\@@unitstringFfrench +\let\@teenthstring=\@@teenthstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenthstring=\@@tenthstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrenchswiss +\let\@ninetieths=\@@ninetiethsfrenchswiss +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundredth{centi\`eme}\def\@hundred{cent}% +\def\@thousandth{mili\`eme}\def\@thousand{mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% French (feminine): +% \begin{macrocode} +\DeclareRobustCommand{\@ordinalstringFfrenchfrance}[2]{% +\ifnum#1=1\relax +\def#2{premi\`ere}% +\else +\let\@unitthstring=\@@unitthstringfrench +\let\@unitstring=\@@unitstringFfrench +\let\@teenthstring=\@@teenthstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenthstring=\@@tenthstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventieths=\@@seventiethsfrench +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@teenstringfrench +\def\@hundredth{centi\`eme}\def\@hundred{cent}% +\def\@thousandth{mili\`eme}\def\@thousand{mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Belgian (feminine): +% \begin{macrocode} +\DeclareRobustCommand{\@ordinalstringFfrenchbelgian}[2]{% +\ifnum#1=1\relax +\def#2{premi\`ere}% +\else +\let\@unitthstring=\@@unitthstringfrench +\let\@unitstring=\@@unitstringFfrench +\let\@teenthstring=\@@teenthstringfrench +\let\@teenstring=\@@teenstringfrench +\let\@tenthstring=\@@tenthstringfrench +\let\@tenstring=\@@tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@teenstringfrench +\def\@hundredth{centi\`eme}\def\@hundred{cent}% +\def\@thousandth{mili\`eme}\def\@thousand{mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Set up default dialect: +% \begin{macrocode} +\let\@ordinalstringFfrench=\@ordinalstringFfrenchfrance +% \end{macrocode} +% Make neuter same as masculine: +% \begin{macrocode} +\let\@ordinalstringNfrench\@ordinalstringMfrench +% \end{macrocode} +% As above, but with initial letters in upper case. Swiss (masculine): +% \begin{macrocode} +\DeclareRobustCommand{\@OrdinalstringMfrenchswiss}[2]{% +\ifnum#1=1\relax +\def#2{Premi\`ere}% +\else +\let\@unitthstring=\@@Unitthstringfrench +\let\@unitstring=\@@Unitstringfrench +\let\@teenthstring=\@@Teenthstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenthstring=\@@Tenthstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrenchswiss +\let\@ninetieths=\@@ninetiethsfrenchswiss +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% +\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% French (masculine): +% \begin{macrocode} +\DeclareRobustCommand{\@OrdinalstringMfrenchfrance}[2]{% +\ifnum#1=1\relax +\def#2{Premi\`ere}% +\else +\let\@unitthstring=\@@Unitthstringfrench +\let\@unitstring=\@@Unitstringfrench +\let\@teenthstring=\@@Teenthstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenthstring=\@@Tenthstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventieths=\@@seventiethsfrench +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@Teenstringfrench +\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% +\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Belgian (masculine): +% \begin{macrocode} +\DeclareRobustCommand{\@OrdinalstringMfrenchbelgian}[2]{% +\ifnum#1=1\relax +\def#2{Premi\`ere}% +\else +\let\@unitthstring=\@@Unitthstringfrench +\let\@unitstring=\@@Unitstringfrench +\let\@teenthstring=\@@Teenthstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenthstring=\@@Tenthstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@Teenstringfrench +\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% +\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Set up default dialect: +% \begin{macrocode} +\let\@OrdinalstringMfrench=\@OrdinalstringMfrenchfrance +% \end{macrocode} +% As above, but feminine form. Swiss: +% \begin{macrocode} +\DeclareRobustCommand{\@OrdinalstringFfrenchswiss}[2]{% +\ifnum#1=1\relax +\def#2{Premi\`ere}% +\else +\let\@unitthstring=\@@Unitthstringfrench +\let\@unitstring=\@@UnitstringFfrench +\let\@teenthstring=\@@Teenthstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenthstring=\@@Tenthstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrenchswiss +\let\@ninetieths=\@@ninetiethsfrenchswiss +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% +\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% French (feminine): +% \begin{macrocode} +\DeclareRobustCommand{\@OrdinalstringFfrenchfrance}[2]{% +\ifnum#1=1\relax +\def#2{Premi\`ere}% +\else +\let\@unitthstring=\@@Unitthstringfrench +\let\@unitstring=\@@UnitstringFfrench +\let\@teenthstring=\@@Teenthstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenthstring=\@@Tenthstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventieths=\@@seventiethsfrench +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@Teenstringfrench +\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% +\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Belgian (feminine): +% \begin{macrocode} +\DeclareRobustCommand{\@OrdinalstringFfrenchbelgian}[2]{% +\ifnum#1=1\relax +\def#2{Premi\`ere}% +\else +\let\@unitthstring=\@@Unitthstringfrench +\let\@unitstring=\@@UnitstringFfrench +\let\@teenthstring=\@@Teenthstringfrench +\let\@teenstring=\@@Teenstringfrench +\let\@tenthstring=\@@Tenthstringfrench +\let\@tenstring=\@@Tenstringfrench +\let\@seventieths=\@@seventiethsfrenchswiss +\let\@eightieths=\@@eightiethsfrench +\let\@ninetieths=\@@ninetiethsfrench +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\@teenstring=\@@Teenstringfrench +\def\@hundredth{Centi\`eme}\def\@hundred{Cent}% +\def\@thousandth{Mili\`eme}\def\@thousand{Mille}% +\def\@andname{et}% +\@@ordinalstringfrench{#1}{#2}% +\fi} +% \end{macrocode} +% Set up default dialect: +% \begin{macrocode} +\let\@OrdinalstringFfrench=\@OrdinalstringFfrenchfrance +% \end{macrocode} +% Make neuter same as masculine: +% \begin{macrocode} +\let\@OrdinalstringNfrench\@OrdinalstringMfrench +% \end{macrocode} +% In order to convert numbers into textual ordinals, need +% to break it up into units, tens and teens. First the units. +% The argument must be a number or count register between 0 +% and 9. +% \begin{macrocode} +\newcommand*{\@@unitthstringfrench}[1]{% +\ifcase#1\relax +zero% +\or uni\`eme% +\or deuxi\`eme% +\or troisi\`eme% +\or quatri\`eme% +\or cinqui\`eme% +\or sixi\`eme% +\or septi\`eme% +\or huiti\`eme% +\or neuvi\`eme% +\fi +} +% \end{macrocode} +% Tens (includes Swiss and Belgian variants, special cases are +% dealt with later.) +% \begin{macrocode} +\newcommand*{\@@tenthstringfrench}[1]{% +\ifcase#1\relax +\or dixi\`eme% +\or vingti\`eme% +\or trentri\`eme% +\or quaranti\`eme% +\or cinquanti\`eme% +\or soixanti\`eme% +\or septenti\`eme% +\or huitanti\`eme% +\or nonenti\`eme% +\fi +} +% \end{macrocode} +% Teens: +% \begin{macrocode} +\newcommand*{\@@teenthstringfrench}[1]{% +\ifcase#1\relax +dixi\`eme% +\or onzi\`eme% +\or douzi\`eme% +\or treizi\`eme% +\or quatorzi\`eme% +\or quinzi\`eme% +\or seizi\`eme% +\or dix-septi\`eme% +\or dix-huiti\`eme% +\or dix-neuvi\`eme% +\fi +} +% \end{macrocode} +% Seventies vary depending on dialect. Swiss: +% \begin{macrocode} +\newcommand*{\@@seventiethsfrenchswiss}[1]{% +\ifcase#1\relax +\@tenthstring{7}% +\or +\@tenstring{7} \@andname\ \@unitthstring{1}% +\else +\@tenstring{7}-\@unitthstring{#1}% +\fi} +% \end{macrocode} +% Eighties vary depending on dialect. Swiss: +% \begin{macrocode} +\newcommand*{\@@eightiethsfrenchswiss}[1]{% +\ifcase#1\relax +\@tenthstring{8}% +\or +\@tenstring{8} \@andname\ \@unitthstring{1}% +\else +\@tenstring{8}-\@unitthstring{#1}% +\fi} +% \end{macrocode} +% Nineties vary depending on dialect. Swiss: +% \begin{macrocode} +\newcommand*{\@@ninetiethsfrenchswiss}[1]{% +\ifcase#1\relax +\@tenthstring{9}% +\or +\@tenstring{9} \@andname\ \@unitthstring{1}% +\else +\@tenstring{9}-\@unitthstring{#1}% +\fi} +% \end{macrocode} +% French (as spoken in France) version: +% \begin{macrocode} +\newcommand*{\@@seventiethsfrench}[1]{% +\ifnum#1=0\relax +\@tenstring{6}% +-% +\else +\@tenstring{6}% +\ \@andname\ +\fi +\@teenthstring{#1}% +} +% \end{macrocode} +% Eighties (as spoken in France): +% \begin{macrocode} +\newcommand*{\@@eightiethsfrench}[1]{% +\ifnum#1>0\relax +\@unitstring{4}-\@tenstring{2}% +-\@unitthstring{#1}% +\else +\@unitstring{4}-\@tenthstring{2}% +\fi +} +% \end{macrocode} +% Nineties (as spoken in France): +% \begin{macrocode} +\newcommand*{\@@ninetiethsfrench}[1]{% +\@unitstring{4}-\@tenstring{2}-\@teenthstring{#1}% +} +% \end{macrocode} +% As above, but with initial letter in upper case. Units: +% \begin{macrocode} +\newcommand*{\@@Unitthstringfrench}[1]{% +\ifcase#1\relax +Zero% +\or Uni\`eme% +\or Deuxi\`eme% +\or Troisi\`eme% +\or Quatri\`eme% +\or Cinqui\`eme% +\or Sixi\`eme% +\or Septi\`eme% +\or Huiti\`eme% +\or Neuvi\`eme% +\fi +} +% \end{macrocode} +% Tens (includes Belgian and Swiss variants): +% \begin{macrocode} +\newcommand*{\@@Tenthstringfrench}[1]{% +\ifcase#1\relax +\or Dixi\`eme% +\or Vingti\`eme% +\or Trentri\`eme% +\or Quaranti\`eme% +\or Cinquanti\`eme% +\or Soixanti\`eme% +\or Septenti\`eme% +\or Huitanti\`eme% +\or Nonenti\`eme% +\fi +} +% \end{macrocode} +% Teens: +% \begin{macrocode} +\newcommand*{\@@Teenthstringfrench}[1]{% +\ifcase#1\relax +Dixi\`eme% +\or Onzi\`eme% +\or Douzi\`eme% +\or Treizi\`eme% +\or Quatorzi\`eme% +\or Quinzi\`eme% +\or Seizi\`eme% +\or Dix-Septi\`eme% +\or Dix-Huiti\`eme% +\or Dix-Neuvi\`eme% +\fi +} +% \end{macrocode} +% Store textual representation of number (first argument) in given control +% sequence (second argument). +% \begin{macrocode} +\newcommand*{\@@numberstringfrench}[2]{% +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\fi +\fi +\def#2{}% +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>9\relax +% #1 is greater or equal to 10000 + \@tmpstrctr=\@strctr + \divide\@strctr by 10\relax + \ifnum\@strctr>1\relax + \ifthenelse{\(\@strctr>6\)\and\(\@strctr<10\)}{% + \@modulo{\@tmpstrctr}{10}% + \ifnum\@strctr<8\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@seventies{\@tmpstrctr}}% + \else + \ifnum\@strctr<9\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@eighties{\@tmpstrctr}}% + \else + \ifnum\@strctr<10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@nineties{\@tmpstrctr}}% + \fi + \fi + \fi + }{% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% + \fi + }% + \else + \@strctr=#1\relax + \divide\@strctr by 1000 + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@thousand}% +\else + \ifnum\@strctr>0\relax + \ifnum\@strctr>1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@thousand}% + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{1000}% +\divide\@strctr by 100 +\ifnum\@strctr>0\relax + \ifnum#1>1000\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ }% + \fi + \@tmpstrctr=#1\relax + \@modulo{\@tmpstrctr}{1000}\relax + \ifnum\@tmpstrctr=100\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{10}}% + \else + \ifnum\@strctr>1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@hundred}% + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{100}% +%\@tmpstrctr=#1\relax +%\divide\@tmpstrctr by 100\relax +\ifnum#1>100\relax + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ }% + \else + \ifnum\@tmpstrctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr s}% + \fi% + \fi +\fi +\ifnum\@strctr>19\relax + \@tmpstrctr=\@strctr + \divide\@strctr by 10\relax + \ifthenelse{\@strctr>6}{% + \@modulo{\@tmpstrctr}{10}% + \ifnum\@strctr<8\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@seventies{\@tmpstrctr}}% + \else + \ifnum\@strctr<9\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@eighties{\@tmpstrctr}}% + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@nineties{\@tmpstrctr}}% + \fi + \fi + }{% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \ifnum\@strctr=1\relax + \edef#2{\@@fc@numstr\ \@andname\ }% + \else + \edef#2{\@@fc@numstr-}% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + }% +\else + \ifnum\@strctr<10\relax + \ifnum\@strctr=0\relax + \ifnum#1<100\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + \else%(>0,<10) + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + \else%>10 + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \fi +\fi +} +% \end{macrocode} +% Store textual representation of an ordinal (from number +% specified in first argument) in given control +% sequence (second argument). +% \begin{macrocode} +\newcommand*{\@@ordinalstringfrench}[2]{% +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\fi +\fi +\def#2{}% +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>9 +% #1 is greater or equal to 10000 + \@tmpstrctr=\@strctr + \divide\@strctr by 10\relax + \ifnum\@strctr>1\relax + \ifthenelse{\@strctr>6}{% + \@modulo{\@tmpstrctr}{10}% + \ifnum\@strctr=7\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@seventies{\@tmpstrctr}}% + \else + \ifnum\@strctr=8\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@eighties{\@tmpstrctr}}% + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@nineties{\@tmpstrctr}}% + \fi + \fi + }{% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \ifnum\@strctr=1\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@andname}% + \fi + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@unitstring{\@strctr}}% + \fi + }% + \else + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenstring{\@strctr}}% + \fi + \@strctr=#1\relax \@modulo{\@strctr}{1000}% + \ifnum\@strctr=0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@thousandth}% + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@thousand}% + \fi +\else + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{1000}% + \ifnum\@strctr=0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@thousandth}% + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@thousand}% + \fi + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{1000}% +\divide\@strctr by 100\relax +\ifnum\@strctr>0\relax + \ifnum#1>1000\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ }% + \fi + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{100}% + \let\@@fc@ordstr#2\relax + \ifnum\@strctr=0\relax + \edef#2{\@@fc@ordstr\ \@hundredth}% + \else + \edef#2{\@@fc@ordstr\ \@hundred}% + \fi +\fi +\@tmpstrctr=\@strctr +\@strctr=#1\relax \@modulo{\@strctr}{100}% +\ifnum#1>100\relax + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@andname\ }% + \fi +\fi +\ifnum\@strctr>19\relax + \@tmpstrctr=\@strctr + \divide\@strctr by 10\relax + \@modulo{\@tmpstrctr}{10}% + \ifthenelse{\@strctr>6}{% + \ifnum\@strctr=7\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@seventieths{\@tmpstrctr}}% + \else + \ifnum\@strctr=8\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@eightieths{\@tmpstrctr}}% + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@ninetieths{\@tmpstrctr}}% + \fi + \fi + }{% + \ifnum\@tmpstrctr=0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenthstring{\@strctr}}% + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% + \fi + \@strctr=#1\relax \@modulo{\@strctr}{10}% + \ifnum\@strctr=1\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@andname}% + \fi + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@unitthstring{\@strctr}}% + \fi + }% +\else + \ifnum\@strctr<10\relax + \ifnum\@strctr=0\relax + \ifnum#1<100\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi + \else + \@modulo{\@strctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% + \fi +\fi +} % \end{macrocode} -% As above, but initial letters in upper case: +%\iffalse % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringMportuges}[2]{% -\let\@unitstring=\@@Unitstringportuges -\let\@teenstring=\@@Teenstringportuges -\let\@tenstring=\@@Tenstringportuges -\let\@hundredstring=\@@Hundredstringportuges -\def\@hundred{Cem}\def\@thousand{Mil}% -\def\@andname{e}% -\@@numberstringportuges{#1}{#2}} +% % \end{macrocode} -% As above, but feminine form: +%\fi +%\iffalse % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringFportuges}[2]{% -\let\@unitstring=\@@UnitstringFportuges -\let\@teenstring=\@@Teenstringportuges -\let\@tenstring=\@@Tenstringportuges -\let\@hundredstring=\@@HundredstringFportuges -\def\@hundred{Cem}\def\@thousand{Mil}% -\def\@andname{e}% -\@@numberstringportuges{#1}{#2}} +%<*fc-german.def> % \end{macrocode} -% Make neuter same as masculine: +%\fi +% \subsubsection{fc-german.def} +% German definitions (thank you to K. H. Fricke for supplying +% this information) % \begin{macrocode} -\let\@NumberstringNportuges\@NumberstringMportuges +\ProvidesFile{fc-german.def}[2007/06/14] % \end{macrocode} -% As above, but for ordinals. +% Define macro that converts a number or count register (first +% argument) to an ordinal, and stores the result in the +% second argument, which must be a control sequence. +% Masculine: % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringMportuges}[2]{% -\let\@unitthstring=\@@unitthstringportuges -\let\@unitstring=\@@unitstringportuges -\let\@teenthstring=\@@teenthstringportuges -\let\@tenthstring=\@@tenthstringportuges -\let\@hundredthstring=\@@hundredthstringportuges -\def\@thousandth{mil\'esimo}% -\@@ordinalstringportuges{#1}{#2}} +\newcommand{\@ordinalMgerman}[2]{% +\edef#2{\number#1\relax.}} % \end{macrocode} -% Feminine form: +% Feminine: % \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringFportuges}[2]{% -\let\@unitthstring=\@@unitthstringFportuges -\let\@unitstring=\@@unitstringFportuges -\let\@teenthstring=\@@teenthstringportuges -\let\@tenthstring=\@@tenthstringFportuges -\let\@hundredthstring=\@@hundredthstringFportuges -\def\@thousandth{mil\'esima}% -\@@ordinalstringportuges{#1}{#2}} +\newcommand{\@ordinalFgerman}[2]{% +\edef#2{\number#1\relax.}} % \end{macrocode} -% Make neuter same as masculine: +% Neuter: % \begin{macrocode} -\let\@ordinalstringNportuges\@ordinalstringMportuges +\newcommand{\@ordinalNgerman}[2]{% +\edef#2{\number#1\relax.}} % \end{macrocode} -% As above, but initial letters in upper case (masculine): +% Convert a number to text. The easiest way to do this is to +% break it up into units, tens and teens. +% Units (argument must be a number from 0 to 9, 1 on its own (eins) +% is dealt with separately): % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMportuges}[2]{% -\let\@unitthstring=\@@Unitthstringportuges -\let\@unitstring=\@@Unitstringportuges -\let\@teenthstring=\@@teenthstringportuges -\let\@tenthstring=\@@Tenthstringportuges -\let\@hundredthstring=\@@Hundredthstringportuges -\def\@thousandth{Mil\'esimo}% -\@@ordinalstringportuges{#1}{#2}} +\newcommand{\@@unitstringgerman}[1]{% +\ifcase#1% +null% +\or ein% +\or zwei% +\or drei% +\or vier% +\or f\"unf% +\or sechs% +\or sieben% +\or acht% +\or neun% +\fi +} % \end{macrocode} -% Feminine form: +% Tens (argument must go from 1 to 10): % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringFportuges}[2]{% -\let\@unitthstring=\@@UnitthstringFportuges -\let\@unitstring=\@@UnitstringFportuges -\let\@teenthstring=\@@teenthstringportuges -\let\@tenthstring=\@@TenthstringFportuges -\let\@hundredthstring=\@@HundredthstringFportuges -\def\@thousandth{Mil\'esima}% -\@@ordinalstringportuges{#1}{#2}} +\newcommand{\@@tenstringgerman}[1]{% +\ifcase#1% +\or zehn% +\or zwanzig% +\or drei{\ss}ig% +\or vierzig% +\or f\"unfzig% +\or sechzig% +\or siebzig% +\or achtzig% +\or neunzig% +\or einhundert% +\fi +} % \end{macrocode} -% Make neuter same as masculine: +% |\einhundert| is set to |einhundert| by default, user can +% redefine this command to just |hundert| if required, similarly +% for |\eintausend|. % \begin{macrocode} -\let\@OrdinalstringNportuges\@OrdinalstringMportuges +\providecommand*{\einhundert}{einhundert} +\providecommand*{\eintausend}{eintausend} % \end{macrocode} -% In order to do the ordinals, split into units, teens, tens -% and hundreds. Units: +% Teens: % \begin{macrocode} -\newcommand*{\@@unitthstringportuges}[1]{% -\ifcase#1\relax -zero% -\or primeiro% -\or segundo% -\or terceiro% -\or quarto% -\or quinto% -\or sexto% -\or s\'etimo% -\or oitavo% -\or nono% +\newcommand{\@@teenstringgerman}[1]{% +\ifcase#1% +zehn% +\or elf% +\or zw\"olf% +\or dreizehn% +\or vierzehn% +\or f\"unfzehn% +\or sechzehn% +\or siebzehn% +\or achtzehn% +\or neunzehn% \fi } % \end{macrocode} -% Tens: +% The results are stored in the second argument, but doesn't +% display anything. % \begin{macrocode} -\newcommand*{\@@tenthstringportuges}[1]{% -\ifcase#1\relax -\or d\'ecimo% -\or vig\'esimo% -\or trig\'esimo% -\or quadrag\'esimo% -\or q\"uinquag\'esimo% -\or sexag\'esimo% -\or setuag\'esimo% -\or octog\'esimo% -\or nonag\'esimo% -\fi -} +\DeclareRobustCommand{\@numberstringMgerman}[2]{% +\let\@unitstring=\@@unitstringgerman +\let\@teenstring=\@@teenstringgerman +\let\@tenstring=\@@tenstringgerman +\@@numberstringgerman{#1}{#2}} % \end{macrocode} -% Teens: +% Feminine and neuter forms: % \begin{macrocode} -\newcommand*{\@@teenthstringportuges}[1]{% -\@tenthstring{1}% -\ifnum#1>0\relax --\@unitthstring{#1}% -\fi} +\let\@numberstringFgerman=\@numberstringMgerman +\let\@numberstringNgerman=\@numberstringMgerman % \end{macrocode} -% Hundreds: +% As above, but initial letters in upper case: % \begin{macrocode} -\newcommand*{\@@hundredthstringportuges}[1]{% -\ifcase#1\relax -\or cent\'esimo% -\or ducent\'esimo% -\or trecent\'esimo% -\or quadringent\'esimo% -\or q\"uingent\'esimo% -\or seiscent\'esimo% -\or setingent\'esimo% -\or octingent\'esimo% -\or nongent\'esimo% -\fi} +\DeclareRobustCommand{\@NumberstringMgerman}[2]{% +\@numberstringMgerman{#1}{\@@num@str}% +\edef#2{\noexpand\MakeUppercase\@@num@str}} % \end{macrocode} -% Units (feminine): +% Feminine and neuter form: % \begin{macrocode} -\newcommand*{\@@unitthstringFportuges}[1]{% -\ifcase#1\relax -zero% -\or primeira% -\or segunda% -\or terceira% -\or quarta% -\or quinta% -\or sexta% -\or s\'etima% -\or oitava% -\or nona% -\fi -} +\let\@NumberstringFgerman=\@NumberstringMgerman +\let\@NumberstringNgerman=\@NumberstringMgerman % \end{macrocode} -% Tens (feminine): +% As above, but for ordinals. % \begin{macrocode} -\newcommand*{\@@tenthstringFportuges}[1]{% -\ifcase#1\relax -\or d\'ecima% -\or vig\'esima% -\or trig\'esima% -\or quadrag\'esima% -\or q\"uinquag\'esima% -\or sexag\'esima% -\or setuag\'esima% -\or octog\'esima% -\or nonag\'esima% -\fi -} +\DeclareRobustCommand{\@ordinalstringMgerman}[2]{% +\let\@unitthstring=\@@unitthstringMgerman +\let\@teenthstring=\@@teenthstringMgerman +\let\@tenthstring=\@@tenthstringMgerman +\let\@unitstring=\@@unitstringgerman +\let\@teenstring=\@@teenstringgerman +\let\@tenstring=\@@tenstringgerman +\def\@thousandth{tausendster}% +\def\@hundredth{hundertster}% +\@@ordinalstringgerman{#1}{#2}} % \end{macrocode} -% Hundreds (feminine): +% Feminine form: % \begin{macrocode} -\newcommand*{\@@hundredthstringFportuges}[1]{% -\ifcase#1\relax -\or cent\'esima% -\or ducent\'esima% -\or trecent\'esima% -\or quadringent\'esima% -\or q\"uingent\'esima% -\or seiscent\'esima% -\or setingent\'esima% -\or octingent\'esima% -\or nongent\'esima% -\fi} +\DeclareRobustCommand{\@ordinalstringFgerman}[2]{% +\let\@unitthstring=\@@unitthstringFgerman +\let\@teenthstring=\@@teenthstringFgerman +\let\@tenthstring=\@@tenthstringFgerman +\let\@unitstring=\@@unitstringgerman +\let\@teenstring=\@@teenstringgerman +\let\@tenstring=\@@tenstringgerman +\def\@thousandth{tausendste}% +\def\@hundredth{hundertste}% +\@@ordinalstringgerman{#1}{#2}} % \end{macrocode} -% As above, but with initial letter in upper case. Units: +% Neuter form: % \begin{macrocode} -\newcommand*{\@@Unitthstringportuges}[1]{% -\ifcase#1\relax -Zero% -\or Primeiro% -\or Segundo% -\or Terceiro% -\or Quarto% -\or Quinto% -\or Sexto% -\or S\'etimo% -\or Oitavo% -\or Nono% -\fi -} +\DeclareRobustCommand{\@ordinalstringNgerman}[2]{% +\let\@unitthstring=\@@unitthstringNgerman +\let\@teenthstring=\@@teenthstringNgerman +\let\@tenthstring=\@@tenthstringNgerman +\let\@unitstring=\@@unitstringgerman +\let\@teenstring=\@@teenstringgerman +\let\@tenstring=\@@tenstringgerman +\def\@thousandth{tausendstes}% +\def\@hundredth{hunderstes}% +\@@ordinalstringgerman{#1}{#2}} % \end{macrocode} -% Tens: +% As above, but with initial letters in upper case. % \begin{macrocode} -\newcommand*{\@@Tenthstringportuges}[1]{% -\ifcase#1\relax -\or D\'ecimo% -\or Vig\'esimo% -\or Trig\'esimo% -\or Quadrag\'esimo% -\or Q\"uinquag\'esimo% -\or Sexag\'esimo% -\or Setuag\'esimo% -\or Octog\'esimo% -\or Nonag\'esimo% -\fi -} +\DeclareRobustCommand{\@OrdinalstringMgerman}[2]{% +\@ordinalstringMgerman{#1}{\@@num@str}% +\edef#2{\protect\MakeUppercase\@@num@str}} % \end{macrocode} -% Hundreds: +% Feminine form: % \begin{macrocode} -\newcommand*{\@@Hundredthstringportuges}[1]{% -\ifcase#1\relax -\or Cent\'esimo% -\or Ducent\'esimo% -\or Trecent\'esimo% -\or Quadringent\'esimo% -\or Q\"uingent\'esimo% -\or Seiscent\'esimo% -\or Setingent\'esimo% -\or Octingent\'esimo% -\or Nongent\'esimo% -\fi} +\DeclareRobustCommand{\@OrdinalstringFgerman}[2]{% +\@ordinalstringFgerman{#1}{\@@num@str}% +\edef#2{\protect\MakeUppercase\@@num@str}} % \end{macrocode} -% As above, but feminine. Units: +% Neuter form: % \begin{macrocode} -\newcommand*{\@@UnitthstringFportuges}[1]{% -\ifcase#1\relax -Zera% -\or Primeira% -\or Segunda% -\or Terceira% -\or Quarta% -\or Quinta% -\or Sexta% -\or S\'etima% -\or Oitava% -\or Nona% -\fi -} +\DeclareRobustCommand{\@OrdinalstringNgerman}[2]{% +\@ordinalstringNgerman{#1}{\@@num@str}% +\edef#2{\protect\MakeUppercase\@@num@str}} % \end{macrocode} -% Tens (feminine); +% Code for converting numbers into textual ordinals. As before, +% it is easier to split it into units, tens and teens. +% Units: % \begin{macrocode} -\newcommand*{\@@TenthstringFportuges}[1]{% -\ifcase#1\relax -\or D\'ecima% -\or Vig\'esima% -\or Trig\'esima% -\or Quadrag\'esima% -\or Q\"uinquag\'esima% -\or Sexag\'esima% -\or Setuag\'esima% -\or Octog\'esima% -\or Nonag\'esima% +\newcommand{\@@unitthstringMgerman}[1]{% +\ifcase#1% +nullter% +\or erster% +\or zweiter% +\or dritter% +\or vierter% +\or f\"unter% +\or sechster% +\or siebter% +\or achter% +\or neunter% \fi } % \end{macrocode} -% Hundreds (feminine): +% Tens: % \begin{macrocode} -\newcommand*{\@@HundredthstringFportuges}[1]{% -\ifcase#1\relax -\or Cent\'esima% -\or Ducent\'esima% -\or Trecent\'esima% -\or Quadringent\'esima% -\or Q\"uingent\'esima% -\or Seiscent\'esima% -\or Setingent\'esima% -\or Octingent\'esima% -\or Nongent\'esima% -\fi} +\newcommand{\@@tenthstringMgerman}[1]{% +\ifcase#1% +\or zehnter% +\or zwanzigster% +\or drei{\ss}igster% +\or vierzigster% +\or f\"unfzigster% +\or sechzigster% +\or siebzigster% +\or achtzigster% +\or neunzigster% +\fi +} % \end{macrocode} -% This has changed in version 1.09, so that it now stores -% the result in the second argument (a control sequence), but it -% doesn't display anything. Since it only affects internal macros, -% it shouldn't affect documents created with older versions. -% (These internal macros are not meant for use in documents.) +% Teens: % \begin{macrocode} -\newcommand*{\@@numberstringportuges}[2]{% -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000}% -\else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% -\fi -\fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>9 -% #1 is greater or equal to 10000 - \divide\@strctr by 10 - \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1 \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \ifnum\@strctr>0 - \ifnum\@strctr=1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@andname}% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% - \fi - \else - \@strctr=#1\relax - \divide\@strctr by 1000\relax - \@modulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@thousand}% -\else - \ifnum\@strctr>0\relax - \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@thousand}% - \fi -\fi -\@strctr=#1\relax \@modulo{\@strctr}{1000}% -\divide\@strctr by 100\relax -\ifnum\@strctr>0\relax - \ifnum#1>1000 \relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ }% - \fi - \@tmpstrctr=#1\relax - \@modulo{\@tmpstrctr}{1000}% - \let\@@fc@numstr#2\relax - \ifnum\@tmpstrctr=100\relax - \edef#2{\@@fc@numstr\@tenstring{10}}% - \else - \edef#2{\@@fc@numstr\@hundredstring{\@strctr}}% - \fi% -\fi -\@strctr=#1\relax \@modulo{\@strctr}{100}% -\ifnum#1>100\relax - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@andname\ }% - \fi -\fi -\ifnum\@strctr>19\relax - \divide\@strctr by 10\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1\relax \@modulo{\@strctr}{10}% - \ifnum\@strctr>0 - \ifnum\@strctr=1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@andname}% - \else - \ifnum#1>100\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@andname}% - \fi - \fi - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% - \fi -\else - \ifnum\@strctr<10\relax - \ifnum\@strctr=0\relax - \ifnum#1<100\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% - \fi - \else%(>0,<10) - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% - \fi - \else%>10 - \@modulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% - \fi +\newcommand{\@@teenthstringMgerman}[1]{% +\ifcase#1% +zehnter% +\or elfter% +\or zw\"olfter% +\or dreizehnter% +\or vierzehnter% +\or f\"unfzehnter% +\or sechzehnter% +\or siebzehnter% +\or achtzehnter% +\or neunzehnter% \fi } % \end{macrocode} -% As above, but for ordinals. +% Units (feminine): % \begin{macrocode} -\newcommand*{\@@ordinalstringportuges}[2]{% -\@strctr=#1\relax -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000}% -\else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% -\else -\def#2{}% -\ifnum\@strctr>999\relax - \divide\@strctr by 1000\relax - \ifnum\@strctr>1\relax - \ifnum\@strctr>9\relax - \@tmpstrctr=\@strctr - \ifnum\@strctr<20 - \@modulo{\@tmpstrctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenthstring{\@tmpstrctr}}% - \else - \divide\@tmpstrctr by 10\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% - \@tmpstrctr=\@strctr - \@modulo{\@tmpstrctr}{10}% - \ifnum\@tmpstrctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@tmpstrctr}}% - \fi - \fi - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \fi - \fi - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@thousandth}% -\fi -\@strctr=#1\relax -\@modulo{\@strctr}{1000}% -\ifnum\@strctr>99\relax - \@tmpstrctr=\@strctr - \divide\@tmpstrctr by 100\relax - \ifnum#1>1000\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr-}% - \fi - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@hundredthstring{\@tmpstrctr}}% -\fi -\@modulo{\@strctr}{100}% -\ifnum#1>99\relax - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr-}% - \fi -\fi -\ifnum\@strctr>9\relax - \@tmpstrctr=\@strctr - \divide\@tmpstrctr by 10\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% - \@tmpstrctr=\@strctr - \@modulo{\@tmpstrctr}{10}% - \ifnum\@tmpstrctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr-\@unitthstring{\@tmpstrctr}}% - \fi -\else - \ifnum\@strctr=0\relax - \ifnum#1=0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{0}}% - \fi - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% - \fi -\fi -\fi +\newcommand{\@@unitthstringFgerman}[1]{% +\ifcase#1% +nullte% +\or erste% +\or zweite% +\or dritte% +\or vierte% +\or f\"unfte% +\or sechste% +\or siebte% +\or achte% +\or neunte% \fi } % \end{macrocode} -%\iffalse +% Tens (feminine): % \begin{macrocode} -% +\newcommand{\@@tenthstringFgerman}[1]{% +\ifcase#1% +\or zehnte% +\or zwanzigste% +\or drei{\ss}igste% +\or vierzigste% +\or f\"unfzigste% +\or sechzigste% +\or siebzigste% +\or achtzigste% +\or neunzigste% +\fi +} % \end{macrocode} -%\fi -%\iffalse +% Teens (feminine) % \begin{macrocode} -%<*fc-spanish.def> +\newcommand{\@@teenthstringFgerman}[1]{% +\ifcase#1% +zehnte% +\or elfte% +\or zw\"olfte% +\or dreizehnte% +\or vierzehnte% +\or f\"unfzehnte% +\or sechzehnte% +\or siebzehnte% +\or achtzehnte% +\or neunzehnte% +\fi +} % \end{macrocode} -%\fi -% \subsection{fc-spanish.def} -% Spanish definitions +% Units (neuter): % \begin{macrocode} -\ProvidesFile{fc-spanish.def}[2007/05/26] +\newcommand{\@@unitthstringNgerman}[1]{% +\ifcase#1% +nulltes% +\or erstes% +\or zweites% +\or drittes% +\or viertes% +\or f\"unte% +\or sechstes% +\or siebtes% +\or achtes% +\or neuntes% +\fi +} % \end{macrocode} -% Define macro that converts a number or count register (first -% argument) to an ordinal, and stores the result in the -% second argument, which must be a control sequence. -% Masculine: +% Tens (neuter): % \begin{macrocode} -\newcommand{\@ordinalMspanish}[2]{% -\edef#2{\number#1\relax\noexpand\fmtord{o}}} +\newcommand{\@@tenthstringNgerman}[1]{% +\ifcase#1% +\or zehntes% +\or zwanzigstes% +\or drei{\ss}igstes% +\or vierzigstes% +\or f\"unfzigstes% +\or sechzigstes% +\or siebzigstes% +\or achtzigstes% +\or neunzigstes% +\fi +} % \end{macrocode} -% Feminine: +% Teens (neuter) % \begin{macrocode} -\newcommand{\@ordinalFspanish}[2]{% -\edef#2{\number#1\relax\noexpand\fmtord{a}}} +\newcommand{\@@teenthstringNgerman}[1]{% +\ifcase#1% +zehntes% +\or elftes% +\or zw\"olftes% +\or dreizehntes% +\or vierzehntes% +\or f\"unfzehntes% +\or sechzehntes% +\or siebzehntes% +\or achtzehntes% +\or neunzehntes% +\fi +} % \end{macrocode} -% Make neuter same as masculine: +% This appends the results to |#2| for number |#2| (in range 0 to 100.) +% null and eins are dealt with separately in |\@@numberstringgerman|. % \begin{macrocode} -\let\@ordinalNspanish\@ordinalMspanish +\newcommand{\@@numberunderhundredgerman}[2]{% +\ifnum#1<10\relax + \ifnum#1>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{#1}}% + \fi +\else + \@tmpstrctr=#1\relax + \@modulo{\@tmpstrctr}{10}% + \ifnum#1<20\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@tmpstrctr}}% + \else + \ifnum\@tmpstrctr=0\relax + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@tmpstrctr}und}% + \fi + \@tmpstrctr=#1\relax + \divide\@tmpstrctr by 10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@tmpstrctr}}% + \fi +\fi +} % \end{macrocode} -% Convert a number to text. The easiest way to do this is to -% break it up into units, tens, teens, twenties and hundreds. -% Units (argument must be a number from 0 to 9): +% This stores the results in the second argument +% (which must be a control +% sequence), but it doesn't display anything. % \begin{macrocode} -\newcommand{\@@unitstringspanish}[1]{% -\ifcase#1\relax -cero% -\or uno% -\or dos% -\or tres% -\or cuatro% -\or cinco% -\or seis% -\or siete% -\or ocho% -\or nueve% +\newcommand{\@@numberstringgerman}[2]{% +\ifnum#1>99999\relax + \PackageError{fmtcount}{Out of range}% + {This macro only works for values less than 100000}% +\else + \ifnum#1<0\relax + \PackageError{fmtcount}{Negative numbers not permitted}% + {This macro does not work for negative numbers, however + you can try typing "minus" first, and then pass the modulus of + this number}% + \fi +\fi +\def#2{}% +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>1\relax +% #1 is >= 2000, \@strctr now contains the number of thousands +\@@numberunderhundredgerman{\@strctr}{#2}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr tausend}% +\else +% #1 lies in range [1000,1999] + \ifnum\@strctr=1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\eintausend}% + \fi \fi -} -% \end{macrocode} -% Feminine: -% \begin{macrocode} -\newcommand{\@@unitstringFspanish}[1]{% -\ifcase#1\relax -cera% -\or una% -\or dos% -\or tres% -\or cuatro% -\or cinco% -\or seis% -\or siete% -\or ocho% -\or nueve% +\@strctr=#1\relax +\@modulo{\@strctr}{1000}% +\divide\@strctr by 100\relax +\ifnum\@strctr>1\relax +% now dealing with number in range [200,999] + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}hundert}% +\else + \ifnum\@strctr=1\relax +% dealing with number in range [100,199] + \ifnum#1>1000\relax +% if orginal number > 1000, use einhundert + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr einhundert}% + \else +% otherwise use \einhundert + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\einhundert}% + \fi + \fi +\fi +\@strctr=#1\relax +\@modulo{\@strctr}{100}% +\ifnum#1=0\relax + \def#2{null}% +\else + \ifnum\@strctr=1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr eins}% + \else + \@@numberunderhundredgerman{\@strctr}{#2}% + \fi \fi } % \end{macrocode} -% Tens (argument must go from 1 to 10): +% As above, but for ordinals % \begin{macrocode} -\newcommand{\@@tenstringspanish}[1]{% -\ifcase#1\relax -\or diez% -\or viente% -\or treinta% -\or cuarenta% -\or cincuenta% -\or sesenta% -\or setenta% -\or ochenta% -\or noventa% -\or cien% +\newcommand{\@@numberunderhundredthgerman}[2]{% +\ifnum#1<10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitthstring{#1}}% +\else + \@tmpstrctr=#1\relax + \@modulo{\@tmpstrctr}{10}% + \ifnum#1<20\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenthstring{\@tmpstrctr}}% + \else + \ifnum\@tmpstrctr=0\relax + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@tmpstrctr}und}% + \fi + \@tmpstrctr=#1\relax + \divide\@tmpstrctr by 10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenthstring{\@tmpstrctr}}% + \fi \fi } % \end{macrocode} -% Teens: % \begin{macrocode} -\newcommand{\@@teenstringspanish}[1]{% -\ifcase#1\relax -diez% -\or once% -\or doce% -\or trece% -\or catorce% -\or quince% -\or diecis\'eis% -\or diecisiete% -\or dieciocho% -\or diecinueve% +\newcommand{\@@ordinalstringgerman}[2]{% +\ifnum#1>99999\relax + \PackageError{fmtcount}{Out of range}% + {This macro only works for values less than 100000}% +\else + \ifnum#1<0\relax + \PackageError{fmtcount}{Negative numbers not permitted}% + {This macro does not work for negative numbers, however + you can try typing "minus" first, and then pass the modulus of + this number}% + \fi +\fi +\def#2{}% +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>1\relax +% #1 is >= 2000, \@strctr now contains the number of thousands +\@@numberunderhundredgerman{\@strctr}{#2}% + \let\@@fc@numstr#2\relax + % is that it, or is there more? + \@tmpstrctr=#1\relax \@modulo{\@tmpstrctr}{1000}% + \ifnum\@tmpstrctr=0\relax + \edef#2{\@@fc@numstr\@thousandth}% + \else + \edef#2{\@@fc@numstr tausend}% + \fi +\else +% #1 lies in range [1000,1999] + \ifnum\@strctr=1\relax + \ifnum#1=1000\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@thousandth}% + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\eintausend}% + \fi + \fi +\fi +\@strctr=#1\relax +\@modulo{\@strctr}{1000}% +\divide\@strctr by 100\relax +\ifnum\@strctr>1\relax +% now dealing with number in range [200,999] + \let\@@fc@numstr#2\relax + % is that it, or is there more? + \@tmpstrctr=#1\relax \@modulo{\@tmpstrctr}{100}% + \ifnum\@tmpstrctr=0\relax + \ifnum\@strctr=1\relax + \edef#2{\@@fc@numstr\@hundredth}% + \else + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\@hundredth}% + \fi + \else + \edef#2{\@@fc@numstr\@unitstring{\@strctr}hundert}% + \fi +\else + \ifnum\@strctr=1\relax +% dealing with number in range [100,199] +% is that it, or is there more? + \@tmpstrctr=#1\relax \@modulo{\@tmpstrctr}{100}% + \ifnum\@tmpstrctr=0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@hundredth}% + \else + \ifnum#1>1000\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr einhundert}% + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\einhundert}% + \fi + \fi + \fi \fi +\@strctr=#1\relax +\@modulo{\@strctr}{100}% +\ifthenelse{\@strctr=0 \and #1>0}{}{% +\@@numberunderhundredthgerman{\@strctr}{#2}% +}% } % \end{macrocode} -% Twenties: -% \begin{macrocode} -\newcommand{\@@twentystringspanish}[1]{% -\ifcase#1\relax -veinte% -\or veintiuno% -\or veintid\'os% -\or veintitr\'es% -\or veinticuatro% -\or veinticinco% -\or veintis\'eis% -\or veintisiete% -\or veintiocho% -\or veintinueve% -\fi} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\newcommand{\@@twentystringFspanish}[1]{% -\ifcase#1\relax -veinte% -\or veintiuna% -\or veintid\'os% -\or veintitr\'es% -\or veinticuatro% -\or veinticinco% -\or veintis\'eis% -\or veintisiete% -\or veintiocho% -\or veintinueve% -\fi} -% \end{macrocode} -% Hundreds: -% \begin{macrocode} -\newcommand{\@@hundredstringspanish}[1]{% -\ifcase#1\relax -\or ciento% -\or doscientos% -\or trescientos% -\or cuatrocientos% -\or quinientos% -\or seiscientos% -\or setecientos% -\or ochocientos% -\or novecientos% -\fi} -% \end{macrocode} -% Feminine form: +% Set |ngerman| to be equivalent to |german|. Is it okay to do +% this? (I don't know the difference between the two.) % \begin{macrocode} -\newcommand{\@@hundredstringFspanish}[1]{% -\ifcase#1\relax -\or cienta% -\or doscientas% -\or trescientas% -\or cuatrocientas% -\or quinientas% -\or seiscientas% -\or setecientas% -\or ochocientas% -\or novecientas% -\fi} +\let\@ordinalMngerman=\@ordinalMgerman +\let\@ordinalFngerman=\@ordinalFgerman +\let\@ordinalNngerman=\@ordinalNgerman +\let\@numberstringMngerman=\@numberstringMgerman +\let\@numberstringFngerman=\@numberstringFgerman +\let\@numberstringNngerman=\@numberstringNgerman +\let\@NumberstringMngerman=\@NumberstringMgerman +\let\@NumberstringFngerman=\@NumberstringFgerman +\let\@NumberstringNngerman=\@NumberstringNgerman +\let\@ordinalstringMngerman=\@ordinalstringMgerman +\let\@ordinalstringFngerman=\@ordinalstringFgerman +\let\@ordinalstringNngerman=\@ordinalstringNgerman +\let\@OrdinalstringMngerman=\@OrdinalstringMgerman +\let\@OrdinalstringFngerman=\@OrdinalstringFgerman +\let\@OrdinalstringNngerman=\@OrdinalstringNgerman % \end{macrocode} -% As above, but with initial letter uppercase: +%\iffalse % \begin{macrocode} -\newcommand{\@@Unitstringspanish}[1]{% -\ifcase#1\relax -Cero% -\or Uno% -\or Dos% -\or Tres% -\or Cuatro% -\or Cinco% -\or Seis% -\or Siete% -\or Ocho% -\or Nueve% -\fi -} +% % \end{macrocode} -% Feminine form: +%\fi +%\iffalse % \begin{macrocode} -\newcommand{\@@UnitstringFspanish}[1]{% -\ifcase#1\relax -Cera% -\or Una% -\or Dos% -\or Tres% -\or Cuatro% -\or Cinco% -\or Seis% -\or Siete% -\or Ocho% -\or Nueve% -\fi -} +%<*fc-italian.def> % \end{macrocode} -% Tens: +%\fi +% \subsubsection{fc-italian} +% Italian definitions provided by Edoardo Pasca (2008). % \begin{macrocode} -\newcommand{\@@Tenstringspanish}[1]{% +\ProvidesFile{fc-italian.def}[2009/10/02 Italian support for fmtcount (Edoardo Pasca)] +\newcommand{\@@unitstringitalian}[1]{% \ifcase#1\relax -\or Diez% -\or Viente% -\or Treinta% -\or Cuarenta% -\or Cincuenta% -\or Sesenta% -\or Setenta% -\or Ochenta% -\or Noventa% -\or Cien% +zero% +\or uno% +\or due% +\or tre% +\or quattro% +\or cinque% +\or sei% +\or sette% +\or otto% +\or nove% \fi } -% \end{macrocode} -% Teens: -% \begin{macrocode} -\newcommand{\@@Teenstringspanish}[1]{% + +\newcommand{\@@unitstringFitalian}[1]{% \ifcase#1\relax -Diez% -\or Once% -\or Doce% -\or Trece% -\or Catorce% -\or Quince% -\or Diecis\'eis% -\or Diecisiete% -\or Dieciocho% -\or Diecinueve% +zero% +\or una% +\or doe% +\or tre% +\or quattro% +\or cinque% +\or sei% +\or sette% +\or otto% +\or nove% \fi } -% \end{macrocode} -% Twenties: -% \begin{macrocode} -\newcommand{\@@Twentystringspanish}[1]{% -\ifcase#1\relax -Veinte% -\or Veintiuno% -\or Veintid\'os% -\or Veintitr\'es% -\or Veinticuatro% -\or Veinticinco% -\or Veintis\'eis% -\or Veintisiete% -\or Veintiocho% -\or Veintinueve% -\fi} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\newcommand{\@@TwentystringFspanish}[1]{% + +\newcommand{\@@tenstringitalian}[1]{% \ifcase#1\relax -Veinte% -\or Veintiuna% -\or Veintid\'os% -\or Veintitr\'es% -\or Veinticuatro% -\or Veinticinco% -\or Veintis\'eis% -\or Veintisiete% -\or Veintiocho% -\or Veintinueve% -\fi} -% \end{macrocode} -% Hundreds: -% \begin{macrocode} -\newcommand{\@@Hundredstringspanish}[1]{% +\or dieci% +\or venti% +\or trenta% +\or quaranta% +\or cinquanta% +\or sessanta% +\or settanta% +\or ottanta% +\or novanta% +\or cento% +\fi +} + +\newcommand{\@@teenstringitalian}[1]{% \ifcase#1\relax -\or Ciento% -\or Doscientos% -\or Trescientos% -\or Cuatrocientos% -\or Quinientos% -\or Seiscientos% -\or Setecientos% -\or Ochocientos% -\or Novecientos% -\fi} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\newcommand{\@@HundredstringFspanish}[1]{% +dieci% +\or undici% +\or dodici% +\or tredici% +\or quattordici% +\or quindici% +\or sedici% +\or diciassette% +\or diciotto% +\or diciannove% +\fi +} + +\newcommand{\@@twentystringitalian}[1]{% \ifcase#1\relax -\or Cienta% -\or Doscientas% -\or Trescientas% -\or Cuatrocientas% -\or Quinientas% -\or Seiscientas% -\or Setecientas% -\or Ochocientas% -\or Novecientas% -\fi} -% \end{macrocode} -% This has changed in version 1.09, so that it now stores the -% result in the second argument, but doesn't display anything. -% Since it only affects internal macros, it shouldn't affect -% documents created with older versions. (These internal macros -% are not meant for use in documents.) -% \begin{macrocode} -\DeclareRobustCommand{\@numberstringMspanish}[2]{% -\let\@unitstring=\@@unitstringspanish -\let\@teenstring=\@@teenstringspanish -\let\@tenstring=\@@tenstringspanish -\let\@twentystring=\@@twentystringspanish -\let\@hundredstring=\@@hundredstringspanish -\def\@hundred{cien}\def\@thousand{mil}% -\def\@andname{y}% -\@@numberstringspanish{#1}{#2}} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\DeclareRobustCommand{\@numberstringFspanish}[2]{% -\let\@unitstring=\@@unitstringFspanish -\let\@teenstring=\@@teenstringspanish -\let\@tenstring=\@@tenstringspanish -\let\@twentystring=\@@twentystringFspanish -\let\@hundredstring=\@@hundredstringFspanish -\def\@hundred{cien}\def\@thousand{mil}% -\def\@andname{y}% -\@@numberstringspanish{#1}{#2}} -% \end{macrocode} -% Make neuter same as masculine: -% \begin{macrocode} -\let\@numberstringNspanish\@numberstringMspanish -% \end{macrocode} -% As above, but initial letters in upper case: -% \begin{macrocode} -\DeclareRobustCommand{\@NumberstringMspanish}[2]{% -\let\@unitstring=\@@Unitstringspanish -\let\@teenstring=\@@Teenstringspanish -\let\@tenstring=\@@Tenstringspanish -\let\@twentystring=\@@Twentystringspanish -\let\@hundredstring=\@@Hundredstringspanish -\def\@andname{y}% -\def\@hundred{Cien}\def\@thousand{Mil}% -\@@numberstringspanish{#1}{#2}} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\DeclareRobustCommand{\@NumberstringFspanish}[2]{% -\let\@unitstring=\@@UnitstringFspanish -\let\@teenstring=\@@Teenstringspanish -\let\@tenstring=\@@Tenstringspanish -\let\@twentystring=\@@TwentystringFspanish -\let\@hundredstring=\@@HundredstringFspanish -\def\@andname{y}% -\def\@hundred{Cien}\def\@thousand{Mil}% -\@@numberstringspanish{#1}{#2}} -% \end{macrocode} -% Make neuter same as masculine: -% \begin{macrocode} -\let\@NumberstringNspanish\@NumberstringMspanish -% \end{macrocode} -% As above, but for ordinals. -% \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringMspanish}[2]{% -\let\@unitthstring=\@@unitthstringspanish -\let\@unitstring=\@@unitstringspanish -\let\@teenthstring=\@@teenthstringspanish -\let\@tenthstring=\@@tenthstringspanish -\let\@hundredthstring=\@@hundredthstringspanish -\def\@thousandth{mil\'esimo}% -\@@ordinalstringspanish{#1}{#2}} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\DeclareRobustCommand{\@ordinalstringFspanish}[2]{% -\let\@unitthstring=\@@unitthstringFspanish -\let\@unitstring=\@@unitstringFspanish -\let\@teenthstring=\@@teenthstringFspanish -\let\@tenthstring=\@@tenthstringFspanish -\let\@hundredthstring=\@@hundredthstringFspanish -\def\@thousandth{mil\'esima}% -\@@ordinalstringspanish{#1}{#2}} -% \end{macrocode} -% Make neuter same as masculine: -% \begin{macrocode} -\let\@ordinalstringNspanish\@ordinalstringMspanish -% \end{macrocode} -% As above, but with initial letters in upper case. -% \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMspanish}[2]{% -\let\@unitthstring=\@@Unitthstringspanish -\let\@unitstring=\@@Unitstringspanish -\let\@teenthstring=\@@Teenthstringspanish -\let\@tenthstring=\@@Tenthstringspanish -\let\@hundredthstring=\@@Hundredthstringspanish -\def\@thousandth{Mil\'esimo}% -\@@ordinalstringspanish{#1}{#2}} -% \end{macrocode} -% Feminine form: -% \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringFspanish}[2]{% -\let\@unitthstring=\@@UnitthstringFspanish -\let\@unitstring=\@@UnitstringFspanish -\let\@teenthstring=\@@TeenthstringFspanish -\let\@tenthstring=\@@TenthstringFspanish -\let\@hundredthstring=\@@HundredthstringFspanish -\def\@thousandth{Mil\'esima}% -\@@ordinalstringspanish{#1}{#2}} -% \end{macrocode} -% Make neuter same as masculine: -% \begin{macrocode} -\let\@OrdinalstringNspanish\@OrdinalstringMspanish -% \end{macrocode} -% Code for convert numbers into textual ordinals. As before, -% it is easier to split it into units, tens, teens and hundreds. -% Units: -% \begin{macrocode} -\newcommand{\@@unitthstringspanish}[1]{% +venti% +\or ventuno% +\or ventidue% +\or ventitre% +\or ventiquattro% +\or venticinque% +\or ventisei% +\or ventisette% +\or ventiotto% +\or ventinove% +\fi} + +\newcommand{\@@twentystringFitalian}[1]{% \ifcase#1\relax -cero% -\or primero% -\or segundo% -\or tercero% -\or cuarto% +venti% +\or ventuna% +\or ventidue% +\or ventitre% +\or ventiquattro% +\or venticinque% +\or ventisei% +\or ventisette% +\or ventiotto% +\or ventinove% +\fi} + +\newcommand{\@@hundredstringitalian}[1]{% +\ifcase#1\relax +\or cento% +\or duecento% +\or trecento% +\or quattrocento% +\or cinquecento% +\or seicento% +\or settecento% +\or ottocento% +\or novecento% +\fi} + +\newcommand{\@@hundredstringFitalian}[1]{% +\ifcase#1\relax +\or cento% +\or duecento% +\or trecento% +\or quattrocento% +\or cinquecento% +\or seicento% +\or settecento% +\or ottocento% +\or novecento% +\fi} + +\newcommand{\@@Unitstringitalian}[1]{% +\ifcase#1\relax +Zero% +\or Uno% +\or Due% +\or Tre% +\or Quattro% +\or Cinque% +\or Sei% +\or Sette% +\or Otto% +\or Nove% +\fi +} + +\newcommand{\@@UnitstringFitalian}[1]{% +\ifcase#1\relax +Zero% +\or Una% +\or Due% +\or Tre% +\or Quattro% +\or Cinque% +\or Sei% +\or Sette% +\or Otto% +\or Nove% +\fi +} + +\newcommand{\@@Tenstringitalian}[1]{% +\ifcase#1\relax +\or Dieci% +\or Venti% +\or Trenta% +\or Quaranta% +\or Cinquanta% +\or Sessanta% +\or Settanta% +\or Ottanta% +\or Novanta% +\or Cento% +\fi +} + +\newcommand{\@@Teenstringitalian}[1]{% +\ifcase#1\relax +Dieci% +\or Undici% +\or Dodici% +\or Tredici% +\or Quattordici% +\or Quindici% +\or Sedici% +\or Diciassette% +\or Diciotto% +\or Diciannove% +\fi +} + +\newcommand{\@@Twentystringitalian}[1]{% +\ifcase#1\relax +Venti% +\or Ventuno% +\or Ventidue% +\or Ventitre% +\or Ventiquattro% +\or Venticinque% +\or Ventisei% +\or Ventisette% +\or Ventiotto% +\or Ventinove% +\fi} + +\newcommand{\@@TwentystringFitalian}[1]{% +\ifcase#1\relax +Venti% +\or Ventuno% +\or Ventidue% +\or Ventitre% +\or Ventiquattro% +\or Venticinque% +\or Ventisei% +\or Ventisette% +\or Ventiotto% +\or Ventinove% +\fi} + +\newcommand{\@@Hundredstringitalian}[1]{% +\ifcase#1\relax +\or Cento% +\or Duecento% +\or Trecento% +\or Quattrocento% +\or Cinquecento% +\or Seicento% +\or Settecento% +\or Ottocento% +\or Novecento% +\fi} + +\newcommand{\@@HundredstringFitalian}[1]{% +\ifcase#1\relax +\or Cento% +\or Duecento% +\or Trecento% +\or Quattrocento% +\or Cinquecento% +\or Seicento% +\or Settecento% +\or Ottocento% +\or Novecento% +\fi} + + +\newcommand{\@numberstringMitalian}[2]{% +\let\@unitstring=\@@unitstringitalian +\let\@teenstring=\@@teenstringitalian +\let\@tenstring=\@@tenstringitalian +\let\@twentystring=\@@twentystringitalian +\let\@hundredstring=\@@hundredstringitalian +\def\@hundred{cien}\def\@thousand{mil}% +\def\@andname{y}% +\@@numberstringitalian{#1}{#2}} + +\newcommand{\@numberstringFitalian}[2]{% +\let\@unitstring=\@@unitstringFitalian +\let\@teenstring=\@@teenstringitalian +\let\@tenstring=\@@tenstringitalian +\let\@twentystring=\@@twentystringFitalian +\let\@hundredstring=\@@hundredstringFitalian +\def\@hundred{cien}\def\@thousand{mil}% +\def\@andname{y}% +\@@numberstringitalian{#1}{#2}} + +\newcommand{\@NumberstringMitalian}[2]{% +\let\@unitstring=\@@Unitstringitalian +\let\@teenstring=\@@Teenstringitalian +\let\@tenstring=\@@Tenstringitalian +\let\@twentystring=\@@Twentystringitalian +\let\@hundredstring=\@@Hundredstringitalian +\def\@andname{y}% +\def\@hundred{Cien}\def\@thousand{Mil}% +\@@numberstringitalian{#1}{#2}} + +\newcommand{\@NumberstringFitalian}[2]{% +\let\@unitstring=\@@UnitstringFitalian +\let\@teenstring=\@@Teenstringitalian +\let\@tenstring=\@@Tenstringitalian +\let\@twentystring=\@@TwentystringFitalian +\let\@hundredstring=\@@HundredstringFitalian +\def\@andname{y}% +\def\@hundred{Cien}\def\@thousand{Mil}% +\@@numberstringitalian{#1}{#2}} + +\newcommand{\@ordinalstringMitalian}[2]{% +\let\@unitthstring=\@@unitthstringitalian +\let\@unitstring=\@@unitstringitalian +\let\@teenthstring=\@@teenthstringitalian +\let\@tenthstring=\@@tenthstringitalian +\let\@hundredthstring=\@@hundredthstringitalian +\def\@thousandth{millesimo}% +\@@ordinalstringitalian{#1}{#2}} + +\newcommand{\@ordinalstringFitalian}[2]{% +\let\@unitthstring=\@@unitthstringFitalian +\let\@unitstring=\@@unitstringFitalian +\let\@teenthstring=\@@teenthstringFitalian +\let\@tenthstring=\@@tenthstringFitalian +\let\@hundredthstring=\@@hundredthstringFitalian +\def\@thousandth{millesima}% +\@@ordinalstringitalian{#1}{#2}} + +\newcommand{\@OrdinalstringMitalian}[2]{% +\let\@unitthstring=\@@Unitthstringitalian +\let\@unitstring=\@@Unitstringitalian +\let\@teenthstring=\@@Teenthstringitalian +\let\@tenthstring=\@@Tenthstringitalian +\let\@hundredthstring=\@@Hundredthstringitalian +\def\@thousandth{Millesimo}% +\@@ordinalstringitalian{#1}{#2}} + +\newcommand{\@OrdinalstringFitalian}[2]{% +\let\@unitthstring=\@@UnitthstringFitalian +\let\@unitstring=\@@UnitstringFitalian +\let\@teenthstring=\@@TeenthstringFitalian +\let\@tenthstring=\@@TenthstringFitalian +\let\@hundredthstring=\@@HundredthstringFitalian +\def\@thousandth{Millesima}% +\@@ordinalstringitalian{#1}{#2}} + +\newcommand{\@ordinalMitalian}[2]{\edef#2{#1\relax\noexpand\fmtord{o}}} +\newcommand{\@ordinalFitalian}[2]{\edef#2{#1\relax\noexpand\fmtord{a}}} + +\newcommand{\@@unitthstringitalian}[1]{% +\ifcase#1\relax +zero% +\or primo% +\or secondo% +\or terzo% +\or quarto% \or quinto% -\or sexto% -\or s\'eptimo% -\or octavo% -\or noveno% +\or sesto% +\or settimo% +\or ottavo% +\or nono% \fi } -% \end{macrocode} -% Tens: -% \begin{macrocode} -\newcommand{\@@tenthstringspanish}[1]{% + +\newcommand{\@@tenthstringitalian}[1]{% \ifcase#1\relax -\or d\'ecimo% -\or vig\'esimo% -\or trig\'esimo% -\or cuadrag\'esimo% -\or quincuag\'esimo% -\or sexag\'esimo% -\or septuag\'esimo% -\or octog\'esimo% -\or nonag\'esimo% +\or decimo% +\or ventesimo% +\or trentesimo% +\or quarantesimo% +\or cinquantesimo% +\or sessantesimo% +\or settantesimo% +\or ottantesimo% +\or novantesimo% \fi } -% \end{macrocode} -% Teens: -% \begin{macrocode} -\newcommand{\@@teenthstringspanish}[1]{% + +\newcommand{\@@teenthstringitalian}[1]{% \ifcase#1\relax -d\'ecimo% -\or und\'ecimo% -\or duod\'ecimo% -\or decimotercero% -\or decimocuarto% -\or decimoquinto% -\or decimosexto% -\or decimos\'eptimo% -\or decimoctavo% -\or decimonoveno% +decimo% +\or undicesimo% +\or dodicesimo% +\or tredicesimo% +\or quattordicesimo% +\or quindicesimo% +\or sedicesimo% +\or diciassettesimo% +\or diciottesimo% +\or diciannovesimo% \fi } -% \end{macrocode} -% Hundreds: -% \begin{macrocode} -\newcommand{\@@hundredthstringspanish}[1]{% + +\newcommand{\@@hundredthstringitalian}[1]{% \ifcase#1\relax -\or cent\'esimo% -\or ducent\'esimo% -\or tricent\'esimo% -\or cuadringent\'esimo% -\or quingent\'esimo% -\or sexcent\'esimo% -\or septing\'esimo% -\or octingent\'esimo% -\or noningent\'esimo% +\or centesimo% +\or duecentesimo% +\or trecentesimo% +\or quattrocentesimo% +\or cinquecentesimo% +\or seicentesimo% +\or settecentesimo% +\or ottocentesimo% +\or novecentesimo% \fi} -% \end{macrocode} -% Units (feminine): -% \begin{macrocode} -\newcommand{\@@unitthstringFspanish}[1]{% + +\newcommand{\@@unitthstringFitalian}[1]{% \ifcase#1\relax -cera% -\or primera% -\or segunda% -\or tercera% -\or cuarta% +zero% +\or prima% +\or seconda% +\or terza% +\or quarta% \or quinta% -\or sexta% -\or s\'eptima% -\or octava% -\or novena% +\or sesta% +\or settima% +\or ottava% +\or nona% \fi } -% \end{macrocode} -% Tens (feminine): -% \begin{macrocode} -\newcommand{\@@tenthstringFspanish}[1]{% + +\newcommand{\@@tenthstringFitalian}[1]{% \ifcase#1\relax -\or d\'ecima% -\or vig\'esima% -\or trig\'esima% -\or cuadrag\'esima% -\or quincuag\'esima% -\or sexag\'esima% -\or septuag\'esima% -\or octog\'esima% -\or nonag\'esima% +\or decima% +\or ventesima% +\or trentesima% +\or quarantesima% +\or cinquantesima% +\or sessantesima% +\or settantesima% +\or ottantesima% +\or novantesima% \fi } -% \end{macrocode} -% Teens (feminine) -% \begin{macrocode} -\newcommand{\@@teenthstringFspanish}[1]{% + +\newcommand{\@@teenthstringFitalian}[1]{% \ifcase#1\relax -d\'ecima% -\or und\'ecima% -\or duod\'ecima% -\or decimotercera% -\or decimocuarta% -\or decimoquinta% -\or decimosexta% -\or decimos\'eptima% -\or decimoctava% -\or decimonovena% +decima% +\or undicesima% +\or dodicesima% +\or tredicesima% +\or quattordicesima% +\or quindicesima% +\or sedicesima% +\or diciassettesima% +\or diciottesima% +\or diciannovesima% \fi } -% \end{macrocode} -% Hundreds (feminine) -% \begin{macrocode} -\newcommand{\@@hundredthstringFspanish}[1]{% + +\newcommand{\@@hundredthstringFitalian}[1]{% \ifcase#1\relax -\or cent\'esima% -\or ducent\'esima% -\or tricent\'esima% -\or cuadringent\'esima% -\or quingent\'esima% -\or sexcent\'esima% -\or septing\'esima% -\or octingent\'esima% -\or noningent\'esima% +\or centesima% +\or duecentesima% +\or trecentesima% +\or quattrocentesima% +\or cinquecentesima% +\or seicentesima% +\or settecentesima% +\or ottocentesima% +\or novecentesima% \fi} -% \end{macrocode} -% As above, but with initial letters in upper case -% \begin{macrocode} -\newcommand{\@@Unitthstringspanish}[1]{% + +\newcommand{\@@Unitthstringitalian}[1]{% \ifcase#1\relax -Cero% -\or Primero% -\or Segundo% -\or Tercero% -\or Cuarto% +Zero% +\or Primo% +\or Secondo% +\or Terzo% +\or Quarto% \or Quinto% -\or Sexto% -\or S\'eptimo% -\or Octavo% -\or Noveno% +\or Sesto% +\or Settimo% +\or Ottavo% +\or Nono% \fi } -% \end{macrocode} -% Tens: -% \begin{macrocode} -\newcommand{\@@Tenthstringspanish}[1]{% + +\newcommand{\@@Tenthstringitalian}[1]{% \ifcase#1\relax -\or D\'ecimo% -\or Vig\'esimo% -\or Trig\'esimo% -\or Cuadrag\'esimo% -\or Quincuag\'esimo% -\or Sexag\'esimo% -\or Septuag\'esimo% -\or Octog\'esimo% -\or Nonag\'esimo% +\or Decimo% +\or Ventesimo% +\or Trentesimo% +\or Quarantesimo% +\or Cinquantesimo% +\or Sessantesimo% +\or Settantesimo% +\or Ottantesimo% +\or Novantesimo% \fi } -% \end{macrocode} -% Teens: -% \begin{macrocode} -\newcommand{\@@Teenthstringspanish}[1]{% + +\newcommand{\@@Teenthstringitalian}[1]{% \ifcase#1\relax -D\'ecimo% -\or Und\'ecimo% -\or Duod\'ecimo% -\or Decimotercero% -\or Decimocuarto% -\or Decimoquinto% -\or Decimosexto% -\or Decimos\'eptimo% -\or Decimoctavo% -\or Decimonoveno% +Decimo% +\or Undicesimo% +\or Dodicesimo% +\or Tredicesimo% +\or Quattordicesimo% +\or Quindicesimo% +\or Sedicesimo% +\or Diciassettesimo% +\or Diciottesimo% +\or Diciannovesimo% \fi } -% \end{macrocode} -% Hundreds -% \begin{macrocode} -\newcommand{\@@Hundredthstringspanish}[1]{% + +\newcommand{\@@Hundredthstringitalian}[1]{% \ifcase#1\relax -\or Cent\'esimo% -\or Ducent\'esimo% -\or Tricent\'esimo% -\or Cuadringent\'esimo% -\or Quingent\'esimo% -\or Sexcent\'esimo% -\or Septing\'esimo% -\or Octingent\'esimo% -\or Noningent\'esimo% +\or Centesimo% +\or Duecentesimo% +\or Trecentesimo% +\or Quattrocentesimo% +\or Cinquecentesimo% +\or Seicentesimo% +\or Settecentesimo% +\or Ottocentesimo% +\or Novecentesimo% \fi} -% \end{macrocode} -% As above, but feminine. -% \begin{macrocode} -\newcommand{\@@UnitthstringFspanish}[1]{% + +\newcommand{\@@UnitthstringFitalian}[1]{% \ifcase#1\relax -Cera% -\or Primera% -\or Segunda% -\or Tercera% -\or Cuarta% +Zero% +\or Prima% +\or Seconda% +\or Terza% +\or Quarta% \or Quinta% -\or Sexta% -\or S\'eptima% -\or Octava% -\or Novena% +\or Sesta% +\or Settima% +\or Ottava% +\or Nona% \fi } -% \end{macrocode} -% Tens (feminine) -% \begin{macrocode} -\newcommand{\@@TenthstringFspanish}[1]{% + +\newcommand{\@@TenthstringFitalian}[1]{% \ifcase#1\relax -\or D\'ecima% -\or Vig\'esima% -\or Trig\'esima% -\or Cuadrag\'esima% -\or Quincuag\'esima% -\or Sexag\'esima% -\or Septuag\'esima% -\or Octog\'esima% -\or Nonag\'esima% +\or Decima% +\or Ventesima% +\or Trentesima% +\or Quarantesima% +\or Cinquantesima% +\or Sessantesima% +\or Settantesima% +\or Ottantesima% +\or Novantesima% \fi } -% \end{macrocode} -% Teens (feminine): -% \begin{macrocode} -\newcommand{\@@TeenthstringFspanish}[1]{% + +\newcommand{\@@TeenthstringFitalian}[1]{% \ifcase#1\relax -D\'ecima% -\or Und\'ecima% -\or Duod\'ecima% -\or Decimotercera% -\or Decimocuarta% -\or Decimoquinta% -\or Decimosexta% -\or Decimos\'eptima% -\or Decimoctava% -\or Decimonovena% +Decima% +\or Undicesima% +\or Dodicesima% +\or Tredicesima% +\or Quattordicesima% +\or Quindicesima% +\or Sedicesima% +\or Diciassettesima% +\or Diciottesima% +\or Diciannovesima% \fi } -% \end{macrocode} -% Hundreds (feminine): -% \begin{macrocode} -\newcommand{\@@HundredthstringFspanish}[1]{% + +\newcommand{\@@HundredthstringFitalian}[1]{% \ifcase#1\relax -\or Cent\'esima% -\or Ducent\'esima% -\or Tricent\'esima% -\or Cuadringent\'esima% -\or Quingent\'esima% -\or Sexcent\'esima% -\or Septing\'esima% -\or Octingent\'esima% -\or Noningent\'esima% +\or Centesima% +\or Duecentesima% +\or Trecentesima% +\or Quattrocentesima% +\or Cinquecentesima% +\or Seicentesima% +\or Settecentesima% +\or Ottocentesima% +\or Novecentesima% \fi} -% \end{macrocode} -% This has changed in version 1.09, so that it now stores the -% results in the second argument (which must be a control -% sequence), but it doesn't display anything. Since it only -% affects internal macros, it shouldn't affect documnets created -% with older versions. (These internal macros are not meant for -% use in documents.) -% \begin{macrocode} -\newcommand{\@@numberstringspanish}[2]{% -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000}% + +\newcommand{\@@numberstringitalian}[2]{% +\def#2{}% +\ifnum#1>99999\relax + \PackageError{fmtcount}{Out of range}% + {This macro only works for values less than 100000}% \else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% -\fi + \ifnum#1<0\relax + \PackageError{fmtcount}{Negative numbers not permitted}% + {This macro does not work for negative numbers, however + you can try typing "minus" first, and then pass the modulus of + this number}% + \fi \fi -\def#2{}% \@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>9 -% #1 is greater or equal to 10000 - \divide\@strctr by 10 - \ifnum\@strctr>1 - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% +\ifnum\@strctr>9\relax + \divide\@strctr by 10\relax + \ifnum\@strctr>1\relax + \edef#2{\@tenstring{\@strctr}}% \@strctr=#1 \divide\@strctr by 1000\relax \@modulo{\@strctr}{10}% \ifnum\@strctr>0\relax @@ -4408,10 +4749,10 @@ this number}% \let\@@fc@numstr#2\relax \edef#2{\@@fc@numstr\ \@thousand}% \else - \ifnum\@strctr>0\relax + \ifnum\@strctr>0\relax \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% \fi \let\@@fc@numstr#2\relax \edef#2{\@@fc@numstr\@thousand}% @@ -4426,20 +4767,19 @@ this number}% \fi \@tmpstrctr=#1\relax \@modulo{\@tmpstrctr}{1000}% + \let\@@fc@numstr#2\relax \ifnum\@tmpstrctr=100\relax - \let\@@fc@numstr#2\relax \edef#2{\@@fc@numstr\@tenstring{10}}% \else - \let\@@fc@numstr#2\relax \edef#2{\@@fc@numstr\@hundredstring{\@strctr}}% \fi \fi \@strctr=#1\relax \@modulo{\@strctr}{100}% \ifnum#1>100\relax - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\ \@andname\ }% - \fi + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname\ }% + \fi \fi \ifnum\@strctr>29\relax \divide\@strctr by 10\relax @@ -4454,8 +4794,8 @@ this number}% \ifnum\@strctr<10\relax \ifnum\@strctr=0\relax \ifnum#1<100\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% \fi \else \let\@@fc@numstr#2\relax @@ -4474,1365 +4814,1801 @@ this number}% \fi \fi } -% \end{macrocode} -% As above, but for ordinals -% \begin{macrocode} -\newcommand{\@@ordinalstringspanish}[2]{% + +\newcommand{\@@ordinalstringitalian}[2]{% \@strctr=#1\relax -\ifnum#1>99999 -\PackageError{fmtcount}{Out of range}% -{This macro only works for values less than 100000}% -\else -\ifnum#1<0 -\PackageError{fmtcount}{Negative numbers not permitted}% -{This macro does not work for negative numbers, however -you can try typing "minus" first, and then pass the modulus of -this number}% -\else \def#2{}% -\ifnum\@strctr>999\relax - \divide\@strctr by 1000\relax - \ifnum\@strctr>1\relax - \ifnum\@strctr>9\relax - \@tmpstrctr=\@strctr - \ifnum\@strctr<20 - \@modulo{\@tmpstrctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenthstring{\@tmpstrctr}}% - \else - \divide\@tmpstrctr by 10\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% - \@tmpstrctr=\@strctr - \@modulo{\@tmpstrctr}{10}% - \ifnum\@tmpstrctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@tmpstrctr}}% +\ifnum#1>99999\relax + \PackageError{fmtcount}{Out of range}% + {This macro only works for values less than 100000}% +\else + \ifnum#1<0\relax + \PackageError{fmtcount}{Negative numbers not permitted}% + {This macro does not work for negative numbers, however + you can try typing "minus" first, and then pass the modulus of + this number}% + \else + \ifnum\@strctr>999\relax + \divide\@strctr by 1000\relax + \ifnum\@strctr>1\relax + \ifnum\@strctr>9\relax + \@tmpstrctr=\@strctr + \ifnum\@strctr<20\relax + \@modulo{\@tmpstrctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenthstring{\@tmpstrctr} }% + \else + \divide\@tmpstrctr by 10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenthstring{\@tmpstrctr} }% + \@tmpstrctr=\@strctr + \@modulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitthstring{\@tmpstrctr} }% + \fi + \fi + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr} }% \fi \fi - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@thousandth}% \fi - \fi - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@thousandth}% -\fi -\@strctr=#1\relax -\@modulo{\@strctr}{1000}% -\ifnum\@strctr>99\relax - \@tmpstrctr=\@strctr - \divide\@tmpstrctr by 100\relax - \ifnum#1>1000\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ }% - \fi - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@hundredthstring{\@tmpstrctr}}% -\fi -\@modulo{\@strctr}{100}% -\ifnum#1>99\relax - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ }% - \fi -\fi -\ifnum\@strctr>19\relax - \@tmpstrctr=\@strctr - \divide\@tmpstrctr by 10\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% - \@tmpstrctr=\@strctr - \@modulo{\@tmpstrctr}{10}% - \ifnum\@tmpstrctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@unitthstring{\@tmpstrctr}}% - \fi -\else - \ifnum\@strctr>9\relax - \@modulo{\@strctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% - \else - \ifnum\@strctr=0\relax - \ifnum#1=0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{0}}% + \@strctr=#1\relax + \@modulo{\@strctr}{1000}% + \ifnum\@strctr>99\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 100\relax + \ifnum#1>1000\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ }% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@hundredthstring{\@tmpstrctr}}% + \fi + \@modulo{\@strctr}{100}% + \ifnum#1>99\relax + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ }% + \fi + \fi + \ifnum\@strctr>19\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenthstring{\@tmpstrctr}}% + \@tmpstrctr=\@strctr + \@modulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@unitthstring{\@tmpstrctr}}% \fi \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \ifnum\@strctr>9\relax + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenthstring{\@strctr}}% + \else + \ifnum\@strctr=0\relax + \ifnum#1=0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{0}}% + \fi + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitthstring{\@strctr}}% + \fi + \fi \fi \fi \fi -\fi -\fi } % \end{macrocode} + %\iffalse % \begin{macrocode} -% +% % \end{macrocode} %\fi %\iffalse % \begin{macrocode} -%<*fc-UKenglish.def> +%<*fc-portuges.def> % \end{macrocode} %\fi -% \subsection{fc-UKenglish.def} -% UK English definitions -% \begin{macrocode} -\ProvidesFile{fc-UKenglish}[2007/06/14] -% \end{macrocode} -% Check that fc-english.def has been loaded -% \begin{macrocode} -\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} -% \end{macrocode} -% These are all just synonyms for the commands provided by -% fc-english.def. -% \begin{macrocode} -\let\@ordinalMUKenglish\@ordinalMenglish -\let\@ordinalFUKenglish\@ordinalMenglish -\let\@ordinalNUKenglish\@ordinalMenglish -\let\@numberstringMUKenglish\@numberstringMenglish -\let\@numberstringFUKenglish\@numberstringMenglish -\let\@numberstringNUKenglish\@numberstringMenglish -\let\@NumberstringMUKenglish\@NumberstringMenglish -\let\@NumberstringFUKenglish\@NumberstringMenglish -\let\@NumberstringNUKenglish\@NumberstringMenglish -\let\@ordinalstringMUKenglish\@ordinalstringMenglish -\let\@ordinalstringFUKenglish\@ordinalstringMenglish -\let\@ordinalstringNUKenglish\@ordinalstringMenglish -\let\@OrdinalstringMUKenglish\@OrdinalstringMenglish -\let\@OrdinalstringFUKenglish\@OrdinalstringMenglish -\let\@OrdinalstringNUKenglish\@OrdinalstringMenglish -% \end{macrocode} -%\iffalse +% \subsubsection{fc-portuges.def} +% Portuguse definitions % \begin{macrocode} -% +\ProvidesFile{fc-portuges.def}[2007/05/26] % \end{macrocode} -%\fi -%\iffalse +% Define macro that converts a number or count register (first +% argument) to an ordinal, and stores the result in the second +% argument, which should be a control sequence. Masculine: % \begin{macrocode} -%<*fc-USenglish.def> +\newcommand*{\@ordinalMportuges}[2]{% +\ifnum#1=0\relax + \edef#2{\number#1}% +\else + \edef#2{\number#1\relax\noexpand\fmtord{o}}% +\fi} % \end{macrocode} -%\fi -% \subsection{fc-USenglish.def} -% US English definitions +% Feminine: % \begin{macrocode} -\ProvidesFile{fc-USenglish}[2007/06/14] +\newcommand*{\@ordinalFportuges}[2]{% +\ifnum#1=0\relax + \edef#2{\number#1}% +\else + \edef#2{\number#1\relax\noexpand\fmtord{a}}% +\fi} % \end{macrocode} -% Check that fc-english.def has been loaded +% Make neuter same as masculine: % \begin{macrocode} -\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} +\let\@ordinalNportuges\@ordinalMportuges % \end{macrocode} -% These are all just synonyms for the commands provided by -% fc-english.def. +% Convert a number to a textual representation. To make it easier, +% split it up into units, tens, teens and hundreds. Units (argument must +% be a number from 0 to 9): % \begin{macrocode} -\let\@ordinalMUSenglish\@ordinalMenglish -\let\@ordinalFUSenglish\@ordinalMenglish -\let\@ordinalNUSenglish\@ordinalMenglish -\let\@numberstringMUSenglish\@numberstringMenglish -\let\@numberstringFUSenglish\@numberstringMenglish -\let\@numberstringNUSenglish\@numberstringMenglish -\let\@NumberstringMUSenglish\@NumberstringMenglish -\let\@NumberstringFUSenglish\@NumberstringMenglish -\let\@NumberstringNUSenglish\@NumberstringMenglish -\let\@ordinalstringMUSenglish\@ordinalstringMenglish -\let\@ordinalstringFUSenglish\@ordinalstringMenglish -\let\@ordinalstringNUSenglish\@ordinalstringMenglish -\let\@OrdinalstringMUSenglish\@OrdinalstringMenglish -\let\@OrdinalstringFUSenglish\@OrdinalstringMenglish -\let\@OrdinalstringNUSenglish\@OrdinalstringMenglish +\newcommand*{\@@unitstringportuges}[1]{% +\ifcase#1\relax +zero% +\or um% +\or dois% +\or tr\^es% +\or quatro% +\or cinco% +\or seis% +\or sete% +\or oito% +\or nove% +\fi +} +% \end{macrocode} +% As above, but for feminine: +% \begin{macrocode} +\newcommand*{\@@unitstringFportuges}[1]{% +\ifcase#1\relax +zero% +\or uma% +\or duas% +\or tr\^es% +\or quatro% +\or cinco% +\or seis% +\or sete% +\or oito% +\or nove% +\fi +} % \end{macrocode} -%\iffalse +% Tens (argument must be a number from 0 to 10): % \begin{macrocode} -% +\newcommand*{\@@tenstringportuges}[1]{% +\ifcase#1\relax +\or dez% +\or vinte% +\or trinta% +\or quarenta% +\or cinq\"uenta% +\or sessenta% +\or setenta% +\or oitenta% +\or noventa% +\or cem% +\fi +} % \end{macrocode} -%\fi -%\iffalse +% Teens (argument must be a number from 0 to 9): % \begin{macrocode} -%<*fmtcount.sty> +\newcommand*{\@@teenstringportuges}[1]{% +\ifcase#1\relax +dez% +\or onze% +\or doze% +\or treze% +\or quatorze% +\or quinze% +\or dezesseis% +\or dezessete% +\or dezoito% +\or dezenove% +\fi +} % \end{macrocode} -%\fi -%\subsection{fmtcount.sty} -% This section deals with the code for |fmtcount.sty| +% Hundreds: % \begin{macrocode} -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fmtcount}[2007/07/20 v1.3] -\RequirePackage{ifthen} -\RequirePackage{keyval} +\newcommand*{\@@hundredstringportuges}[1]{% +\ifcase#1\relax +\or cento% +\or duzentos% +\or trezentos% +\or quatrocentos% +\or quinhentos% +\or seiscentos% +\or setecentos% +\or oitocentos% +\or novecentos% +\fi} % \end{macrocode} -% These commands need to be defined before the -% configuration file is loaded.\changes{1.3}{2007/7/19}{no -%longer using xspace package} -% -% Define the macro to format the |st|, |nd|, |rd| or |th| of an -% ordinal. -%\begin{macro}{\fmtord} +% Hundreds (feminine): % \begin{macrocode} -\providecommand*{\fmtord}[1]{\textsuperscript{#1}} +\newcommand*{\@@hundredstringFportuges}[1]{% +\ifcase#1\relax +\or cento% +\or duzentas% +\or trezentas% +\or quatrocentas% +\or quinhentas% +\or seiscentas% +\or setecentas% +\or oitocentas% +\or novecentas% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\padzeros} -%\begin{definition} -%\cs{padzeroes}\oarg{n} -%\end{definition} -% Specifies how many digits should be displayed for commands such as -% \cs{decimal} and \cs{binary}. +% Units (initial letter in upper case): % \begin{macrocode} -\newcount\c@padzeroesN -\c@padzeroesN=1\relax -\providecommand*{\padzeroes}[1][17]{\c@padzeroesN=#1} +\newcommand*{\@@Unitstringportuges}[1]{% +\ifcase#1\relax +Zero% +\or Um% +\or Dois% +\or Tr\^es% +\or Quatro% +\or Cinco% +\or Seis% +\or Sete% +\or Oito% +\or Nove% +\fi +} % \end{macrocode} -%\end{macro} -% Load appropriate language definition files: -%\changes{v1.1}{14 June 2007}{added check for UKenglish, -% british and USenglish babel settings} +% As above, but feminine: % \begin{macrocode} -\@ifundefined{l@english}{}{\input{fc-english.def}} -\@ifundefined{l@UKenglish}{}{\input{fc-UKenglish.def}} -\@ifundefined{l@british}{}{\input{fc-british.def}} -\@ifundefined{l@USenglish}{}{\input{fc-USenglish.def}} -\@ifundefined{l@spanish}{}{\input{fc-spanish.def}} -\@ifundefined{l@portuges}{}{\input{fc-portuges.def}} -\@ifundefined{l@french}{}{\input{fc-french.def}} -\@ifundefined{l@german}{% -\@ifundefined{l@ngerman}{}{\input{fc-german.def}}}{% -\input{fc-german.def}} +\newcommand*{\@@UnitstringFportuges}[1]{% +\ifcase#1\relax +Zera% +\or Uma% +\or Duas% +\or Tr\^es% +\or Quatro% +\or Cinco% +\or Seis% +\or Sete% +\or Oito% +\or Nove% +\fi +} % \end{macrocode} -%\begin{macro}{\fmtcount@french} -% Define keys for use with |\fmtcountsetoptions|. -% Key to switch French dialects (Does babel store -%this kind of information?) +% Tens (with initial letter in upper case): % \begin{macrocode} -\def\fmtcount@french{france} -\define@key{fmtcount}{french}[france]{% -\@ifundefined{datefrench}{% -\PackageError{fmtcount}{Language `french' not defined}{You need -to load babel before loading fmtcount}}{ -\ifthenelse{\equal{#1}{france} - \or\equal{#1}{swiss} - \or\equal{#1}{belgian}}{% - \def\fmtcount@french{#1}}{% -\PackageError{fmtcount}{Invalid value `#1' to french key} -{Option `french' can only take the values `france', -`belgian' or `swiss'}} -}} +\newcommand*{\@@Tenstringportuges}[1]{% +\ifcase#1\relax +\or Dez% +\or Vinte% +\or Trinta% +\or Quarenta% +\or Cinq\"uenta% +\or Sessenta% +\or Setenta% +\or Oitenta% +\or Noventa% +\or Cem% +\fi +} % \end{macrocode} -%\end{macro} -% Key to determine how to display the ordinal +% Teens (with initial letter in upper case): % \begin{macrocode} -\define@key{fmtcount}{fmtord}{% -\ifthenelse{\equal{#1}{level} - \or\equal{#1}{raise} - \or\equal{#1}{user}}{ - \def\fmtcount@fmtord{#1}}{% -\PackageError{fmtcount}{Invalid value `#1' to fmtord key} -{Option `fmtord' can only take the values `level', `raise' -or `user'}}} +\newcommand*{\@@Teenstringportuges}[1]{% +\ifcase#1\relax +Dez% +\or Onze% +\or Doze% +\or Treze% +\or Quatorze% +\or Quinze% +\or Dezesseis% +\or Dezessete% +\or Dezoito% +\or Dezenove% +\fi +} % \end{macrocode} -%\begin{macro}{\iffmtord@abbrv} -% Key to determine whether the ordinal should be abbreviated -% (language dependent, currently only affects French ordinals.) +% Hundreds (with initial letter in upper case): % \begin{macrocode} -\newif\iffmtord@abbrv -\fmtord@abbrvfalse -\define@key{fmtcount}{abbrv}[true]{% -\ifthenelse{\equal{#1}{true}\or\equal{#1}{false}}{ - \csname fmtord@abbrv#1\endcsname}{% -\PackageError{fmtcount}{Invalid value `#1' to fmtord key} -{Option `fmtord' can only take the values `true' or -`false'}}} +\newcommand*{\@@Hundredstringportuges}[1]{% +\ifcase#1\relax +\or Cento% +\or Duzentos% +\or Trezentos% +\or Quatrocentos% +\or Quinhentos% +\or Seiscentos% +\or Setecentos% +\or Oitocentos% +\or Novecentos% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\fmtcountsetoptions} -% Define command to set options. +% As above, but feminine: % \begin{macrocode} -\newcommand*{\fmtcountsetoptions}[1]{% -\def\fmtcount@fmtord{}% -\setkeys{fmtcount}{#1}% -\@ifundefined{datefrench}{}{% -\edef\@ordinalstringMfrench{\noexpand -\csname @ordinalstringMfrench\fmtcount@french\noexpand\endcsname}% -\edef\@ordinalstringFfrench{\noexpand -\csname @ordinalstringFfrench\fmtcount@french\noexpand\endcsname}% -\edef\@OrdinalstringMfrench{\noexpand -\csname @OrdinalstringMfrench\fmtcount@french\noexpand\endcsname}% -\edef\@OrdinalstringFfrench{\noexpand -\csname @OrdinalstringFfrench\fmtcount@french\noexpand\endcsname}% -\edef\@numberstringMfrench{\noexpand -\csname @numberstringMfrench\fmtcount@french\noexpand\endcsname}% -\edef\@numberstringFfrench{\noexpand -\csname @numberstringFfrench\fmtcount@french\noexpand\endcsname}% -\edef\@NumberstringMfrench{\noexpand -\csname @NumberstringMfrench\fmtcount@french\noexpand\endcsname}% -\edef\@NumberstringFfrench{\noexpand -\csname @NumberstringFfrench\fmtcount@french\noexpand\endcsname}% -}% -% -\ifthenelse{\equal{\fmtcount@fmtord}{level}}{% -\renewcommand{\fmtord}[1]{##1}}{% -\ifthenelse{\equal{\fmtcount@fmtord}{raise}}{% -\renewcommand{\fmtord}[1]{\textsuperscript{##1}}}{% -}} -} +\newcommand*{\@@HundredstringFportuges}[1]{% +\ifcase#1\relax +\or Cento% +\or Duzentas% +\or Trezentas% +\or Quatrocentas% +\or Quinhentas% +\or Seiscentas% +\or Setecentas% +\or Oitocentas% +\or Novecentas% +\fi} % \end{macrocode} -%\end{macro} -% Load confguration file if it exists. This needs to be done -% before the package options, to allow the user to override -% the settings in the configuration file. +% This has changed in version 1.08, so that it now stores +% the result in the second argument, but doesn't display +% anything. Since it only affects internal macros, it shouldn't +% affect documents created with older versions. (These internal +% macros are not meant for use in documents.) % \begin{macrocode} -\InputIfFileExists{fmtcount.cfg}{% -\typeout{Using configuration file fmtcount.cfg}}{% -\typeout{No configuration file fmtcount.cfg found.}} +\DeclareRobustCommand{\@numberstringMportuges}[2]{% +\let\@unitstring=\@@unitstringportuges +\let\@teenstring=\@@teenstringportuges +\let\@tenstring=\@@tenstringportuges +\let\@hundredstring=\@@hundredstringportuges +\def\@hundred{cem}\def\@thousand{mil}% +\def\@andname{e}% +\@@numberstringportuges{#1}{#2}} % \end{macrocode} -%Declare options +% As above, but feminine form: % \begin{macrocode} -\DeclareOption{level}{\def\fmtcount@fmtord{level}% -\def\fmtord#1{#1}} -\DeclareOption{raise}{\def\fmtcount@fmtord{raise}% -\def\fmtord#1{\textsuperscript{#1}}} +\DeclareRobustCommand{\@numberstringFportuges}[2]{% +\let\@unitstring=\@@unitstringFportuges +\let\@teenstring=\@@teenstringportuges +\let\@tenstring=\@@tenstringportuges +\let\@hundredstring=\@@hundredstringFportuges +\def\@hundred{cem}\def\@thousand{mil}% +\def\@andname{e}% +\@@numberstringportuges{#1}{#2}} % \end{macrocode} -% Process package options +% Make neuter same as masculine: % \begin{macrocode} -\ProcessOptions +\let\@numberstringNportuges\@numberstringMportuges % \end{macrocode} -%\begin{macro}{\@modulo} -%\begin{definition} -%\cs{@modulo}\marg{count reg}\marg{n} -%\end{definition} -% Sets the count register to be its value modulo \meta{n}. -% This is used for the -% date, time, ordinal and numberstring commands. (The fmtcount -% package was originally part of the datetime package.) +% As above, but initial letters in upper case: % \begin{macrocode} -\newcount\@DT@modctr -\def\@modulo#1#2{% -\@DT@modctr=#1\relax -\divide \@DT@modctr by #2\relax -\multiply \@DT@modctr by #2\relax -\advance #1 by -\@DT@modctr} +\DeclareRobustCommand{\@NumberstringMportuges}[2]{% +\let\@unitstring=\@@Unitstringportuges +\let\@teenstring=\@@Teenstringportuges +\let\@tenstring=\@@Tenstringportuges +\let\@hundredstring=\@@Hundredstringportuges +\def\@hundred{Cem}\def\@thousand{Mil}% +\def\@andname{e}% +\@@numberstringportuges{#1}{#2}} % \end{macrocode} -%\end{macro} -% The following registers are needed by |\@ordinal| etc +% As above, but feminine form: % \begin{macrocode} -\newcount\@ordinalctr -\newcount\@orgargctr -\newcount\@strctr -\newcount\@tmpstrctr +\DeclareRobustCommand{\@NumberstringFportuges}[2]{% +\let\@unitstring=\@@UnitstringFportuges +\let\@teenstring=\@@Teenstringportuges +\let\@tenstring=\@@Tenstringportuges +\let\@hundredstring=\@@HundredstringFportuges +\def\@hundred{Cem}\def\@thousand{Mil}% +\def\@andname{e}% +\@@numberstringportuges{#1}{#2}} % \end{macrocode} -%Define commands that display numbers in different bases. -% Define counters and conditionals needed. +% Make neuter same as masculine: % \begin{macrocode} -\newif\if@DT@padzeroes -\newcount\@DT@loopN -\newcount\@DT@X +\let\@NumberstringNportuges\@NumberstringMportuges % \end{macrocode} -%\begin{macro}{\binarynum} -% Converts a decimal number to binary, and display. +% As above, but for ordinals. % \begin{macrocode} -\newcommand*{\@binary}[1]{% -\@DT@padzeroestrue -\@DT@loopN=17\relax -\@strctr=\@DT@loopN -\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% -\@strctr=65536\relax -\@DT@X=#1\relax -\loop -\@DT@modctr=\@DT@X -\divide\@DT@modctr by \@strctr -\ifthenelse{\boolean{@DT@padzeroes} \and \(\@DT@modctr=0\) \and \(\@DT@loopN>\c@padzeroesN\)}{}{\the\@DT@modctr}% -\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi -\multiply\@DT@modctr by \@strctr -\advance\@DT@X by -\@DT@modctr -\divide\@strctr by 2\relax -\advance\@DT@loopN by -1\relax -\ifnum\@strctr>1 -\repeat -\the\@DT@X} - -\let\binarynum=\@binary +\DeclareRobustCommand{\@ordinalstringMportuges}[2]{% +\let\@unitthstring=\@@unitthstringportuges +\let\@unitstring=\@@unitstringportuges +\let\@teenthstring=\@@teenthstringportuges +\let\@tenthstring=\@@tenthstringportuges +\let\@hundredthstring=\@@hundredthstringportuges +\def\@thousandth{mil\'esimo}% +\@@ordinalstringportuges{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\octalnum} -% Converts a decimal number to octal, and displays. +% Feminine form: % \begin{macrocode} -\newcommand*{\@octal}[1]{% -\ifnum#1>32768 -\PackageError{fmtcount}{Value of counter too large for \protect\@octal}{Maximum value 32768} -\else -\@DT@padzeroestrue -\@DT@loopN=6\relax -\@strctr=\@DT@loopN -\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% -\@strctr=32768\relax -\@DT@X=#1\relax -\loop -\@DT@modctr=\@DT@X -\divide\@DT@modctr by \@strctr -\ifthenelse{\boolean{@DT@padzeroes} \and \(\@DT@modctr=0\) \and \(\@DT@loopN>\c@padzeroesN\)}{}{\the\@DT@modctr}% -\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi -\multiply\@DT@modctr by \@strctr -\advance\@DT@X by -\@DT@modctr -\divide\@strctr by 8\relax -\advance\@DT@loopN by -1\relax -\ifnum\@strctr>1 -\repeat -\the\@DT@X -\fi} -\let\octalnum=\@octal +\DeclareRobustCommand{\@ordinalstringFportuges}[2]{% +\let\@unitthstring=\@@unitthstringFportuges +\let\@unitstring=\@@unitstringFportuges +\let\@teenthstring=\@@teenthstringportuges +\let\@tenthstring=\@@tenthstringFportuges +\let\@hundredthstring=\@@hundredthstringFportuges +\def\@thousandth{mil\'esima}% +\@@ordinalstringportuges{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\hexadecimalnum} -% Converts a decimal number to a lowercase hexadecimal number, -% and displays it. +% Make neuter same as masculine: % \begin{macrocode} -\newcommand*{\@@hexadecimal}[1]{\ifcase#10\or1\or2\or3\or4\or5\or -6\or7\or8\or9\or a\or b\or c\or d\or e\or f\fi} - -\newcommand*{\@hexadecimal}[1]{% -\@DT@padzeroestrue -\@DT@loopN=5\relax -\@strctr=\@DT@loopN -\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% -\@strctr=65536\relax -\@DT@X=#1\relax -\loop -\@DT@modctr=\@DT@X -\divide\@DT@modctr by \@strctr -\ifthenelse{\boolean{@DT@padzeroes}\and\(\@DT@modctr=0\)\and -\(\@DT@loopN>\c@padzeroesN\)}{}{\@@hexadecimal\@DT@modctr}% -\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi -\multiply\@DT@modctr by \@strctr -\advance\@DT@X by -\@DT@modctr -\divide\@strctr by 16\relax -\advance\@DT@loopN by -1\relax -\ifnum\@strctr>1 -\repeat -\@@hexadecimal\@DT@X} - -\let\hexadecimalnum=\@hexadecimal +\let\@ordinalstringNportuges\@ordinalstringMportuges +% \end{macrocode} +% As above, but initial letters in upper case (masculine): +% \begin{macrocode} +\DeclareRobustCommand{\@OrdinalstringMportuges}[2]{% +\let\@unitthstring=\@@Unitthstringportuges +\let\@unitstring=\@@Unitstringportuges +\let\@teenthstring=\@@teenthstringportuges +\let\@tenthstring=\@@Tenthstringportuges +\let\@hundredthstring=\@@Hundredthstringportuges +\def\@thousandth{Mil\'esimo}% +\@@ordinalstringportuges{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\Hexadecimalnum} -% Uppercase hexadecimal +% Feminine form: % \begin{macrocode} -\newcommand*{\@@Hexadecimal}[1]{\ifcase#10\or1\or2\or3\or4\or5\or6\or -7\or8\or9\or A\or B\or C\or D\or E\or F\fi} - -\newcommand*{\@Hexadecimal}[1]{% -\@DT@padzeroestrue -\@DT@loopN=5\relax -\@strctr=\@DT@loopN -\whiledo{\@strctr<\c@padzeroesN}{0\advance\@strctr by 1}% -\@strctr=65536\relax -\@DT@X=#1\relax -\loop -\@DT@modctr=\@DT@X -\divide\@DT@modctr by \@strctr -\ifthenelse{\boolean{@DT@padzeroes} \and \(\@DT@modctr=0\) \and \(\@DT@loopN>\c@padzeroesN\)}{}{\@@Hexadecimal\@DT@modctr}% -\ifnum\@DT@modctr=0\else\@DT@padzeroesfalse\fi -\multiply\@DT@modctr by \@strctr -\advance\@DT@X by -\@DT@modctr -\divide\@strctr by 16\relax -\advance\@DT@loopN by -1\relax -\ifnum\@strctr>1 -\repeat -\@@Hexadecimal\@DT@X} - -\let\Hexadecimalnum=\@Hexadecimal +\DeclareRobustCommand{\@OrdinalstringFportuges}[2]{% +\let\@unitthstring=\@@UnitthstringFportuges +\let\@unitstring=\@@UnitstringFportuges +\let\@teenthstring=\@@teenthstringportuges +\let\@tenthstring=\@@TenthstringFportuges +\let\@hundredthstring=\@@HundredthstringFportuges +\def\@thousandth{Mil\'esima}% +\@@ordinalstringportuges{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\aaalphnum} -% Lowercase alphabetical representation (a \ldots\ z aa \ldots\ zz) +% Make neuter same as masculine: % \begin{macrocode} -\newcommand*{\@aaalph}[1]{% -\@DT@loopN=#1\relax -\advance\@DT@loopN by -1\relax -\divide\@DT@loopN by 26\relax -\@DT@modctr=\@DT@loopN -\multiply\@DT@modctr by 26\relax -\@DT@X=#1\relax -\advance\@DT@X by -1\relax -\advance\@DT@X by -\@DT@modctr -\advance\@DT@loopN by 1\relax -\advance\@DT@X by 1\relax -\loop -\@alph\@DT@X -\advance\@DT@loopN by -1\relax -\ifnum\@DT@loopN>0 -\repeat -} - -\let\aaalphnum=\@aaalph +\let\@OrdinalstringNportuges\@OrdinalstringMportuges % \end{macrocode} -%\end{macro} -%\begin{macro}{\AAAlphnum} -% Uppercase alphabetical representation (a \ldots\ z aa \ldots\ zz) +% In order to do the ordinals, split into units, teens, tens +% and hundreds. Units: % \begin{macrocode} -\newcommand*{\@AAAlph}[1]{% -\@DT@loopN=#1\relax -\advance\@DT@loopN by -1\relax -\divide\@DT@loopN by 26\relax -\@DT@modctr=\@DT@loopN -\multiply\@DT@modctr by 26\relax -\@DT@X=#1\relax -\advance\@DT@X by -1\relax -\advance\@DT@X by -\@DT@modctr -\advance\@DT@loopN by 1\relax -\advance\@DT@X by 1\relax -\loop -\@Alph\@DT@X -\advance\@DT@loopN by -1\relax -\ifnum\@DT@loopN>0 -\repeat +\newcommand*{\@@unitthstringportuges}[1]{% +\ifcase#1\relax +zero% +\or primeiro% +\or segundo% +\or terceiro% +\or quarto% +\or quinto% +\or sexto% +\or s\'etimo% +\or oitavo% +\or nono% +\fi } - -\let\AAAlphnum=\@AAAlph % \end{macrocode} -%\end{macro} -%\begin{macro}{\abalphnum} -% Lowercase alphabetical representation +% Tens: % \begin{macrocode} -\newcommand*{\@abalph}[1]{% -\ifnum#1>17576\relax -\PackageError{fmtcount}{Value of counter too large for -\protect\@abalph}{Maximum value 17576}% -\else -\@DT@padzeroestrue -\@strctr=17576\relax -\@DT@X=#1\relax -\advance\@DT@X by -1\relax -\loop -\@DT@modctr=\@DT@X -\divide\@DT@modctr by \@strctr -\ifthenelse{\boolean{@DT@padzeroes}\and -\(\@DT@modctr=1\)}{}{\@alph\@DT@modctr}% -\ifnum\@DT@modctr=1\else\@DT@padzeroesfalse\fi -\multiply\@DT@modctr by \@strctr -\advance\@DT@X by -\@DT@modctr -\divide\@strctr by 26\relax -\ifnum\@strctr>1 -\repeat -\advance\@DT@X by 1\relax -\@alph\@DT@X -\fi} - -\let\abalphnum=\@abalph +\newcommand*{\@@tenthstringportuges}[1]{% +\ifcase#1\relax +\or d\'ecimo% +\or vig\'esimo% +\or trig\'esimo% +\or quadrag\'esimo% +\or q\"uinquag\'esimo% +\or sexag\'esimo% +\or setuag\'esimo% +\or octog\'esimo% +\or nonag\'esimo% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ABAlphnum} -% Uppercase alphabetical representation +% Teens: % \begin{macrocode} -\newcommand*{\@ABAlph}[1]{% -\ifnum#1>17576\relax -\PackageError{fmtcount}{Value of counter too large for -\protect\@ABAlph}{Maximum value 17576}% -\else -\@DT@padzeroestrue -\@strctr=17576\relax -\@DT@X=#1\relax -\advance\@DT@X by -1\relax -\loop -\@DT@modctr=\@DT@X -\divide\@DT@modctr by \@strctr -\ifthenelse{\boolean{@DT@padzeroes}\and -\(\@DT@modctr=1\)}{}{\@Alph\@DT@modctr}% -\ifnum\@DT@modctr=1\else\@DT@padzeroesfalse\fi -\multiply\@DT@modctr by \@strctr -\advance\@DT@X by -\@DT@modctr -\divide\@strctr by 26\relax -\ifnum\@strctr>1 -\repeat -\advance\@DT@X by 1\relax -\@Alph\@DT@X +\newcommand*{\@@teenthstringportuges}[1]{% +\@tenthstring{1}% +\ifnum#1>0\relax +-\@unitthstring{#1}% \fi} - -\let\ABAlphnum=\@ABAlph % \end{macrocode} -%\end{macro} -%\begin{macro}{\@fmtc@count} -% Recursive command to count number of characters in argument. -% |\@strctr| should be set to zero before calling it. +% Hundreds: % \begin{macrocode} -\def\@fmtc@count#1#2\relax{% -\if\relax#1 -\else -\advance\@strctr by 1\relax -\@fmtc@count#2\relax +\newcommand*{\@@hundredthstringportuges}[1]{% +\ifcase#1\relax +\or cent\'esimo% +\or ducent\'esimo% +\or trecent\'esimo% +\or quadringent\'esimo% +\or q\"uingent\'esimo% +\or seiscent\'esimo% +\or setingent\'esimo% +\or octingent\'esimo% +\or nongent\'esimo% \fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@decimal} -% Format number as a decimal, possibly padded with zeroes in front. +% Units (feminine): % \begin{macrocode} -\newcommand{\@decimal}[1]{% -\@strctr=0\relax -\expandafter\@fmtc@count\number#1\relax -\@DT@loopN=\c@padzeroesN -\advance\@DT@loopN by -\@strctr -\ifnum\@DT@loopN>0\relax -\@strctr=0\relax -\whiledo{\@strctr < \@DT@loopN}{0\advance\@strctr by 1}% +\newcommand*{\@@unitthstringFportuges}[1]{% +\ifcase#1\relax +zero% +\or primeira% +\or segunda% +\or terceira% +\or quarta% +\or quinta% +\or sexta% +\or s\'etima% +\or oitava% +\or nona% \fi -\number#1\relax } - -\let\decimalnum=\@decimal -% \end{macrocode} -%\end{macro} -%\begin{macro}{\FCordinal} -%\begin{definition} -%\cs{FCordinal}\marg{number} -%\end{definition} -% This is a bit cumbersome. Previously \cs{@ordinal} -% was defined in a similar way to \cs{abalph} etc. -% This ensured that the actual value of the counter was -% written in the new label stuff in the .aux file. However -% adding in an optional argument to determine the gender -% for multilingual compatibility messed things up somewhat. -% This was the only work around I could get to keep the -% the cross-referencing stuff working, which is why -% the optional argument comes \emph{after} the compulsory -% argument, instead of the usual manner of placing it before. -% Note however, that putting the optional argument means that -% any spaces will be ignored after the command if the optional -% argument is omitted. -% Version 1.04 changed \cs{ordinal} to \cs{FCordinal} -% to prevent it clashing with the memoir class. -% \begin{macrocode} -\newcommand{\FCordinal}[1]{% -\expandafter\protect\expandafter\ordinalnum{% -\expandafter\the\csname c@#1\endcsname}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ordinal} -% If \cs{ordinal} isn't defined make \cs{ordinal} a synonym -% for \cs{FCordinal} to maintain compatibility with previous -% versions. +% Tens (feminine): % \begin{macrocode} -\@ifundefined{ordinal}{\let\ordinal\FCordinal}{% -\PackageWarning{fmtcount}{\string\ordinal -\space already defined use \string\FCordinal \space instead.}} +\newcommand*{\@@tenthstringFportuges}[1]{% +\ifcase#1\relax +\or d\'ecima% +\or vig\'esima% +\or trig\'esima% +\or quadrag\'esima% +\or q\"uinquag\'esima% +\or sexag\'esima% +\or setuag\'esima% +\or octog\'esima% +\or nonag\'esima% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ordinalnum} -% Display ordinal where value is given as a number or -% count register instead of a counter: +% Hundreds (feminine): % \begin{macrocode} -\newcommand*{\ordinalnum}[1]{\@ifnextchar[{\@ordinalnum{#1}}{% -\@ordinalnum{#1}[m]}} +\newcommand*{\@@hundredthstringFportuges}[1]{% +\ifcase#1\relax +\or cent\'esima% +\or ducent\'esima% +\or trecent\'esima% +\or quadringent\'esima% +\or q\"uingent\'esima% +\or seiscent\'esima% +\or setingent\'esima% +\or octingent\'esima% +\or nongent\'esima% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@ordinalnum} -% Display ordinal according to gender (neuter added in v1.1, -% \cs{xspace} added in v1.2, and removed in v1.3\footnote{I -%couldn't get it to work consistently both with and without the -%optional argument}): +% As above, but with initial letter in upper case. Units: % \begin{macrocode} -\def\@ordinalnum#1[#2]{{% -\ifthenelse{\equal{#2}{f}}{% - \protect\@ordinalF{#1}{\@fc@ordstr}% - }{% - \ifthenelse{\equal{#2}{n}}{% - \protect\@ordinalN{#1}{\@fc@ordstr}% - }{% - \ifthenelse{\equal{#2}{m}}{}{% - \PackageError{fmtcount}{Invalid gender option `#2'}{% - Available options are m, f or n}% - }% - \protect\@ordinalM{#1}{\@fc@ordstr}% - }% - }% -\@fc@ordstr -}} +\newcommand*{\@@Unitthstringportuges}[1]{% +\ifcase#1\relax +Zero% +\or Primeiro% +\or Segundo% +\or Terceiro% +\or Quarto% +\or Quinto% +\or Sexto% +\or S\'etimo% +\or Oitavo% +\or Nono% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeordinal} -% Store the ordinal (first argument -% is identifying name, second argument is a counter.) +% Tens: % \begin{macrocode} -\newcommand*{\storeordinal}[2]{% -\expandafter\protect\expandafter\storeordinalnum{#1}{% -\expandafter\the\csname c@#2\endcsname}} +\newcommand*{\@@Tenthstringportuges}[1]{% +\ifcase#1\relax +\or D\'ecimo% +\or Vig\'esimo% +\or Trig\'esimo% +\or Quadrag\'esimo% +\or Q\"uinquag\'esimo% +\or Sexag\'esimo% +\or Setuag\'esimo% +\or Octog\'esimo% +\or Nonag\'esimo% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeordinalnum} -% Store ordinal (first argument -% is identifying name, second argument is a number or -% count register.) +% Hundreds: % \begin{macrocode} -\newcommand*{\storeordinalnum}[2]{% -\@ifnextchar[{\@storeordinalnum{#1}{#2}}{% -\@storeordinalnum{#1}{#2}[m]}} +\newcommand*{\@@Hundredthstringportuges}[1]{% +\ifcase#1\relax +\or Cent\'esimo% +\or Ducent\'esimo% +\or Trecent\'esimo% +\or Quadringent\'esimo% +\or Q\"uingent\'esimo% +\or Seiscent\'esimo% +\or Setingent\'esimo% +\or Octingent\'esimo% +\or Nongent\'esimo% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@storeordinalnum} -% Store ordinal according to gender: +% As above, but feminine. Units: % \begin{macrocode} -\def\@storeordinalnum#1#2[#3]{% -\ifthenelse{\equal{#3}{f}}{% -\protect\@ordinalF{#2}{\@fc@ord}}{% -\ifthenelse{\equal{#3}{n}}{% -\protect\@ordinalN{#2}{\@fc@ord}}{% -\ifthenelse{\equal{#3}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#3'}{% -Available options are m or f}}% -\protect\@ordinalM{#2}{\@fc@ord}}}% -\expandafter\let\csname @fcs@#1\endcsname\@fc@ord} +\newcommand*{\@@UnitthstringFportuges}[1]{% +\ifcase#1\relax +Zera% +\or Primeira% +\or Segunda% +\or Terceira% +\or Quarta% +\or Quinta% +\or Sexta% +\or S\'etima% +\or Oitava% +\or Nona% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\FMCuse} -% Get stored information: +% Tens (feminine); % \begin{macrocode} -\newcommand*{\FMCuse}[1]{\csname @fcs@#1\endcsname} +\newcommand*{\@@TenthstringFportuges}[1]{% +\ifcase#1\relax +\or D\'ecima% +\or Vig\'esima% +\or Trig\'esima% +\or Quadrag\'esima% +\or Q\"uinquag\'esima% +\or Sexag\'esima% +\or Setuag\'esima% +\or Octog\'esima% +\or Nonag\'esima% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ordinalstring} -% Display ordinal as a string (argument is a counter) +% Hundreds (feminine): % \begin{macrocode} -\newcommand*{\ordinalstring}[1]{% -\expandafter\protect\expandafter\ordinalstringnum{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand*{\@@HundredthstringFportuges}[1]{% +\ifcase#1\relax +\or Cent\'esima% +\or Ducent\'esima% +\or Trecent\'esima% +\or Quadringent\'esima% +\or Q\"uingent\'esima% +\or Seiscent\'esima% +\or Setingent\'esima% +\or Octingent\'esima% +\or Nongent\'esima% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ordinalstringnum} -% Display ordinal as a string (argument is a count register or -% number.) +% This has changed in version 1.09, so that it now stores +% the result in the second argument (a control sequence), but it +% doesn't display anything. Since it only affects internal macros, +% it shouldn't affect documents created with older versions. +% (These internal macros are not meant for use in documents.) % \begin{macrocode} -\newcommand{\ordinalstringnum}[1]{% -\@ifnextchar[{\@ordinal@string{#1}}{\@ordinal@string{#1}[m]}} +\newcommand*{\@@numberstringportuges}[2]{% +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\fi +\fi +\def#2{}% +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>9 +% #1 is greater or equal to 10000 + \divide\@strctr by 10 + \ifnum\@strctr>1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1 \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \ifnum\@strctr>0 + \ifnum\@strctr=1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname}% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% + \fi + \else + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@thousand}% +\else + \ifnum\@strctr>0\relax + \ifnum\@strctr>1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@thousand}% + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{1000}% +\divide\@strctr by 100\relax +\ifnum\@strctr>0\relax + \ifnum#1>1000 \relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ }% + \fi + \@tmpstrctr=#1\relax + \@modulo{\@tmpstrctr}{1000}% + \let\@@fc@numstr#2\relax + \ifnum\@tmpstrctr=100\relax + \edef#2{\@@fc@numstr\@tenstring{10}}% + \else + \edef#2{\@@fc@numstr\@hundredstring{\@strctr}}% + \fi% +\fi +\@strctr=#1\relax \@modulo{\@strctr}{100}% +\ifnum#1>100\relax + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname\ }% + \fi +\fi +\ifnum\@strctr>19\relax + \divide\@strctr by 10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{10}% + \ifnum\@strctr>0 + \ifnum\@strctr=1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname}% + \else + \ifnum#1>100\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname}% + \fi + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% + \fi +\else + \ifnum\@strctr<10\relax + \ifnum\@strctr=0\relax + \ifnum#1<100\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + \else%(>0,<10) + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + \else%>10 + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \fi +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@ordinal@string} -% Display ordinal as a string according to gender. +% As above, but for ordinals. % \begin{macrocode} -\def\@ordinal@string#1[#2]{{% -\ifthenelse{\equal{#2}{f}}{% -\protect\@ordinalstringF{#1}{\@fc@ordstr}}{% -\ifthenelse{\equal{#2}{n}}{% -\protect\@ordinalstringN{#1}{\@fc@ordstr}}{% -\ifthenelse{\equal{#2}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#2' to -\string\ordinalstring}{Available options are m, f or f}}% -\protect\@ordinalstringM{#1}{\@fc@ordstr}}}\@fc@ordstr}} +\newcommand*{\@@ordinalstringportuges}[2]{% +\@strctr=#1\relax +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\else +\def#2{}% +\ifnum\@strctr>999\relax + \divide\@strctr by 1000\relax + \ifnum\@strctr>1\relax + \ifnum\@strctr>9\relax + \@tmpstrctr=\@strctr + \ifnum\@strctr<20 + \@modulo{\@tmpstrctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenthstring{\@tmpstrctr}}% + \else + \divide\@tmpstrctr by 10\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% + \@tmpstrctr=\@strctr + \@modulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@tmpstrctr}}% + \fi + \fi + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \fi + \fi + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@thousandth}% +\fi +\@strctr=#1\relax +\@modulo{\@strctr}{1000}% +\ifnum\@strctr>99\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 100\relax + \ifnum#1>1000\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr-}% + \fi + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@hundredthstring{\@tmpstrctr}}% +\fi +\@modulo{\@strctr}{100}% +\ifnum#1>99\relax + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr-}% + \fi +\fi +\ifnum\@strctr>9\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 10\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% + \@tmpstrctr=\@strctr + \@modulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr-\@unitthstring{\@tmpstrctr}}% + \fi +\else + \ifnum\@strctr=0\relax + \ifnum#1=0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{0}}% + \fi + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi +\fi +\fi +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeordinalstring} -% Store textual representation of number. First argument is -% identifying name, second argument is the counter set to the -% required number. +%\iffalse % \begin{macrocode} -\newcommand*{\storeordinalstring}[2]{% -\expandafter\protect\expandafter\storeordinalstringnum{#1}{% -\expandafter\the\csname c@#2\endcsname}} +% % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeordinalstringnum} -% Store textual representation of number. First argument is -% identifying name, second argument is a count register or number. +%\fi +%\iffalse % \begin{macrocode} -\newcommand*{\storeordinalstringnum}[2]{% -\@ifnextchar[{\@store@ordinal@string{#1}{#2}}{% -\@store@ordinal@string{#1}{#2}[m]}} +%<*fc-spanish.def> % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@ordinal@string} -% Store textual representation of number according to gender. +%\fi +% \subsubsection{fc-spanish.def} +% Spanish definitions % \begin{macrocode} -\def\@store@ordinal@string#1#2[#3]{% -\ifthenelse{\equal{#3}{f}}{% -\protect\@ordinalstringF{#2}{\@fc@ordstr}}{% -\ifthenelse{\equal{#3}{n}}{% -\protect\@ordinalstringN{#2}{\@fc@ordstr}}{% -\ifthenelse{\equal{#3}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#3' to -\string\ordinalstring}{Available options are m, f or n}}% -\protect\@ordinalstringM{#2}{\@fc@ordstr}}}% -\expandafter\let\csname @fcs@#1\endcsname\@fc@ordstr} +\ProvidesFile{fc-spanish.def}[2007/05/26] % \end{macrocode} -%\end{macro} -%\begin{macro}{\Ordinalstring} -% Display ordinal as a string with initial letters in upper case -% (argument is a counter) +% Define macro that converts a number or count register (first +% argument) to an ordinal, and stores the result in the +% second argument, which must be a control sequence. +% Masculine: % \begin{macrocode} -\newcommand*{\Ordinalstring}[1]{% -\expandafter\protect\expandafter\Ordinalstringnum{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@ordinalMspanish}[2]{% +\edef#2{\number#1\relax\noexpand\fmtord{o}}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\Ordinalstringnum} -% Display ordinal as a string with initial letters in upper case -% (argument is a number or count register) +% Feminine: % \begin{macrocode} -\newcommand*{\Ordinalstringnum}[1]{% -\@ifnextchar[{\@Ordinal@string{#1}}{\@Ordinal@string{#1}[m]}} +\newcommand{\@ordinalFspanish}[2]{% +\edef#2{\number#1\relax\noexpand\fmtord{a}}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@Ordinal@string} -% Display ordinal as a string with initial letters in upper case -% according to gender +% Make neuter same as masculine: % \begin{macrocode} -\def\@Ordinal@string#1[#2]{{% -\ifthenelse{\equal{#2}{f}}{% -\protect\@OrdinalstringF{#1}{\@fc@ordstr}}{% -\ifthenelse{\equal{#2}{n}}{% -\protect\@OrdinalstringN{#1}{\@fc@ordstr}}{% -\ifthenelse{\equal{#2}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#2'}{% -Available options are m, f or n}}% -\protect\@OrdinalstringM{#1}{\@fc@ordstr}}}\@fc@ordstr}} +\let\@ordinalNspanish\@ordinalMspanish % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeOrdinalstring} -% Store textual representation of number, with initial letters in -% upper case. First argument is identifying name, second argument -% is the counter set to the -% required number. +% Convert a number to text. The easiest way to do this is to +% break it up into units, tens, teens, twenties and hundreds. +% Units (argument must be a number from 0 to 9): % \begin{macrocode} -\newcommand*{\storeOrdinalstring}[2]{% -\expandafter\protect\expandafter\storeOrdinalstringnum{#1}{% -\expandafter\the\csname c@#2\endcsname}} +\newcommand{\@@unitstringspanish}[1]{% +\ifcase#1\relax +cero% +\or uno% +\or dos% +\or tres% +\or cuatro% +\or cinco% +\or seis% +\or siete% +\or ocho% +\or nueve% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeOrdinalstringnum} -% Store textual representation of number, with initial letters in -% upper case. First argument is identifying name, second argument -% is a count register or number. +% Feminine: % \begin{macrocode} -\newcommand*{\storeOrdinalstringnum}[2]{% -\@ifnextchar[{\@store@Ordinal@string{#1}{#2}}{% -\@store@Ordinal@string{#1}{#2}[m]}} +\newcommand{\@@unitstringFspanish}[1]{% +\ifcase#1\relax +cera% +\or una% +\or dos% +\or tres% +\or cuatro% +\or cinco% +\or seis% +\or siete% +\or ocho% +\or nueve% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@Ordinal@string} -% Store textual representation of number according to gender, -% with initial letters in upper case. +% Tens (argument must go from 1 to 10): % \begin{macrocode} -\def\@store@Ordinal@string#1#2[#3]{% -\ifthenelse{\equal{#3}{f}}{% -\protect\@OrdinalstringF{#2}{\@fc@ordstr}}{% -\ifthenelse{\equal{#3}{n}}{% -\protect\@OrdinalstringN{#2}{\@fc@ordstr}}{% -\ifthenelse{\equal{#3}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#3'}{% -Available options are m or f}}% -\protect\@OrdinalstringM{#2}{\@fc@ordstr}}}% -\expandafter\let\csname @fcs@#1\endcsname\@fc@ordstr} +\newcommand{\@@tenstringspanish}[1]{% +\ifcase#1\relax +\or diez% +\or viente% +\or treinta% +\or cuarenta% +\or cincuenta% +\or sesenta% +\or setenta% +\or ochenta% +\or noventa% +\or cien% +\fi +} % \end{macrocode} -%\end{macro} -% -%\begin{macro}{\storeORDINALstring} -% Store upper case textual representation of ordinal. The first -% argument is identifying name, the second argument is a counter. +% Teens: % \begin{macrocode} -\newcommand*{\storeORDINALstring}[2]{% -\expandafter\protect\expandafter\storeORDINALstringnum{#1}{% -\expandafter\the\csname c@#2\endcsname}} +\newcommand{\@@teenstringspanish}[1]{% +\ifcase#1\relax +diez% +\or once% +\or doce% +\or trece% +\or catorce% +\or quince% +\or diecis\'eis% +\or diecisiete% +\or dieciocho% +\or diecinueve% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeORDINALstringnum} -% As above, but the second argument is a count register or a -% number. +% Twenties: % \begin{macrocode} -\newcommand*{\storeORDINALstringnum}[2]{% -\@ifnextchar[{\@store@ORDINAL@string{#1}{#2}}{% -\@store@ORDINAL@string{#1}{#2}[m]}} +\newcommand{\@@twentystringspanish}[1]{% +\ifcase#1\relax +veinte% +\or veintiuno% +\or veintid\'os% +\or veintitr\'es% +\or veinticuatro% +\or veinticinco% +\or veintis\'eis% +\or veintisiete% +\or veintiocho% +\or veintinueve% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@ORDINAL@string} -% Gender is specified as an optional argument at the end. +% Feminine form: % \begin{macrocode} -\def\@store@ORDINAL@string#1#2[#3]{% -\ifthenelse{\equal{#3}{f}}{% -\protect\@ordinalstringF{#2}{\@fc@ordstr}}{% -\ifthenelse{\equal{#3}{n}}{% -\protect\@ordinalstringN{#2}{\@fc@ordstr}}{% -\ifthenelse{\equal{#3}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#3'}{% -Available options are m or f}}% -\protect\@ordinalstringM{#2}{\@fc@ordstr}}}% -\expandafter\edef\csname @fcs@#1\endcsname{% -\noexpand\MakeUppercase{\@fc@ordstr}}} +\newcommand{\@@twentystringFspanish}[1]{% +\ifcase#1\relax +veinte% +\or veintiuna% +\or veintid\'os% +\or veintitr\'es% +\or veinticuatro% +\or veinticinco% +\or veintis\'eis% +\or veintisiete% +\or veintiocho% +\or veintinueve% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ORDINALstring} -% Display upper case textual representation of an ordinal. The -% argument must be a counter. +% Hundreds: % \begin{macrocode} -\newcommand*{\ORDINALstring}[1]{% -\expandafter\protect\expandafter\ORDINALstringnum{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@hundredstringspanish}[1]{% +\ifcase#1\relax +\or ciento% +\or doscientos% +\or trescientos% +\or cuatrocientos% +\or quinientos% +\or seiscientos% +\or setecientos% +\or ochocientos% +\or novecientos% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ORDINALstringnum} -% As above, but the argument is a count register or a number. +% Feminine form: % \begin{macrocode} -\newcommand*{\ORDINALstringnum}[1]{% -\@ifnextchar[{\@ORDINAL@string{#1}}{\@ORDINAL@string{#1}[m]}} +\newcommand{\@@hundredstringFspanish}[1]{% +\ifcase#1\relax +\or cienta% +\or doscientas% +\or trescientas% +\or cuatrocientas% +\or quinientas% +\or seiscientas% +\or setecientas% +\or ochocientas% +\or novecientas% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@ORDINAL@string} -% Gender is specified as an optional argument at the end. +% As above, but with initial letter uppercase: % \begin{macrocode} -\def\@ORDINAL@string#1[#2]{{% -\ifthenelse{\equal{#2}{f}}{% -\protect\@ordinalstringF{#1}{\@fc@ordstr}}{% -\ifthenelse{\equal{#2}{n}}{% -\protect\@ordinalstringN{#1}{\@fc@ordstr}}{% -\ifthenelse{\equal{#2}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#2'}{% -Available options are m, f or n}}% -\protect\@ordinalstringM{#1}{\@fc@ordstr}}}% -\MakeUppercase{\@fc@ordstr}}} +\newcommand{\@@Unitstringspanish}[1]{% +\ifcase#1\relax +Cero% +\or Uno% +\or Dos% +\or Tres% +\or Cuatro% +\or Cinco% +\or Seis% +\or Siete% +\or Ocho% +\or Nueve% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storenumberstring} -% Convert number to textual respresentation, and store. First -% argument is the identifying name, second argument is a counter -% containing the number. +% Feminine form: % \begin{macrocode} -\newcommand*{\storenumberstring}[2]{% -\expandafter\protect\expandafter\storenumberstringnum{#1}{% -\expandafter\the\csname c@#2\endcsname}} +\newcommand{\@@UnitstringFspanish}[1]{% +\ifcase#1\relax +Cera% +\or Una% +\or Dos% +\or Tres% +\or Cuatro% +\or Cinco% +\or Seis% +\or Siete% +\or Ocho% +\or Nueve% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storenumberstringnum} -% As above, but second argument is a number or count register. +% Tens: % \begin{macrocode} -\newcommand{\storenumberstringnum}[2]{% -\@ifnextchar[{\@store@number@string{#1}{#2}}{% -\@store@number@string{#1}{#2}[m]}} +\newcommand{\@@Tenstringspanish}[1]{% +\ifcase#1\relax +\or Diez% +\or Viente% +\or Treinta% +\or Cuarenta% +\or Cincuenta% +\or Sesenta% +\or Setenta% +\or Ochenta% +\or Noventa% +\or Cien% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@number@string} -% Gender is given as optional argument, \emph{at the end}. +% Teens: % \begin{macrocode} -\def\@store@number@string#1#2[#3]{% -\ifthenelse{\equal{#3}{f}}{% -\protect\@numberstringF{#2}{\@fc@numstr}}{% -\ifthenelse{\equal{#3}{n}}{% -\protect\@numberstringN{#2}{\@fc@numstr}}{% -\ifthenelse{\equal{#3}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#3'}{% -Available options are m, f or n}}% -\protect\@numberstringM{#2}{\@fc@numstr}}}% -\expandafter\let\csname @fcs@#1\endcsname\@fc@numstr} +\newcommand{\@@Teenstringspanish}[1]{% +\ifcase#1\relax +Diez% +\or Once% +\or Doce% +\or Trece% +\or Catorce% +\or Quince% +\or Diecis\'eis% +\or Diecisiete% +\or Dieciocho% +\or Diecinueve% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\numberstring} -% Display textual representation of a number. The argument -% must be a counter. +% Twenties: +% \begin{macrocode} +\newcommand{\@@Twentystringspanish}[1]{% +\ifcase#1\relax +Veinte% +\or Veintiuno% +\or Veintid\'os% +\or Veintitr\'es% +\or Veinticuatro% +\or Veinticinco% +\or Veintis\'eis% +\or Veintisiete% +\or Veintiocho% +\or Veintinueve% +\fi} +% \end{macrocode} +% Feminine form: % \begin{macrocode} -\newcommand*{\numberstring}[1]{% -\expandafter\protect\expandafter\numberstringnum{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@TwentystringFspanish}[1]{% +\ifcase#1\relax +Veinte% +\or Veintiuna% +\or Veintid\'os% +\or Veintitr\'es% +\or Veinticuatro% +\or Veinticinco% +\or Veintis\'eis% +\or Veintisiete% +\or Veintiocho% +\or Veintinueve% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\numberstringnum} -% As above, but the argument is a count register or a number. +% Hundreds: % \begin{macrocode} -\newcommand*{\numberstringnum}[1]{% -\@ifnextchar[{\@number@string{#1}}{\@number@string{#1}[m]}% -} +\newcommand{\@@Hundredstringspanish}[1]{% +\ifcase#1\relax +\or Ciento% +\or Doscientos% +\or Trescientos% +\or Cuatrocientos% +\or Quinientos% +\or Seiscientos% +\or Setecientos% +\or Ochocientos% +\or Novecientos% +\fi} % \end{macrocode} -%\end{macro} -% -%\begin{macro}{\@number@string} -% Gender is specified as an optional argument \emph{at the end}. +% Feminine form: % \begin{macrocode} -\def\@number@string#1[#2]{{% -\ifthenelse{\equal{#2}{f}}{% -\protect\@numberstringF{#1}{\@fc@numstr}}{% -\ifthenelse{\equal{#2}{n}}{% -\protect\@numberstringN{#1}{\@fc@numstr}}{% -\ifthenelse{\equal{#2}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#2'}{% -Available options are m, f or n}}% -\protect\@numberstringM{#1}{\@fc@numstr}}}\@fc@numstr}} +\newcommand{\@@HundredstringFspanish}[1]{% +\ifcase#1\relax +\or Cienta% +\or Doscientas% +\or Trescientas% +\or Cuatrocientas% +\or Quinientas% +\or Seiscientas% +\or Setecientas% +\or Ochocientas% +\or Novecientas% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeNumberstring} -% Store textual representation of number. First argument is -% identifying name, second argument is a counter. +% This has changed in version 1.09, so that it now stores the +% result in the second argument, but doesn't display anything. +% Since it only affects internal macros, it shouldn't affect +% documents created with older versions. (These internal macros +% are not meant for use in documents.) % \begin{macrocode} -\newcommand*{\storeNumberstring}[2]{% -\expandafter\protect\expandafter\storeNumberstringnum{#1}{% -\expandafter\the\csname c@#2\endcsname}} +\DeclareRobustCommand{\@numberstringMspanish}[2]{% +\let\@unitstring=\@@unitstringspanish +\let\@teenstring=\@@teenstringspanish +\let\@tenstring=\@@tenstringspanish +\let\@twentystring=\@@twentystringspanish +\let\@hundredstring=\@@hundredstringspanish +\def\@hundred{cien}\def\@thousand{mil}% +\def\@andname{y}% +\@@numberstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeNumberstringnum} -% As above, but second argument is a count register or number. +% Feminine form: % \begin{macrocode} -\newcommand{\storeNumberstringnum}[2]{% -\@ifnextchar[{\@store@Number@string{#1}{#2}}{% -\@store@Number@string{#1}{#2}[m]}} +\DeclareRobustCommand{\@numberstringFspanish}[2]{% +\let\@unitstring=\@@unitstringFspanish +\let\@teenstring=\@@teenstringspanish +\let\@tenstring=\@@tenstringspanish +\let\@twentystring=\@@twentystringFspanish +\let\@hundredstring=\@@hundredstringFspanish +\def\@hundred{cien}\def\@thousand{mil}% +\def\@andname{y}% +\@@numberstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@Number@string} -% Gender is specified as an optional argument \emph{at the end}: +% Make neuter same as masculine: % \begin{macrocode} -\def\@store@Number@string#1#2[#3]{% -\ifthenelse{\equal{#3}{f}}{% -\protect\@NumberstringF{#2}{\@fc@numstr}}{% -\ifthenelse{\equal{#3}{n}}{% -\protect\@NumberstringN{#2}{\@fc@numstr}}{% -\ifthenelse{\equal{#3}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#3'}{% -Available options are m, f or n}}% -\protect\@NumberstringM{#2}{\@fc@numstr}}}% -\expandafter\let\csname @fcs@#1\endcsname\@fc@numstr} +\let\@numberstringNspanish\@numberstringMspanish % \end{macrocode} -%\end{macro} -%\begin{macro}{\Numberstring} -% Display textual representation of number. The argument must be -% a counter. +% As above, but initial letters in upper case: % \begin{macrocode} -\newcommand*{\Numberstring}[1]{% -\expandafter\protect\expandafter\Numberstringnum{% -\expandafter\the\csname c@#1\endcsname}} +\DeclareRobustCommand{\@NumberstringMspanish}[2]{% +\let\@unitstring=\@@Unitstringspanish +\let\@teenstring=\@@Teenstringspanish +\let\@tenstring=\@@Tenstringspanish +\let\@twentystring=\@@Twentystringspanish +\let\@hundredstring=\@@Hundredstringspanish +\def\@andname{y}% +\def\@hundred{Cien}\def\@thousand{Mil}% +\@@numberstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\Numberstringnum} -% As above, but the argument is a count register or number. +% Feminine form: % \begin{macrocode} -\newcommand*{\Numberstringnum}[1]{% -\@ifnextchar[{\@Number@string{#1}}{\@Number@string{#1}[m]}} +\DeclareRobustCommand{\@NumberstringFspanish}[2]{% +\let\@unitstring=\@@UnitstringFspanish +\let\@teenstring=\@@Teenstringspanish +\let\@tenstring=\@@Tenstringspanish +\let\@twentystring=\@@TwentystringFspanish +\let\@hundredstring=\@@HundredstringFspanish +\def\@andname{y}% +\def\@hundred{Cien}\def\@thousand{Mil}% +\@@numberstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@Number@string} -% Gender is specified as an optional argument at the end. +% Make neuter same as masculine: % \begin{macrocode} -\def\@Number@string#1[#2]{{% -\ifthenelse{\equal{#2}{f}}{% -\protect\@NumberstringF{#1}{\@fc@numstr}}{% -\ifthenelse{\equal{#2}{n}}{% -\protect\@NumberstringN{#1}{\@fc@numstr}}{% -\ifthenelse{\equal{#2}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#2'}{% -Available options are m, f or n}}% -\protect\@NumberstringM{#1}{\@fc@numstr}}}\@fc@numstr}} +\let\@NumberstringNspanish\@NumberstringMspanish % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeNUMBERstring} -% Store upper case textual representation of number. The first -% argument is identifying name, the second argument is a counter. +% As above, but for ordinals. % \begin{macrocode} -\newcommand{\storeNUMBERstring}[2]{% -\expandafter\protect\expandafter\storeNUMBERstringnum{#1}{% -\expandafter\the\csname c@#2\endcsname}} +\DeclareRobustCommand{\@ordinalstringMspanish}[2]{% +\let\@unitthstring=\@@unitthstringspanish +\let\@unitstring=\@@unitstringspanish +\let\@teenthstring=\@@teenthstringspanish +\let\@tenthstring=\@@tenthstringspanish +\let\@hundredthstring=\@@hundredthstringspanish +\def\@thousandth{mil\'esimo}% +\@@ordinalstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeNUMBERstringnum} -% As above, but the second argument is a count register or a -% number. +% Feminine form: % \begin{macrocode} -\newcommand{\storeNUMBERstringnum}[2]{% -\@ifnextchar[{\@store@NUMBER@string{#1}{#2}}{% -\@store@NUMBER@string{#1}{#2}[m]}} +\DeclareRobustCommand{\@ordinalstringFspanish}[2]{% +\let\@unitthstring=\@@unitthstringFspanish +\let\@unitstring=\@@unitstringFspanish +\let\@teenthstring=\@@teenthstringFspanish +\let\@tenthstring=\@@tenthstringFspanish +\let\@hundredthstring=\@@hundredthstringFspanish +\def\@thousandth{mil\'esima}% +\@@ordinalstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@NUMBER@string} -% Gender is specified as an optional argument at the end. +% Make neuter same as masculine: % \begin{macrocode} -\def\@store@NUMBER@string#1#2[#3]{% -\ifthenelse{\equal{#3}{f}}{% -\protect\@numberstringF{#2}{\@fc@numstr}}{% -\ifthenelse{\equal{#3}{n}}{% -\protect\@numberstringN{#2}{\@fc@numstr}}{% -\ifthenelse{\equal{#3}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#3'}{% -Available options are m or f}}% -\protect\@numberstringM{#2}{\@fc@numstr}}}% -\expandafter\edef\csname @fcs@#1\endcsname{% -\noexpand\MakeUppercase{\@fc@numstr}}} +\let\@ordinalstringNspanish\@ordinalstringMspanish % \end{macrocode} -%\end{macro} -%\begin{macro}{\NUMBERstring} -% Display upper case textual representation of a number. The -% argument must be a counter. +% As above, but with initial letters in upper case. % \begin{macrocode} -\newcommand*{\NUMBERstring}[1]{% -\expandafter\protect\expandafter\NUMBERstringnum{% -\expandafter\the\csname c@#1\endcsname}} +\DeclareRobustCommand{\@OrdinalstringMspanish}[2]{% +\let\@unitthstring=\@@Unitthstringspanish +\let\@unitstring=\@@Unitstringspanish +\let\@teenthstring=\@@Teenthstringspanish +\let\@tenthstring=\@@Tenthstringspanish +\let\@hundredthstring=\@@Hundredthstringspanish +\def\@thousandth{Mil\'esimo}% +\@@ordinalstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\NUMBERstringnum} -% As above, but the argument is a count register or a number. +% Feminine form: % \begin{macrocode} -\newcommand*{\NUMBERstringnum}[1]{% -\@ifnextchar[{\@NUMBER@string{#1}}{\@NUMBER@string{#1}[m]}} +\DeclareRobustCommand{\@OrdinalstringFspanish}[2]{% +\let\@unitthstring=\@@UnitthstringFspanish +\let\@unitstring=\@@UnitstringFspanish +\let\@teenthstring=\@@TeenthstringFspanish +\let\@tenthstring=\@@TenthstringFspanish +\let\@hundredthstring=\@@HundredthstringFspanish +\def\@thousandth{Mil\'esima}% +\@@ordinalstringspanish{#1}{#2}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@NUMBER@string} -% Gender is specified as an optional argument at the end. +% Make neuter same as masculine: % \begin{macrocode} -\def\@NUMBER@string#1[#2]{{% -\ifthenelse{\equal{#2}{f}}{% -\protect\@numberstringF{#1}{\@fc@numstr}}{% -\ifthenelse{\equal{#2}{n}}{% -\protect\@numberstringN{#1}{\@fc@numstr}}{% -\ifthenelse{\equal{#2}{m}}{}{% -\PackageError{fmtcount}{Invalid gender option `#2'}{% -Available options are m, f or n}}% -\protect\@numberstringM{#1}{\@fc@numstr}}}% -\MakeUppercase{\@fc@numstr}}} +\let\@OrdinalstringNspanish\@OrdinalstringMspanish % \end{macrocode} -%\end{macro} -%\begin{macro}{\binary} -% Number representations in other bases. Binary: +% Code for convert numbers into textual ordinals. As before, +% it is easier to split it into units, tens, teens and hundreds. +% Units: % \begin{macrocode} -\providecommand*{\binary}[1]{% -\expandafter\protect\expandafter\@binary{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@unitthstringspanish}[1]{% +\ifcase#1\relax +cero% +\or primero% +\or segundo% +\or tercero% +\or cuarto% +\or quinto% +\or sexto% +\or s\'eptimo% +\or octavo% +\or noveno% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\aaalph} -% Like \verb"\alph", but goes beyond 26. -% (a \ldots\ z aa \ldots zz \ldots) +% Tens: % \begin{macrocode} -\providecommand*{\aaalph}[1]{% -\expandafter\protect\expandafter\@aaalph{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@tenthstringspanish}[1]{% +\ifcase#1\relax +\or d\'ecimo% +\or vig\'esimo% +\or trig\'esimo% +\or cuadrag\'esimo% +\or quincuag\'esimo% +\or sexag\'esimo% +\or septuag\'esimo% +\or octog\'esimo% +\or nonag\'esimo% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\AAAlph} -% As before, but upper case. +% Teens: % \begin{macrocode} -\providecommand*{\AAAlph}[1]{% -\expandafter\protect\expandafter\@AAAlph{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@teenthstringspanish}[1]{% +\ifcase#1\relax +d\'ecimo% +\or und\'ecimo% +\or duod\'ecimo% +\or decimotercero% +\or decimocuarto% +\or decimoquinto% +\or decimosexto% +\or decimos\'eptimo% +\or decimoctavo% +\or decimonoveno% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\abalph} -% Like \verb"\alph", but goes beyond 26. -% (a \ldots\ z ab \ldots az \ldots) +% Hundreds: % \begin{macrocode} -\providecommand*{\abalph}[1]{% -\expandafter\protect\expandafter\@abalph{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@hundredthstringspanish}[1]{% +\ifcase#1\relax +\or cent\'esimo% +\or ducent\'esimo% +\or tricent\'esimo% +\or cuadringent\'esimo% +\or quingent\'esimo% +\or sexcent\'esimo% +\or septing\'esimo% +\or octingent\'esimo% +\or noningent\'esimo% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\ABAlph} -% As above, but upper case. +% Units (feminine): % \begin{macrocode} -\providecommand*{\ABAlph}[1]{% -\expandafter\protect\expandafter\@ABAlph{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@unitthstringFspanish}[1]{% +\ifcase#1\relax +cera% +\or primera% +\or segunda% +\or tercera% +\or cuarta% +\or quinta% +\or sexta% +\or s\'eptima% +\or octava% +\or novena% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\hexadecimal} -% Hexadecimal: +% Tens (feminine): % \begin{macrocode} -\providecommand*{\hexadecimal}[1]{% -\expandafter\protect\expandafter\@hexadecimal{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@tenthstringFspanish}[1]{% +\ifcase#1\relax +\or d\'ecima% +\or vig\'esima% +\or trig\'esima% +\or cuadrag\'esima% +\or quincuag\'esima% +\or sexag\'esima% +\or septuag\'esima% +\or octog\'esima% +\or nonag\'esima% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\Hexadecimal} -% As above, but in upper case. +% Teens (feminine) % \begin{macrocode} -\providecommand*{\Hexadecimal}[1]{% -\expandafter\protect\expandafter\@Hexadecimal{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@teenthstringFspanish}[1]{% +\ifcase#1\relax +d\'ecima% +\or und\'ecima% +\or duod\'ecima% +\or decimotercera% +\or decimocuarta% +\or decimoquinta% +\or decimosexta% +\or decimos\'eptima% +\or decimoctava% +\or decimonovena% +\fi +} % \end{macrocode} -%\end{macro} -%\begin{macro}{\octal} -% Octal: +% Hundreds (feminine) % \begin{macrocode} -\providecommand*{\octal}[1]{% -\expandafter\protect\expandafter\@octal{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@hundredthstringFspanish}[1]{% +\ifcase#1\relax +\or cent\'esima% +\or ducent\'esima% +\or tricent\'esima% +\or cuadringent\'esima% +\or quingent\'esima% +\or sexcent\'esima% +\or septing\'esima% +\or octingent\'esima% +\or noningent\'esima% +\fi} % \end{macrocode} -%\end{macro} -%\begin{macro}{\decimal} -% Decimal: +% As above, but with initial letters in upper case % \begin{macrocode} -\providecommand*{\decimal}[1]{% -\expandafter\protect\expandafter\@decimal{% -\expandafter\the\csname c@#1\endcsname}} +\newcommand{\@@Unitthstringspanish}[1]{% +\ifcase#1\relax +Cero% +\or Primero% +\or Segundo% +\or Tercero% +\or Cuarto% +\or Quinto% +\or Sexto% +\or S\'eptimo% +\or Octavo% +\or Noveno% +\fi +} % \end{macrocode} -%\end{macro} -% -%\subsubsection{Multilinguage Definitions} -%\begin{macro}{\@setdef@ultfmtcount} -% If multilingual support is provided, make \verb"\@numberstring" -% etc use the correct language (if defined). -% Otherwise use English definitions. "\@setdef@ultfmtcount" -% sets the macros to use English. +% Tens: % \begin{macrocode} -\def\@setdef@ultfmtcount{ -\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} -\def\@ordinalstringM{\@ordinalstringMenglish} -\let\@ordinalstringF=\@ordinalstringMenglish -\let\@ordinalstringN=\@ordinalstringMenglish -\def\@OrdinalstringM{\@OrdinalstringMenglish} -\let\@OrdinalstringF=\@OrdinalstringMenglish -\let\@OrdinalstringN=\@OrdinalstringMenglish -\def\@numberstringM{\@numberstringMenglish} -\let\@numberstringF=\@numberstringMenglish -\let\@numberstringN=\@numberstringMenglish -\def\@NumberstringM{\@NumberstringMenglish} -\let\@NumberstringF=\@NumberstringMenglish -\let\@NumberstringN=\@NumberstringMenglish -\def\@ordinalM{\@ordinalMenglish} -\let\@ordinalF=\@ordinalM -\let\@ordinalN=\@ordinalM +\newcommand{\@@Tenthstringspanish}[1]{% +\ifcase#1\relax +\or D\'ecimo% +\or Vig\'esimo% +\or Trig\'esimo% +\or Cuadrag\'esimo% +\or Quincuag\'esimo% +\or Sexag\'esimo% +\or Septuag\'esimo% +\or Octog\'esimo% +\or Nonag\'esimo% +\fi } % \end{macrocode} -%\end{macro} -%\begin{macro}{\@set@mulitling@fmtcount} -% This defines the number and ordinal string macros to use -% \cs{languagename}: +% Teens: % \begin{macrocode} -\def\@set@mulitling@fmtcount{% +\newcommand{\@@Teenthstringspanish}[1]{% +\ifcase#1\relax +D\'ecimo% +\or Und\'ecimo% +\or Duod\'ecimo% +\or Decimotercero% +\or Decimocuarto% +\or Decimoquinto% +\or Decimosexto% +\or Decimos\'eptimo% +\or Decimoctavo% +\or Decimonoveno% +\fi +} % \end{macrocode} -% The masculine version of \cs{numberstring}: +% Hundreds % \begin{macrocode} -\def\@numberstringM{\@ifundefined{@numberstringM\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@numberstringM}}{% -\csname @numberstringM\languagename\endcsname}}% +\newcommand{\@@Hundredthstringspanish}[1]{% +\ifcase#1\relax +\or Cent\'esimo% +\or Ducent\'esimo% +\or Tricent\'esimo% +\or Cuadringent\'esimo% +\or Quingent\'esimo% +\or Sexcent\'esimo% +\or Septing\'esimo% +\or Octingent\'esimo% +\or Noningent\'esimo% +\fi} % \end{macrocode} -% The feminine version of \cs{numberstring}: +% As above, but feminine. % \begin{macrocode} -\def\@numberstringF{\@ifundefined{@numberstringF\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@numberstringF}}{% -\csname @numberstringF\languagename\endcsname}}% +\newcommand{\@@UnitthstringFspanish}[1]{% +\ifcase#1\relax +Cera% +\or Primera% +\or Segunda% +\or Tercera% +\or Cuarta% +\or Quinta% +\or Sexta% +\or S\'eptima% +\or Octava% +\or Novena% +\fi +} % \end{macrocode} -% The neuter version of \cs{numberstring}: +% Tens (feminine) % \begin{macrocode} -\def\@numberstringN{\@ifundefined{@numberstringN\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@numberstringN}}{% -\csname @numberstringN\languagename\endcsname}}% +\newcommand{\@@TenthstringFspanish}[1]{% +\ifcase#1\relax +\or D\'ecima% +\or Vig\'esima% +\or Trig\'esima% +\or Cuadrag\'esima% +\or Quincuag\'esima% +\or Sexag\'esima% +\or Septuag\'esima% +\or Octog\'esima% +\or Nonag\'esima% +\fi +} % \end{macrocode} -% The masculine version of \cs{Numberstring}: +% Teens (feminine): % \begin{macrocode} -\def\@NumberstringM{\@ifundefined{@NumberstringM\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@NumberstringM}}{% -\csname @NumberstringM\languagename\endcsname}}% +\newcommand{\@@TeenthstringFspanish}[1]{% +\ifcase#1\relax +D\'ecima% +\or Und\'ecima% +\or Duod\'ecima% +\or Decimotercera% +\or Decimocuarta% +\or Decimoquinta% +\or Decimosexta% +\or Decimos\'eptima% +\or Decimoctava% +\or Decimonovena% +\fi +} % \end{macrocode} -% The feminine version of \cs{Numberstring}: +% Hundreds (feminine): % \begin{macrocode} -\def\@NumberstringF{\@ifundefined{@NumberstringF\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@NumberstringF}}{% -\csname @NumberstringF\languagename\endcsname}}% +\newcommand{\@@HundredthstringFspanish}[1]{% +\ifcase#1\relax +\or Cent\'esima% +\or Ducent\'esima% +\or Tricent\'esima% +\or Cuadringent\'esima% +\or Quingent\'esima% +\or Sexcent\'esima% +\or Septing\'esima% +\or Octingent\'esima% +\or Noningent\'esima% +\fi} + % \end{macrocode} -% The neuter version of \cs{Numberstring}: +% This has changed in version 1.09, so that it now stores the +% results in the second argument (which must be a control +% sequence), but it doesn't display anything. Since it only +% affects internal macros, it shouldn't affect documnets created +% with older versions. (These internal macros are not meant for +% use in documents.) % \begin{macrocode} -\def\@NumberstringN{\@ifundefined{@NumberstringN\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@NumberstringN}}{% -\csname @NumberstringN\languagename\endcsname}}% +\newcommand{\@@numberstringspanish}[2]{% +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\fi +\fi +\def#2{}% +\@strctr=#1\relax \divide\@strctr by 1000\relax +\ifnum\@strctr>9 +% #1 is greater or equal to 10000 + \divide\@strctr by 10 + \ifnum\@strctr>1 + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1 \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname\ \@unitstring{\@strctr}}% + \fi + \else + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@thousand}% +\else + \ifnum\@strctr>0\relax + \ifnum\@strctr>1\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% + \fi + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@thousand}% + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{1000}% +\divide\@strctr by 100\relax +\ifnum\@strctr>0\relax + \ifnum#1>1000\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ }% + \fi + \@tmpstrctr=#1\relax + \@modulo{\@tmpstrctr}{1000}% + \ifnum\@tmpstrctr=100\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{10}}% + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@hundredstring{\@strctr}}% + \fi +\fi +\@strctr=#1\relax \@modulo{\@strctr}{100}% +\ifnum#1>100\relax + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname\ }% + \fi +\fi +\ifnum\@strctr>29\relax + \divide\@strctr by 10\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1\relax \@modulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\ \@andname\ \@unitstring{\@strctr}}% + \fi +\else + \ifnum\@strctr<10\relax + \ifnum\@strctr=0\relax + \ifnum#1<100\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + \else + \ifnum\@strctr>19\relax + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@twentystring{\@strctr}}% + \else + \@modulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \fi + \fi +\fi +} % \end{macrocode} -% The masculine version of \cs{ordinal}: +% As above, but for ordinals % \begin{macrocode} -\def\@ordinalM{\@ifundefined{@ordinalM\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@ordinalM}}{% -\csname @ordinalM\languagename\endcsname}}% +\newcommand{\@@ordinalstringspanish}[2]{% +\@strctr=#1\relax +\ifnum#1>99999 +\PackageError{fmtcount}{Out of range}% +{This macro only works for values less than 100000}% +\else +\ifnum#1<0 +\PackageError{fmtcount}{Negative numbers not permitted}% +{This macro does not work for negative numbers, however +you can try typing "minus" first, and then pass the modulus of +this number}% +\else +\def#2{}% +\ifnum\@strctr>999\relax + \divide\@strctr by 1000\relax + \ifnum\@strctr>1\relax + \ifnum\@strctr>9\relax + \@tmpstrctr=\@strctr + \ifnum\@strctr<20 + \@modulo{\@tmpstrctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenthstring{\@tmpstrctr}}% + \else + \divide\@tmpstrctr by 10\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% + \@tmpstrctr=\@strctr + \@modulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@tmpstrctr}}% + \fi + \fi + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \fi + \fi + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@thousandth}% +\fi +\@strctr=#1\relax +\@modulo{\@strctr}{1000}% +\ifnum\@strctr>99\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 100\relax + \ifnum#1>1000\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ }% + \fi + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@hundredthstring{\@tmpstrctr}}% +\fi +\@modulo{\@strctr}{100}% +\ifnum#1>99\relax + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ }% + \fi +\fi +\ifnum\@strctr>19\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 10\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% + \@tmpstrctr=\@strctr + \@modulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@unitthstring{\@tmpstrctr}}% + \fi +\else + \ifnum\@strctr>9\relax + \@modulo{\@strctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% + \else + \ifnum\@strctr=0\relax + \ifnum#1=0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitstring{0}}% + \fi + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi + \fi +\fi +\fi +\fi +} % \end{macrocode} -% The feminine version of \cs{ordinal}: +%\iffalse % \begin{macrocode} -\def\@ordinalF{\@ifundefined{@ordinalF\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@ordinalF}}{% -\csname @ordinalF\languagename\endcsname}}% +% % \end{macrocode} -% The neuter version of \cs{ordinal}: +%\fi +%\iffalse % \begin{macrocode} -\def\@ordinalN{\@ifundefined{@ordinalN\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@ordinalN}}{% -\csname @ordinalN\languagename\endcsname}}% +%<*fc-UKenglish.def> % \end{macrocode} -% The masculine version of \cs{ordinalstring}: +%\fi +% \subsubsection{fc-UKenglish.def} +% UK English definitions % \begin{macrocode} -\def\@ordinalstringM{\@ifundefined{@ordinalstringM\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@ordinalstringM}}{% -\csname @ordinalstringM\languagename\endcsname}}% +\ProvidesFile{fc-UKenglish}[2007/06/14] % \end{macrocode} -% The feminine version of \cs{ordinalstring}: +% Check that fc-english.def has been loaded % \begin{macrocode} -\def\@ordinalstringF{\@ifundefined{@ordinalstringF\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@ordinalstringF}}{% -\csname @ordinalstringF\languagename\endcsname}}% +\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} % \end{macrocode} -% The neuter version of \cs{ordinalstring}: +% These are all just synonyms for the commands provided by +% fc-english.def. % \begin{macrocode} -\def\@ordinalstringN{\@ifundefined{@ordinalstringN\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@ordinalstringN}}{% -\csname @ordinalstringN\languagename\endcsname}}% +\let\@ordinalMUKenglish\@ordinalMenglish +\let\@ordinalFUKenglish\@ordinalMenglish +\let\@ordinalNUKenglish\@ordinalMenglish +\let\@numberstringMUKenglish\@numberstringMenglish +\let\@numberstringFUKenglish\@numberstringMenglish +\let\@numberstringNUKenglish\@numberstringMenglish +\let\@NumberstringMUKenglish\@NumberstringMenglish +\let\@NumberstringFUKenglish\@NumberstringMenglish +\let\@NumberstringNUKenglish\@NumberstringMenglish +\let\@ordinalstringMUKenglish\@ordinalstringMenglish +\let\@ordinalstringFUKenglish\@ordinalstringMenglish +\let\@ordinalstringNUKenglish\@ordinalstringMenglish +\let\@OrdinalstringMUKenglish\@OrdinalstringMenglish +\let\@OrdinalstringFUKenglish\@OrdinalstringMenglish +\let\@OrdinalstringNUKenglish\@OrdinalstringMenglish % \end{macrocode} -% The masculine version of \cs{Ordinalstring}: +%\iffalse % \begin{macrocode} -\def\@OrdinalstringM{\@ifundefined{@OrdinalstringM\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@OrdinalstringM}}{% -\csname @OrdinalstringM\languagename\endcsname}}% +% % \end{macrocode} -% The feminine version of \cs{Ordinalstring}: +%\fi +%\iffalse % \begin{macrocode} -\def\@OrdinalstringF{\@ifundefined{@OrdinalstringF\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@OrdinalstringF}}{% -\csname @OrdinalstringF\languagename\endcsname}}% +%<*fc-USenglish.def> % \end{macrocode} -% The neuter version of \cs{Ordinalstring}: +%\fi +% \subsubsection{fc-USenglish.def} +% US English definitions % \begin{macrocode} -\def\@OrdinalstringN{\@ifundefined{@OrdinalstringN\languagename}{% -\PackageError{fmtcount}{No support for language '\languagename'}{% -The fmtcount package currently does not support language -'\languagename' for command \string\@OrdinalstringN}}{% -\csname @OrdinalstringN\languagename\endcsname}} -} +\ProvidesFile{fc-USenglish}[2007/06/14] % \end{macrocode} -%\end{macro} -% Check to see if babel or ngerman packages have been loaded. +% Check that fc-english.def has been loaded % \begin{macrocode} -\@ifpackageloaded{babel}{% -\ifthenelse{\equal{\languagename}{nohyphenation}\or -\equal{languagename}{english}}{\@setdef@ultfmtcount}{% -\@set@mulitling@fmtcount} -}{% -\@ifpackageloaded{ngerman}{% -\@ifundefined{@numberstringMgerman}{% -\input{fc-german.def}}{}\@set@mulitling@fmtcount}{% -\@setdef@ultfmtcount}} +\@ifundefined{@ordinalMenglish}{\input{fc-english.def}}{} % \end{macrocode} -% Backwards compatibility: +% These are all just synonyms for the commands provided by +% fc-english.def. % \begin{macrocode} -\let\@ordinal=\@ordinalM -\let\@ordinalstring=\@ordinalstringM -\let\@Ordinalstring=\@OrdinalstringM -\let\@numberstring=\@numberstringM -\let\@Numberstring=\@NumberstringM +\let\@ordinalMUSenglish\@ordinalMenglish +\let\@ordinalFUSenglish\@ordinalMenglish +\let\@ordinalNUSenglish\@ordinalMenglish +\let\@numberstringMUSenglish\@numberstringMenglish +\let\@numberstringFUSenglish\@numberstringMenglish +\let\@numberstringNUSenglish\@numberstringMenglish +\let\@NumberstringMUSenglish\@NumberstringMenglish +\let\@NumberstringFUSenglish\@NumberstringMenglish +\let\@NumberstringNUSenglish\@NumberstringMenglish +\let\@ordinalstringMUSenglish\@ordinalstringMenglish +\let\@ordinalstringFUSenglish\@ordinalstringMenglish +\let\@ordinalstringNUSenglish\@ordinalstringMenglish +\let\@OrdinalstringMUSenglish\@OrdinalstringMenglish +\let\@OrdinalstringFUSenglish\@OrdinalstringMenglish +\let\@OrdinalstringNUSenglish\@OrdinalstringMenglish % \end{macrocode} %\iffalse % \begin{macrocode} -% +% % \end{macrocode} %\fi %\iffalse @@ -8520,5 +9296,405 @@ sub load_fmtcount_cfg{ % % \end{macrocode} %\fi +%\iffalse +% \begin{macrocode} +%<*fc-lang.tex> +% \end{macrocode} +%\fi +% \begin{macrocode} + % This is an interactive script. Run it through \LaTeX + % and enter appropriate responses. (This won't work with + % LaTeX2HTML + +\documentclass[a4paper]{article} + +\usepackage[french,english,spanish,portuges,ngerman,italian]{babel} +\usepackage{fmtcount} + +\newcounter{startval} +\newcounter{endval} +\newcounter{stepsize} +\newcounter{N} +\newcount\myctr +\newcount\langid + +\begin{document} + +\section{Displaying the value of a counter} + +\typeout{This is an interactive script, testing the fmtcount package.} + +\langid=-1 + +\loop +\typeout{Which language?^^J} +\typeout{[1] English} +\typeout{[2] Portuguese} +\typeout{[3] Spanish} +\typeout{[4] French} +\typeout{[5] French (Swiss)} +\typeout{[6] French (Belgium)} +\typeout{[7] German} +\typeout{[8] Italian} + +\typein[\response]{} + +\ifthenelse{\equal{\response}{1}}{\langid=1}{ +\ifthenelse{\equal{\response}{2}}{\langid=2}{ +\ifthenelse{\equal{\response}{3}}{\langid=3}{ +\ifthenelse{\equal{\response}{4}}{\langid=4\fmtcountsetoptions{french}}{ +\ifthenelse{\equal{\response}{5}}{\langid=5\fmtcountsetoptions{french=swiss}}{ +\ifthenelse{\equal{\response}{6}}{\langid=6\fmtcountsetoptions{french=belgian}} +{\ifthenelse{\equal{\response}{7}}{\langid=7}{% +\ifthenelse{\equal{\response}{8}}{\langid=8}{% +\langid=-1 +\typeout{Invalid response '\response', please select a number from 1 to 6}}}}}}}}} +\ifnum\langid=-1 +\repeat + +\ifcase\langid +\or \selectlanguage{english} +Current language: English. +\or \selectlanguage{portuges} +Current language: Portuguese. +\or \selectlanguage{spanish} +Current language: Spanish. +\or \selectlanguage{french} +Current language: French. +\or \selectlanguage{french} +Current language: French (Swiss). +\or \selectlanguage{french} +Current language: French (Belgium). +\or \selectlanguage{ngerman} +Current language: German. +\or \selectlanguage{italian} +Current language: Italian. +\fi + +\def\startval{-1} + +\loop +\typein[\startval]{Start value? (Integer from 0 to 99999) +[Default 1]} +\ifthenelse{\equal{\startval}{}}{\def\startval{1}}{} +\ifnum\startval<0\def\startval{-1}\fi +\ifnum\startval>99999\def\startval{-1}\fi +\ifnum\startval=-1 +\repeat + +\def\endval{-1} + +\loop +\typein[\endval]{End value? (Integer from 0 to 99999) +[Default 1000]} +\ifthenelse{\equal{\endval}{}}{\def\endval{1000}}{} +\ifnum\endval<0\def\endval{-1}\fi +\ifnum\endval>99999\def\endval{-1}\fi +\ifnum\endval=-1 +\repeat + +\def\stepsize{0} + +\loop +\typein[\stepsize]{Step size? (Non zero integer) +[Default 1]} +\ifthenelse{\equal{\stepsize}{}}{\def\stepsize{1}}{} +\ifnum\stepsize=0 +\repeat + +\typeout{From {\startval} to {\endval} step {\stepsize}} + +\ifnum\startval<\endval +\ifnum\stepsize<0 +\PackageError{fc-lang}{Infinite loop not permitted!}{} +\def\endval{\startval} +\fi +\fi + +\ifnum\startval>\endval +\ifnum\stepsize>0 +\PackageError{fc-lang}{Infinite loop not permitted!}{} +\def\endval{\startval} +\fi +\fi + +\newcount\numformat + +\numformat=-1 +\loop +\typeout{Which format?^^J} +\typeout{[1] ordinalstring} +\typeout{[2] Ordinalstring} +\typeout{[3] ORDINALstring} +\typeout{[4] numberstring} +\typeout{[5] Numberstring} +\typeout{[6] NUMBERstring} + +\typein[\response]{Default: 1} + +\ifthenelse{\equal{\response}{}}{\def\response{1}}{}%default val +\ifthenelse{\equal{\response}{1}}{\numformat=1}{ +\ifthenelse{\equal{\response}{2}}{\numformat=2}{ +\ifthenelse{\equal{\response}{3}}{\numformat=3}{ +\ifthenelse{\equal{\response}{4}}{\numformat=4}{ +\ifthenelse{\equal{\response}{5}}{\numformat=5}{ +\ifthenelse{\equal{\response}{6}}{\numformat=6}{\numformat=-1 +\typeout{Invalid response '\response', please select a number from 1 to 4}}}}}}} +\ifnum\numformat=-1 +\repeat + +\ifcase\numformat +\or\def\stringtype{ordinalstring} +\or\def\stringtype{Ordinalstring} +\or\def\stringtype{ORDINALstring} +\or\def\stringtype{numberstring} +\or\def\stringtype{Numberstring} +\or\def\stringtype{NUMBERstring} +\fi + +\ifnum\langid>3\relax + \ifnum\langid<7\relax + \myctr=-1\relax + \loop + \typeout{Ordinal type?^^J} + \typeout{[1] eme} + \typeout{[2] e} + \typein[\response]{Default: 1} + \ifthenelse{\equal{\response}{}}% + {% + \def\response{1}% default + \myctr=1\relax + }% + {% + \ifthenelse{\equal{\response}{1}}% + {% + \fmtcountsetoptions{abbrv=false}\myctr=1\relax + }% + {% + \ifthenelse{\equal{\response}{2}}% + {% + \fmtcountsetoptions{abbrv}\myctr=2\relax + }% + {% + \myctr=-1\relax + }% + }% + }% + \ifnum\myctr=-1 + \repeat + \fi +\fi + +\myctr=-1 +\loop +\typeout{Ordinal format?^^J} +\typeout{[1] raised} +\typeout{[2] level} +\typein[\response]{Default: 1} +\ifthenelse{\equal{\response}{1}\or\equal{\response}{}}{% +\fmtcountsetoptions{fmtord=raise}\myctr=1}{% +\ifthenelse{\equal{\response}{2}}{% +\fmtcountsetoptions{fmtord=level}\myctr=2}{% +\myctr=-1}} +\ifnum\myctr=-1 +\repeat + +\ifnum\langid=1 +\myctr=1 +\else +\ifthenelse{\langid=7 \and \numformat>3}{}{% +\loop +\ifnum\langid=7 + \typein[\response]{Gender? (m, f or n) [Default: m]} + \ifthenelse{\equal{\response}{m}}{\myctr=1}{ + \ifthenelse{\equal{\response}{f}}{\myctr=2}{ + \ifthenelse{\equal{\response}{n}}{\myctr=3}{ + \ifthenelse{\equal{\response}{}}{\myctr=1}{% + \myctr=-1 + \typeout{Invalid response '\response'}}}}} +\else + \typein[\response]{Gender? (m or f) [Default: m]} + \ifthenelse{\equal{\response}{m}}{\myctr=1}{ + \ifthenelse{\equal{\response}{f}}{\myctr=2}{% + \ifthenelse{\equal{\response}{}}{\myctr=1}{% + \myctr=-1 + \typeout{Invalid response '\response'}}}} +\fi +\ifnum\myctr=-1 +\repeat +} +\fi + +\ifcase\myctr +\or \def\gender{m} +\or \def\gender{f} +\or \def\gender{n} +\fi + +\ifnum\langid=7 +\ifnum\startval>99 +\myctr=-1 +\loop +\typeout{einhundert/eintausend or hundert/tausend?^^J} +\typeout{[1] einhundert/eintausend} +\typeout{[2] hundert/tausend} +\typein[\response]{Default: 1} +\ifthenelse{\equal{\response}{}}{\def\response{1}}{}%default +\ifthenelse{\equal{\response}{1}}{% +\renewcommand{\einhundert}{einhundert} +\renewcommand{\eintausend}{eintausend} +\myctr=1}{% +\ifthenelse{\equal{\response}{2}}{% +\renewcommand{\einhundert}{hundert} +\renewcommand{\eintausend}{tausend} +\myctr=2}{% +\myctr=-1}} +\ifnum\myctr=-1 +\repeat +\fi +\fi + +\setcounter{startval}{\startval} +\setcounter{endval}{\endval} +\setcounter{stepsize}{\stepsize} + +\stepcounter{endval} +\begin{ttfamily} +\noindent +\makebox[0.25in][c]{N} +\makebox[0.5in][c]{ordinal}\quad +\stringtype +\par +\myctr=\value{startval} +\loop +\noindent +\setcounter{N}{\myctr} +\makebox[0.25in][r]{\arabic{N}} +\makebox[0.5in][r]{\ordinal{N}[\gender]}\quad +\csname\stringtype\endcsname{N}[\gender]. +\par +\advance\myctr by \value{stepsize}\relax +\ifnum\myctr<\value{endval} +\repeat + +\end{ttfamily} + +\end{document} +% \end{macrocode} +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*fc-samp.tex> +% \end{macrocode} +%\fi +% \begin{macrocode} +\documentclass[a4paper]{article} + +\usepackage{fmtcount} +\newcounter{N} + +\padzeroes[5] + +\newcommand{\printrow}[1]{% +\newline +\setcounter{N}{#1} +\makebox[0.75in][r]{\decimal{N}\quad} +\makebox[0.75in][r]{\hexadecimal{N}\quad} +\makebox[0.75in][r]{\ordinal{N}\quad} +\makebox[2in][l]{\numberstring{N}} +} + +\renewcommand{\thesection}{\ordinal{section}} + +\begin{document} + +\section{Displaying the value of a counter} +\label{ex} + +\begin{ttfamily} +\noindent +\makebox[0.75in][c]{decimal} +\makebox[0.75in][c]{hexadecimal} +\makebox[0.75in][c]{ordinal} +numberstring +\printrow{0} +\printrow{1} +\printrow{2} +\printrow{3} +\printrow{4} +\printrow{5} +\printrow{6} +\printrow{7} +\printrow{8} +\printrow{9} +\printrow{10} +\printrow{11} +\printrow{12} +\printrow{13} +\printrow{14} +\printrow{15} +\printrow{16} +\printrow{17} +\printrow{18} +\printrow{19} +\printrow{20} +\printrow{21} +\printrow{22} +\printrow{23} +\printrow{24} +\printrow{25} +\printrow{30} +\printrow{40} +\printrow{50} +\printrow{60} +\printrow{70} +\printrow{71} +\printrow{75} +\printrow{80} +\printrow{81} +\printrow{85} +\printrow{90} +\printrow{91} +\printrow{95} +\printrow{100} +\printrow{101} +\printrow{110} +\printrow{125} +\printrow{150} +\printrow{170} +\printrow{180} +\printrow{190} +\printrow{200} +\printrow{250} +\printrow{300} +\printrow{400} +\printrow{500} +\printrow{600} +\printrow{700} +\printrow{800} +\printrow{900} +\printrow{1000} +\printrow{99999} +\end{ttfamily} + +\section{Cross-Referencing} + +Referencing a label: \ref{ex}. + +Passing numbers explicitly: \ordinalnum{10}, +\Numberstringnum{10}, \NUMBERstringnum{10}, \Ordinalstringnum{10}, +\ORDINALstringnum{10}. + +\end{document} +% \end{macrocode} +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi %\Finale \endinput diff --git a/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins b/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins index ade931c60ae..ce3f24e2327 100644 --- a/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins +++ b/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins @@ -1,10 +1,10 @@ -% fmtcount.ins generated using makedtx version 0.94b 2007/8/20 12:28 +% fmtcount.ins generated using makedtx version 0.94b 2009/10/2 18:35 \input docstrip \preamble fmtcount.dtx - Copyright 2007 Nicola Talbot + Copyright 2009 Nicola Talbot This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 @@ -18,13 +18,15 @@ The Current Maintainer of this work is Nicola Talbot. - This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-british.def, fc-english.def, fc-french.def, fc-german.def, fc-portuges.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fmtcount.sty, fmtcount.perl. + This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fmtcount.sty, fc-british.def, fc-english.def, fc-french.def, fc-german.def, fc-italian.def, fc-portuges.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fmtcount.perl, fc-lang.tex, fc-samp.tex. \endpreamble \askforoverwritefalse -\generate{\file{fc-british.def}{\usepreamble\defaultpreamble +\generate{\file{fmtcount.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{fmtcount.dtx}{fmtcount.sty,package}} +\file{fc-british.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-british.def,package}} \file{fc-english.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-english.def,package}} @@ -32,6 +34,8 @@ \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-french.def,package}} \file{fc-german.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-german.def,package}} +\file{fc-italian.def}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-italian.def,package}} \file{fc-portuges.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-portuges.def,package}} \file{fc-spanish.def}{\usepreamble\defaultpreamble @@ -40,9 +44,11 @@ \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-UKenglish.def,package}} \file{fc-USenglish.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-USenglish.def,package}} -\file{fmtcount.sty}{\usepreamble\defaultpreamble -\usepostamble\defaultpostamble\from{fmtcount.dtx}{fmtcount.sty,package}} \file{fmtcount.perl}{\nopreamble\nopostamble\from{fmtcount.dtx}{fmtcount.perl}} +\file{fc-lang.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-lang.tex,package}} +\file{fc-samp.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-samp.tex,package}} } \endbatchfile diff --git a/Master/texmf-dist/source/latex/fmtcount/fmtcount.perl b/Master/texmf-dist/source/latex/fmtcount/fmtcount.perl new file mode 100644 index 00000000000..bc7d3b9fb4e --- /dev/null +++ b/Master/texmf-dist/source/latex/fmtcount/fmtcount.perl @@ -0,0 +1,2670 @@ +# File : fmtcount.perl +# Author : Nicola Talbot +# Date : 26 May 2007 +# Version : 1.05 +# Description : LaTeX2HTML implementation of fmtcount package + +package main; + +sub do_fmtcount_raise{ + local($tmp)=""; + + $tmp .= 'sub do_cmd_fmtord{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($suffix) = &missing_braces unless (s/$next_pair_pr_rx/$suffix=$2;\'\'/eo);'; + $tmp .= 'join("", "",$suffix,"",$_);'; + $tmp .='}'; + + eval($tmp); +} + +sub do_fmtcount_level{ + local($tmp)=""; + + $tmp .= 'sub do_cmd_fmtord{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($suffix) = &missing_braces unless (s/$next_pair_pr_rx/$suffix=$2;\'\'/eo);'; + $tmp .= 'join("", $suffix,$_);'; + $tmp .='}'; + + eval($tmp); +} + +if (not defined &do_cmd_fmtord) +{ + &do_fmtcount_raise(@_); +} + +$frenchdialect = 'france'; +$ordinalabbrv = 0; + +sub get_ordinal_suffix_english{ + local($num,$gender) = @_; + local($suffix); + + if ((($num % 10) == 1) && ($num%100 != 11)) + { + $suffix = 'st'; + } + elsif ((($num % 10) == 2) && ($num%100 != 12)) + { + $suffix = 'nd'; + } + elsif ((($num % 10) == 3) && ($num%100 != 13)) + { + $suffix = 'rd'; + } + else + { + $suffix = 'th'; + } + + $suffix; +} + +sub get_ordinal_suffix_french{ + local($num,$gender) = @_; + local($_); + + if ($ordinalabbrv > 0) + { + $_ = 'e'; + } + else + { + if ($num == 1) + { + $_ = ($gender eq 'f' ? 'ere' : 'er'); + } + else + { + $_ = 'eme'; + } + } +} + +sub get_ordinal_suffix_spanish{ + local($num,$gender) = @_; + + ($gender eq 'f' ? 'a' : 'o'); +} + +sub get_ordinal_suffix_portuges{ + local($num,$gender) = @_; + + ($gender eq 'f' ? 'a' : 'o'); +} + +sub get_ordinal_suffix_german{ + local($num,$gender) = @_; + + ''; +} + +sub get_ordinal_suffix_ngerman{ + local($num,$gender) = @_; + + ''; +} + +sub get_ordinal_suffix{ + local($num,$gender) = @_; + local($suffix,$suffixsub); + + $suffixsub = "get_ordinal_suffix_$default_language"; + + if (defined ($suffixsub)) + { + $suffix = &$suffixsub($num,$gender); + } + else + { + $suffix = &get_ordinal_suffix_english($num,$gender); + } + + $suffix; +} + +sub getordinal{ + local($num,$gender) = @_; + local($suffix) = &get_ordinal_suffix($num,$gender); + local($text)=''; + + if ($suffix eq '') + { + $text = $num; + } + else + { + local($br_id) = ++$global{'max_id'}; + $text = $num . "\\fmtord${OP}$br_id${CP}$suffix${OP}$br_id${CP}"; + } + + $text; +} + +sub do_cmd_ordinalnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + my($gender)='m'; + local($suffix)=''; + + if (s/\[([mfn])\]//) + { + $gender = $1; + } + + $suffix = &get_ordinal_suffix($num,$gender); + + local($br_id) = ++$global{'max_id'}; + join('', $num, "\\fmtord${OP}$br_id${CP}$suffix${OP}$br_id${CP}", $_); +} + +sub do_cmd_FCordinal{ + &do_cmd_ordinal; +} + +sub do_cmd_ordinal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + my($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $str eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{ORDINAL{', $ctr, '}}', $_[0]); + } + else + { + join('', &getordinal($val, $gender), $_[0]); + } +} + +sub do_cmd_storeordinal{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + local($ctr, $val, $id, $_) = &read_counter_value($_); + my($gender)='m'; + + $_ =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + $fmtcntvar{$key} = join('', '{ORDINAL{', $ctr, '}}'); + } + else + { + $fmtcntvar{$key} = &getordinal($val, $gender); + } + + $_; +} + +sub do_cmd_storeordinalnum{ + local($_) = @_; + local($key, $val); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $val = &missing_braces + unless (s/$next_pair_pr_rx/$val=$2;''/eo); + + my($gender)='m'; + + if ($_ =~s/\s*\[([mfn])\]//) + { + $gender = $1; + } + + $fmtcntvar{$key} = &getordinal($val, $gender); + + $_; +} + +@unitthstring = ('zeroth', + 'first', + 'second', + 'third', + 'fourth', + 'fifth', + 'sixth', + 'seventh', + 'eighth', + 'ninth'); + +@tenthstring = ('', + 'tenth', + 'twentieth', + 'thirtieth', + 'fortieth', + 'fiftieth', + 'sixtieth', + 'seventieth', + 'eightieth', + 'ninetieth'); + +@teenthstring = ('tenth', + 'eleventh', + 'twelfth', + 'thirteenth', + 'fourteenth', + 'fifteenth', + 'sixteenth', + 'seventeenth', + 'eighteenth', + 'nineteenth'); + +@unitstring = ('zero', + 'one', + 'two', + 'three', + 'four', + 'five', + 'six', + 'seven', + 'eight', + 'nine'); + +@teenstring = ('ten', + 'eleven', + 'twelve', + 'thirteen', + 'fourteen', + 'fifteen', + 'sixteen', + 'seventeen', + 'eighteen', + 'nineteen'); +@tenstring = ('', + 'ten', + 'twenty', + 'thirty', + 'forty', + 'fifty', + 'sixty', + 'seventy', + 'eighty', + 'ninety'); + +$hundredname = "hundred"; +$hundredthname = "hundredth"; +$thousandname = "thousand"; +$thousandthname = "thousandth"; + +sub get_numberstringenglish{ + local($num) = @_; + local($name)=""; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = &get_numberstringenglish($num/1000); + $name .= $thousands . " $thousandname"; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = &get_numberstringenglish($num/100); + $name .= $hundreds . " $hundredname"; + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " and "; } + + if ($num >= 20) + { + $name .= $tenstring[$num/10]; + + if ($num%10 > 0) { $name .= '-'; } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenstring[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstring[$num%10]; + } + } + + $name; +} + +@unitthstringfrench = ('zeroi\`eme', + 'uni\`eme', + 'deuxi\`eme', + 'troisi\`eme', + 'quatri\`eme', + 'cinqui\`eme', + 'sixi\`eme', + 'septi\`eme', + 'huiti\`eme', + 'neuvi\`eme'); + +@tenthstringfrench = ('', + 'dixi\`eme', + 'vingti\`eme', + 'trentri\`eme', + 'quaranti\`eme', + 'cinquanti\`eme', + 'soixanti\`eme', + 'septenti\`eme', + 'huitanti\`eme', + 'nonenti\`eme'); + +@teenthstringfrench = ('dixi\`eme', + 'onzi\`eme', + 'douzi\`eme', + 'treizi\`eme', + 'quatorzi\`eme', + 'quinzi\`eme', + 'seizi\`eme', + 'dix-septi\`eme', + 'dix-huiti\`eme', + 'dix-neuvi\`eme'); + +@unitstringfrench = ('zero', + 'un', + 'deux', + 'trois', + 'quatre', + 'cinq', + 'six', + 'sept', + 'huit', + 'neuf'); + +@teenstringfrench = ('dix', + 'onze', + 'douze', + 'treize', + 'quatorze', + 'quinze', + 'seize', + 'dix-sept', + 'dix-huit', + 'dix-neuf'); + +@tenstringfrench = ('', + 'dix', + 'vingt', + 'trente', + 'quarante', + 'cinquante', + 'soixante', + 'septente', + 'huitante', + 'nonente'); + +$hundrednamefrench = "cent"; +$hundredthnamefrench = "centi\\`eme"; +$thousandnamefrench = "mille"; +$thousandthnamefrench = "mili\\`eme"; + +@unitthstringspanish = ('cero', + 'primero', + 'segundo', + 'tercero', + 'cuarto', + 'quinto', + 'sexto', + 's\\\'eptimo', + 'octavo', + 'noveno'); + +@tenthstringspanish = ('', + 'd\\\'ecimo', + 'vig\\\'esimo', + 'trig\\\'esimo', + 'cuadrag\\\'esimo', + 'quincuag\\\'esimo', + 'sexag\\\'esimo', + 'septuag\\\'esimo', + 'octog\\\'esimo', + 'nonag\\\'esimo'); + +@teenthstringspanish = ('d\\\'ecimo', + 'und\\\'ecimo', + 'duod\\\'ecimo', + 'decimotercero', + 'decimocuarto', + 'decimoquinto', + 'decimosexto', + 'decimos\\\'eptimo', + 'decimoctavo', + 'decimonoveno'); + +@hundredthstringspanish = ('', + 'cent\\\'esimo', + 'ducent\\\'esimo', + 'tricent\\\'esimo', + 'cuadringent\\\'esimo', + 'quingent\\\'esimo', + 'sexcent\\\'esimo', + 'septing\\\'esimo', + 'octingent\\\'esimo', + 'noningent\\\'esimo'); + +@unitstringspanish = ('cero', + 'uno', + 'dos', + 'tres', + 'cuatro', + 'cinco', + 'seis', + 'siete', + 'ocho', + 'nueve'); + +@teenstringspanish = ('diez', + 'once', + 'doce', + 'trece', + 'catorce', + 'quince', + 'diecis\\\'eis', + 'diecisiete', + 'dieciocho', + 'diecinueve'); + +@twentystringspanish = ('viente', + 'vientiuno', + 'vientid\\\'os', + 'vientitr\\\'es', + 'vienticuatro', + 'vienticinco', + 'vientis\\\'eis', + 'vientisiete', + 'vientiocho', + 'vientinueve'); + +@tenstringspanish = ('', + 'diez', + 'viente', + 'treinta', + 'cuarenta', + 'cincuenta', + 'sesenta', + 'setenta', + 'ochenta', + 'noventa'); + +@hundredstringspanish = ('', + 'ciento', + 'doscientos', + 'trescientos', + 'cuatrocientos', + 'quinientos', + 'seiscientos', + 'setecientos', + 'ochocientos', + 'novecientos'); + +$hundrednamespanish = "cien"; +$hundredthnamespanish = "centi\\`eme"; +$thousandnamespanish = "mil"; +$thousandthnamespanish = "mil\\'esimo"; + +@unitthstringportuges = ('zero', + 'primeiro', + 'segundo', + 'terceiro', + 'quatro', + 'quinto', + 'sexto', + 's\\\'etimo', + 'oitavo', + 'nono'); + +@tenthstringportuges = ('', + 'd\\\'ecimo', + 'vig\\\'esimo', + 'trig\\\'esimo', + 'quadrag\\\'esimo', + 'q\"uinquag\\\'esimo', + 'sexag\\\'esimo', + 'setuag\\\'esimo', + 'octog\\\'esimo', + 'nonag\\\'esimo'); + +@hundredthstringportuges = ('', + 'cent\\\'esimo', + 'ducent\\\'esimo', + 'trecent\\\'esimo', + 'quadringent\\\'esimo', + 'q\"uingent\\\'esimo', + 'seiscent\\\'esimo', + 'setingent\\\'esimo', + 'octingent\\\'esimo', + 'nongent\\\'esimo'); + +@unitstringportuges = ('zero', + 'um', + 'dois', + 'tr\^es', + 'quatro', + 'cinco', + 'seis', + 'sete', + 'oito', + 'nove'); + +@teenstringportuges = ('dez', + 'onze', + 'doze', + 'treze', + 'quatorze', + 'quinze', + 'dezesseis', + 'dezessete', + 'dezoito', + 'dezenove'); + +@tenstringportuges = ('', + 'dez', + 'vinte', + 'trinta', + 'quaranta', + 'cinq\"uenta', + 'sessenta', + 'setenta', + 'oitenta', + 'noventa'); + +@hundredstringportuges = ('', + 'cento', + 'duzentos', + 'trezentos', + 'quatrocentos', + 'quinhentos', + 'seiscentos', + 'setecentos', + 'oitocentos', + 'novecentos'); + +$hundrednameportuges = "cem"; +$thousandnameportuges = "mil"; +$thousandthnameportuges = "mil\\'esimo"; + +sub get_numberstringfrench{ + local($num,$gender) = @_; + local($name)=""; + + if ($gender eq 'f') + { + $unitstringfrench[1] = 'une'; + } + else + { + $unitstringfrench[1] = 'un'; + } + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringfrench($num/1000,$gender).' '; + } + + $name .= $thousands . $thousandnamefrench; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num >= 200) + { + $hundreds = &get_numberstringfrench($num/100,$gender).' '; + } + + $name .= $hundreds . $hundrednamefrench; + $num = $num%100; + + if (($_[0]%100 == 0) && ($_[0]/100 > 1)) + { + $name .= 's'; + } + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " "; } + + if ($num >= 20) + { + if ($frenchdialect eq 'france' and $num >= 70) + { + if ($num < 80) + { + $name .= $tenstringfrench[6]; + + if ($num%10 == 1) + { + $name .= ' et '; + } + else + { + $name .= '-'; + } + + $num = 10+($num%10); + } + else + { + $name .= 'quatre-vingt' . ($num==80?'s':'-'); + + if ($num >= 90) + { + $num = 10+($num%10); + } + } + } + elsif ($frenchdialect eq 'belgian' + && ($num >= 80) && ($num < 90)) + { + $name .= 'quatre-vingt' . ($num==80?'s':'-'); + } + else + { + $name .= $tenstringfrench[$num/10]; + + if ($num%10 == 1) { $name .= ' et ';} + elsif ($num%10 > 0) { $name .= '-'; } + } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenstringfrench[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstringfrench[$num%10]; + } + } + + $name; +} + +sub get_numberstringspanish{ + local($num,$gender) = @_; + local($name)=""; + + if ($gender eq 'f') + { + $unitstringspanish[1] = 'una'; + } + else + { + $unitstringspanish[1] = 'uno'; + } + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringspanish($num/1000,$gender).' '; + } + + $name .= $thousands . $thousandnamespanish; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num > 100) + { + $hundreds = $hundredstringspanish[$num/100]; + } + else + { + $hundreds = 'cien'; + } + + $name .= $hundreds; + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " y "; } + + if ($num >= 30) + { + $name .= $tenstringspanish[$num/10]; + + if ($num%10 > 0) { $name .= ' y '; } + } + + if (($num >=20) && ($num < 30)) + { + $name .= $twentystringspanish[$num%10]; + } + elsif (($num >= 10) && ($num < 20)) + { + $name .= $teenstringspanish[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstringspanish[$num%10]; + } + } + + $name; +} + +sub get_numberstringportuges{ + local($num,$gender) = @_; + local($name)=""; + + if ($gender eq 'f') + { + $unitstringportuges[0] = 'zera'; + $unitstringportuges[1] = 'uma'; + $unitstringportuges[2] = 'duas'; + } + else + { + $unitstringportuges[0] = 'zero'; + $unitstringportuges[1] = 'um'; + $unitstringportuges[2] = 'dois'; + } + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringportuges($num/1000,$gender).' '; + } + + $name .= $thousands . $thousandnameportuges; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num > 100) + { + $hundreds = $hundredstringportuges[$num/100]; + + if ($gender eq 'f' and $num >= 200) + { + $hundreds =~s/o(s?)$/a\1/; + } + } + else + { + $hundreds = $hundrednameportuges; + } + + $name .= $hundreds; + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " e "; } + + if ($num >= 20) + { + $name .= $tenstringportuges[$num/10]; + + if ($num%10 == 1) { $name .= ' e ';} + elsif ($num%10 > 0) { $name .= ' '; } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenstringportuges[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstringportuges[$num%10]; + } + } + + $name; +} + +@unitthstringMgerman = ('nullter', + 'erster', + 'zweiter', + 'dritter', + 'vierter', + 'f\\"unter', + 'sechster', + 'siebter', + 'achter', + 'neunter'); + +@tenthstringMgerman = ('', + 'zehnter', + 'zwanzigster', + 'drei\\ss igster', + 'vierzigster', + 'f\\"unfzigster', + 'sechzigster', + 'siebzigster', + 'achtzigster', + 'neunzigster'); + +@teenthstringMgerman = ('zehnter', + 'elfter', + 'zw\\"olfter', + 'dreizehnter', + 'vierzehnter', + 'f\\"unfzehnter', + 'sechzehnter', + 'siebzehnter', + 'achtzehnter', + 'neunzehnter'); + +@unitthstringFgerman = ('nullte', + 'erste', + 'zweite', + 'dritte', + 'vierte', + 'f\\"unfte', + 'sechste', + 'siebte', + 'achte', + 'neunte'); + +@tenthstringFgerman = ('', + 'zehnte', + 'zwanzigste', + 'drei\\ss igste', + 'vierzigste', + 'f\\"unfzigste', + 'sechzigste', + 'siebzigste', + 'achtzigste', + 'neunzigste'); + +@teenthstringFgerman = ('zehnte', + 'elfte', + 'zw\\"olfte', + 'dreizehnte', + 'vierzehnte', + 'f\\"unfzehnte', + 'sechzehnte', + 'siebzehnte', + 'achtzehnte', + 'neunzehnte'); + +@unitthstringNgerman = ('nulltes', + 'erstes', + 'zweites', + 'drittes', + 'viertes', + 'f\\"unte', + 'sechstes', + 'siebtes', + 'achtes', + 'neuntes'); + +@tenthstringNgerman = ('', + 'zehntes', + 'zwanzigstes', + 'drei\\ss igstes', + 'vierzigstes', + 'f\\"unfzigstes', + 'sechzigstes', + 'siebzigstes', + 'achtzigstes', + 'neunzigstes'); + +@teenthstringNgerman = ('zehntes', + 'elftes', + 'zw\\"olftes', + 'dreizehntes', + 'vierzehntes', + 'f\\"unfzehntes', + 'sechzehntes', + 'siebzehntes', + 'achtzehntes', + 'neunzehntes'); + +@unitstringgerman = ('null', + 'ein', # eins dealt with separately (this is for prefixes) + 'zwei', + 'drei', + 'vier', + 'f\\"unf', + 'sechs', + 'sieben', + 'acht', + 'neun'); + +@teenstringgerman = ('zehn', + 'elf', + 'zw\\"olf', + 'dreizehn', + 'vierzehn', + 'f\\"unfzehn', + 'sechzehn', + 'siebzehn', + 'achtzehn', + 'neunzehn'); + +@tenstringgerman = ('', + 'zehn', + 'zwanzig', + 'drei\\ss ig', + 'vierzig', + 'f\\"unfzig', + 'sechzig', + 'siebzig', + 'achtzig', + 'neunzig'); + +sub do_cmd_einhundert{ + local($_) = @_; + + "einhundert$_"; +} + +sub do_cmd_eintausend{ + local($_) = @_; + + "eintausend$_"; +} + +sub get_numberunderhundredgerman{ + local($num)=@_; + local($name)=''; + + if ($num == 1) + { + $name = 'eins'; + } + elsif ($num < 10) + { + $name = $unitstringgerman[$num]; + } + elsif ($num%10 == 0) + { + $name = $tenstringgerman[$num/10]; + } + else + { + $name = join('und', $unitstringgerman[$num%10], + $tenstringgerman[$num/10]); + } + + $name; +} + +sub get_numberstringgerman{ + local($orgnum,$gender) = @_; + local($name)=""; + + local($num) = $orgnum; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000 and $num < 2000) + { + $name = &translate_commands("\\eintausend "); + } + elsif ($num >= 2000) + { + $name = &get_numberunderhundredgerman($num/1000) + . "tausend"; + } + + $num = $orgnum%1000; + + if ($num >= 100 and $num < 200) + { + if ($orgnum > 1000) + { + $name .= "einhundert"; + } + else + { + $name = &translate_commands("\\einhundert "); + } + } + elsif ($num >= 200) + { + $name .= $unitstringgerman[$num/100]."hundert"; + } + + $num = $num%100; + + if ($orgnum == 0) + { + $name = 'null'; + } + elsif ($num > 0) + { + $name .= &get_numberunderhundredgerman($num); + } + } + + $name; +} + +sub get_numberstring{ + local($val,$gender) = @_; + + if ($default_language eq 'french') + { + &get_numberstringfrench($val,$gender); + } + elsif ($default_language eq 'spanish') + { + &get_numberstringspanish($val,$gender); + } + elsif ($default_language eq 'portuges') + { + &get_numberstringportuges($val,$gender); + } + elsif ($default_language eq 'german' + or $default_language eq 'ngerman') + { + &get_numberstringgerman($val,$gender); + } + else + { + &get_numberstringenglish($val); + } +} + +sub do_cmd_numberstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces unless + s/$next_pair_pr_rx/$num=$2;''/eo; + + if (s/\[(m|f|n)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_numberstring($num,$gender), $_); +} + +sub do_cmd_numberstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + my($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{NUMBERSTRING{', $ctr, '}}', $_[0]); + } + else + { + join('', &get_numberstring($val, $gender), $_[0]); + } +} + +sub do_cmd_storenumberstring{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + local($ctr, $val, $id, $_) = &read_counter_value($_); + my($gender)='m'; + + $_ =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + $fmtcntvar{$key} = join('', '{NUMBERSTRING{', $ctr, '}}'); + } + else + { + $fmtcntvar{$key} = join('', &get_numberstring($val, $gender)); + } + + $_; +} + +sub do_cmd_storenumberstringnum{ + local($_) = @_; + local($key, $val); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $val = &missing_braces + unless (s/$next_pair_pr_rx/$val=$2;''/eo); + + my($gender)='m'; + + if ($_ =~s/\s*\[([mfn])\]//) + { + $gender = $1; + } + + $fmtcntvar{$key} = join('', &get_numberstring($val, $gender)); + + $_; +} + +sub get_Numberstring{ + local($val,$gender) = @_; + local($string) = &get_numberstring($val,$gender); + + if ($default_language=~m/german/) + { + $string =~ s/([a-z])([^\s\-]+)/\u\1\2/; + } + else + { + $string =~ s/([a-z])([^\s\-]+)/\u\1\2/g; + + if ($default_language eq 'french') + { + $string =~ s/ Et / et /g; + } + elsif ($default_language eq 'spanish') + { + $string =~ s/ Y / y /g; + } + elsif ($default_language eq 'portuges') + { + $string =~ s/ E / e /g; + } + else + { + $string =~ s/ And / and /g; + } + } + + $string; +} + +sub do_cmd_Numberstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + if (s/\[(m|f|n)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_Numberstring($num,$gender), $_); +} + +sub do_cmd_Numberstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + my($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{NNUMBERSTRING{', $ctr, '}}', $_[0]); + } + else + { + join('', &get_Numberstring($val, $gender), $_[0]); + } +} + +sub do_cmd_storeNumberstring{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + local($ctr, $val, $id, $_) = &read_counter_value($_); + my($gender)='m'; + + $_ =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_ =~s/\s*\[([mfn])\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + $fmtcntvar{$key} = join('', '{NNUMBERSTRING{', $ctr, '}}'); + } + else + { + $fmtcntvar{$key} = join('', &get_Numberstring($val, $gender)); + } + + $_; +} + +sub do_cmd_storeNumberstringnum{ + local($_) = @_; + local($key, $val); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $val = &missing_braces + unless (s/$next_pair_pr_rx/$val=$2;''/eo); + + my($gender)='m'; + + if ($_ =~s/\s*\[([mfn])\]//) + { + $gender = $1; + } + + $fmtcntvar{$key} = join('', &get_Numberstring($val, $gender)); + + $_; +} + +sub do_cmd_NUMBERstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + if (s/\[(m|f|n)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', uc(&get_numberstring($num,$gender)), $_); +} + +sub do_cmd_NUMBERstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + my($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{CAPNUMBERSTRING{', $ctr, '}}', $_); + } + else + { + join('', uc(&get_numberstring($val, $gender)), $_); + } +} + +sub do_cmd_storeNUMBERstring{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + local($ctr, $val, $id, $_) = &read_counter_value($_); + my($gender)='m'; + + $_ =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + $fmtcntvar{$key} = join('', '{CAPNUMBERSTRING{', $ctr, '}}'); + } + else + { + $fmtcntvar{$key} = uc(&get_numberstring($val, $gender)); + } + + $_; +} + +sub do_cmd_storeNUMBERstringnum{ + local($_) = @_; + local($key, $val); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $val = &missing_braces + unless (s/$next_pair_pr_rx/$val=$2;''/eo); + + my($gender)='m'; + + if ($_ =~s/\s*\[([mfn])\]//) + { + $gender = $1; + } + + $fmtcntvar{$key} = uc(&get_numberstring($val, $gender)); + + $_; +} + +sub get_ordinalstringenglish{ + local($num) = @_; + local($name)=""; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = &get_numberstring($num/1000); + $name .= $thousands; + + if ($num%1000 > 0) + { + $name .= " $thousandname"; + } + else + { + $name .= " $thousandthname"; + } + + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = &get_numberstring($num/100); + $name .= $hundreds; + + if ($num%100 > 0) + { + $name .= " $hundredname"; + } + else + { + $name .= " $hundredthname"; + } + + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " and "; } + + if ($num >= 20) + { + if ($num%10 > 0) + { + $name .= $tenstring[$num/10] . '-'; + } + else + { + $name .= $tenthstring[$num/10]; + } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenthstring[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitthstring[$num%10]; + } + } + + $name; +} + +sub get_ordinalstringfrench{ + local($num,$gender) = @_; + local($name)=""; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringfrench($num/1000,$gender).' '; + } + + $num = $num%1000; + + if ($num > 0) + { + $name .= $thousands . $thousandnamefrench; + } + else + { + $name .= $thousands . $thousandthnamefrench; + } + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num >= 200) + { + $hundreds = &get_numberstringfrench($num/100,$gender).' '; + } + + $num = $num%100; + + if ($num > 0) + { + $name .= $hundreds . $hundrednamefrench; + } + else + { + $name .= $hundreds . $hundredthnamefrench; + } + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " "; } + + if ($num >= 20) + { + if ($frenchdialect eq 'france' and $num >= 70) + { + if ($num < 80) + { + if ($num%10 > 0) + { + $name .= $tenstringfrench[6]; + } + else + { + $name .= $tenthstringfrench[6]; + } + + if ($num%10 == 1) + { + $name .= ' et '; + } + else + { + $name .= '-'; + } + + $num = 10+($num%10); + } + else + { + $name .= 'quatre-vingt' . ($num==80?'i\`eme':'-'); + + if ($num >= 90) + { + $num = 10+($num%10); + } + } + } + elsif ($frenchdialect eq 'belgian' and $num >= 80) + { + $name .= 'quatre-vingt' . ($num==80?'i\`eme':'-'); + + if ($num >= 90) + { + $num = 10+($num%10); + } + } + else + { + if ($num%10 > 0) + { + $name .= $tenstringfrench[$num/10]; + } + else + { + $name .= $tenthstringfrench[$num/10]; + } + + if ($num%10 == 1) { $name .= ' et ';} + elsif ($num%10 > 0) { $name .= '-'; } + } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenthstringfrench[$num%10]; + } + elsif ($_[0] == 1) + { + $name = 'premi\`ere'; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitthstringfrench[$num%10]; + } + } + + $name; +} + +sub get_ordinalstringspanish{ + local($num,$gender) = @_; + local($name)=""; + local($str); + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + if ($num >= 2000) + { + local($thousands) = &get_ordinalstringspanish($num/1000); + + if ($gender eq 'f') + { + $thousands =~s/o(s?)$/a\1/; + } + + $name .= $thousands. " "; + } + else + { + $name = ""; + } + + $name .= "$thousandthnamespanish"; + + if ($gender eq 'f') + { + $name =~s/o$/a/; + } + + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = $hundredthstringspanish[$num/100]; + + if ($gender eq 'f') + { + $hundreds =~s/o$/a/; + } + + $name .= $hundreds; + + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " "; } + + local($lastbit)=""; + + if ($num >= 20) + { + $lastbit = $tenthstringspanish[$num/10]; + + if ($num%10 > 0) + { + $lastbit .= ' '; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + + $lastbit = ""; + } + + if (($num >= 10) && ($num < 20)) + { + $lastbit = $teenthstringspanish[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $lastbit = $unitthstringspanish[$num%10]; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + } + + $name; +} + +sub get_ordinalstringportuges{ + local($num,$gender) = @_; + local($name)=""; + local($str); + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + if ($num >= 2000) + { + local($thousands) = &get_ordinalstringportuges($num/1000); + + if ($gender eq 'f') + { + $thousands =~s/o(s?)$/a\1/; + } + + $name .= $thousands. " "; + } + else + { + $name = ""; + } + + $name .= "$thousandthnameportuges"; + + if ($gender eq 'f') + { + $name =~s/o$/a/; + } + + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = $hundredthstringportuges[$num/100]; + + if ($gender eq 'f') + { + $hundreds =~s/o$/a/; + } + + $name .= $hundreds; + + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= "-"; } + + local($lastbit)=""; + + if ($num >= 10) + { + $lastbit = $tenthstringportuges[$num/10]; + + if ($num%10 > 0) + { + $lastbit .= '-'; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + + $lastbit = ""; + } + + if (($num%10 > 0) || ($_[0] == 0)) + { + $lastbit = $unitthstringportuges[$num%10]; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + } + + $name; +} + +sub get_numberunderhundredthgerman{ + local($num,$gender)=@_; + local($name)=''; + + if ($num < 10) + { + if ($gender eq 'F') + { + $name = $unitthstringFgerman[$num]; + } + elsif ($gender eq 'N') + { + $name = $unitthstringNgerman[$num]; + } + else + { + $name = $unitthstringMgerman[$num]; + } + } + elsif ($num%10 == 0) + { + if ($gender eq 'F') + { + $name = $tenthstringFgerman[$num/10]; + } + elsif ($gender eq 'N') + { + $name = $tenthstringNgerman[$num/10]; + } + else + { + $name = $tenthstringMgerman[$num/10]; + } + } + else + { + local($tenth); + if ($gender eq 'F') + { + $tenth = $tenthstringFgerman[$num/10]; + } + elsif ($gender eq 'N') + { + $tenth = $tenthstringNgerman[$num/10]; + } + else + { + $tenth = $tenthstringMgerman[$num/10]; + } + + $name = join('und', $unitstringgerman[$num%10], $tenth); + } + + $name; +} + +sub get_ordinalstringgerman{ + local($orgnum,$gender) = @_; + local($name)=""; + local($suffix)=''; + + $gender = uc($gender); + + if ($gender eq 'F') + { + $suffix = 'ste'; + } + elsif ($gender eq 'N') + { + $suffix = 'stes'; + } + else + { + $suffix = 'ster'; + $gender = 'M'; + } + + local($num) = $orgnum; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000 and $num < 2000) + { + $name = &translate_commands("\\eintausend "); + } + elsif ($num >= 2000) + { + $name = &get_numberunderhundredgerman($num/1000) + . "tausend"; + } + + $num = $orgnum%1000; + + # is that it or is there more? + if ($orgnum >= 1000 and $num == 0) + { + $name .= $suffix; + return $name; + } + + if ($num >= 100 and $num < 200) + { + if ($orgnum > 1000) + { + $name .= "einhundert"; + } + else + { + $name = &translate_commands("\\einhundert "); + } + } + elsif ($num >= 200) + { + $name .= $unitstringgerman[$num/100]."hundert"; + } + + $num = $num%100; + + # is that it or is there more? + if ($orgnum >= 100 and $num == 0) + { + $name .= $suffix; + return $name; + } + + if ($orgnum == 0) + { + if ($gender eq 'F') + { + $name = $unitthstringFgerman[0]; + } + elsif ($gender eq 'N') + { + $name = $unitthstringNgerman[0]; + } + else + { + $name = $unitthstringMgerman[0]; + } + } + elsif ($num > 0) + { + $name .= &get_numberunderhundredthgerman($num,$gender); + } + } + + $name; +} + +sub get_ordinalstring{ + local($val,$gender) = @_; + + if ($default_language eq 'french') + { + &get_ordinalstringfrench($val,$gender); + } + elsif ($default_language eq 'spanish') + { + &get_ordinalstringspanish($val,$gender); + } + elsif ($default_language eq 'portuges') + { + &get_ordinalstringportuges($val,$gender); + } + elsif ($default_language eq 'german' + or $default_language eq 'ngerman') + { + &get_ordinalstringgerman($val,$gender); + } + else + { + &get_ordinalstringenglish($val); + } +} + +sub do_cmd_ordinalstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + if (s/\[(m|f|n)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_ordinalstring($num,$gender), $_); +} + +sub do_cmd_ordinalstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + my($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{ORDINALSTRING{', $ctr, '}}', $_); + } + else + { + join('', &get_ordinalstring($val, $gender), $_); + } +} + + %fmtcntvar = (); + +sub do_cmd_FMCuse{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $fmtcntvar{$key}.$_; +} + +sub do_cmd_storeordinalstring{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + local($ctr, $val, $id, $_) = &read_counter_value($_); + my($gender)='m'; + + $_ =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + $fmtcntvar{$key} = join('', '{ORDINALSTRING{', $ctr, '}}'); + } + else + { + $fmtcntvar{$key} = join('', &get_ordinalstring($val, $gender)); + } + + $_; +} + +sub do_cmd_storeordinalstringnum{ + local($_) = @_; + local($key, $val); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $val = &missing_braces + unless (s/$next_pair_pr_rx/$val=$2;''/eo); + + my($gender)='m'; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + $fmtcntvar{$key} = join('', &get_ordinalstring($val, $gender)); + + $_; +} + +sub get_Ordinalstring{ + local($val,$gender) = @_; + local($string) = &get_ordinalstring($val,$gender); + + if ($default_language=~m/german/) + { + $string =~ s/\b([a-z])([^\s\-]+)/\u\1\2/; + } + else + { + $string =~ s/\b([a-z])([^\s\-]+)/\u\1\2/g; + + if ($default_language eq 'french') + { + $string =~ s/ Et / et /g; + } + else + { + $string =~ s/ And / and /g; + } + } + + $string; +} + +sub do_cmd_Ordinalstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + if (s/\[(m|f|n)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_Ordinalstring($num,$gender), $_); +} + +sub do_cmd_Ordinalstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + my($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{OORDINALSTRING{', $ctr, '}}', $_[0]); + } + else + { + join('', &get_Ordinalstring($val, $gender), $_[0]); + } +} + +sub do_cmd_storeOrdinalstring{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + local($ctr, $val, $id, $_) = &read_counter_value($_); + my($gender)='m'; + + $_ =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + $fmtcntvar{$key} = join('', '{OORDINALSTRING{', $ctr, '}}'); + } + else + { + $fmtcntvar{$key} = join('', &get_Ordinalstring($val, $gender)); + } + + $_; +} + +sub do_cmd_storeOrdinalstringnum{ + local($_) = @_; + local($key, $val); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $val = &missing_braces + unless (s/$next_pair_pr_rx/$val=$2;''/eo); + + my($gender)='m'; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + $fmtcntvar{$key} = join('', &get_Ordinalstring($val, $gender)); + + $_; +} + +sub do_cmd_ORDINALstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + if (s/\[(m|f|n)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', uc(&get_ordinalstring($num,$gender)), $_); +} + +sub do_cmd_ORDINALstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + my($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{CAPORDINALSTRING{', $ctr, '}}', $_); + } + else + { + join('', uc(&get_ordinalstring($val, $gender)), $_); + } +} + +sub do_cmd_storeORDINALstring{ + local($_) = @_; + local($key); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + local($ctr, $val, $id, $_) = &read_counter_value($_); + my($gender)='m'; + + $_ =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + $fmtcntvar{$key} = join('', '{CAPORDINALSTRING{', $ctr, '}}'); + } + else + { + $fmtcntvar{$key} = uc(&get_ordinalstring($val, $gender)); + } + + $_; +} + +sub do_cmd_storeORDINALstringnum{ + local($_) = @_; + local($key, $val); + + $key = &missing_braces + unless ((s/$next_pair_pr_rx//o)&&($key=$2)); + + $val = &missing_braces + unless (s/$next_pair_pr_rx/$val=$2;''/eo); + + my($gender)='m'; + + if ($_ =~s/\s*\[(.)\]//) + { + $gender = $1; + } + + $fmtcntvar{$key} = uc(&get_ordinalstring($val, $gender)); + + $_; +} + +sub do_cmd_fmtcountsetoptions{ + local($_) = @_; + local($options) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($options=$2)); + + if ($options =~ m/french=?(\w*)(,|$)/) + { + if ($1 eq 'france' or $1 eq 'swiss' or $1 eq 'belgian') + { + $frenchdialect = $1; + + print "Using French dialect: $1" if ($VERBOSITY > 0) ; + } + elsif ($1 eq '') + { + $frenchdialect = 'france'; + + print "Using French dialect: france" if ($VERBOSITY > 0); + } + else + { + &write_warnings("unknown french dialect '$1'"); + } + } + + if ($options =~ m/abbrv=?(\w*)(,|$)/) + { + if ($1 eq 'true' or $1 eq '') + { + $ordinalabbrv = 1; + + print "Setting abbrv=true" if ($VERBOSITY > 0); + } + elsif ($1 eq 'false') + { + $ordinalabbrv = 0; + + print "Setting abbrv=false" if ($VERBOSITY > 0); + } + else + { + &write_warnings("fmtcountsetoptions key abbrv: unknown value '$1'."); + } + } + + if ($options =~ m/fmtord=(\w*)(,|$)/) + { + if ($1 eq 'raise') + { + &do_fmtcount_raise(); + + print "Using raised ordinals" if ($VERBOSITY > 0); + } + elsif ($1 eq 'level') + { + &do_fmtcount_level(); + + print "Using level ordinals" if ($VERBOSITY > 0); + } + elsif ($1 eq 'user') + { + # do nothing + + print "Using user defined fmtord" if ($VERBOSITY > 0); + } + else + { + &write_warnings("unknown fmtcount option fmtord=$1"); + } + } + + $_[0]; +} + +$padzeroes = 0; + +sub do_cmd_padzeroes{ + local($_) = @_; + local($val,$pat) = &get_next_optional_argument; + + if ($val eq '') + { + $padzeroes = 17; + } + else + { + $padzeroes = $val; + } + + $_; +} + +sub get_binary{ + local($num) = @_; + local($val) = ""; + + for (my $i=17; $i>=0; $i--) + { + if (($i < $padzeroes) || ($num & (1 << $i)) || !($val eq "")) + { + $val .= ($num & (1 << $i) ? 1 : 0); + } + } + + $val; +} + +sub do_cmd_binary{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_binary($val), $_); +} + +sub do_cmd_binarynum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', &get_binary($num), $_); +} + +sub get_decimal{ + local($num) = @_; + + sprintf "%0${padzeroes}d", $num; +} + +sub do_cmd_decimal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_decimal($val), $_); +} + +sub do_cmd_decimalnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', &get_decimal($num), $_); +} + +sub get_hexadecimal{ + local($num) = @_; + + sprintf "%0${padzeroes}lx", $num; +} + +sub do_cmd_hexadecimal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_hexadecimal($val), $_); +} + +sub do_cmd_hexadecimalnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', &get_hexadecimal($num), $_); +} + +sub get_Hexadecimal{ + local($num) = @_; + + sprintf "%0${padzeroes}lX", $num; +} + +sub do_cmd_Hexadecimal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_Hexadecimal($val), $_); +} + +sub do_cmd_Hexadecimalnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', &get_Hexadecimal($num), $_); +} + +sub get_octal{ + local($num) = @_; + + sprintf "%0${padzeroes}lo", $num; +} + +sub do_cmd_octal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_octal($val), $_); +} + +sub do_cmd_octalnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', &get_octal($num), $_); +} + +sub get_aaalph{ + local($num) = @_; + local($rep) = int($num/26) + 1; + local($c) = chr(ord('a')-1+$num%26); + + local($_) = $c x $rep; +} + +sub do_cmd_aaalph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_aaalph($val), $_); +} + +sub get_AAAlph{ + local($num) = @_; + local($rep) = int($num/26) + 1; + local($c) = chr(ord('A')-1+$num%26); + + local($_) = $c x $rep; +} + +sub do_cmd_AAAlph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_AAAlph($val), $_); +} + +sub do_cmd_aaalphnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', (sprintf "%${padzeroes}s", &get_aaalph($num)), $_); +} + +sub do_cmd_AAAlphnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', uc(sprintf "%${padzeroes}s", &get_aaalph($num)), $_); +} + +sub get_abalph{ + local($num) = @_; + local($str); + + if ($num == 0) + { + $str = ''; + } + elsif ($num > 0 && $num <= 26) + { + $str = chr(ord('a')-1+$num); + } + else + { + $str = &get_abalph(int($num/26)) . chr(ord('a')-1+($num%26)); + } + + $str; +} + +sub do_cmd_abalph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', (sprintf "%${padzeroes}s", &get_abalph($val)), $_); +} + +sub do_cmd_abalphnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', (sprintf "%${padzeroes}s", &get_abalph($num)), $_); +} + +sub do_cmd_ABAlph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', uc(sprintf "%${padzeroes}s", &get_abalph($val)), $_); +} + +sub do_cmd_ABAlphnum{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + join('', uc(sprintf "%${padzeroes}s", &get_abalph($num)), $_); +} + +sub get_twodigit{ + local($num) = @_; + + sprintf "%02d", $num; +} + +sub do_cmd_twodigit{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + # this is a cludge + if ($num eq "THEDAY" or $num eq "THEYEAR" or $num eq "THEMONTH") + { + join('', 'TWODIGIT{', $num, '}', $_); + } + else + { + join('', &get_twodigit($num), $_); + } +} + +# this was put here to help with the definition of \datelatin + +sub do_cmd_romannumeral{ + local($_) = @_; + local($num) = &missing_braces + unless (s/$next_pair_pr_rx/$num=$2;''/eo); + + # this is a cludge + if ($num eq "THEDAY" or $num eq "THEYEAR" or $num eq "THEMONTH") + { + join('', 'ROMANNUMERAL{', $num, '}', $_); + } + else + { + join('', &froman($num), $_); + } +} + +# load configuration file if it exists +# Note: The configuration file should be loaded before +# the package options are executed. + +# why doesn't this work? If I call this subroutine it +# causes an infinite loop. + +sub load_fmtcount_cfg{ + local($file,$found); + + $file = &fulltexpath('fmtcount.cfg'); + + $found = (-f $file); + + if (!$found) + { + foreach $texpath (split /$envkey/, $TEXINPUTS) + { + $file = "$texpath${dd}fmtcount.cfg"; + + last if ($found = (-f $file)); + } + } + + if ($found) + { + print "\nusing configuration file $file\n"; + + &slurp_input($file); + &pre_process; + &substitute_meta_cmds if (%new_command || %new_environment); + &wrap_shorthand_environments; + $_ = &translate_commands(&translate_environments($_)); + + print "\n processed size: ".length($_)."\n" if ($VERBOSITY>1) + } + else + { + print "\nNo configuation file fmtcount.cfg found\n" if ($VERBOSITY>1) + } +} + +1; -- cgit v1.2.3