From 5eb3d28bc68d47fc7eb74e47ac1f6f5c0787ec72 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 9 May 2015 22:19:10 +0000 Subject: fmtcount (9may15) git-svn-id: svn://tug.org/texlive/trunk@37298 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/fmtcount/CHANGES | 22 + Master/texmf-dist/doc/latex/fmtcount/README | 4 +- Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex | 7 +- .../doc/latex/fmtcount/fc-typeout-languages.tex | 20 + Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf | Bin 525553 -> 537356 bytes .../texmf-dist/source/latex/fmtcount/fmtcount.dtx | 13758 ++++++++++--------- .../texmf-dist/source/latex/fmtcount/fmtcount.ins | 20 +- .../texmf-dist/tex/latex/fmtcount/fc-UKenglish.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-USenglish.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-american.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-british.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-english.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-francais.def | 7 +- Master/texmf-dist/tex/latex/fmtcount/fc-french.def | 52 +- .../texmf-dist/tex/latex/fmtcount/fc-frenchb.def | 7 +- Master/texmf-dist/tex/latex/fmtcount/fc-german.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-germanb.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-italian.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-ngerman.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-ngermanb.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-portuges.def | 7 +- .../tex/latex/fmtcount/fc-portuguese.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fc-spanish.def | 7 +- .../texmf-dist/tex/latex/fmtcount/fcnumparser.sty | 7 +- Master/texmf-dist/tex/latex/fmtcount/fcprefix.sty | 7 +- Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty | 154 +- 26 files changed, 7238 insertions(+), 6918 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/fmtcount/fc-typeout-languages.tex diff --git a/Master/texmf-dist/doc/latex/fmtcount/CHANGES b/Master/texmf-dist/doc/latex/fmtcount/CHANGES index e63267c0b2a..6e23a87d5fc 100644 --- a/Master/texmf-dist/doc/latex/fmtcount/CHANGES +++ b/Master/texmf-dist/doc/latex/fmtcount/CHANGES @@ -1,5 +1,27 @@ fmtcount package versions: +Version 3.01: + + * Make fmtord option language dependant + + * Support language as a documentclass option + + * Some improvements in code documentation and testing + + * Use xkeyval instead of keyval for option processing, so as to avoid + trouble with option de-bracketting + + * Solve issue #15: protect \' for accent in French ordinal + + * Make 1er/1re, 2e the default for French abbreviated ordinals, and + make abbreviated ordinals the default --- as opposed to + non-abbreviated like 2\`eme. + + * Solve issue #16: (use of superscript font for ordinals when + available and xelatex is used) + +Version 3.00: + Version 2.04: * Renamed \@modulo to \@FCmodulo to avoid conflict with other diff --git a/Master/texmf-dist/doc/latex/fmtcount/README b/Master/texmf-dist/doc/latex/fmtcount/README index 081c38f578e..e4ba96130ad 100644 --- a/Master/texmf-dist/doc/latex/fmtcount/README +++ b/Master/texmf-dist/doc/latex/fmtcount/README @@ -1,6 +1,6 @@ -LaTeX Package : fmtcount v3.00 +LaTeX Package : fmtcount v3.01 -Last Modified : 2014-07-18 +Last Modified : 2015-05-05 Author : Nicola Talbot and Vincent Belaïche diff --git a/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex b/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex index cbc8141779f..f0f0c00b84e 100644 --- a/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex +++ b/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex @@ -93,8 +93,11 @@ numberstring Referencing a label: \ref{ex}. -Passing numbers explicitly: \ordinalnum{10}, -\Numberstringnum{10}, \NUMBERstringnum{10}, \Ordinalstringnum{10}, +Passing numbers explicitly: +\ordinalnum{10}, +\Numberstringnum{10}, +\NUMBERstringnum{10}, +\Ordinalstringnum{10}, \ORDINALstringnum{10}. \end{document} diff --git a/Master/texmf-dist/doc/latex/fmtcount/fc-typeout-languages.tex b/Master/texmf-dist/doc/latex/fmtcount/fc-typeout-languages.tex new file mode 100644 index 00000000000..1759593d13e --- /dev/null +++ b/Master/texmf-dist/doc/latex/fmtcount/fc-typeout-languages.tex @@ -0,0 +1,20 @@ +\documentclass{article} +\usepackage{fmtcount} +\usepackage{lipsum} +\newwrite\styfiles +\openout\styfiles=fc-styfiles.txt +\begin{document} +\immediate\write\styfiles{STYFILES=\string\^^J} +\makeatletter +{% + \def\@tempb#1{% + \immediate\write\styfiles{fc-#1.def\string\^^J}% + }% + \fc@iterate@on@languages\@tempb +} +\makeatother +\immediate\write\styfiles{fmtcount.sty fcnumparser.sty fcprefix.sty} +\closeout\styfiles +\lipsum +\clearpage +\end{document} diff --git a/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf b/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf index c916e486947..9bc1c9296e0 100644 Binary files a/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf and b/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf differ diff --git a/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx b/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx index 77ebb29e78c..9293bdd287d 100644 --- a/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx +++ b/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx @@ -1,12 +1,11 @@ %\iffalse % fmtcount.dtx generated using makedtx version 0.94b (c) Nicola Talbot % Command line args: -% -src "(.+)\.(sty)=>\1.\2" -% -src "(.+)\.(def)=>\1.\2" +% -src "(.+)\.(sty|def)$=>\1.\2" % -doc "fmtcount-manual.tex" % -author "Nicola Talbot and Vincent Belaïche" % fmtcount -% Created on 2014/7/28 7:55 +% Created on 2015/5/8 16:50 %\fi %\iffalse %<*package> @@ -29,7 +28,7 @@ %\fi % \iffalse % Doc-Source file to use with LaTeX2e -% Copyright (C) 2014 Nicola Talbot and Vincent Belaïche, all rights reserved. +% Copyright (C) 2015 Nicola Talbot and Vincent Belaïche, all rights reserved. % \fi % \iffalse %<*driver> @@ -42,7 +41,7 @@ \usepackage{tabularx,supertabular,multirow} \usepackage[T1]{fontenc} \usepackage{cmap} -\usepackage{fmtcount}% needed +\usepackage{fmtcount}% needed for \fc@iterate@on@languages \newcommand*\uref[1]{\href{#1}{#1}} \DeclareMathOperator{\intv}{..} \newcommand*\interface{} @@ -79,7 +78,7 @@ pdftitle={fmtcount.sty: Displaying the Values of LaTeX Counters}, pdfkeywords={LaTeX,counter}]{hyperref} -\CheckSum{9801} +\CheckSum{9930} \doxitem{Option}{option}{options} @@ -98,7 +97,7 @@ % \url{www.dickimaw-books.com} % \and % Vincent Bela\"iche} -% \date{2014-07-18 (version 3.00)\relax +% \date{2015-05-05 (version 3.01)\relax %} % \maketitle % \tableofcontents @@ -470,8 +469,8 @@ %\begin{definition}[\DescribeMacro{\fmtcountsetoptions}] %\cs{fmtcountsetoptions}\verb"{fmtord="\meta{type}\verb'}' %\end{definition} -%where \meta{type} is either \texttt{level} or -%\texttt{raise}. +%where \meta{type} is either \texttt{level} or \texttt{raise}. Since version~3.01 of \sty{fmtcount}, it is also +%possible to set \meta{type} on a language by language basis, see~\S~\ref{sec:multilingual-support}. % %\section{Multilingual Support} %\label{sec:multilingual-support} @@ -525,6 +524,31 @@ %you will need to let me know how to form the numbers and ordinals %from~0 to~99999 in that language for each gender. % +%\subsection{Options for setting ordinal ending position raise/level} +%\label{sec:options-fmtord} +% +%\begin{definition}[\DescribeMacro{\fmtcountsetoptions}] +%\cs{fmtcountsetoptions}\verb"{"\meta{language}\verb"={fmtord="\meta{type}\verb'}}' +%\end{definition} +%where \meta{language} is one of the supported language \meta{type} is either \texttt{level} or \texttt{raise} +%or \texttt{undefine}. If the value is \texttt{level} or \texttt{raise}, then that will set the \texttt{fmtord} +%option accordingly\footnote{see~\S~\ref{sec:package-options}} only for that language \meta{language}. If the +%value is \texttt{undefine}, then the non-language specific behaviour is followed. +% +%Some \meta{language} are synonyms, here is a table: +% +%\begin{center} +% \begin{tabular}{|l|l|}\hline +% \textbf{language}& \textbf{alias(es)}\\\hline +% english& british\\\hline +% french&frenchb\\\hline +% &germanb\\ +% german&ngerman\\ +% &ngermanb\\\hline +% USenglish&american\\\hline +% \end{tabular} +%\end{center} +% %\subsection{Options for French} %\label{sec:options-french} % @@ -585,9 +609,9 @@ %\cs{ordinal}. Selon \meta{boolean} on a:\newline %\begin{tabularx}{\linewidth}{@{}lX@{}} % \pkgopt{true}& pour produire des ordinaux de la forme -% 2\textsuperscript{e}, ou\\ +% {\def\languagename{french}\csname fmtord@abbrvtrue\endcsname\ordinalnum{2}} (par défaut), ou\\ % \pkgopt{false}& pour produire des ordinaux de la forme -% 2\textsuperscript{eme} (par defaut)\\ +% {\def\languagename{french}\csname fmtord@abbrvfalse\endcsname\ordinalnum{2}} \\ %\end{tabularx} % %\begin{definition}[\DescribeOption{vingt plural}] @@ -854,7949 +878,8093 @@ %\url{https://github.com/nlct/fmtcount/issues/}. % % +%% Local Variables: +%% coding: utf-8 +%% End: % %\StopEventually{} %\section{The Code} %\iffalse % \begin{macrocode} -%<*fcnumparser.sty> +%<*fc-american.def> % \end{macrocode} %\fi -%\subsection{fcnumparser.sty} +% \subsubsection{fc-american.def} +% American English definitions % \begin{macrocode} -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fcnumparser}[2012/09/28] +\ProvidesFCLanguage{american}[2013/08/17]% % \end{macrocode} -% \cs{fc@counter@parser} is just a shorthand to parse a number held in a counter. +% Loaded fc-USenglish.def if not already loaded % \begin{macrocode} -\def\fc@counter@parser#1{% - \expandafter\fc@number@parser\expandafter{\the#1.}% -} +\FCloadlang{USenglish}% % \end{macrocode} +% These are all just synonyms for the commands provided by +% fc-USenglish.def. % \begin{macrocode} -\newcount\fc@digit@counter - -\def\fc@end@{\fc@end} +\global\let\@ordinalMamerican\@ordinalMUSenglish +\global\let\@ordinalFamerican\@ordinalMUSenglish +\global\let\@ordinalNamerican\@ordinalMUSenglish +\global\let\@numberstringMamerican\@numberstringMUSenglish +\global\let\@numberstringFamerican\@numberstringMUSenglish +\global\let\@numberstringNamerican\@numberstringMUSenglish +\global\let\@NumberstringMamerican\@NumberstringMUSenglish +\global\let\@NumberstringFamerican\@NumberstringMUSenglish +\global\let\@NumberstringNamerican\@NumberstringMUSenglish +\global\let\@ordinalstringMamerican\@ordinalstringMUSenglish +\global\let\@ordinalstringFamerican\@ordinalstringMUSenglish +\global\let\@ordinalstringNamerican\@ordinalstringMUSenglish +\global\let\@OrdinalstringMamerican\@OrdinalstringMUSenglish +\global\let\@OrdinalstringFamerican\@OrdinalstringMUSenglish +\global\let\@OrdinalstringNamerican\@OrdinalstringMUSenglish % \end{macrocode} -% \DescribeMacro{\fc@number@analysis} First of all we need to separate the number between integer and fractional -% part. Number to be analysed is in `\texttt{\#1}'. Decimal separator may be . or , whichever first. At end of -% this macro, integer part goes to \cs{fc@integer@part} and fractional part goes to \cs{fc@fractional@part}. +%\iffalse % \begin{macrocode} -\def\fc@number@analysis#1\fc@nil{% +% % \end{macrocode} -% First check for the presence of a decimal point in the number. +%\fi +%\iffalse % \begin{macrocode} - \def\@tempb##1.##2\fc@nil{\def\fc@integer@part{##1}\def\@tempa{##2}}% - \@tempb#1.\fc@end\fc@nil - \ifx\@tempa\fc@end@ +%<*fc-british.def> % \end{macrocode} -% Here \cs{@tempa} is \cs{ifx}-equal to \cs{fc@end}, which means that the number does not contain any decimal -% point. So we do the same trick to search for a comma. +%\fi +% \subsubsection{fc-british.def} +% British definitions % \begin{macrocode} - \def\@tempb##1,##2\fc@nil{\def\fc@integer@part{##1}\def\@tempa{##2}}% - \@tempb#1,\fc@end\fc@nil - \ifx\@tempa\fc@end@ +\ProvidesFCLanguage{british}[2013/08/17]% % \end{macrocode} -% No comma either, so fractional part is set empty. +% Load fc-english.def, if not already loaded % \begin{macrocode} - \def\fc@fractional@part{}% - \else +\FCloadlang{english}% % \end{macrocode} -% Comma has been found, so we just need to drop `\texttt{,}\cs{fc@end}' from the end of \cs{@tempa} to get the -% fractional part. +% These are all just synonyms for the commands provided by +% fc-english.def. % \begin{macrocode} - \def\@tempb##1,\fc@end{\def\fc@fractional@part{##1}}% - \expandafter\@tempb\@tempa - \fi - \else +\global\let\@ordinalMbritish\@ordinalMenglish +\global\let\@ordinalFbritish\@ordinalMenglish +\global\let\@ordinalNbritish\@ordinalMenglish +\global\let\@numberstringMbritish\@numberstringMenglish +\global\let\@numberstringFbritish\@numberstringMenglish +\global\let\@numberstringNbritish\@numberstringMenglish +\global\let\@NumberstringMbritish\@NumberstringMenglish +\global\let\@NumberstringFbritish\@NumberstringMenglish +\global\let\@NumberstringNbritish\@NumberstringMenglish +\global\let\@ordinalstringMbritish\@ordinalstringMenglish +\global\let\@ordinalstringFbritish\@ordinalstringMenglish +\global\let\@ordinalstringNbritish\@ordinalstringMenglish +\global\let\@OrdinalstringMbritish\@OrdinalstringMenglish +\global\let\@OrdinalstringFbritish\@OrdinalstringMenglish +\global\let\@OrdinalstringNbritish\@OrdinalstringMenglish % \end{macrocode} -% Decimal point has been found, so we just need to drop `\texttt{.}\cs{fc@end}' from the end \cs{@tempa} to -% get the fractional part. +%\iffalse % \begin{macrocode} - \def\@tempb##1.\fc@end{\def\fc@fractional@part{##1}}% - \expandafter\@tempb\@tempa - \fi -} +% % \end{macrocode} -% \DescribeMacro{\fc@number@parser} Macro \cs{fc@number@parser} is the main engine to parse a number. Argument -% `\#1' is input and contains the number to be parsed. At end of this macro, each digit is stored separately -% in a \cs{fc@digit@}\meta{$n$}, and macros \cs{fc@min@weight} and \cs{fc@max@weight} are set to the bounds -% for \meta{$n$}. +%\fi +%\iffalse % \begin{macrocode} -\def\fc@number@parser#1{% +%<*fc-english.def> % \end{macrocode} -% First remove all the spaces in \texttt{\#1}, and place the result into \cs{@tempa}. +%\fi +% \subsubsection{fc-english.def} +% English definitions % \begin{macrocode} - \let\@tempa\@empty - \def\@tempb##1##2\fc@nil{% - \def\@tempc{##1}% - \ifx\@tempc\space - \else - \expandafter\def\expandafter\@tempa\expandafter{\@tempa ##1}% - \fi - \def\@tempc{##2}% - \ifx\@tempc\@empty - \expandafter\@gobble - \else - \expandafter\@tempb - \fi - ##2\fc@nil - }% - \@tempb#1\fc@nil +\ProvidesFCLanguage{english}[2013/08/17]% % \end{macrocode} -% Get the sign into \cs{fc@sign} and the unsigned number part into \cs{fc@number}. +% 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} - \def\@tempb##1##2\fc@nil{\def\fc@sign{##1}\def\fc@number{##2}}% - \expandafter\@tempb\@tempa\fc@nil - \expandafter\if\fc@sign+% - \def\fc@sign@case{1}% +\newcommand*\@ordinalMenglish[2]{% +\def\@fc@ord{}% +\@orgargctr=#1\relax +\@ordinalctr=#1% +\@FCmodulo{\@ordinalctr}{100}% +\ifnum\@ordinalctr=11\relax + \def\@fc@ord{th}% +\else + \ifnum\@ordinalctr=12\relax + \def\@fc@ord{th}% \else - \expandafter\if\fc@sign-% - \def\fc@sign@case{2}% + \ifnum\@ordinalctr=13\relax + \def\@fc@ord{th}% \else - \def\fc@sign{}% - \def\fc@sign@case{0}% - \let\fc@number\@tempa + \@FCmodulo{\@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 - \ifx\fc@number\@empty - \PackageError{fcnumparser}{Invalid number}{Number must contain at least one non blank - character after sign}% - \fi +\fi +\edef#2{\number#1\relax\noexpand\fmtord{\@fc@ord}}% +}% +\global\let\@ordinalMenglish\@ordinalMenglish % \end{macrocode} -% Now, split \cs{fc@number} into \cs{fc@integer@part} and \cs{fc@fractional@part}. +% There is no gender difference in English, so make feminine and +% neuter the same as the masculine. % \begin{macrocode} - \expandafter\fc@number@analysis\fc@number\fc@nil +\global\let\@ordinalFenglish=\@ordinalMenglish +\global\let\@ordinalNenglish=\@ordinalMenglish % \end{macrocode} -% Now, split \cs{fc@integer@part} into a sequence of \cs{fc@digit@}\meta{$n$} with \meta{$n$} ranging from -% \cs{fc@unit@weight} to \cs{fc@max@weight}. We will use macro \cs{fc@parse@integer@digits} for that, but that -% will place the digits into \cs{fc@digit@}\meta{$n$} with \meta{$n$} ranging from -% \(2\times\cs{fc@unit@weight}-\cs{fc@max@weight}\) upto \(\cs{fc@unit@weight}-1\). +% 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} - \expandafter\fc@digit@counter\fc@unit@weight - \expandafter\fc@parse@integer@digits\fc@integer@part\fc@end\fc@nil +\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 +}% +\global\let\@@unitstringenglish\@@unitstringenglish % \end{macrocode} -% First we compute the weight of the most significant digit: after \cs{fc@parse@integer@digits}, -% \cs{fc@digit@counter} is equal to \(\cs{fc@unit@weight} -\mathrm{mw} -1\) and we want to set -% \cs{fc@max@weight} to \(\cs{fc@unit@weight} +\mathrm{mw}\) so we do: -% \begin{equation*} -% \cs{fc@max@weight}\leftarrow (-\cs{fc@digit@counter}) + 2\times\cs{fc@unit@weight} -1 -% \end{equation*} +% Next the tens, again the argument should be between 0 and 9 +% inclusive. % \begin{macrocode} - \fc@digit@counter -\fc@digit@counter - \advance\fc@digit@counter by \fc@unit@weight - \advance\fc@digit@counter by \fc@unit@weight - \advance\fc@digit@counter by -1 % - \edef\fc@max@weight{\the\fc@digit@counter}% +\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 +}% +\global\let\@@tenstringenglish\@@tenstringenglish % \end{macrocode} -% Now we loop for \(i = \cs{fc@unit@weight}\) to \cs{fc@max@weight} in order to copy all the digits from -% \cs{fc@digit@}\meta{\(i + \mathrm{offset}\)} to \cs{fc@digit@}\meta{\(i\)}. First we compute -% \(\mathrm{offset}\) into \cs{@tempi}. +% Finally the teens, again the argument should be between 0 and 9 +% inclusive. % \begin{macrocode} - {% - \count0 \fc@unit@weight\relax - \count1 \fc@max@weight\relax - \advance\count0 by -\count1 % - \advance\count0 by -1 % - \def\@tempa##1{\def\@tempb{\def\@tempi{##1}}}% - \expandafter\@tempa\expandafter{\the\count0}% - \expandafter - }\@tempb +\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 +}% +\global\let\@@teenstringenglish\@@teenstringenglish % \end{macrocode} -% Now we loop to copy the digits. To do that we define a macro \cs{@templ} for terminal recursion. +% As above, but with the initial letter in uppercase. The units: % \begin{macrocode} - \expandafter\fc@digit@counter\fc@unit@weight - \def\@templ{% - \ifnum\fc@digit@counter>\fc@max@weight - \let\next\relax - \else +\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 +}% +\global\let\@@Unitstringenglish\@@Unitstringenglish % \end{macrocode} -% Here is the loop body: +% The tens: % \begin{macrocode} - {% - \count0 \@tempi - \advance\count0 by \fc@digit@counter - \expandafter\def\expandafter\@tempd\expandafter{\csname fc@digit@\the\count0\endcsname}% - \expandafter\def\expandafter\@tempe\expandafter{\csname fc@digit@\the\fc@digit@counter\endcsname}% - \def\@tempa####1####2{\def\@tempb{\let####1####2}}% - \expandafter\expandafter\expandafter\@tempa\expandafter\@tempe\@tempd - \expandafter - }\@tempb - \advance\fc@digit@counter by 1 % - \fi - \next - }% - \let\next\@templ - \@templ +\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 +}% +\global\let\@@Tenstringenglish\@@Tenstringenglish % \end{macrocode} -% Split \cs{fc@fractional@part} into a sequence of \cs{fc@digit@}\meta{$n$} with \meta{$n$} ranging from -% \(\cs{fc@unit@weight}-1\) to \cs{fc@min@weight} by step of \(-1\). This is much more simpler because we get -% the digits with the final range of index, so no post-processing loop is needed. +% The teens: % \begin{macrocode} - \expandafter\fc@digit@counter\fc@unit@weight - \expandafter\fc@parse@integer@digits\fc@fractional@part\fc@end\fc@nil - \edef\fc@min@weight{\the\fc@digit@counter}% -} +\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 +}% +\global\let\@@Teenstringenglish\@@Teenstringenglish % \end{macrocode} -% \DescribeMacro{\fc@parse@integer@digits} Macro \cs{fc@parse@integer@digits} is used to +% 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} -\ifcsundef{fc@parse@integer@digits}{}{% - \PackageError{fcnumparser}{Duplicate definition}{Redefinition of - macro `fc@parse@integer@digits'}} -\def\fc@parse@integer@digits#1#2\fc@nil{% - \def\@tempa{#1}% - \ifx\@tempa\fc@end@ - \def\next##1\fc@nil{}% +\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 + \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 + \@FCmodulo{\@strctr}{10}% + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr-\@unitstring{\@strctr}}% + \fi \else - \let\next\fc@parse@integer@digits - \advance\fc@digit@counter by -1 - \expandafter\def\csname fc@digit@\the\fc@digit@counter\endcsname{#1}% + \@strctr=#1\relax + \divide\@strctr by 1000\relax + \@FCmodulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% \fi - \next#2\fc@nil -} - - -\newcommand*{\fc@unit@weight}{0} - -% \end{macrocode} -% Now we have macros to read a few digits from the \cs{fc@digit@}\meta{$n$} array and form a correspoding -% number.\newline \DescribeMacro{\fc@read@unit} \cs{fc@read@unit} just reads one digit and form an integer in -% the range \([0 \intv 9]\). First we check that the macro is not yet defined. -% \begin{macrocode} -\ifcsundef{fc@read@unit}{}{% - \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro `fc@read@unit'}} -% \end{macrocode} -% Arguments as follows:\def\interface{\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&output counter: into which the read value is placed\\ -% \#2&input number: unit weight at which reach the value is to be read -% \end{tabularx}}\interface -% \#2 does not need to be comprised between \cs{fc@min@weight} and {fc@min@weight}, if outside this interval, -% then a zero is read. -% \begin{macrocode} -\def\fc@read@unit#1#2{% - \ifnum#2>\fc@max@weight - #1=0\relax + \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 \@FCmodulo{\@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 \@FCmodulo{\@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 \@FCmodulo{\@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 - \ifnum#2<\fc@min@weight - #1=0\relax - \else - {% - \edef\@tempa{\number#2}% - \count0=\@tempa - \edef\@tempa{\csname fc@digit@\the\count0\endcsname}% - \def\@tempb##1{\def\@tempa{#1=##1\relax}}% - \expandafter\@tempb\expandafter{\@tempa}% - \expandafter - }\@tempa - \fi + \@FCmodulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% \fi -} +\fi +}% +\global\let\@@numberstringenglish\@@numberstringenglish % \end{macrocode} -% \DescribeMacro{\fc@read@hundred} Macro \cs{fc@read@hundred} is used to read a pair of digits and form an -% integer in the range \([0 \intv 99]\). First we check that the macro is not yet defined. +% All lower case version, the second argument must be a +% control sequence. % \begin{macrocode} -\ifcsundef{fc@read@hundred}{}{% - \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro `fc@read@hundred'}} +\DeclareRobustCommand{\@numberstringMenglish}[2]{% + \let\@unitstring=\@@unitstringenglish + \let\@teenstring=\@@teenstringenglish + \let\@tenstring=\@@tenstringenglish + \def\@hundred{hundred}\def\@thousand{thousand}% + \def\@andname{and}% + \@@numberstringenglish{#1}{#2}% +}% +\global\let\@numberstringMenglish\@numberstringMenglish % \end{macrocode} -% Arguments as follows --- same interface as \cs{fc@read@unit}:\interface +% There is no gender in English, so make feminine and neuter the +% same +% as the masculine. % \begin{macrocode} -\def\fc@read@hundred#1#2{% - {% - \fc@read@unit{\count0}{#2}% - \def\@tempa##1{\fc@read@unit{\count1}{##1}}% - \count2=#2% - \advance\count2 by 1 % - \expandafter\@tempa{\the\count2}% - \multiply\count1 by 10 % - \advance\count1 by \count0 % - \def\@tempa##1{\def\@tempb{#1=##1\relax}} - \expandafter\@tempa\expandafter{\the\count1}% - \expandafter - }\@tempb -} +\global\let\@numberstringFenglish=\@numberstringMenglish +\global\let\@numberstringNenglish=\@numberstringMenglish % \end{macrocode} -% \DescribeMacro{\fc@read@thousand} Macro \cs{fc@read@thousand} is used to read a trio of digits and form an -% integer in the range \([0 \intv 999]\). First we check that the macro is not yet defined. +% This version makes the first letter of each word an uppercase +% character (except ``and''). The second argument must be a control +% sequence. % \begin{macrocode} -\ifcsundef{fc@read@thousand}{}{% - \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro - `fc@read@thousand'}} -% \end{macrocode} -% Arguments as follows --- same interface as \cs{fc@read@unit}:\interface -% \begin{macrocode} -\def\fc@read@thousand#1#2{% - {% - \fc@read@unit{\count0}{#2}% - \def\@tempa##1{\fc@read@hundred{\count1}{##1}}% - \count2=#2% - \advance\count2 by 1 % - \expandafter\@tempa{\the\count2}% - \multiply\count1 by 10 % - \advance\count1 by \count0 % - \def\@tempa##1{\def\@tempb{#1=##1\relax}} - \expandafter\@tempa\expandafter{\the\count1}% - \expandafter - }\@tempb -} +\newcommand*\@NumberstringMenglish[2]{% + \let\@unitstring=\@@Unitstringenglish + \let\@teenstring=\@@Teenstringenglish + \let\@tenstring=\@@Tenstringenglish + \def\@hundred{Hundred}\def\@thousand{Thousand}% + \def\@andname{and}% + \@@numberstringenglish{#1}{#2}% +}% +\global\let\@NumberstringMenglish\@NumberstringMenglish % \end{macrocode} -% Note: one myriad is ten thousand. -% \DescribeMacro{\fc@read@thousand} Macro \cs{fc@read@myriad} is used to read a quatuor of digits and form an -% integer in the range \([0 \intv 9999]\). First we check that the macro is not yet defined. +% There is no gender in English, so make feminine and neuter the +% same +% as the masculine. % \begin{macrocode} -\ifcsundef{fc@read@myriad}{}{% - \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro - `fc@read@myriad'}} +\global\let\@NumberstringFenglish=\@NumberstringMenglish +\global\let\@NumberstringNenglish=\@NumberstringMenglish % \end{macrocode} -% Arguments as follows --- same interface as \cs{fc@read@unit}:\interface +% Define a macro that produces an ordinal as a string. Again, break +% it up into units, teens and tens. First the units: % \begin{macrocode} -\def\fc@read@myriad#1#2{% - {% - \fc@read@hundred{\count0}{#2}% - \def\@tempa##1{\fc@read@hundred{\count1}{##1}}% - \count2=#2 - \advance\count2 by 2 - \expandafter\@tempa{\the\count2}% - \multiply\count1 by 100 % - \advance\count1 by \count0 % - \def\@tempa##1{\def\@tempb{#1=##1\relax}}% - \expandafter\@tempa\expandafter{\the\count1}% - \expandafter - }\@tempb -} +\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 +}% +\global\let\@@unitthstringenglish\@@unitthstringenglish % \end{macrocode} -% \DescribeMacro{\fc@check@nonzeros} Macro \cs{fc@check@nonzeros} is used to check whether the number -% represented by digits \cs{fc@digit@}\meta{$n$}, with \(n\) in some interval, is zero, one, or more than one. -% First we check that the macro is not yet defined. +% Next the tens: % \begin{macrocode} -\ifcsundef{fc@check@nonzeros}{}{% - \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro - `fc@check@nonzeros'}} +\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 +}% +\global\let\@@tenthstringenglish\@@tenthstringenglish % \end{macrocode} -% Arguments as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&input number: minimum unit unit weight at which start to search the non-zeros\\ -% \#2&input number: maximum unit weight at which end to seach the non-zeros\\ -% \#3&output macro: let \(n\) be the number represented by digits the weight of which span from \texttt{\#1} -% to \texttt{\#2}, then \texttt{\#3} is set to the number min(n,9).\\ -% \end{tabularx} -% Actually \cs{fc@check@nonzeros} is just a wrapper to collect arguments, and the real job is delegated to -% \cs{fc@@check@nonzeros@inner} which is called inside a group. +% The teens: % \begin{macrocode} -\def\fc@check@nonzeros#1#2#3{% - {% +\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 +}% +\global\let\@@teenthstringenglish\@@teenthstringenglish % \end{macrocode} -% So first we save inputs into local macros used by \cs{fc@@check@nonzeros@inner} as input arguments +% As before, but with the first letter in upper case. The units: % \begin{macrocode} - \edef\@@tempa{\number#1}% - \edef\@tempb{\number#2}% - \count0=\@@tempa - \count1=\@tempb\relax +\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 +}% +\global\let\@@Unitthstringenglish\@@Unitthstringenglish % \end{macrocode} -% Then we do the real job +% The tens: % \begin{macrocode} - \fc@@check@nonzeros@inner +\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 +}% +\global\let\@@Tenthstringenglish\@@Tenthstringenglish % \end{macrocode} -% And finally, we propagate the output after end of group --- i.e. closing brace. +% The teens: % \begin{macrocode} - \def\@tempd##1{\def\@tempa{\def#3{##1}}}% - \expandafter\@tempd\expandafter{\@tempc}% - \expandafter - }\@tempa -} +\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 +}% +\global\let\@@Teenthstringenglish\@@Teenthstringenglish % \end{macrocode} -% \DescribeMacro{\fc@@check@nonzeros@inner} Macro \cs{fc@@check@nonzeros@inner} Check wehther some part of the -% parsed value contains some non-zero digit At the call of this macro we expect that:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash}rX@{}} -% \cs{@tempa}&input/output macro:\newline\noindent -% \settowidth{\tabcolwidth}{output}% -% \begin{tabular*}{\hsize}{@{}>{\raggedleft\arraybackslash\itshape}r% -% p{\dimexpr\hsize-2\tabcolsep-\tabcolwidth}@{}} -% input&minimum unit unit weight at which start to search the non-zeros\\ -% output¯o may have been redefined -% \end{tabular*}\\ -% \cs{@tempb}&input/output macro:\newline\noindent -% \settowidth{\tabcolwidth}{output}% -% \begin{tabular*}{\hsize}{@{}>{\raggedleft\arraybackslash\itshape}r% -% p{\dimexpr\hsize-2\tabcolsep-\tabcolwidth}@{}} -% input&maximum unit weight at which end to seach the non-zeros\\ -% output¯o may have been redefined -% \end{tabular*}\\ -% \cs{@tempc}&ouput macro: 0 if all-zeros, 1 if at least one zero is found\\ -% \cs{count0}&output counter: \(\mathrm{weight}+1\) of the first found non zero starting from minimum -% \(\mathrm{weight}\). -% \end{tabularx} +% 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} -\def\fc@@check@nonzeros@inner{% - \ifnum\count0<\fc@min@weight - \count0=\fc@min@weight\relax - \fi - \ifnum\count1>\fc@max@weight\relax - \count1=\fc@max@weight - \fi - \count2\count0 % - \advance\count2 by 1 % - \ifnum\count0>\count1 % - \PackageError{fcnumparser}{Unexpected arguments}{Number in argument 2 of macro - `fc@check@nonzeros' must be at least equal to number in argument 1}% - \else - \fc@@check@nonzeros@inner@loopbody - \ifnum\@tempc>0 % - \ifnum\@tempc<9 % - \ifnum\count0>\count1 % - \else - \let\@tempd\@tempc - \fc@@check@nonzeros@inner@loopbody - \ifnum\@tempc=0 % - \let\@tempc\@tempd - \else - \def\@tempc{9}% - \fi - \fi - \fi - \fi - \fi -} +\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 % \end{macrocode} +% \#1 is greater or equal to 10000 % \begin{macrocode} -\def\fc@@check@nonzeros@inner@loopbody{% - % \@tempc <- digit of weight \count0 - \expandafter\let\expandafter\@tempc\csname fc@digit@\the\count0\endcsname - \advance\count0 by 1 % - \ifnum\@tempc=0 % - \ifnum\count0>\count1 % - \let\next\relax - \else - \let\next\fc@@check@nonzeros@inner@loopbody - \fi - \else - \ifnum\count0>\count2 % - \def\@tempc{9}% + \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 + \@FCmodulo{\@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 + \@FCmodulo{\@strctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenstring{\@strctr}}% + \fi + \@strctr=#1\relax \@FCmodulo{\@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 \@FCmodulo{\@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 \@FCmodulo{\@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 \@FCmodulo{\@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 \@FCmodulo{\@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 + \@FCmodulo{\@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 \@FCmodulo{\@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 - \let\next\relax - \fi - \next -} -% \end{macrocode} -% \DescribeMacro{\fc@intpart@find@last} Macro \cs{fc@intpart@find@last} find the rightmost non zero digit in the -% integer part. First check that the macro is not yet defined. -% \begin{macrocode} -\ifcsundef{fc@intpart@find@last}{}{% - \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro - `fc@intpart@find@last'}} + \else + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi + \else + \@FCmodulo{\@strctr}{10}% + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% + \fi +\fi +}% +\global\let\@@ordinalstringenglish\@@ordinalstringenglish % \end{macrocode} -% When macro is called, the number of interest is already parsed, that is to say each digit of weight \(w\) is -% stored in macro \cs{fc@digit@}\meta{$w$}. Macro \cs{fc@intpart@find@last} takes one single argument which -% is a counter to set to the result. +% All lower case version. Again, the second argument must be a +% control sequence in which the resulting text is stored. % \begin{macrocode} -\def\fc@intpart@find@last#1{% - {% +\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}% +}% +\global\let\@ordinalstringMenglish\@ordinalstringMenglish % \end{macrocode} -% Counter \cs{count0} will hold the result. So we will loop on \cs{count0}, starting from -% \(\min\{u,w_{\mathrm{min}}\}\), where \(u\triangleq\cs{fc@unit@weight}\), and -% \(w_{\mathrm{min}}\triangleq\cs{fc@min@weight}\). So first set \cs{count0} to -% \(\min\{u,w_{\mathrm{min}}\}\): +% No gender in English, so make feminine and neuter same as +% masculine: % \begin{macrocode} - \count0=\fc@unit@weight\space - \ifnum\count0<\fc@min@weight\space - \count0=\fc@min@weight\space - \fi +\global\let\@ordinalstringFenglish=\@ordinalstringMenglish +\global\let\@ordinalstringNenglish=\@ordinalstringMenglish % \end{macrocode} -% Now the loop. This is done by defining macro \cs{@templ} for final recursion. +% First letter of each word in upper case: % \begin{macrocode} - \def\@templ{% - \ifnum\csname fc@digit@\the\count0\endcsname=0 % - \advance\count0 by 1 % - \ifnum\count0>\fc@max@weight\space - \let\next\relax - \fi - \else - \let\next\relax - \fi - \next - }% - \let\next\@templ - \@templ +\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}% +}% +\global\let\@OrdinalstringMenglish\@OrdinalstringMenglish % \end{macrocode} -% Now propagate result after closing bracket into counter \texttt{\#1}. +% No gender in English, so make feminine and neuter same as +% masculine: % \begin{macrocode} - \toks0{#1}% - \edef\@tempa{\the\toks0=\the\count0}% - \expandafter - }\@tempa\space -} +\global\let\@OrdinalstringFenglish=\@OrdinalstringMenglish +\global\let\@OrdinalstringNenglish=\@OrdinalstringMenglish % \end{macrocode} -% \DescribeMacro{\fc@get@last@word} Getting last word. Arguments as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&input: full sequence\\ -% \#2&output macro 1: all sequence without last word\\ -% \#3&output macro 2: last word\\ -% \end{tabularx} +%\iffalse % \begin{macrocode} -\ifcsundef{fc@get@last@word}{}{\PackageError{fcnumparser}{Duplicate definition}{Redefinition - of macro `fc@get@last@word'}}% -\def\fc@get@last@word#1#2#3{% - {% +% % \end{macrocode} -% First we split \texttt{\#1} into two parts: everything that is upto \cs{fc@case} exclusive goes to -% \cs{toks0}, and evrything from \cs{fc@case} exclusive upto the final \cs{@nil} exclusive goes to \cs{toks1}. +%\fi +%\iffalse % \begin{macrocode} - \def\@tempa##1\fc@case##2\@nil\fc@end{% - \toks0{##1}% +%<*fc-francais.def> % \end{macrocode} -% Actually a dummy \cs{fc@case} is appended to \cs{toks1}, because that makes easier further checking that it -% does not contains any other \cs{fc@case}. +%\fi +% \subsubsection{fc-francais.def} % \begin{macrocode} - \toks1{##2\fc@case}% - }% - \@tempa#1\fc@end +\ProvidesFCLanguage{francais}[2013/08/17]% +\FCloadlang{french}% % \end{macrocode} -% Now leading part upto last word should be in \cs{toks0}, and last word should be in \cs{toks1}. However we -% need to check that this is really the last word, i.e. we need to check that there is no \cs{fc@case} inside -% \cs{toks1} other than the tailing dummy one. To that purpose we will loop while we find that \cs{toks1} -% contains some \cs{fc@case}. First we define \cs{@tempa} to split \cs{the}\cs{toks1} between parts before and -% after some potential \cs{fc@case}. +% Set |francais| to be equivalent to |french|. % \begin{macrocode} - \def\@tempa##1\fc@case##2\fc@end{% - \toks2{##1}% - \def\@tempb{##2}% - \toks3{##2}% - }% +\global\let\@ordinalMfrancais=\@ordinalMfrench +\global\let\@ordinalFfrancais=\@ordinalFfrench +\global\let\@ordinalNfrancais=\@ordinalNfrench +\global\let\@numberstringMfrancais=\@numberstringMfrench +\global\let\@numberstringFfrancais=\@numberstringFfrench +\global\let\@numberstringNfrancais=\@numberstringNfrench +\global\let\@NumberstringMfrancais=\@NumberstringMfrench +\global\let\@NumberstringFfrancais=\@NumberstringFfrench +\global\let\@NumberstringNfrancais=\@NumberstringNfrench +\global\let\@ordinalstringMfrancais=\@ordinalstringMfrench +\global\let\@ordinalstringFfrancais=\@ordinalstringFfrench +\global\let\@ordinalstringNfrancais=\@ordinalstringNfrench +\global\let\@OrdinalstringMfrancais=\@OrdinalstringMfrench +\global\let\@OrdinalstringFfrancais=\@OrdinalstringFfrench +\global\let\@OrdinalstringNfrancais=\@OrdinalstringNfrench % \end{macrocode} -% \cs{@tempt} is just an aliases of \cs{toks0} to make its handling easier later on. + +%\iffalse % \begin{macrocode} - \toksdef\@tempt0 % +% % \end{macrocode} -% Now the loop itself, this is done by terminal recursion with macro \cs{@templ}. +%\fi +%\iffalse % \begin{macrocode} - \def\@templ{% - \expandafter\@tempa\the\toks1 \fc@end - \ifx\@tempb\@empty +%<*fc-french.def> % \end{macrocode} -% \cs{@tempb} empty means that the only \cs{fc@case} found in \cs{the}\cs{toks1} is the dummy one. So we end -% the loop here, \cs{toks2} contains the last word. +%\fi +% \subsubsection{fc-french.def} +% Definitions for French. % \begin{macrocode} - \let\next\relax - \else +\ProvidesFCLanguage{french}[2012/10/24]% % \end{macrocode} -% \cs{@tempb} is not empty, first we use -% \begin{macrocode} - \expandafter\expandafter\expandafter\@tempt - \expandafter\expandafter\expandafter{% - \expandafter\the\expandafter\@tempt - \expandafter\fc@case\the\toks2}% - \toks1\toks3 % - \fi - \next - }% - \let\next\@templ - \@templ - \edef\@tempa{\def\noexpand#2{\the\toks0}\def\noexpand#3{\the\toks2}}% - \expandafter - }\@tempa -} -% \end{macrocode} -% \DescribeMacro{\fc@get@last@word} Getting last letter. Arguments as follows:\newline\noindent +% Package \styfmt{fcprefix} is needed to format the prefix \meta{$n$} in \meta{$n$}illion or +% \meta{$n$}illiard. Big numbers were developped based on reference: +% \uref{http://www.alain.be/boece/noms\_de\_nombre.html} +% (Package now loaded by \styfmt{fmtcount}) +% +% Options for controlling plural mark. First of all we define some temporary macro \cs{fc@french@set@plural} +% in order to factorize code that defines an plural mark option:\newline\noindent % \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&input: full word\\ -% \#2&output macro 1: all word without last letter\\ -% \#3&output macro 2: last letter\\ +% \#1&key name,\\ +% \#2&key value,\\ +% \#3&configuration index for `\texttt{reformed}', \\ +% \#4&configuration index for `\texttt{traditional}',\\ +% \#5&configuration index for `\texttt{reformed o}', and\\ +% \#6&configuration index for `\texttt{traditional o}'. % \end{tabularx} % \begin{macrocode} -\ifcsundef{fc@get@last@letter}{}{\PackageError{fcnumparser}{Duplicate definition}{Redefinition - of macro `fc@get@last@letter'}}% -\def\fc@get@last@letter#1#2#3{% - {% -% \end{macrocode} -% First copy input to local \cs{toks1}. What we are going to to is to bubble one by one letters from -% \cs{toks1} which initial contains the whole word, into \cs{toks0}. At the end of the macro \cs{toks0} will -% therefore contain the whole work but the last letter, and the last letter will be in \cs{toks1}. -% \begin{macrocode} - \toks1{#1}% - \toks0{}% - \toksdef\@tempt0 % -% \end{macrocode} -% We define \cs{@tempa} in order to pop the first letter from the remaining of word. -% \begin{macrocode} - \def\@tempa##1##2\fc@nil{% - \toks2{##1}% - \toks3{##2}% - \def\@tempb{##2}% - }% -% \end{macrocode} -% Now we define \cs{@templ} to do the loop by terminal recursion. -% \begin{macrocode} - \def\@templ{% - \expandafter\@tempa\the\toks1 \fc@nil - \ifx\@tempb\@empty -% \end{macrocode} -% Stop loop, as \cs{toks1} has been detected to be one single letter. -% \begin{macrocode} - \let\next\relax - \else -% \end{macrocode} -% Here we append to \cs{toks0} the content of \cs{toks2}, i.e. the next letter. -% \begin{macrocode} - \expandafter\expandafter\expandafter\@tempt - \expandafter\expandafter\expandafter{% - \expandafter\the\expandafter\@tempt - \the\toks2}% -% \end{macrocode} -% And the remaining letters go to \cs{toks1} for the next iteration. -% \begin{macrocode} - \toks1\toks3 % - \fi - \next - }% -% \end{macrocode} -% Here run the loop. -% \begin{macrocode} - \let\next\@templ - \next -% \end{macrocode} -% Now propagate the results into macros \texttt{\#2} and \texttt{\#3} after closing brace. -% \begin{macrocode} - \edef\@tempa{\def\noexpand#2{\the\toks0}\def\noexpand#3{\the\toks1}}% - \expandafter - }\@tempa -}% -% \end{macrocode} -\iffalse Local variables: \fi -\iffalse mode: docTeX \fi -\iffalse End: \fi -%\iffalse -% \begin{macrocode} -% -% \end{macrocode} -%\fi -%\iffalse -% \begin{macrocode} -%<*fcprefix.sty> -% \end{macrocode} -%\fi -%\subsection{fcprefix.sty} -% Pseudo-latin prefixes. -% \begin{macrocode} -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fcprefix}[2012/09/28] -\RequirePackage{ifthen} -\RequirePackage{keyval} -\RequirePackage{fcnumparser} -% \end{macrocode} -% Option `\texttt{use duode and unde}' is to select whether \(18\) and suchlikes (\(\meta{x}8\), -% \(\meta{x}9\)) writes like duodevicies, or like octodecies. For French it should be `\texttt{below -% 20}'. Possible values are `\texttt{below 20}' and `\texttt{never}'. -% \begin{macrocode} -\define@key{fcprefix}{use duode and unde}[below20]{% - \ifthenelse{\equal{#1}{below20}}{% - \def\fc@duodeandunde{2}% +\def\fc@french@set@plural#1#2#3#4#5#6{% + \ifthenelse{\equal{#2}{reformed}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#3}% }{% - \ifthenelse{\equal{#1}{never}}{% - \def\fc@duodeandunde{0}% + \ifthenelse{\equal{#2}{traditional}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#4}% }{% - \PackageError{fcprefix}{Unexpected option}{% - Option `use duode and unde' expects `below 20' or `never' }% - }% - }% -} -% \end{macrocode} -% Default is `\texttt{below 20}' like in French. -% \begin{macrocode} -\def\fc@duodeandunde{2} + \ifthenelse{\equal{#2}{reformed o}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#5}% + }{% + \ifthenelse{\equal{#2}{traditional o}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#6}% + }{% + \ifthenelse{\equal{#2}{always}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{0}% + }{% + \ifthenelse{\equal{#2}{never}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{1}% + }{% + \ifthenelse{\equal{#2}{multiple}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{2}% + }{% + \ifthenelse{\equal{#2}{multiple g-last}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{3}% + }{% + \ifthenelse{\equal{#2}{multiple l-last}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{4}% + }{% + \ifthenelse{\equal{#2}{multiple lng-last}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{5}% + }{% + \ifthenelse{\equal{#2}{multiple ng-last}}{% + \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{6}% + }{% + \PackageError{fmtcount}{Unexpected argument}{% + `#2' was unexpected: french option `#1 plural' expects `reformed', `traditional', + `reformed o', `traditional o', `always', `never', `multiple', `multiple g-last', + `multiple l-last', `multiple lng-last', or `multiple ng-last'.% + }}}}}}}}}}}}} % \end{macrocode} -% Option `\texttt{numeral u in duo}', this can be `\texttt{true}' or `\texttt{false}' and is used to select -% whether 12 and suchlikes write like dodec\meta{xxx} or duodec\meta{xxx} for numerals. +% Now a shorthand \cs{@tempa} is defined just to define all the options controlling plural mark. This +% shorthand takes into account that `\texttt{reformed}' and `\texttt{traditional}' have the same effect, and +% so do `\texttt{reformed o}' and `\texttt{traditional o}'. % \begin{macrocode} -\define@key{fcprefix}{numeral u in duo}[false]{% - \ifthenelse{\equal{#1}{false}}{% - \let\fc@u@in@duo\@empty - }{% - \ifthenelse{\equal{#1}{true}}{% - \def\fc@u@in@duo{u}% - }{% - \PackageError{fcprefix}{Unexpected option}{% - Option `numeral u in duo' expects `true' or `false' }% - }% +\def\@tempa#1#2#3{% + \define@key{fcfrench}{#1 plural}[reformed]{% + \fc@french@set@plural{#1}{##1}{#2}{#2}{#3}{#3}% }% } +\@tempa{vingt}{4}{5} +\@tempa{cent}{4}{5} +\@tempa{mil}{0}{0} +\@tempa{n-illion}{2}{6} +\@tempa{n-illiard}{2}{6} % \end{macrocode} -% Option `\texttt{e accute}', this can be `\texttt{true}' or `\texttt{false}' and is used to select whether -% letter `\texttt{e}' has an accute accent when it pronounce [e] in French. +% For option `\texttt{all plural}' we cannot use the \cs{@tempa} shorthand, because `\texttt{all plural}' +% is just a multiplexer. % \begin{macrocode} -\define@key{fcprefix}{e accute}[false]{% - \ifthenelse{\equal{#1}{false}}{% - \let\fc@prefix@eaccute\@firstofone - }{% - \ifthenelse{\equal{#1}{true}}{% - \let\fc@prefix@eaccute\'% - }{% - \PackageError{fcprefix}{Unexpected option}{% - Option `e accute' expects `true' or `false' }% - }% - }% +\define@key{fcfrench}{all plural}[reformed]{% + \csname KV@fcfrench@vingt plural\endcsname{#1}% + \csname KV@fcfrench@cent plural\endcsname{#1}% + \csname KV@fcfrench@mil plural\endcsname{#1}% + \csname KV@fcfrench@n-illion plural\endcsname{#1}% + \csname KV@fcfrench@n-illiard plural\endcsname{#1}% } % \end{macrocode} -% Default is to set accute accent like in French. -% \begin{macrocode} -\let\fc@prefix@eaccute\'% -% \end{macrocode} -% Option `\texttt{power of millia}' tells how millia is raise to power n. It expects value:\newline\noindent +% Now options `\texttt{dash or space}', we have three possible key values:\newline\noindent % \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% recursive&for which millia squared is noted as `milliamillia'\\ -% arabic&for which millia squared is noted as `millia\^{}2'\\ -% prefix&for which millia squared is noted as `bismillia' +% traditional& use dash for numbers below 100, except when `et' is used, and space otherwise\\ +% reformed& reform of 1990, use dash except with million \& milliard, and suchlikes, +% i.e. \meta{$n$}illion and \meta{$n$}illiard,\\ +% always& always use dashes to separate all words % \end{tabularx} % \begin{macrocode} -\define@key{fcprefix}{power of millia}[prefix]{% - \ifthenelse{\equal{#1}{prefix}}{% - \let\fc@power@of@millia@init\@gobbletwo - \let\fc@power@of@millia\fc@@prefix@millia +\define@key{fcfrench}{dash or space}[reformed]{% + \ifthenelse{\equal{#1}{traditional}}{% + \let\fc@frenchoptions@supermillion@dos\space% + \let\fc@frenchoptions@submillion@dos\space }{% - \ifthenelse{\equal{#1}{arabic}}{% - \let\fc@power@of@millia@init\@gobbletwo - \let\fc@power@of@millia\fc@@arabic@millia + \ifthenelse{\equal{#1}{reformed}\or\equal{#1}{1990}}{% + \let\fc@frenchoptions@supermillion@dos\space + \def\fc@frenchoptions@submillion@dos{-}% }{% - \ifthenelse{\equal{#1}{recursive}}{% - \let\fc@power@of@millia@init\fc@@recurse@millia@init - \let\fc@power@of@millia\fc@@recurse@millia + \ifthenelse{\equal{#1}{always}}{% + \def\fc@frenchoptions@supermillion@dos{-}% + \def\fc@frenchoptions@submillion@dos{-}% }{% - \PackageError{fcprefix}{Unexpected option}{% - Option `power of millia' expects `recursive', `arabic', or `prefix' }% + \PackageError{fmtcount}{Unexpected argument}{% + French option `dash or space' expects `always', `reformed' or `traditional' + } }% }% }% } % \end{macrocode} -% Arguments as follows:\def\interface{\newline\noindent +% Option `\texttt{scale}', can take 3 possible values:\newline\noindent % \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1& output macro\\ -% \#2& number with current weight \(w\) -% \end{tabularx}}\interface -% \begin{macrocode} -\def\fc@@recurse@millia#1#2{% - \let\@tempp#1% - \edef#1{millia\@tempp}% -} -% \end{macrocode} -% Arguments as follows --- same interface as \cs{fc@@recurse@millia}: \interface -% \begin{macrocode} -\def\fc@@recurse@millia@init#1#2{% - {% -% \end{macrocode} -% Save input argument current weight \(w\) into local macro \cs{@tempb}. -% \begin{macrocode} - \edef\@tempb{\number#2}% -% \end{macrocode} -% Now main loop from 0 to \(w\). Final value of \cs{@tempa} will be the result. -% \begin{macrocode} - \count0=0 % - \let\@tempa\@empty - \loop - \ifnum\count0<\@tempb - \advance\count0 by 1 % - \expandafter\def - \expandafter\@tempa\expandafter{\@tempa millia}% - \repeat -% \end{macrocode} -% Now propagate the expansion of \cs{@tempa} into \texttt{\#1} after closing bace. +% long& for which \meta{\(n\)}illions \& \meta{\(n\)}illiards are used with \(10^{6\times n} = 1 +% \textrm{\meta{$n$}}illion\), and \(10^{6\times n+3} = 1 \textrm{\meta{$n$}}illiard\)\\ +% short& for which \meta{$n$}illions only are used with \(10^{3\times n+3} = 1 +% \textrm{\meta{$n$}illion}\)\\ +% recursive& for which \(10^{18} = \textrm{un milliard de milliards}\) +% \end{tabularx} % \begin{macrocode} - \edef\@tempb{\def\noexpand#1{\@tempa}}% - \expandafter - }\@tempb +\define@key{fcfrench}{scale}[recursive]{% + \ifthenelse{\equal{#1}{long}}{% + \let\fc@poweroften\fc@@pot@longscalefrench + }{% + \ifthenelse{\equal{#1}{recursive}}{% + \let\fc@poweroften\fc@@pot@recursivefrench + }{% + \ifthenelse{\equal{#1}{short}}{% + \let\fc@poweroften\fc@@pot@shortscalefrench + }{% + \PackageError{fmtcount}{Unexpected argument}{% + French option `scale' expects `long', `recursive' or `short' + } + }% + }% + }% } % \end{macrocode} -% Arguments as follows --- same interface as \cs{fc@@recurse@millia}: \interface +% Option `\texttt{n-illiard upto}' is ignored if `\texttt{scale}' is different from `\texttt{long}'. It can +% take the following values:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% infinity&in that case \meta{$n$}illard are never disabled,\\ +% infty&this is just a shorthand for `\texttt{infinity}', and\\ +% \textrm{\(n\)}& any integer that is such that \(n>0\), and that \(\forall k\in\mathbb{N}, k\geq n\), +% number \(10^{6\times k+3}\) will be formatted as ``mille \meta{$n$}illions'' +% \end{tabularx} % \begin{macrocode} -\def\fc@@arabic@millia#1#2{% - \ifnnum#2=0 % - \let#1\@empty - \else - \edef#1{millia\^{}\the#2}% - \fi +\define@key{fcfrench}{n-illiard upto}[infinity]{% + \ifthenelse{\equal{#1}{infinity}}{% + \def\fc@longscale@nilliard@upto{0}% + }{% + \ifthenelse{\equal{#1}{infty}}{% + \def\fc@longscale@nilliard@upto{0}% + }{% + \if Q\ifnum9<1#1Q\fi\else + \PackageError{fmtcount}{Unexpected argument}{% + French option `milliard threshold' expects `infinity', or equivalently `infty', or a non negative + integer.}% + \fi + \def\fc@longscale@nilliard@upto{#1}% + }}% } % \end{macrocode} -% Arguments as follows --- same interface as \cs{fc@@recurse@millia}: \interface +% Now, the options `\texttt{france}', `\texttt{swiss}' and `\texttt{belgian}' are defined to select the +% dialect to use. Macro \cs{@tempa} is just a local shorthand to define each one of this option. % \begin{macrocode} -\def\fc@@prefix@millia#1#2{% - \fc@@latin@numeral@pefix{#2}{#1}% -} +\def\@tempa#1{% + \define@key{fcfrench}{#1}[]{% + \PackageError{fmtcount}{Unexpected argument}{French option with key `#1' does not take + any value}}% + \expandafter\def\csname KV@fcfrench@#1@default\endcsname{% + \def\fmtcount@french{#1}}% +}% +\@tempa{france}\@tempa{swiss}\@tempa{belgian}% % \end{macrocode} -% Default value of option `\texttt{power of millia}' is `\texttt{prefix}': +% Make `\texttt{france}' the default dialect for `\texttt{french}' language +% \changes{3.01}{2014-12-18}{Move French specific stuff from \styfmt{fmtcount.sty} to \styfmt{fc-french.def}.} % \begin{macrocode} -\let\fc@power@of@millia@init\@gobbletwo -\let\fc@power@of@millia\fc@@prefix@millia +\def\fmtcount@french{france}% % \end{macrocode} -% \DescribeMacro{\fc@@latin@cardinal@pefix} Compute a cardinal prefix for n-illion, like \(1 \Rightarrow -% \textrm{`m'}\), \(2 \Rightarrow \textrm{`bi'}\), \(3 \Rightarrow \textrm{`tri'}\). The algorithm to derive -% this prefix is that of Russ Rowlett I founds its documentation on Alain Lassine's site: -% \url{http://www.alain.be/Boece/grands\_nombres.html}. First check that macro is not yet defined. +% Now, option `\texttt{dialect}' is now defined so that `\texttt{france}', `\texttt{swiss}' and +% `\texttt{belgian}' can also be used as key values, which is more conventional although less concise. % \begin{macrocode} -\ifcsundef{fc@@latin@cardinal@pefix}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro `fc@@latin@cardinal@pefix'}} +\define@key{fcfrench}{dialect}[france]{% + \ifthenelse{\equal{#1}{france} + \or\equal{#1}{swiss} + \or\equal{#1}{belgian}}{% + \def\fmtcount@french{#1}}{% + \PackageError{fmtcount}{Invalid value `#1' to french option dialect key} + {Option `french' can only take the values `france', + `belgian' or `swiss'}}} % \end{macrocode} -% Arguments as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&input number to be formated\\ -% \#2&outut macro name into which to place the formatted result -% \end{tabularx} +% The option \texttt{mil plural mark} allows to make the plural of \texttt{mil} to be regular, +% i.e. \texttt{mils}, instead of \texttt{mille}. By default it is `\texttt{le}'. % \begin{macrocode} -\def\fc@@latin@cardinal@pefix#1#2{% - {% +\define@key{fcfrench}{mil plural mark}[le]{% + \def\fc@frenchoptions@mil@plural@mark{#1}} % \end{macrocode} -% First we put input argument into local macro @cs{@tempa} with full expansion. +% Definition of case handling macros. This should be moved somewhere else to be commonalized between all +% languages. % \begin{macrocode} - \edef\@tempa{\number#1}% +\def\fc@UpperCaseFirstLetter#1#2\@nil{% + \uppercase{#1}#2} + +\def\fc@CaseIden#1\@nil{% + #1% +} +\def\fc@UpperCaseAll#1\@nil{% + \uppercase{#1}% +} + +\let\fc@case\fc@CaseIden + % \end{macrocode} -% Now parse number from expanded input. +% \DescribeMacro{\@ordinalMfrench} +% \changes{3.01}{2014-11-12}{Protect \cs{`}, for solving +% \uref{http://github.com/nlct/fmtcount/issues/15}{Issue \#15}, and +% correct non abbreviated ordinal finals} +% \changes{3.01}{2014-11-20}{Add a package warning about non +% abbreviated ordinals in French being incorrect. Change ``i\`eme'' +% to ``\`eme'' which is the most frequent non abbreviated form.} % \begin{macrocode} - \expandafter\fc@number@parser\expandafter{\@tempa}% - \count2=0 % +\newcommand*{\@ordinalMfrench}[2]{% +\iffmtord@abbrv + \ifnum#1=1 % + \edef#2{\number#1\relax\noexpand\fmtord{er}}% + \else + \edef#2{\number#1\relax\noexpand\fmtord{e}}% + \fi +\else + \PackageWarning{fmtcount}{Non abbreviated ordinal finals (`eme) are + considered incorrect in French.}% + \ifnum#1=1 % + \edef#2{\number#1\relax\noexpand\fmtord{er}}% + \else + \protected@edef#2{\number#1\relax\noexpand\fmtord{\protect\`eme}}% + \fi +\fi} % \end{macrocode} -% \cs{@tempt} will hold the optional final \texttt{t}, \cs{@tempu} is used to initialize \cs{@tempt} to `t' -% when the firt non-zero 3digit group is met, which is the job made by \cs{@tempi}. +% \DescribeMacro{\@ordinalFfrench} +% \changes{3.01}{2014-11-10}{Protect \cs{`}, for solving +% \uref{http://github.com/nlct/fmtcount/issues/15}{Issue \#15}} +% \changes{3.01}{2014-11-20}{Add a package warning about non +% abbreviated ordinals in French being incorrect. Change ``i\`eme'' +% to ``\`eme'' which is the most frequent non abbreviated form.} % \begin{macrocode} - \let\@tempt\@empty - \def\@tempu{t}% +\newcommand*{\@ordinalFfrench}[2]{% +\iffmtord@abbrv + \ifnum#1=1 % + \edef#2{\number#1\relax\noexpand\fmtord{re}}% + \else + \edef#2{\number#1\relax\noexpand\fmtord{e}}% + \fi +\else + \PackageWarning{fmtcount}{Non abbreviated ordinal finals (`eme) are + considered incorrect in French.}% + \ifnum#1=1 % + \protected@edef#2{\number#1\relax\noexpand\fmtord{\protect\`ere}}% + \else + \protected@edef#2{\number#1\relax\noexpand\fmtord{\protect\`eme}}% + \fi +\fi} % \end{macrocode} -% \cs{@tempm} will hold the \texttt{millia\^}\(^{n\div 3}\) +% In French neutral gender and masculine gender are formally identical. % \begin{macrocode} - \let\@tempm\@empty +\let\@ordinalNfrench\@ordinalMfrench % \end{macrocode} -% Loop by means of terminal recursion of herinafter defined macro \cs{@templ}. We loop by group of 3 digits. +% \DescribeMacro{\@@unitstringfrench} % \begin{macrocode} - \def\@templ{% - \ifnum\count2>\fc@max@weight - \let\next\relax - \else +\newcommand*{\@@unitstringfrench}[1]{% +\noexpand\fc@case +\ifcase#1 % +z\'ero% +\or un% +\or deux% +\or trois% +\or quatre% +\or cinq% +\or six% +\or sept% +\or huit% +\or neuf% +\fi +\noexpand\@nil +} % \end{macrocode} -% Loop body. Here we read a group of 3 consecutive digits \(d_2d_1d_0\) and place them respectively into -% \cs{count3}, \cs{count4}, and \cs{count5}. +% \DescribeMacro{\@@tenstringfrench} % \begin{macrocode} - \fc@read@unit{\count3}{\count2}% - \advance\count2 by 1 % - \fc@read@unit{\count4}{\count2}% - \advance\count2 by 1 % - \fc@read@unit{\count5}{\count2}% - \advance\count2 by 1 % +\newcommand*{\@@tenstringfrench}[1]{% +\noexpand\fc@case +\ifcase#1 % +\or dix% +\or vingt% +\or trente% +\or quarante% +\or cinquante% +\or soixante% +\or septante% +\or huitante% +\or nonante% +\or cent% +\fi +\noexpand\@nil +} % \end{macrocode} -% If the 3 considered digits \(d_2d_1d_0\) are not all zero, then set \cs{@tempt} to `\texttt{t}' for the -% first time this event is met. +% \DescribeMacro{\@@teenstringfrench} % \begin{macrocode} - \edef\@tempn{% - \ifnum\count3=0\else 1\fi - \ifnum\count4=0\else 1\fi - \ifnum\count5=0\else 1\fi - }% - \ifx\@tempn\@empty\else - \let\@tempt\@tempu - \let\@tempu\@empty - \fi +\newcommand*{\@@teenstringfrench}[1]{% +\noexpand\fc@case +\ifcase#1 % + dix% +\or onze% +\or douze% +\or treize% +\or quatorze% +\or quinze% +\or seize% +\or dix\noexpand\@nil-\noexpand\fc@case sept% +\or dix\noexpand\@nil-\noexpand\fc@case huit% +\or dix\noexpand\@nil-\noexpand\fc@case neuf% +\fi +\noexpand\@nil +} % \end{macrocode} -% Now process the current group \(d_2d_1d_0\) of 3 digits. +% \DescribeMacro{\@@seventiesfrench} % \begin{macrocode} - \let\@tempp\@tempa - \edef\@tempa{% +\newcommand*{\@@seventiesfrench}[1]{% +\@tenstring{6}% +\ifnum#1=1 % +\fc@frenchoptions@submillion@dos\@andname\fc@frenchoptions@submillion@dos +\else +-% +\fi +\@teenstring{#1}% +} % \end{macrocode} -% Here we process \(d_{2}\) held by \cs{count5}, that is to say hundreds. -% \begin{macrocode} - \ifcase\count5 % - \or cen% - \or ducen% - \or trecen% - \or quadringen% - \or quingen% - \or sescen% - \or septigen% - \or octingen% - \or nongen% - \fi -% \end{macrocode} -% Here we process \(d_1d_0\) held by \cs{count4} \& \cs{count3}, that is to say tens and units. -% \begin{macrocode} - \ifnum\count4=0 % - % x0(0..9) - \ifnum\count2=3 % - % Absolute weight zero - \ifcase\count3 \@tempt - \or m% - \or b% - \or tr% - \or quadr% - \or quin\@tempt - \or sex\@tempt - \or sep\@tempt - \or oc\@tempt - \or non% - \fi - \else -% \end{macrocode} -% Here the weight of \cs{count3} is \(3\times n\), with \(n>0\), i.e. this is followed by a -% \texttt{millia\^}\(n\). -% \begin{macrocode} - \ifcase\count3 % - \or \ifnum\count2>\fc@max@weight\else un\fi - \or d\fc@u@in@duo o% - \or tre% - \or quattuor% - \or quin% - \or sex% - \or septen% - \or octo% - \or novem% - \fi - \fi - \else - % x(10..99) - \ifcase\count3 % - \or un% - \or d\fc@u@in@duo o% - \or tre% - \or quattuor% - \or quin% - \or sex% - \or septen% - \or octo% - \or novem% - \fi - \ifcase\count4 % - \or dec% - \or vigin\@tempt - \or trigin\@tempt - \or quadragin\@tempt - \or quinquagin\@tempt - \or sexagin\@tempt - \or septuagin\@tempt - \or octogin\@tempt - \or nonagin\@tempt - \fi - \fi -% \end{macrocode} -% Insert the \texttt{millia\^}\(^{(n\div 3)}\) only if \(d_2d_1d_0\not=0\), i.e. if one of \cs{count3} -% \cs{count4} or \cs{count5} is non zero. -% \begin{macrocode} - \@tempm -% \end{macrocode} -% And append previous version of \cs{@tempa}. -% \begin{macrocode} - \@tempp - }% -% \end{macrocode} -% ``Concatenate'' \texttt{millia} to \cs{@tempm}, so that \cs{@tempm} will expand to -% \texttt{millia\^}\(^{(n\div 3)+1}\) at the next iteration. Actually whether this is a concatenation or some -% \texttt{millia} prefixing depends of option `\texttt{power of millia}'. -% \begin{macrocode} - \fc@power@of@millia\@tempm{\count2}% - \fi - \next - }% - \let\@tempa\@empty - \let\next\@templ - \@templ -% \end{macrocode} -% Propagate expansion of \cs{@tempa} into \texttt{\#2} after closing bracket. -% \begin{macrocode} - \def\@tempb##1{\def\@tempa{\def#2{##1}}}% - \expandafter\@tempb\expandafter{\@tempa}% - \expandafter - }\@tempa -} -% \end{macrocode} -% \DescribeMacro{\fc@@latin@numeral@pefix} Compute a numeral prefix -% like `s\'emel', `bis', `ter', `quater', -% etc\ldots I found the algorithm to derive this prefix on Alain Lassine's site: -% \url{http://www.alain.be/Boece/nombres\_gargantuesques.html}. First check that the macro is not yet defined. -% \begin{macrocode} -\ifcsundef{fc@@latin@numeral@pefix}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@@latin@numeral@pefix'}} -% \end{macrocode} -% Arguments as follows:\newline\noindent +% \DescribeMacro{\@@eightiesfrench}Macro \cs{@@eightiesfrench} is used to format numbers in the interval +% \([80\intv 89]\). Argument as follows:\newline % \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1& input number to be formatted,\\ -% \#2& outut macro name into which to place the result +% \#1&digit \(d_{w}\) such that the number to be formatted is \(80 + d_{w}\)\\ +% \end{tabularx} +% Implicit arguments as:\newline +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \cs{count0}&weight \(w\) of the number \(d_{w+1}d_{w}\) to be formatted\\ +% \cs{count1}&same as \cs{\#1}\\ +% \cs{count6}&input, counter giving the least weight of non zero digits in top level formatted number +% integral part, with rounding down to a multiple of 3,\\ +% \cs{count9}&input, counter giving the power type of the power of ten following the eighties to be +% formatted; that is `1' for ``mil'' and `2' for ``\meta{$n$}illion\textbar \meta{$n$}illiard''. % \end{tabularx} % \begin{macrocode} -\def\fc@@latin@numeral@pefix#1#2{% - {% - \edef\@tempa{\number#1}% - \def\fc@unit@weight{0}% - \expandafter\fc@number@parser\expandafter{\@tempa}% - \count2=0 % -% \end{macrocode} -% Macro \cs{@tempm} will hold the \texttt{millies\^}\(^{n\div 3}\). -% \begin{macrocode} - \let\@tempm\@empty -% \end{macrocode} -% Loop over digits. This is done by defining macro \cs{@templ} for terminal recursion. -% \begin{macrocode} - \def\@templ{% - \ifnum\count2>\fc@max@weight - \let\next\relax - \else +\newcommand*\@@eightiesfrench[1]{% +\fc@case quatre\@nil-\noexpand\fc@case vingt% +\ifnum#1>0 % + \ifnum\fc@frenchoptions@vingt@plural=0 % vingt plural=always + s% + \fi + \noexpand\@nil + -\@unitstring{#1}% +\else + \ifcase\fc@frenchoptions@vingt@plural\space + s% 0: always + \or + % 1: never + \or + s% 2: multiple + \or + % 3: multiple g-last + \ifnum\count0=\count6\ifnum\count9=0 s\fi\fi + \or + % 4: multiple l-last + \ifnum\count9=1 % + \else + s% + \fi + \or + % 5: multiple lng-last + \ifnum\count9=1 % + \else + \ifnum\count0>0 % + s% + \fi + \fi + \or + % or 6: multiple ng-last + \ifnum\count0>0 % + s% + \fi + \fi + \noexpand\@nil +\fi +} +\newcommand*{\@@ninetiesfrench}[1]{% +\fc@case quatre\@nil-\noexpand\fc@case vingt% +\ifnum\fc@frenchoptions@vingt@plural=0 % vingt plural=always + s% +\fi +\noexpand\@nil +-\@teenstring{#1}% +} +\newcommand*{\@@seventiesfrenchswiss}[1]{% +\@tenstring{7}% +\ifnum#1=1\ \@andname\ \fi +\ifnum#1>1-\fi +\ifnum#1>0 \@unitstring{#1}\fi +} +\newcommand*{\@@eightiesfrenchswiss}[1]{% +\@tenstring{8}% +\ifnum#1=1\ \@andname\ \fi +\ifnum#1>1-\fi +\ifnum#1>0 \@unitstring{#1}\fi +} +\newcommand*{\@@ninetiesfrenchswiss}[1]{% +\@tenstring{9}% +\ifnum#1=1\ \@andname\ \fi +\ifnum#1>1-\fi +\ifnum#1>0 \@unitstring{#1}\fi +} % \end{macrocode} -% Loop body. Three consecutive digits \(d_{2}d_{1}d_{0}\) are read into counters \cs{count3}, \cs{count4}, and -% \cs{count5}. +% \DescribeMacro{\fc@french@common}Macro \cs{fc@french@common} does all the preliminary settings common to all +% French dialects \& formatting options. % \begin{macrocode} - \fc@read@unit{\count3}{\count2}% - \advance\count2 by 1 % - \fc@read@unit{\count4}{\count2}% - \advance\count2 by 1 % - \fc@read@unit{\count5}{\count2}% - \advance\count2 by 1 % +\newcommand*\fc@french@common{% + \let\@unitstring=\@@unitstringfrench + \let\@teenstring=\@@teenstringfrench + \let\@tenstring=\@@tenstringfrench + \def\@hundred{cent}% + \def\@andname{et}% +} % \end{macrocode} -% Check the use of \texttt{duodevicies} instead of \texttt{octodecies}. % \begin{macrocode} - \let\@tempn\@secondoftwo - \ifnum\count3>7 % - \ifnum\count4<\fc@duodeandunde - \ifnum\count4>0 % - \let\@tempn\@firstoftwo - \fi - \fi - \fi - \@tempn - {% use duodevicies for eighteen - \advance\count4 by 1 % - \let\@temps\@secondoftwo - }{% do not use duodevicies for eighteen - \let\@temps\@firstoftwo - }% - \let\@tempp\@tempa - \edef\@tempa{% - % hundreds - \ifcase\count5 % - \expandafter\@gobble - \or c% - \or duc% - \or trec% - \or quadring% - \or quing% - \or sesc% - \or septing% - \or octing% - \or nong% - \fi - {enties}% - \ifnum\count4=0 % +\DeclareRobustCommand{\@numberstringMfrenchswiss}[2]{% +\let\fc@case\fc@CaseIden +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\let\fc@nbrstr@preamble\@empty +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@numberstringMfrenchfrance}[2]{% +\let\fc@case\fc@CaseIden +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\@empty +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@numberstringMfrenchbelgian}[2]{% +\let\fc@case\fc@CaseIden +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\@empty +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\let\@numberstringMfrench=\@numberstringMfrenchfrance +\DeclareRobustCommand{\@numberstringFfrenchswiss}[2]{% +\let\fc@case\fc@CaseIden +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@numberstringFfrenchfrance}[2]{% +\let\fc@case\fc@CaseIden +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@numberstringFfrenchbelgian}[2]{% +\let\fc@case\fc@CaseIden +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\let\@numberstringFfrench=\@numberstringFfrenchfrance +\let\@ordinalstringNfrench\@ordinalstringMfrench +\DeclareRobustCommand{\@NumberstringMfrenchswiss}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\let\fc@nbrstr@preamble\@empty +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@NumberstringMfrenchfrance}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\@empty +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@NumberstringMfrenchbelgian}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\@empty +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\let\@NumberstringMfrench=\@NumberstringMfrenchfrance +\DeclareRobustCommand{\@NumberstringFfrenchswiss}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@NumberstringFfrenchfrance}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\DeclareRobustCommand{\@NumberstringFfrenchbelgian}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble +\let\fc@nbrstr@postamble\@empty +\@@numberstringfrench{#1}{#2}} +\let\@NumberstringFfrench=\@NumberstringFfrenchfrance +\let\@NumberstringNfrench\@NumberstringMfrench +\DeclareRobustCommand{\@ordinalstringMfrenchswiss}[2]{% +\let\fc@case\fc@CaseIden +\let\fc@first=\fc@@firstfrench +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\@@ordinalstringfrench{#1}{#2}% +} +\newcommand*\fc@@firstfrench{premier} +% \end{macrocode} +% \changes{3.01}{2014-11-10}{Protect \cs{`}, for solving +% \uref{http://github.com/nlct/fmtcount/issues/15}{Issue \#15}} +% \begin{macrocode} +\newcommand*\fc@@firstFfrench{premi\protect\`ere} +\DeclareRobustCommand{\@ordinalstringMfrenchfrance}[2]{% +\let\fc@case\fc@CaseIden +\let\fc@first=\fc@@firstfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}} +\DeclareRobustCommand{\@ordinalstringMfrenchbelgian}[2]{% +\let\fc@case\fc@CaseIden +\let\fc@first=\fc@@firstfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}% +} +\let\@ordinalstringMfrench=\@ordinalstringMfrenchfrance +\DeclareRobustCommand{\@ordinalstringFfrenchswiss}[2]{% +\let\fc@case\fc@CaseIden +\let\fc@first=\fc@@firstFfrench +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\@@ordinalstringfrench{#1}{#2}% +} +\DeclareRobustCommand{\@ordinalstringFfrenchfrance}[2]{% +\let\fc@case\fc@CaseIden +\let\fc@first=\fc@@firstFfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}% +} +\DeclareRobustCommand{\@ordinalstringFfrenchbelgian}[2]{% +\let\fc@case\fc@CaseIden +\let\fc@first=\fc@@firstFfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}% +} +\let\@ordinalstringFfrench=\@ordinalstringFfrenchfrance +\let\@ordinalstringNfrench\@ordinalstringMfrench +\DeclareRobustCommand{\@OrdinalstringMfrenchswiss}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\let\fc@first=\fc@@firstfrench +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\@@ordinalstringfrench{#1}{#2}% +} +\DeclareRobustCommand{\@OrdinalstringMfrenchfrance}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\let\fc@first=\fc@@firstfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}% +} +\DeclareRobustCommand{\@OrdinalstringMfrenchbelgian}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\let\fc@first=\fc@@firstfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}% +} +\let\@OrdinalstringMfrench=\@OrdinalstringMfrenchfrance +\DeclareRobustCommand{\@OrdinalstringFfrenchswiss}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\let\fc@first=\fc@@firstfrench +\fc@french@common +\let\@seventies=\@@seventiesfrenchswiss +\let\@eighties=\@@eightiesfrenchswiss +\let\@nineties=\@@ninetiesfrenchswiss +\@@ordinalstringfrench{#1}{#2}% +} +\DeclareRobustCommand{\@OrdinalstringFfrenchfrance}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\let\fc@first=\fc@@firstFfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}% +} +\DeclareRobustCommand{\@OrdinalstringFfrenchbelgian}[2]{% +\let\fc@case\fc@UpperCaseFirstLetter +\let\fc@first=\fc@@firstFfrench +\fc@french@common +\let\@seventies=\@@seventiesfrench +\let\@eighties=\@@eightiesfrench +\let\@nineties=\@@ninetiesfrench +\@@ordinalstringfrench{#1}{#2}% +} +\let\@OrdinalstringFfrench=\@OrdinalstringFfrenchfrance +\let\@OrdinalstringNfrench\@OrdinalstringMfrench +% \end{macrocode} +% \DescribeMacro{\fc@@do@plural@mark}Macro \cs{fc@@do@plural@mark} will expand to the plural mark of +% \meta{$n$}illiard, \meta{$n$}illion, mil, cent or vingt, whichever is applicable. First check that the macro +% is not yet defined. +% \begin{macrocode} +\ifcsundef{fc@@do@plural@mark}{}% +{\PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@@do@plural@mark'}} +% \end{macrocode} +% Arguments as follows:\newline +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&plural mark, `s' in general, but for mil it is \cs{fc@frenchoptions@mil@plural@mark}\\ +% \end{tabularx} +% Implicit arguments as follows:\newline +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \cs{count0}&input, counter giving the weight \(w\), this is expected to be multiple of 3,\\ +% \cs{count1}&input, counter giving the plural value of multiplied object \meta{$n$}illiard, +% \meta{$n$}illion, mil, cent or vingt, whichever is applicable, that is to say it is 1 when the considered +% objet is not multiplied, and 2 or more when it is multiplied,\\ +% \cs{count6}&input, counter giving the least weight of non zero digits in top level formatted number +% integral part, with rounding down to a multiple of 3,\\ +% \cs{count10}&input, counter giving the plural mark control option.\\ +% \end{tabularx} +% \begin{macrocode} +\def\fc@@do@plural@mark#1{% + \ifcase\count10 % + #1% 0=always + \or% 1=never + \or% 2=multiple + \ifnum\count1>1 % + #1% + \fi + \or% 3= multiple g-last + \ifnum\count1>1 % + \ifnum\count0=\count6 % + #1% + \fi + \fi + \or% 4= multiple l-last + \ifnum\count1>1 % + \ifnum\count9=1 % + \else + #1% + \fi + \fi + \or% 5= multiple lng-last + \ifnum\count1>1 % + \ifnum\count9=1 % + \else + \if\count0>\count6 % + #1% + \fi + \fi + \fi + \or% 6= multiple ng-last + \ifnum\count1>1 % + \ifnum\count0>\count6 % + #1% + \fi + \fi + \fi +} +% \end{macrocode} +% \DescribeMacro{\fc@@nbrstr@Fpreamble}Macro \cs{fc@@nbrstr@Fpreamble} do the necessary preliminaries before +% formatting a cardinal with feminine gender. +% \begin{macrocode} +\ifcsundef{fc@@nbrstr@Fpreamble}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@@nbrstr@Fpreamble'}} +% \end{macrocode} +% \DescribeMacro{\fc@@nbrstr@Fpreamble} +% \begin{macrocode} +\def\fc@@nbrstr@Fpreamble{% + \fc@read@unit{\count1}{0}% + \ifnum\count1=1 % + \let\fc@case@save\fc@case + \def\fc@case{\noexpand\fc@case}% + \def\@nil{\noexpand\@nil}% + \let\fc@nbrstr@postamble\fc@@nbrstr@Fpostamble + \fi +} +% \end{macrocode} +% \DescribeMacro{\fc@@nbrstr@Fpostamble} +% \begin{macrocode} +\def\fc@@nbrstr@Fpostamble{% + \let\fc@case\fc@case@save + \expandafter\fc@get@last@word\expandafter{\@tempa}\@tempb\@tempc + \def\@tempd{un}% + \ifx\@tempc\@tempd + \let\@tempc\@tempa + \edef\@tempa{\@tempb\fc@case une\@nil}% + \fi +} +% \end{macrocode} +% \DescribeMacro{\fc@@pot@longscalefrench}Macro \cs{fc@@pot@longscalefrench} is used to produce +% powers of ten with long scale convention. The long scale convention is correct for French and elsewhere in +% Europe. First we check that the macro is not yet defined. +% \begin{macrocode} +\ifcsundef{fc@@pot@longscalefrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@@pot@longscalefrench'}} +% \end{macrocode} +% Argument are as follows:\def\interface{\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&input, plural value of \(d\), that is to say: let \(d\) be the number multiplying the considered power +% of ten, then the plural value \texttt{\#2} is expected to be \(0\) if \(d=0\), \(1\) if \(d=1\), or \(>1\) +% if \(d>1\)\\ +% \#2&output, counter, maybe \(0\) when power of ten is \(1\), \(1\) when power of ten starts with +% ``mil(le)'', or \(2\) when power of ten is a ``\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)''\\ +% \#3&output, macro into which to place the formatted power of ten +% \end{tabularx} +% Implicit arguments as follows:\newline +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \cs{count0}&input, counter giving the weight \(w\), this is expected to be multiple of 3\\ +% \end{tabularx} +% }\interface +% \begin{macrocode} +\def\fc@@pot@longscalefrench#1#2#3{% + {% +% \end{macrocode} +% First the input arguments are saved into local objects: \texttt{\#1} and \texttt{\#1} are respectively saved +% into \cs{@tempa} and \cs{@tempb}. +% \begin{macrocode} + \edef\@tempb{\number#1}% +% \end{macrocode} +% Let \cs{count1} be the plural value. +% \begin{macrocode} + \count1=\@tempb +% \end{macrocode} +% Let \(n\) and \(r\) the the quotient and remainder of division of weight \(w\) by \(6\), that is to say \(w +% = n\times 6 + r\) and \(0\leq r < 6\), then \cs{count2} is set to \(n\) and \cs{count3} is set to \(r\). +% \begin{macrocode} + \count2\count0 % + \divide\count2 by 6 % + \count3\count2 % + \multiply\count3 by 6 % + \count3-\count3 % + \advance\count3 by \count0 % + \ifnum\count0>0 % +% \end{macrocode} +% If weight \(w\) (a.k.a. \cs{count0}) is such that \(w>0\), then \(w\geq 3\) because \(w\) is a multiple of +% \(3\). So we \emph{may} have to append ``mil(le)'' or ``\meta{$n$}illion(s)'' or ``\meta{$n$}illiard(s)''. +% \begin{macrocode} + \ifnum\count1>0 % +% \end{macrocode} +% Plural value is \(>0\) so have at least one ``mil(le)'' or ``\meta{$n$}illion(s)'' or +% ``\meta{$n$}illiard(s)''. We need to distinguish between the case of ``mil(le)'' and that of +% ``\meta{$n$}illion(s)'' or ``\meta{$n$}illiard(s)'', so we \cs{def}ine \cs{@temph} to `\texttt{1}' for +% ``mil(le)'', and to `\texttt{2}' otherwise. +% \begin{macrocode} + \edef\@temph{% + \ifnum\count2=0 % weight=3 +% \end{macrocode} +% Here \(n=0\), with \(n=w\div 6\),but we also know that \(w\geq 3\), so we have \(w=3\) which means we are in +% the ``mil(le)'' case. +% \begin{macrocode} + 1% + \else + \ifnum\count3>2 % +% \end{macrocode} +% Here we are in the case of \(3\leq r < 6\), with \(r\) the remainder of division of weight \(w\) by \(6\), +% we should have ``\meta{$n$}illiard(s)'', but that may also be ``mil(le)'' instead depending on +% option `\texttt{n-illiard upto}', known as \cs{fc@longscale@nilliard@upto}. +% \begin{macrocode} + \ifnum\fc@longscale@nilliard@upto=0 % % \end{macrocode} -% Here \(d_{2}d_{1}d_{0}\) is such that \(d_{1} = 0\). +% Here option `\texttt{n-illiard upto}' is `\texttt{infinity}', so we always use ``\meta{$n$}illiard(s)''. % \begin{macrocode} - \ifcase\count3 % - \or - \ifnum\count2=3 % - s\fc@prefix@eaccute emel% + 2% \else - \ifnum\count2>\fc@max@weight\else un\fi +% \end{macrocode} +% Here option `\texttt{n-illiard upto}' indicate some threshold to which to compare \(n\) +% (a.k.a. \cs{count2}). +% \begin{macrocode} + \ifnum\count2>\fc@longscale@nilliard@upto + 1% + \else + 2% + \fi \fi - \or bis% - \or ter% - \or quater% - \or quinquies% - \or sexies% - \or septies% - \or octies% - \or novies% + \else + 2% \fi - \else + \fi + }% + \ifnum\@temph=1 % % \end{macrocode} -% Here \(d_{2}d_{1}d_{0}\) is such that \(d_{1} \geq 1\). +% Here \(10^w\) is formatted as ``mil(le)''. % \begin{macrocode} - \ifcase\count3 % - \or un% - \or d\fc@u@in@duo o% - \or ter% - \or quater% - \or quin% - \or sex% - \or septen% - \or \@temps{octo}{duod\fc@prefix@eaccute e}% x8 = two before next (x+1)0 - \or \@temps{novem}{und\fc@prefix@eaccute e}% x9 = one before next (x+1)0 - \fi - \ifcase\count4 % - % can't get here - \or d\fc@prefix@eaccute ec% - \or vic% - \or tric% - \or quadrag% - \or quinquag% - \or sexag% - \or septuag% - \or octog% - \or nonag% - \fi - ies% + \count10=\fc@frenchoptions@mil@plural\space + \edef\@tempe{% + \noexpand\fc@case + mil% + \fc@@do@plural@mark\fc@frenchoptions@mil@plural@mark + \noexpand\@nil + }% + \else + % weight >= 6 + \expandafter\fc@@latin@cardinal@pefix\expandafter{\the\count2}\@tempg + % now form the xxx-illion(s) or xxx-illiard(s) word + \ifnum\count3>2 % + \toks10{illiard}% + \count10=\csname fc@frenchoptions@n-illiard@plural\endcsname\space + \else + \toks10{illion}% + \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space \fi - % Insert the millies^(n/3) only if one of \count3 \count4 \count5 is non zero - \@tempm - % add up previous version of \@tempa - \@tempp - }% + \edef\@tempe{% + \noexpand\fc@case + \@tempg + \the\toks10 % + \fc@@do@plural@mark s% + \noexpand\@nil + }% + \fi + \else % \end{macrocode} -% Concatenate \texttt{millies} to \cs{@tempm} so that it is equal to \texttt{millies\^}\(^{n\div 3}\) at the -% next iteration. Here we just have plain concatenation, contrary to cardinal for which a prefix can be used -% instead. +% Here plural indicator of \(d\) indicates that \(d = 0\), so we have \(0\times10^{w}\), and it is not worth +% to format \(10^{w}\), because there are none of them. % \begin{macrocode} - \let\@tempp\@tempp - \edef\@tempm{millies\@tempp}% + \let\@tempe\@empty + \def\@temph{0}% \fi - \next - }% - \let\@tempa\@empty - \let\next\@templ - \@templ + \else % \end{macrocode} -% Now propagate expansion of \@tempa into \texttt{\#2} after closing bracket. +% Case of \(w=0\). % \begin{macrocode} - \def\@tempb##1{\def\@tempa{\def#2{##1}}}% - \expandafter\@tempb\expandafter{\@tempa}% - \expandafter - }\@tempa -} + \let\@tempe\@empty + \def\@temph{0}% + \fi % \end{macrocode} -% Stuff for calling macros. Construct \cs{fc@call}\meta{some macro} can be used to pass two arguments to -% \meta{some macro} with a configurable calling convention: -% \begin{itemize} -% \item the calling convention is such that there is one mandatory argument \meta{marg} and an optional -% argument \meta{oarg} -% \item either \cs{fc@call} is \cs{let} to be equal to \cs{fc@call@opt@arg@second}, and then calling -% convention is that the \meta{marg} is first and \meta{oarg} is second, -% \item or \cs{fc@call} is \cs{let} to be equal to \cs{fc@call@opt@arg@first}, and then calling convention is -% that the \meta{oarg} is first and \meta{aarg} is second, -% \item if \meta{oarg} is absent, then it is by convention set empty, -% \item \meta{some macro} is supposed to have two mandatory arguments of which \meta{oarg} is passed to the -% first, and \meta{marg} is passed to the second, and -% \item \meta{some macro} is called within a group. -% \end{itemize} +% Now place into \@cs{@tempa} the assignment of results \cs{@temph} and \cs{@tempe} to \texttt{\#2} and +% \texttt{\#3} for further propagation after closing brace. % \begin{macrocode} -\def\fc@call@opt@arg@second#1#2{% - \def\@tempb{% - \ifx[\@tempa - \def\@tempc[####1]{% - {#1{####1}{#2}}% - }% - \else - \def\@tempc{{#1{}{#2}}}% - \fi - \@tempc - }% - \futurelet\@tempa - \@tempb + \expandafter\toks\expandafter1\expandafter{\@tempe}% + \toks0{#2}% + \edef\@tempa{\the\toks0 \@temph \def\noexpand#3{\the\toks1}}% + \expandafter + }\@tempa } % \end{macrocode} +% \DescribeMacro{\fc@@pot@shortscalefrench}Macro \cs{fc@@pot@shortscalefrench} is used to produce +% powers of ten with short scale convention. This convention is the US convention and is not correct for +% French and elsewhere in Europe. First we check that the macro is not yet defined. % \begin{macrocode} -\def\fc@call@opt@arg@first#1{% - \def\@tempb{% - \ifx[\@tempa - \def\@tempc[####1]####2{{#1{####1}{####2}}}% - \else - \def\@tempc####1{{#1{}{####1}}}% - \fi - \@tempc - }% - \futurelet\@tempa - \@tempb -} - -\let\fc@call\fc@call@opt@arg@first +\ifcsundef{fc@@pot@shortscalefrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@@pot@shortscalefrench'}} % \end{macrocode} -% User API. -% -% \DescribeMacro{\@latinnumeralstringnum} Macro \cs{@latinnumeralstringnum}. Arguments as -% follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&local options\\ -% \#2& input number -% \end{tabularx} +% Arguments as follows --- same interface as for \cs{fc@@pot@longscalefrench}:\interface % \begin{macrocode} -\newcommand*{\@latinnumeralstringnum}[2]{% - \setkeys{fcprefix}{#1}% - \fc@@latin@numeral@pefix{#2}\@tempa - \@tempa -} +\def\fc@@pot@shortscalefrench#1#2#3{% + {% % \end{macrocode} -% Arguments as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&local options\\ -% \#2&input counter -% \end{tabularx} +% First save input arguments \texttt{\#1}, \texttt{\#2}, and \texttt{\#3} into local macros +% respectively \cs{@tempa}, \cs{@tempb}, \cs{@tempc} and \cs{@tempd}. % \begin{macrocode} -\newcommand*{\@latinnumeralstring}[2]{% - \setkeys{fcprefix}{#1}% - \expandafter\let\expandafter - \@tempa\expandafter\csname c@#2\endcsname - \expandafter\fc@@latin@numeral@pefix\expandafter{\the\@tempa}\@tempa - \@tempa -} + \edef\@tempb{\number#1}% % \end{macrocode} +% And let \cs{count1} be the plural value. % \begin{macrocode} -\newcommand*{\latinnumeralstring}{% - \fc@call\@latinnumeralstring -} + \count1=\@tempb % \end{macrocode} +% Now, let \cs{count2} be the integer \(n\) generating the pseudo latin prefix, i.e. \(n\) is such that \(w = +% 3\times n + 3\). % \begin{macrocode} -\newcommand*{\latinnumeralstringnum}{% - \fc@call\@latinnumeralstringnum -} + \count2\count0 % + \divide\count2 by 3 % + \advance\count2 by -1 % % \end{macrocode} -\iffalse Local variables: \fi -\iffalse mode: docTeX \fi -\iffalse End: \fi -%\iffalse +% Here is the real job, the formatted power of ten will go to \cs{@tempe}, and its power type will go to +% \cs{@temph}. Please remember that the power type is an index in \([0\intv 2]\) indicating whether \(10^w\) +% is formatted as \meta{nothing}, ``mil(le)'' or ``\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)''. % \begin{macrocode} -% + \ifnum\count0>0 % If weight>=3, i.e we do have to append thousand or n-illion(s)/n-illiard(s) + \ifnum\count1>0 % we have at least one thousand/n-illion/n-illiard + \ifnum\count2=0 % + \def\@temph{1}% + \count1=\fc@frenchoptions@mil@plural\space + \edef\@tempe{% + mil% + \fc@@do@plural@mark\fc@frenchoptions@mil@plural@mark + }% + \else + \def\@temph{2}% + % weight >= 6 + \expandafter\fc@@latin@cardinal@pefix\expandafter{\the\count2}\@tempg + \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space + \edef\@tempe{% + \noexpand\fc@case + \@tempg + illion% + \fc@@do@plural@mark s% + \noexpand\@nil + }% + \fi + \else % \end{macrocode} -%\fi -%\iffalse +% Here we have \(d=0\), so nothing is to be formatted for \(d\times 10^w\). % \begin{macrocode} -%<*fmtcount.sty> + \def\@temph{0}% + \let\@tempe\@empty + \fi + \else % \end{macrocode} -%\fi -%\subsection{fmtcount.sty} -% This section deals with the code for |fmtcount.sty| +% Here \(w=0\). % \begin{macrocode} -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fmtcount}[2014/07/18 v3.00] -\RequirePackage{ifthen} -\RequirePackage{keyval} -\RequirePackage{etoolbox} -\RequirePackage{fcprefix} + \def\@temph{0}% + \let\@tempe\@empty + \fi +% now place into \@cs{@tempa} the assignment of results \cs{@temph} and \cs{@tempe} to to \texttt{\#2} and +% \texttt{\#3} for further propagation after closing brace. +% \begin{macrocode} + \expandafter\toks\expandafter1\expandafter{\@tempe}% + \toks0{#2}% + \edef\@tempa{\the\toks0 \@temph \def\noexpand#3{\the\toks1}}% + \expandafter + }\@tempa +} % \end{macrocode} -% \changes{3.00}{2014-07-18}{Add \cs{RequirePackage} for \texttt{ifxetex}} +% \DescribeMacro{\fc@@pot@recursivefrench}Macro \cs{fc@@pot@recursivefrench} is used to produce +% power of tens that are of the form ``million de milliards de milliards'' for \(10^{24}\). First we check +% that the macro is not yet defined. % \begin{macrocode} -\RequirePackage{ifxetex} +\ifcsundef{fc@@pot@recursivefrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@@pot@recursivefrench'}} % \end{macrocode} -% \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}. +% The arguments are as follows --- same interface as for \cs{fc@@pot@longscalefrench}:\interface % \begin{macrocode} -\RequirePackage{amsgen} +\def\fc@@pot@recursivefrench#1#2#3{% + {% % \end{macrocode} -% 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} +% First the input arguments are saved into local objects: \texttt{\#1} and \texttt{\#1} are respectively saved +% into \cs{@tempa} and \cs{@tempb}. % \begin{macrocode} -\providecommand*{\fmtord}[1]{\textsuperscript{#1}} + \edef\@tempb{\number#1}% + \let\@tempa\@@tempa % \end{macrocode} -%\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}. +% New get the inputs \texttt{\#1} and \texttt{\#1} into counters \cs{count0} and \cs{count1} as this is more +% practical. % \begin{macrocode} -\newcount\c@padzeroesN -\c@padzeroesN=1\relax -\providecommand*{\padzeroes}[1][17]{\c@padzeroesN=#1} + \count1=\@tempb\space % \end{macrocode} -%\end{macro} -% -%\begin{macro}{\FCloadlang} -%\changes{2.0}{2012-06-18}{new} -%\changes{2.02}{2012-10-24}{ensured catcode for @ set to `letter' -%before loading file} -%\begin{definition} -%\cs{FCloadlang}\marg{language} -%\end{definition} -% Load \styfmt{fmtcount} language file, -% \texttt{fc-}\meta{language}\texttt{.def}, unless already loaded. -% Unfortunately neither \styfmt{babel} nor \styfmt{polyglossia} keep a list of loaded -% dialects, so we can't load all the necessary def files in the -% preamble as we don't know which dialects the user requires. -% Therefore the dialect definitions get loaded when a command such -% as \cs{ordinalnum} is used, if they -% haven't already been loaded. +% Now compute into \cs{count2} how many times ``de milliards'' has to be repeated. % \begin{macrocode} -\newcount\fc@tmpcatcode -\def\fc@languages{}% -\def\fc@mainlang{}% -\newcommand*{\FCloadlang}[1]{% - \@FC@iflangloaded{#1}{}% - {% - \fc@tmpcatcode=\catcode`\@\relax - \catcode `\@ 11\relax - \InputIfFileExists{fc-#1.def}% - {% - \ifdefempty{\fc@languages}% - {% - \gdef\fc@languages{#1}% + \ifnum\count1>0 % + \count2\count0 % + \divide\count2 by 9 % + \advance\count2 by -1 % + \let\@tempe\@empty + \edef\@tempf{\fc@frenchoptions@supermillion@dos + de\fc@frenchoptions@supermillion@dos\fc@case milliards\@nil}% + \count11\count0 % + \ifnum\count2>0 % + \count3\count2 % + \count3-\count3 % + \multiply\count3 by 9 % + \advance\count11 by \count3 % + \loop + % (\count2, \count3) <- (\count2 div 2, \count2 mod 2) + \count3\count2 % + \divide\count3 by 2 % + \multiply\count3 by 2 % + \count3-\count3 % + \advance\count3 by \count2 % + \divide\count2 by 2 % + \ifnum\count3=1 % + \let\@tempg\@tempe + \edef\@tempe{\@tempg\@tempf}% + \fi + \let\@tempg\@tempf + \edef\@tempf{\@tempg\@tempg}% + \ifnum\count2>0 % + \repeat + \fi + \divide\count11 by 3 % + \ifcase\count11 % 0 .. 5 + % 0 => d milliard(s) (de milliards)* + \def\@temph{2}% + \count10=\csname fc@frenchoptions@n-illiard@plural\endcsname\space + \or % 1 => d mille milliard(s) (de milliards)* + \def\@temph{1}% + \count10=\fc@frenchoptions@mil@plural\space + \or % 2 => d million(s) (de milliards)* + \def\@temph{2}% + \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space + \or % 3 => d milliard(s) (de milliards)* + \def\@temph{2}% + \count10=\csname fc@frenchoptions@n-illiard@plural\endcsname\space + \or % 4 => d mille milliards (de milliards)* + \def\@temph{1}% + \count10=\fc@frenchoptions@mil@plural\space + \else % 5 => d million(s) (de milliards)* + \def\@temph{2}% + \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space + \fi + \let\@tempg\@tempe + \edef\@tempf{% + \ifcase\count11 % 0 .. 5 + \or + mil\fc@@do@plural@mark \fc@frenchoptions@mil@plural@mark + \or + million\fc@@do@plural@mark s% + \or + milliard\fc@@do@plural@mark s% + \or + mil\fc@@do@plural@mark\fc@frenchoptions@mil@plural@mark + \noexpand\@nil\fc@frenchoptions@supermillion@dos + \noexpand\fc@case milliards% 4 + \or + million\fc@@do@plural@mark s% + \noexpand\@nil\fc@frenchoptions@supermillion@dos + de\fc@frenchoptions@supermillion@dos\noexpand\fc@case milliards% 5 + \fi }% - {% - \gappto\fc@languages{,#1}% + \edef\@tempe{% + \ifx\@tempf\@empty\else + \expandafter\fc@case\@tempf\@nil + \fi + \@tempg }% - \gdef\fc@mainlang{#1}% - }% - {}% - \catcode `\@ \fc@tmpcatcode\relax - }% -} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\@FC@iflangloaded} -%\changes{2.0}{2012-06-18}{new} -%\begin{definition} -%\cs{@FC@iflangloaded}\marg{language}\marg{true}\marg{false} -%\end{definition} -%If fmtcount language definition file \texttt{fc-}\meta{language}\texttt{.def} has -%been loaded, do \meta{true} otherwise do \meta{false} -% \begin{macrocode} -\newcommand{\@FC@iflangloaded}[3]{% - \ifcsundef{ver@fc-#1.def}{#3}{#2}% -} + \else + \def\@temph{0}% + \let\@tempe\@empty + \fi % \end{macrocode} -%\end{macro} -%\begin{macro}{\ProvidesFCLanguage} -%\changes{2.0}{2012-06-18}{new} -% Declare fmtcount language definition file. Adapted from -% \ics{ProvidesFile}. +% now place into \@cs{@tempa} the assignment of results \cs{@temph} and \cs{@tempe} to to \texttt{\#2} and +% \texttt{\#3} for further propagation after closing brace. % \begin{macrocode} -\newcommand*{\ProvidesFCLanguage}[1]{% - \ProvidesFile{fc-#1.def}% + \expandafter\toks\expandafter1\expandafter{\@tempe}% + \toks0{#2}% + \edef\@tempa{\the\toks0 \@temph \def\noexpand#3{\the\toks1}}% + \expandafter + }\@tempa } % \end{macrocode} -%\end{macro} -% -% We need that flag to remember that a language has been loaded via package option, so that in the end we can -% set \styfmt{fmtcount} in multiling +% \DescribeMacro{\fc@muladdfrench}Macro \cs{fc@muladdfrench} is used to format the sum of a number \(a\) and +% the product of a number \(d\) by a power of ten \(10^w\). Number \(d\) is made of three consecutive digits +% \(d_{w+2}d_{w+1}d_w\) of respective weights \(w+2\), \(w+1\), and \(w\), while number \(a\) is made of all +% digits with weight \(w' > w+2\) that have already been formatted. First check that the macro is not yet +% defined. % \begin{macrocode} -\newif\iffmtcount@language@option -\fmtcount@language@optionfalse +\ifcsundef{fc@muladdfrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@muladdfrench'}} % \end{macrocode} -%\begin{macro}{\fc@supported@language@list} -% Declare list of supported languages, as a comma separated list. No space, no empty items. Each item is a -% language for which fmtcount is able to load language specific definitions. The raison d'\^etre of this -% list is to commonalize iteration on languages for the two following purposes: -% \begin{itemize} -% \item loading language definition as a result of the language being used by -% \styfmt{babel}/\styfmt{polyglossia} -% \item loading language definition as a result of package option -% \end{itemize} -% These two purposes cannot be handled in the same pass, we need two different passes otherwise there would -% be some corner cases when a package would be required --- as a result of loading language definition for -% one language --- between a \cs{DeclareOption} and a \cs{ProcessOption} which is forbidden by \LaTeXe. -%\changes{3.00}{2014-07-18}{new} -% \begin{macrocode} -\newcommand*\fc@supported@language@list{% -english,% -UKenglish,% -british,% -USenglish,% -american,% -spanish,% -portuges,% -french,% -frenchb,% -francais,% -german,% -germanb,% -ngerman,% -ngermanb,% -italian} +% Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#2&input, plural indicator for number \(d\)\\ +% \#3&input, formatted number \(d\)\\ +% \#5&input, formatted number \(10^w\), i.e. power of ten which is multiplied by \(d\)\\ +% \end{tabularx} +% Implicit arguments from context:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \cs{@tempa}&input, formatted number \(a\)\\ +% &output, macro to which place the mul-add result\\ +% \cs{count8}&input, power type indicator for \(10^{w'}\), where \(w'\) is a weight of \(a\), this is an +% index in \([0\intv 2]\) that reflects whether \(10^{w'}\) is formatted by ``mil(le)'' --- for index \(=1\) +% --- or by ``\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)'' --- for index \(=2\)\\ +% \cs{count9}&input, power type indicator for \(10^w\), this is an index in \([0\intv 2]\) that reflect +% whether the weight \(w\) of \(d\) is formatted by ``meta{nothing}'' --- for index \(=0\), ``mil(le)'' --- +% for index +% \(=1\) --- or by ``\meta{$n$}illion(s)\textbar \meta{$n$}illiard(s)'' --- for index \(=2\)\\ +% \end{tabularx} +% \begin{macrocode} +\def\fc@muladdfrench#1#2#3{% + {% % \end{macrocode} -%\end{macro} -%\begin{macro}{\fc@iterate@on@languages} -%\begin{definition} -%\cs{fc@iterate@on@languages}\marg{body} -%\end{definition} -% Now make some language iterator, note that for the following to work properly -% \cs{fc@supported@language@list} must not be empty. \meta{body} is a macro that takes one argument, and -% \cs{fc@iterate@on@languages} applies it iteratively : -%\changes{3.00}{2014-07-18}{new} +% First we save input arguments \texttt{\#1} -- \texttt{\#3} to local macros \cs{@tempc}, \cs{@tempd} and +% \cs{@tempf}. % \begin{macrocode} -\newcommand*\fc@iterate@on@languages[1]{% - \ifx\fc@supported@language@list\@empty + \edef\@@tempc{#1}% + \edef\@@tempd{#2}% + \edef\@tempf{#3}% + \let\@tempc\@@tempc + \let\@tempd\@@tempd % \end{macrocode} -% That case should never happen ! +% First we want to do the ``multiplication'' of \(d \Rightarrow \cs{@tempd}\) and of \(10^w \Rightarrow +% \cs{@tempf}\). So, prior to this we do some preprocessing of \(d \Rightarrow \cs{@tempd}\): we force +% \cs{@tempd} to \meta{empty} if both \(d=1\) and \(10^w\Rightarrow\) ``mil(le)'', this is because we, +% French, we do not say ``un mil'', but just ``mil''. % \begin{macrocode} - \PackageError{fmtcount}{Macro `\protect\@fc@iterate@on@languages' is empty}{You should never get here: - Something is broken within \texttt{fmtcount}, please report the issue on - \texttt{https://github.com/search?q=fmtcount\&ref=cmdform\&type=Issues}}% - \else - \let\fc@iterate@on@languages@body#1 - \expandafter\@fc@iterate@on@languages\fc@supported@language@list,\@nil,% - \fi -} -\def\@fc@iterate@on@languages#1,{% - {% - \def\@tempa{#1}% - \ifx\@tempa\@nnil - \let\@tempa\@empty - \else - \def\@tempa{% - \fc@iterate@on@languages@body{#1}% - \@fc@iterate@on@languages - }% + \ifnum\@tempc=1 % + \ifnum\count9=1 % + \let\@tempd\@empty \fi - \expandafter - }\@tempa -}% + \fi % \end{macrocode} -%\end{macro} -%\begin{macro}{\@fc@loadifbabelorpolyglossialdf} -%\begin{definition} -%\cs{@fc@loadifbabelorpolyglossialdf}\marg{language} -%\end{definition} -%Loads fmtcount language file, -%\texttt{fc-}\meta{language}\texttt{.def}, -% if one of the following condition is met: -% \begin{itemize} -% \item \styfmt{babel} language definition file \meta{language}\texttt{.ldf} has been loaded --- conditionally -% to compilation with \texttt{latex}, not \texttt{xelatex}. -% \item \styfmt{polyglossia} language definition file \texttt{gloss-}\meta{language}\texttt{.ldf} has been -% loaded --- conditionally to compilation with \texttt{xelatex}, not \texttt{latex}. -% \item \meta{language} option has been passed to package \styfmt{fmtcount}. -% \end{itemize} -% -%\changes{2.03}{2012-11-11}{renamed \cs{@fc@loadifbabelldf} to -% \cs{@fc@loadifbabelorpolyglossialdf}} -%\changes{2.03}{2012-11-11}{added check for polyglossia language} -%\changes{3.00}{2014-07-18}{use \cs{ifxetex} to discriminate between \styfmt{babel} and \styfmt{polyglossia}} +% Now we do the ``multiplication'' of \(d = \cs{@tempd}\) and of \(10^w = \cs{@tempf}\), and place the result +% into \cs{@tempg}. % \begin{macrocode} -\newcommand*{\@fc@loadifbabelorpolyglossialdf}[1]{% - \ifxetex - \IfFileExists{gloss-#1.ldf}{\ifcsundef{#1@loaded}{}{\FCloadlang{#1}}}{}% - \else - \ifcsundef{ver@#1.ldf}{}{\FCloadlang{#1}}% - \fi -} + \edef\@tempg{% + \@tempd + \ifx\@tempd\@empty\else + \ifx\@tempf\@empty\else + \ifcase\count9 % + \or + \fc@frenchoptions@submillion@dos + \or + \fc@frenchoptions@supermillion@dos + \fi + \fi + \fi + \@tempf + }% % \end{macrocode} -%\end{macro} -% -% Load appropriate language definition files: -%\changes{1.1}{14 June 2007}{added check for UKenglish, -% british and USenglish babel settings} -%\changes{2.0}{2012-06-18}{changed check for \cs{l@}\meta{language} -% to check for \cs{date}\meta{language}} -%\changes{3.00}{2014-07-18}{use iterator rather than doing it flat on each language} +% Now to the ``addition'' of \(a\Rightarrow \cs{@tempa}\) and \(d\times 10^w\Rightarrow \cs{@tempg}\), and +% place the results into \cs{@temph}. % \begin{macrocode} -\fc@iterate@on@languages\@fc@loadifbabelorpolyglossialdf + \edef\@temph{% + \@tempa + \ifx\@tempa\@empty\else + \ifx\@tempg\@empty\else + \ifcase\count8 % + \or + \fc@frenchoptions@submillion@dos + \or + \fc@frenchoptions@supermillion@dos + \fi + \fi + \fi + \@tempg + }% +% \end{macrocode} +% Now propagate the result --- i.e. the expansion of \cs{@temph} --- into macro \cs{@tempa} after closing +% brace. +% \begin{macrocode} + \def\@tempb##1{\def\@tempa{\def\@tempa{##1}}}% + \expandafter\@tempb\expandafter{\@temph}% + \expandafter + }\@tempa +}% % \end{macrocode} -%\begin{macro}{\fmtcount@french} -% Define keys for use with |\fmtcountsetoptions|. Key to switch French dialects (Does \styfmt{babel} store -% this kind of information?) +% \DescribeMacro{\fc@lthundredstringfrench}Macro \cs{fc@lthundredstringfrench} is used to format a number in +% interval \([0 \intv 99]\). First we check that it is not already defined. % \begin{macrocode} -\def\fmtcount@french{france} +\ifcsundef{fc@lthundredstringfrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@lthundredstringfrench'}} % \end{macrocode} -%\end{macro} -%\begin{option}{french} +% The number to format is not passed as an argument to this macro, instead each digits of it is in a +% \cs{fc@digit@\meta{w}} macro after this number has been parsed. So the only thing that +% \cs{fc@lthundredstringfrench} needs is to know \meta{w} which is passed as \cs{count0} for the less +% significant digit.\newline +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&intput/output macro to which append the result +% \end{tabularx} +% Implicit input arguments as follows:\newline +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \cs{count0}&weight \(w\) of least significant digit \(d_{w}\). +% \end{tabularx} +% The formatted number is appended to the content of \#1, and the result is placed into \#1. % \begin{macrocode} -\define@key{fmtcount}{french}[france]{% - \@FC@iflangloaded{french}% - {% - \setkeys{fcfrench}{#1}% - }% +\def\fc@lthundredstringfrench#1{% {% - \PackageError{fmtcount}% - {Language `french' not defined}% - {You need to load babel before loading fmtcount}% - }% -} % \end{macrocode} -%\end{option} -%\begin{option}{fmtord} -% Key to determine how to display the ordinal +% First save arguments into local temporary macro. % \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'}% - }% -} + \let\@tempc#1% % \end{macrocode} -%\end{option} -%\begin{macro}{\iffmtord@abbrv} -% Key to determine whether the ordinal should be abbreviated -% (language dependent, currently only affects French ordinals.) +% Read units \(d_w\) to \cs{count1}. % \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'}% - }% -} + \fc@read@unit{\count1}{\count0}% % \end{macrocode} -%\end{macro} -%\begin{option}{prefix} -%\changes{2.0}{2012-06-18}{new} +% Read tens \(d_{w+1}\) to \cs{count2}. % \begin{macrocode} -\define@key{fmtcount}{prefix}[scale=long]{% - \RequirePackage{fmtprefix}% - \fmtprefixsetoption{#1}% -} + \count3\count0 % + \advance\count3 1 % + \fc@read@unit{\count2}{\count3}% % \end{macrocode} -%\end{option} -%\begin{macro}{\fmtcountsetoptions} -% Define command to set options. +% Now do the real job, set macro \cs{@tempa} to \texttt{\#1} followed by \(d_{w+1}d_w\) formatted. % \begin{macrocode} -\newcommand*{\fmtcountsetoptions}[1]{% - \def\fmtcount@fmtord{}% - \setkeys{fmtcount}{#1}% - \@FC@iflangloaded{french}{\ifcsundef{@ordinalstringMfrench}% - {% - \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}}% - }% - {% + \edef\@tempa{% + \@tempc + \ifnum\count2>1 % + % 20 .. 99 + \ifnum\count2>6 % + % 70 .. 99 + \ifnum\count2<8 % + % 70 .. 79 + \@seventies{\count1}% + \else + % 80..99 + \ifnum\count2<9 % + % 80 .. 89 + \@eighties{\count1}% + \else + % 90 .. 99 + \@nineties{\count1}% + \fi + \fi + \else + % 20..69 + \@tenstring{\count2}% + \ifnum\count1>0 % + % x1 .. x0 + \ifnum\count1=1 % + % x1 + \fc@frenchoptions@submillion@dos\@andname\fc@frenchoptions@submillion@dos + \else + % x2 .. x9 + -% + \fi + \@unitstring{\count1}% + \fi + \fi + \else + % 0 .. 19 + \ifnum\count2=0 % when tens = 0 + % 0 .. 9 + \ifnum\count1=0 % when units = 0 + % \count3=1 when #1 = 0, i.e. only for the unit of the top level number + \ifnum\count3=1 % + \ifnum\fc@max@weight=0 % + \@unitstring{0}% + \fi + \fi + \else + % 1 .. 9 + \@unitstring{\count1}% + \fi + \else + % 10 .. 19 + \@teenstring{\count1}% + \fi + \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. -%\changes{2.0}{2012-06-18}{Now no message if fmtcount.cfg not found} +% Now propagate the expansion of \cs{@tempa} into \texttt{\#1} after closing brace. % \begin{macrocode} -\InputIfFileExists{fmtcount.cfg}% -{% - \PackageInfo{fmtcount}{Using configuration file fmtcount.cfg}% -}% -{% + \def\@tempb##1{\def\@tempa{\def#1{##1}}}% + \expandafter\@tempb\expandafter{\@tempa}% + \expandafter + }\@tempa } % \end{macrocode} -%\begin{option}{\meta{language}} -% \begin{macrocode} -\newcommand*\@fc@declare@language@option[1]{% - \DeclareOption{#1}{% - \@FC@iflangloaded{#1}{}{% - \fmtcount@language@optiontrue - \FCloadlang{#1}% - }}}% -\fc@iterate@on@languages\@fc@declare@language@option -% \end{macrocode} -%\end{option} -% -%\begin{option}{level} -% \begin{macrocode} -\DeclareOption{level}{\def\fmtcount@fmtord{level}% - \def\fmtord#1{#1}} -% \end{macrocode} -%\end{option} -%\begin{option}{raise} +% \DescribeMacro{\fc@ltthousandstringfrench}Macro \cs{fc@ltthousandstringfrench} is used to format a number in +% interval \([0 \intv 999]\). First we check that it is not already defined. % \begin{macrocode} -\DeclareOption{raise}{\def\fmtcount@fmtord{raise}% - \def\fmtord#1{\textsuperscript{#1}}} +\ifcsundef{fc@ltthousandstringfrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@ltthousandstringfrench'}} % \end{macrocode} -%\end{option} -% Process package options -% \changes{3.00}{2014-07-18}{Add \cs{relax} after \cs{ProcessOptions} like shown in \texttt{clsguide.pdf}} +% Output is empty for 0. Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#2&output, macro, formatted number \(d = d_{w+2}d_{w+1}d_w\) +% \end{tabularx} +% Implicit input arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \cs{count0}&input weight \(10^{w}\) of number \(d_{w+2}d_{w+1}d_w\) to be formatted.\\ +% \cs{count5}&least weight of formatted number with a non null digit.\\ +% \cs{count9}&input, power type indicator of \(10^{w}\) \(0\Rightarrow\varnothing\), \(1\Rightarrow\textrm { +% ``mil(le)''}\), \(2\Rightarrow\textrm {\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)}\)\\ +% \end{tabularx} % \begin{macrocode} -\ProcessOptions\relax +\def\fc@ltthousandstringfrench#1{% + {% % \end{macrocode} -%\begin{macro}{\@FCmodulo} -%\begin{definition} -%\cs{@FCmodulo}\marg{count reg}\marg{n} -%\end{definition} -%\changes{2.04}{2014-06-09}{renamed \cs{@modulo} to \cs{@FCmodulo}} -% Sets the count register to be its value modulo \meta{n}. -% This is used for the -% date, time, ordinal and numberstring commands. (The -% \styfmt{fmtcount} package was originally part of the -% \sty{datetime} package.) +% Set counter \cs{count2} to digit \(d_{w+2}\), i.e. hundreds. % \begin{macrocode} -\newcount\@DT@modctr -\newcommand*{\@FCmodulo}[2]{% - \@DT@modctr=#1\relax - \divide \@DT@modctr by #2\relax - \multiply \@DT@modctr by #2\relax - \advance #1 by -\@DT@modctr -} + \count4\count0 % + \advance\count4 by 2 % + \fc@read@unit{\count2 }{\count4 }% % \end{macrocode} -%\end{macro} -% The following registers are needed by |\@ordinal| etc +% Check that the two subsequent digits \(d_{w+1}d_w\) are non zero, place check-result into \cs{@tempa}. % \begin{macrocode} -\newcount\@ordinalctr -\newcount\@orgargctr -\newcount\@strctr -\newcount\@tmpstrctr + \advance\count4 by -1 % + \count3\count4 % + \advance\count3 by -1 % + \fc@check@nonzeros{\count3 }{\count4 }\@tempa % \end{macrocode} -%Define commands that display numbers in different bases. -% Define counters and conditionals needed. +% Compute plural mark of `cent' into \cs{@temps}. % \begin{macrocode} -\newif\if@DT@padzeroes -\newcount\@DT@loopN -\newcount\@DT@X + \edef\@temps{% + \ifcase\fc@frenchoptions@cent@plural\space + % 0 => always + s% + \or + % 1 => never + \or + % 2 => multiple + \ifnum\count2>1s\fi + \or + % 3 => multiple g-last + \ifnum\count2>1 \ifnum\@tempa=0 \ifnum\count0=\count6s\fi\fi\fi + \or + % 4 => multiple l-last + \ifnum\count2>1 \ifnum\@tempa=0 \ifnum\count9=0s\else\ifnum\count9=2s\fi\fi\fi\fi + \fi + }% + % compute spacing after cent(s?) into \@tempb + \expandafter\let\expandafter\@tempb + \ifnum\@tempa>0 \fc@frenchoptions@submillion@dos\else\@empty\fi + % now place into \@tempa the hundreds + \edef\@tempa{% + \ifnum\count2=0 % + \else + \ifnum\count2=1 % + \expandafter\fc@case\@hundred\@nil + \else + \@unitstring{\count2}\fc@frenchoptions@submillion@dos + \noexpand\fc@case\@hundred\@temps\noexpand\@nil + \fi + \@tempb + \fi + }% + % now append to \@tempa the ten and unit + \fc@lthundredstringfrench\@tempa % \end{macrocode} -%\begin{macro}{\binarynum} -% Converts a decimal number to binary, and display. +% Propagate expansion of \cs{@tempa} into macro \texttt{\#1} after closing brace. % \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 + \def\@tempb##1{\def\@tempa{\def#1{##1}}}% + \expandafter\@tempb\expandafter{\@tempa}% + \expandafter + }\@tempa } - -\let\binarynum=\@binary % \end{macrocode} -%\end{macro} -%\begin{macro}{\octalnum} -% Converts a decimal number to octal, and displays. +% \DescribeMacro{\@@numberstringfrench}Macro \cs{@@numberstringfrench} is the main engine for formatting +% cadinal numbers in French. First we check that the control sequence is not yet defined. % \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 +\ifcsundef{@@numberstringfrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro `@@numberstringfrench'}} % \end{macrocode} -%\end{macro} -%\begin{macro}{\@@hexadecimalnum} -% Converts number from 0 to 15 into lowercase hexadecimal notation. +% Arguments are as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&number to convert to string\\ +% \#2¯o into which to place the result +% \end{tabularx} % \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 -} +\def\@@numberstringfrench#1#2{% + {% % \end{macrocode} -%\end{macro} -%\begin{macro}{\hexadecimalnum} -% Converts a decimal number to a lowercase hexadecimal number, -% and displays it. +% First parse input number to be formatted and do some error handling. % \begin{macrocode} -\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 + \edef\@tempa{#1}% + \expandafter\fc@number@parser\expandafter{\@tempa}% + \ifnum\fc@min@weight<0 % + \PackageError{fmtcount}{Out of range}% + {This macro does not work with fractional numbers}% + \fi % \end{macrocode} -%\end{macro} -%\begin{macro}{\@@Hexadecimalnum} -% Converts number from 0 to 15 into uppercase hexadecimal notation. +% In the sequel, \cs{@tempa} is used to accumulate the formatted number. Please note that \cs{space} after +% \cs{fc@sign@case} is eaten by preceding number collection. This \cs{space} is needed so that when +% \cs{fc@sign@case} expands to `\texttt{0}', then \cs{@tempa} is defined to `' (i.e. empty) rather than to +% `\cs{relax}'. % \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 -} + \edef\@tempa{\ifcase\fc@sign@case\space\or\fc@case plus\@nil\or\fc@case moins\@nil\fi}% + \fc@nbrstr@preamble + \fc@@nbrstrfrench@inner + \fc@nbrstr@postamble % \end{macrocode} -%\end{macro} -%\begin{macro}{\Hexadecimalnum} -% Uppercase hexadecimal +% Propagate the result --- i.e. expansion of \cs{@tempa} --- into macro \texttt{\#2} after closing brace. % \begin{macrocode} -\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 + \def\@tempb##1{\def\@tempa{\def#2{##1}}}% + \expandafter\@tempb\expandafter{\@tempa}% + \expandafter + }\@tempa } - -\let\Hexadecimalnum=\@Hexadecimal % \end{macrocode} -%\end{macro} -%\begin{macro}{\aaalphnum} -% Lowercase alphabetical representation (a \ldots\ z aa \ldots\ zz) +% \DescribeMacro{\fc@@nbrstrfrench@inner}Common part of \cs{@@numberstringfrench} and \cs +% {@@ordinalstringfrench}. Arguments are as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \cs{@tempa}&input/output, macro to which the result is to be aggregated, initially empty or contains the +% sign indication.\\ +% \end{tabularx} % \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 +\def\fc@@nbrstrfrench@inner{% % \end{macrocode} -%\end{macro} -%\begin{macro}{\AAAlphnum} -% Uppercase alphabetical representation (a \ldots\ z aa \ldots\ zz) +% Now loop, first we compute starting weight as +% \(3\times\left\lfloor\frac{\cs{fc@max@weight}}{3}\right\rfloor\) into \cs{count0}. % \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 + \count0=\fc@max@weight + \divide\count0 by 3 % + \multiply\count0 by 3 % % \end{macrocode} -%\end{macro} -%\begin{macro}{\abalphnum} -% Lowercase alphabetical representation +% Now we compute final weight into \cs{count5}, and round down to multiple of \(3\) into +% \cs{count6}. Warning: \cs{count6} is an implicit input argument to macro \cs{fc@ltthousandstringfrench}. % \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 + \fc@intpart@find@last{\count5 }% + \count6\count5 % + \divide\count6 3 % + \multiply\count6 3 % + \count8=0 % \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}{\ABAlphnum} -% Uppercase alphabetical representation +% First we check whether digits in weight interval \([w \intv (w+2)]\) are all zero and place check result +% into macro \cs{@tempt}. % \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 + \count1\count0 % + \advance\count1 by 2 % + \fc@check@nonzeros{\count0 }{\count1 }\@tempt +% \end{macrocode} +% Now we generate the power of ten \(10^w\), formatted power of ten goes to \cs{@tempb}, while power type +% indicator goes to \cs{count9}. +% \begin{macrocode} + \fc@poweroften\@tempt{\count9 }\@tempb +% \end{macrocode} +% Now we generate the formatted number \(d\) into macro \cs{@tempd} by which we need to multiply +% \(10^w\). Implicit input argument is \cs{count9} for power type of \(10^9\), and \cs{count6} +% \begin{macrocode} + \fc@ltthousandstringfrench\@tempd +% \end{macrocode} +% Finally do the multiplication-addition. Implicit arguments are \cs{@tempa} for input/output growing +% formatted number, \cs{count8} for input previous power type, i.e. power type of \(10^{w+3}\), \cs{count9} +% for input current power type, i.e. power type of \(10^w\). +% \begin{macrocode} + \fc@muladdfrench\@tempt\@tempd\@tempb +% \end{macrocode} +% Then iterate. +% \begin{macrocode} + \count8\count9 % + \advance\count0 by -3 % + \ifnum\count6>\count0 \else \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. -% \cs{@strctr} should be set to zero before calling it. +% \DescribeMacro{\@@ordinalstringfrench}Macro \cs{@@ordinalstringfrench} is the main engine for formatting +% ordinal numbers in French. First check it is not yet defined. % \begin{macrocode} -\def\@fmtc@count#1#2\relax{% - \if\relax#1% - \else - \advance\@strctr by 1\relax - \@fmtc@count#2\relax - \fi -} +\ifcsundef{@@ordinalstringfrench}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `@@ordinalstringfrench'}} % \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. +% Arguments are as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&number to convert to string\\ +% \#2¯o into which to place the result +% \end{tabularx} % \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 +\def\@@ordinalstringfrench#1#2{% + {% % \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. +% First parse input number to be formatted and do some error handling. % \begin{macrocode} -\newcommand{\FCordinal}[1]{% - \expandafter\protect\expandafter\ordinalnum{% - \expandafter\the\csname c@#1\endcsname}% -} + \edef\@tempa{#1}% + \expandafter\fc@number@parser\expandafter{\@tempa}% + \ifnum\fc@min@weight<0 % + \PackageError{fmtcount}{Out of range}% + {This macro does not work with fractional numbers}% + \fi + \ifnum\fc@sign@case>0 % + \PackageError{fmtcount}{Out of range}% + {This macro does with negative or explicitly marked as positive numbers}% + \fi % \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. -% \changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageWarning} to quote macros like -% shown in \texttt{clsguide.pdf}} +% Now handle the special case of first. We set \cs{count0} to \texttt{1} if we are in this case, and to +% \texttt{0} otherwise % \begin{macrocode} -\ifcsundef{ordinal} - {\let\ordinal\FCordinal}% - {% - \PackageWarning{fmtcount}% - {\protect\ordinal \space already defined use - \protect\FCordinal \space instead.} - } + \ifnum\fc@max@weight=0 % + \ifnum\csname fc@digit@0\endcsname=1 % + \count0=1 % + \else + \count0=0 % + \fi + \else + \count0=0 % + \fi + \ifnum\count0=1 % % \end{macrocode} -%\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}} +% \changes{3.01}{2014-11-10}{Protect \cs{`}, for solving +% \uref{http://github.com/nlct/fmtcount/issues/15}{Issue \#15}} % \begin{macrocode} -\newcommand*{\ordinalnum}[1]{% - \new@ifnextchar[% - {\@ordinalnum{#1}}% - {\@ordinalnum{#1}[m]}% -} + \protected@edef\@tempa{\expandafter\fc@case\fc@first\@nil}% + \else % \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}): +% Now we tamper a little bit with the plural handling options to ensure that there is no final plural mark. % \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}% + \def\@tempa##1{% + \expandafter\edef\csname fc@frenchoptions@##1@plural\endcsname{% + \ifcase\csname fc@frenchoptions@##1@plural\endcsname\space + 0% 0: always => always + \or + 1% 1: never => never + \or + 6% 2: multiple => multiple ng-last + \or + 1% 3: multiple g-last => never + \or + 5% 4: multiple l-last => multiple lng-last + \or + 5% 5: multiple lng-last => multiple lng-last + \or + 6% 6: multiple ng-last => multiple ng-last + \fi }% - \protect\@ordinalM{#1}{\@fc@ordstr}% }% - }% - \@fc@ordstr - }% -} + \@tempa{vingt}% + \@tempa{cent}% + \@tempa{mil}% + \@tempa{n-illion}% + \@tempa{n-illiard}% % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeordinal} -% Store the ordinal (first argument -% is identifying name, second argument is a counter.) +% Now make \cs{fc@case} and \cs{@nil} non expandable % \begin{macrocode} -\newcommand*{\storeordinal}[2]{% - \expandafter\protect\expandafter\storeordinalnum{#1}{% - \expandafter\the\csname c@#2\endcsname}% -} + \let\fc@case@save\fc@case + \def\fc@case{\noexpand\fc@case}% + \def\@nil{\noexpand\@nil}% % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeordinalnum} -% Store ordinal (first argument -% is identifying name, second argument is a number or -% count register.) +% In the sequel, \cs{@tempa} is used to accumulate the formatted number. % \begin{macrocode} -\newcommand*{\storeordinalnum}[2]{% - \@ifnextchar[% - {\@storeordinalnum{#1}{#2}}% - {\@storeordinalnum{#1}{#2}[m]}% -} + \let\@tempa\@empty + \fc@@nbrstrfrench@inner % \end{macrocode} -%\end{macro} -%\begin{macro}{\@storeordinalnum} -% Store ordinal according to gender: +% Now restore \cs{fc@case} % \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 -} + \let\fc@case\fc@case@save % \end{macrocode} -%\end{macro} -%\begin{macro}{\FMCuse} -% Get stored information: +% Now we add the ``i\`eme'' ending +% \changes{3.01}{2014-11-10}{Protect \cs{`}, for solving +% \uref{http://github.com/nlct/fmtcount/issues/15}{Issue \#15}} % \begin{macrocode} -\newcommand*{\FMCuse}[1]{\csname @fcs@#1\endcsname} + \expandafter\fc@get@last@word\expandafter{\@tempa}\@tempb\@tempc + \expandafter\fc@get@last@letter\expandafter{\@tempc}\@tempd\@tempe + \def\@tempf{e}% + \ifx\@tempe\@tempf + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempd i\protect\`eme\@nil}% + \else + \def\@tempf{q}% + \ifx\@tempe\@tempf + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempd qui\protect\`eme\@nil}% + \else + \def\@tempf{f}% + \ifx\@tempe\@tempf + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempd vi\protect\`eme\@nil}% + \else + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempc i\protect\`eme\@nil}% + \fi + \fi + \fi + \fi % \end{macrocode} -%\end{macro} -%\begin{macro}{\ordinalstring} -% Display ordinal as a string (argument is a counter) +% Propagate the result --- i.e. expansion of \cs{@tempa} --- into macro \texttt{\#2} after closing brace. % \begin{macrocode} -\newcommand*{\ordinalstring}[1]{% - \expandafter\protect\expandafter\ordinalstringnum{% - \expandafter\the\csname c@#1\endcsname}% + \def\@tempb##1{\def\@tempa{\def#2{##1}}}% + \expandafter\@tempb\expandafter{\@tempa}% + \expandafter + }\@tempa } % \end{macrocode} -%\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}} -%\changes{1.33}{2009/10/15}{Made robust} +% Macro \cs{fc@frenchoptions@setdefaults} allows to set all options to default for the French. % \begin{macrocode} -\newcommand{\ordinalstringnum}[1]{% - \new@ifnextchar[% - {\@ordinal@string{#1}}% - {\@ordinal@string{#1}[m]}% +\newcommand*\fc@frenchoptions@setdefaults{% + \csname KV@fcfrench@all plural\endcsname{reformed}% + \def\fc@frenchoptions@submillion@dos{-}% + \let\fc@frenchoptions@supermillion@dos\space + \let\fc@u@in@duo\@empty% Could be `u' + % \let\fc@poweroften\fc@@pot@longscalefrench + \let\fc@poweroften\fc@@pot@recursivefrench + \def\fc@longscale@nilliard@upto{0}% infinity + \def\fc@frenchoptions@mil@plural@mark{le}% } +\fc@frenchoptions@setdefaults % \end{macrocode} -%\end{macro} -%\begin{macro}{\@ordinal@string} -% Display ordinal as a string according to gender. -% \changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageError} to quote macros like -% shown in \texttt{clsguide.pdf}} -% \changes{3.00}{2014-07-18}{Correct detailed error message, so `n' is one of available gender options} +% Make some indirection to call the current French dialect corresponding macro. +% \changes{3.01}{2014-12-18}{Move French specific stuff from \styfmt{fmtcount.sty} to \styfmt{fc-french.def}.} % \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 \protect\ordinalstring}% - {Available options are m, f or n}% - }% - \protect\@ordinalstringM{#1}{\@fc@ordstr}% - }% - }% - \@fc@ordstr - }% -} +\def\@ordinalstringMfrench{\csuse{@ordinalstringMfrench\fmtcount@french}}% +\def\@ordinalstringFfrench{\csuse{@ordinalstringFfrench\fmtcount@french}}% +\def\@OrdinalstringMfrench{\csuse{@OrdinalstringMfrench\fmtcount@french}}% +\def\@OrdinalstringFfrench{\csuse{@OrdinalstringFfrench\fmtcount@french}}% +\def\@numberstringMfrench{\csuse{@numberstringMfrench\fmtcount@french}}% +\def\@numberstringFfrench{\csuse{@numberstringFfrench\fmtcount@french}}% +\def\@NumberstringMfrench{\csuse{@NumberstringMfrench\fmtcount@french}}% +\def\@NumberstringFfrench{\csuse{@NumberstringFfrench\fmtcount@french}}% +% \end{macrocode} +\iffalse Local variables: \fi +\iffalse mode: docTeX \fi +\iffalse End: \fi +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*fc-frenchb.def> +% \end{macrocode} +%\fi +% \subsubsection{fc-frenchb.def} +% \begin{macrocode} +\ProvidesFCLanguage{frenchb}[2013/08/17]% +\FCloadlang{french}% +% \end{macrocode} +% Set |frenchb| to be equivalent to |french|. +% \begin{macrocode} +\global\let\@ordinalMfrenchb=\@ordinalMfrench +\global\let\@ordinalFfrenchb=\@ordinalFfrench +\global\let\@ordinalNfrenchb=\@ordinalNfrench +\global\let\@numberstringMfrenchb=\@numberstringMfrench +\global\let\@numberstringFfrenchb=\@numberstringFfrench +\global\let\@numberstringNfrenchb=\@numberstringNfrench +\global\let\@NumberstringMfrenchb=\@NumberstringMfrench +\global\let\@NumberstringFfrenchb=\@NumberstringFfrench +\global\let\@NumberstringNfrenchb=\@NumberstringNfrench +\global\let\@ordinalstringMfrenchb=\@ordinalstringMfrench +\global\let\@ordinalstringFfrenchb=\@ordinalstringFfrench +\global\let\@ordinalstringNfrenchb=\@ordinalstringNfrench +\global\let\@OrdinalstringMfrenchb=\@OrdinalstringMfrench +\global\let\@OrdinalstringFfrenchb=\@OrdinalstringFfrench +\global\let\@OrdinalstringNfrenchb=\@OrdinalstringNfrench % \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-german.def> % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@ordinal@string} -% Store textual representation of number according to gender. -% \changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageWarning} to quote macros like -% shown in \texttt{clsguide.pdf}} +%\fi +% \subsubsection{fc-german.def} +% German definitions (thank you to K. H. Fricke for supplying +% this information) % \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 \protect\ordinalstring}% - {Available options are m, f or n}% - }% - \protect\@ordinalstringM{#2}{\@fc@ordstr}% - }% - }% - \expandafter\let\csname @fcs@#1\endcsname\@fc@ordstr -} +\ProvidesFCLanguage{german}[2014/06/09]% % \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{\@ordinalMgerman}[2]{% + \edef#2{\number#1\relax.}% +}% +\global\let\@ordinalMgerman\@ordinalMgerman % \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) -%\changes{1.31}{2009/10/02}{replaced \cs{@ifnextchar} with -%\cs{new@ifnextchar}} +% Feminine: % \begin{macrocode} -\newcommand*{\Ordinalstringnum}[1]{% - \new@ifnextchar[% - {\@Ordinal@string{#1}}% - {\@Ordinal@string{#1}[m]}% -} +\newcommand{\@ordinalFgerman}[2]{% + \edef#2{\number#1\relax.}% +}% +\global\let\@ordinalFgerman\@ordinalFgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\@Ordinal@string} -% Display ordinal as a string with initial letters in upper case -% according to gender +% Neuter: % \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 - }% -} +\newcommand{\@ordinalNgerman}[2]{% + \edef#2{\number#1\relax.}% +}% +\global\let\@ordinalNgerman\@ordinalNgerman % \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 and teens. +% Units (argument must be a number from 0 to 9, 1 on its own (eins) +% is dealt with separately): % \begin{macrocode} -\newcommand*{\storeOrdinalstring}[2]{% - \expandafter\protect\expandafter\storeOrdinalstringnum{#1}{% - \expandafter\the\csname c@#2\endcsname}% -} +\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 +}% +\global\let\@@unitstringgerman\@@unitstringgerman % \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. +% Tens (argument must go from 1 to 10): % \begin{macrocode} -\newcommand*{\storeOrdinalstringnum}[2]{% - \@ifnextchar[% - {\@store@Ordinal@string{#1}{#2}}% - {\@store@Ordinal@string{#1}{#2}[m]}% -} +\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 +}% +\global\let\@@tenstringgerman\@@tenstringgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@Ordinal@string} -% Store textual representation of number according to gender, -% with initial letters in upper case. +% |\einhundert| is set to |einhundert| by default, user can +% redefine this command to just |hundert| if required, similarly +% for |\eintausend|. % \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 -} +\providecommand*{\einhundert}{einhundert}% +\providecommand*{\eintausend}{eintausend}% +\global\let\einhundert\einhundert +\global\let\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% + \fi +}% +\global\let\@@teenstringgerman\@@teenstringgerman +% \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}% +}% +\global\let\@numberstringMgerman\@numberstringMgerman +% \end{macrocode} +% Feminine and neuter forms: +% \begin{macrocode} +\global\let\@numberstringFgerman=\@numberstringMgerman +\global\let\@numberstringNgerman=\@numberstringMgerman % \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. +% As above, but initial letters in upper case: % \begin{macrocode} -\newcommand*{\storeORDINALstring}[2]{% - \expandafter\protect\expandafter\storeORDINALstringnum{#1}{% - \expandafter\the\csname c@#2\endcsname}% -} +\DeclareRobustCommand{\@NumberstringMgerman}[2]{% + \@numberstringMgerman{#1}{\@@num@str}% + \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% +}% +\global\let\@NumberstringMgerman\@NumberstringMgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeORDINALstringnum} -% As above, but the second argument is a count register or a -% number. +% Feminine and neuter form: % \begin{macrocode} -\newcommand*{\storeORDINALstringnum}[2]{% - \@ifnextchar[% - {\@store@ORDINAL@string{#1}{#2}}% - {\@store@ORDINAL@string{#1}{#2}[m]}% -} +\global\let\@NumberstringFgerman=\@NumberstringMgerman +\global\let\@NumberstringNgerman=\@NumberstringMgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@ORDINAL@string} -% Gender is specified as an optional argument at the end. +% As above, but for ordinals. % \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}% - }% -} +\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}% +}% +\global\let\@ordinalstringMgerman\@ordinalstringMgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\ORDINALstring} -% Display upper case textual representation of an ordinal. The -% argument must be a counter. +% Feminine form: % \begin{macrocode} -\newcommand*{\ORDINALstring}[1]{% - \expandafter\protect\expandafter\ORDINALstringnum{% - \expandafter\the\csname c@#1\endcsname - }% -} +\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}% +}% +\global\let\@ordinalstringFgerman\@ordinalstringFgerman % \end{macrocode} -%\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}} +% Neuter form: % \begin{macrocode} -\newcommand*{\ORDINALstringnum}[1]{% - \new@ifnextchar[% - {\@ORDINAL@string{#1}}% - {\@ORDINAL@string{#1}[m]}% -} +\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}% +}% +\global\let\@ordinalstringNgerman\@ordinalstringNgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\@ORDINAL@string} -% Gender is specified as an optional argument at the end. +% As above, but with initial letters in upper case. % \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}% - }% -} +\DeclareRobustCommand{\@OrdinalstringMgerman}[2]{% + \@ordinalstringMgerman{#1}{\@@num@str}% + \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% +}% +\global\let\@OrdinalstringMgerman\@OrdinalstringMgerman % \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}% -} +\DeclareRobustCommand{\@OrdinalstringFgerman}[2]{% + \@ordinalstringFgerman{#1}{\@@num@str}% + \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% +}% +\global\let\@OrdinalstringFgerman\@OrdinalstringFgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\storenumberstringnum} -% As above, but second argument is a number or count register. +% Neuter form: % \begin{macrocode} -\newcommand{\storenumberstringnum}[2]{% - \@ifnextchar[% - {\@store@number@string{#1}{#2}}% - {\@store@number@string{#1}{#2}[m]}% -} +\DeclareRobustCommand{\@OrdinalstringNgerman}[2]{% + \@ordinalstringNgerman{#1}{\@@num@str}% + \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% +}% +\global\let\@OrdinalstringNgerman\@OrdinalstringNgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@number@string} -% Gender is given as optional argument, \emph{at the end}. +% Code for converting numbers into textual ordinals. As before, +% it is easier to split it into units, tens and teens. +% Units: +%\changes{2.0}{2012-09-25}{fixed spelling mistake (correction +%provided by Dominik Wa\ss enhoven)} % \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*\@@unitthstringMgerman[1]{% + \ifcase#1% + nullter% + \or erster% + \or zweiter% + \or dritter% + \or vierter% + \or f\"unfter% + \or sechster% + \or siebter% + \or achter% + \or neunter% + \fi +}% +\global\let\@@unitthstringMgerman\@@unitthstringMgerman +% \end{macrocode} +% Tens: +% \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% + \fi +}% +\global\let\@@tenthstringMgerman\@@tenthstringMgerman +% \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% + \fi +}% +\global\let\@@teenthstringMgerman\@@teenthstringMgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\numberstring} -% Display textual representation of a number. The argument -% must be a counter. +% Units (feminine): % \begin{macrocode} -\newcommand*{\numberstring}[1]{% - \expandafter\protect\expandafter\numberstringnum{% - \expandafter\the\csname c@#1\endcsname}% -} +\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 +}% +\global\let\@@unitthstringFgerman\@@unitthstringFgerman % \end{macrocode} -%\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}} +% Tens (feminine): % \begin{macrocode} -\newcommand*{\numberstringnum}[1]{% - \new@ifnextchar[% - {\@number@string{#1}}% - {\@number@string{#1}[m]}% -} +\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 +}% +\global\let\@@tenthstringFgerman\@@tenthstringFgerman % \end{macrocode} -%\end{macro} -% -%\begin{macro}{\@number@string} -% Gender is specified as an optional argument \emph{at the end}. +% Teens (feminine) % \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*\@@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 +}% +\global\let\@@teenthstringFgerman\@@teenthstringFgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeNumberstring} -% Store textual representation of number. First argument is -% identifying name, second argument is a counter. +% Units (neuter): +%\changes{2.0}{2012-09-25}{fixed spelling mistake (correction +%provided by Dominik Wa\ss enhoven)} % \begin{macrocode} -\newcommand*{\storeNumberstring}[2]{% - \expandafter\protect\expandafter\storeNumberstringnum{#1}{% - \expandafter\the\csname c@#2\endcsname}% -} +\newcommand*\@@unitthstringNgerman[1]{% + \ifcase#1% + nulltes% + \or erstes% + \or zweites% + \or drittes% + \or viertes% + \or f\"unftes% + \or sechstes% + \or siebtes% + \or achtes% + \or neuntes% + \fi +}% +\global\let\@@unitthstringNgerman\@@unitthstringNgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeNumberstringnum} -% As above, but second argument is a count register or number. +% Tens (neuter): % \begin{macrocode} -\newcommand{\storeNumberstringnum}[2]{% - \@ifnextchar[% - {\@store@Number@string{#1}{#2}}% - {\@store@Number@string{#1}{#2}[m]}% -} +\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 +}% +\global\let\@@tenthstringNgerman\@@tenthstringNgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@Number@string} -% Gender is specified as an optional argument \emph{at the end}: +% Teens (neuter) % \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*\@@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 +}% +\global\let\@@teenthstringNgerman\@@teenthstringNgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\Numberstring} -% Display textual representation of number. The argument must be -% a counter. +% 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} -\newcommand*{\Numberstring}[1]{% - \expandafter\protect\expandafter\Numberstringnum{% - \expandafter\the\csname c@#1\endcsname}% -} +\newcommand*\@@numberunderhundredgerman[2]{% +\ifnum#1<10\relax + \ifnum#1>0\relax + \eappto#2{\@unitstring{#1}}% + \fi +\else + \@tmpstrctr=#1\relax + \@FCmodulo{\@tmpstrctr}{10}% + \ifnum#1<20\relax + \eappto#2{\@teenstring{\@tmpstrctr}}% + \else + \ifnum\@tmpstrctr=0\relax + \else + \eappto#2{\@unitstring{\@tmpstrctr}und}% + \fi + \@tmpstrctr=#1\relax + \divide\@tmpstrctr by 10\relax + \eappto#2{\@tenstring{\@tmpstrctr}}% + \fi +\fi +}% +\global\let\@@numberunderhundredgerman\@@numberunderhundredgerman % \end{macrocode} -%\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}} +% This stores the results in the second argument +% (which must be a control +% sequence), but it doesn't display anything. % \begin{macrocode} -\newcommand*{\Numberstringnum}[1]{% - \new@ifnextchar[% - {\@Number@string{#1}}% - {\@Number@string{#1}[m]}% -} +\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 % \end{macrocode} -%\end{macro} -%\begin{macro}{\@Number@string} -% Gender is specified as an optional argument at the end. +% \#1 is $\geq 2000$, \cs{@strctr} now contains the number of thousands % \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 - }% -} + \@@numberunderhundredgerman{\@strctr}{#2}% + \appto#2{tausend}% +\else % \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. +% \#1 lies in range [1000,1999] % \begin{macrocode} -\newcommand{\storeNUMBERstring}[2]{% - \expandafter\protect\expandafter\storeNUMBERstringnum{#1}{% - \expandafter\the\csname c@#2\endcsname}% -} + \ifnum\@strctr=1\relax + \eappto#2{\eintausend}% + \fi +\fi +\@strctr=#1\relax +\@FCmodulo{\@strctr}{1000}% +\divide\@strctr by 100\relax +\ifnum\@strctr>1\relax % \end{macrocode} -%\end{macro} -%\begin{macro}{\storeNUMBERstringnum} -% As above, but the second argument is a count register or a -% number. +% now dealing with number in range [200,999] % \begin{macrocode} -\newcommand{\storeNUMBERstringnum}[2]{% - \@ifnextchar[% - {\@store@NUMBER@string{#1}{#2}}% - {\@store@NUMBER@string{#1}{#2}[m]}% -} + \eappto#2{\@unitstring{\@strctr}hundert}% +\else + \ifnum\@strctr=1\relax % \end{macrocode} -%\end{macro} -%\begin{macro}{\@store@NUMBER@string} -% Gender is specified as an optional argument at the end. +% dealing with number in range [100,199] % \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}% - }% -} + \ifnum#1>1000\relax % \end{macrocode} -%\end{macro} -%\begin{macro}{\NUMBERstring} -% Display upper case textual representation of a number. The -% argument must be a counter. +% if original number $> 1000$, use einhundert % \begin{macrocode} -\newcommand*{\NUMBERstring}[1]{% - \expandafter\protect\expandafter\NUMBERstringnum{% - \expandafter\the\csname c@#1\endcsname}% -} + \appto#2{einhundert}% + \else % \end{macrocode} -%\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}} +% otherwise use \cs{einhundert} % \begin{macrocode} -\newcommand*{\NUMBERstringnum}[1]{% - \new@ifnextchar[% - {\@NUMBER@string{#1}}% - {\@NUMBER@string{#1}[m]}% -} + \eappto#2{\einhundert}% + \fi + \fi +\fi +\@strctr=#1\relax +\@FCmodulo{\@strctr}{100}% +\ifnum#1=0\relax + \def#2{null}% +\else + \ifnum\@strctr=1\relax + \appto#2{eins}% + \else + \@@numberunderhundredgerman{\@strctr}{#2}% + \fi +\fi +}% +\global\let\@@numberstringgerman\@@numberstringgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\@NUMBER@string} -% Gender is specified as an optional argument at the end. +% As above, but for ordinals % \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}% - }% -} +\newcommand*\@@numberunderhundredthgerman[2]{% +\ifnum#1<10\relax + \eappto#2{\@unitthstring{#1}}% +\else + \@tmpstrctr=#1\relax + \@FCmodulo{\@tmpstrctr}{10}% + \ifnum#1<20\relax + \eappto#2{\@teenthstring{\@tmpstrctr}}% + \else + \ifnum\@tmpstrctr=0\relax + \else + \eappto#2{\@unitstring{\@tmpstrctr}und}% + \fi + \@tmpstrctr=#1\relax + \divide\@tmpstrctr by 10\relax + \eappto#2{\@tenthstring{\@tmpstrctr}}% + \fi +\fi +}% +\global\let\@@numberunderhundredthgerman\@@numberunderhundredthgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\binary} -% Number representations in other bases. Binary: % \begin{macrocode} -\providecommand*{\binary}[1]{% - \expandafter\protect\expandafter\@binary{% - \expandafter\the\csname c@#1\endcsname}% -} +\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 % \end{macrocode} -%\end{macro} -%\begin{macro}{\aaalph} -% Like \ics{alph}, but goes beyond 26. -% (a \ldots\ z aa \ldots zz \ldots) +% \#1 is $\geq 2000$, \cs{@strctr} now contains the number of thousands % \begin{macrocode} -\providecommand*{\aaalph}[1]{% - \expandafter\protect\expandafter\@aaalph{% - \expandafter\the\csname c@#1\endcsname}% -} +\@@numberunderhundredgerman{\@strctr}{#2}% % \end{macrocode} -%\end{macro} -%\begin{macro}{\AAAlph} -% As before, but upper case. +% is that it, or is there more? % \begin{macrocode} -\providecommand*{\AAAlph}[1]{% - \expandafter\protect\expandafter\@AAAlph{% - \expandafter\the\csname c@#1\endcsname}% -} + \@tmpstrctr=#1\relax \@FCmodulo{\@tmpstrctr}{1000}% + \ifnum\@tmpstrctr=0\relax + \eappto#2{\@thousandth}% + \else + \appto#2{tausend}% + \fi +\else % \end{macrocode} -%\end{macro} -%\begin{macro}{\abalph} -% Like \ics{alph}, but goes beyond 26. -% (a \ldots\ z ab \ldots az \ldots) +% \#1 lies in range [1000,1999] % \begin{macrocode} -\providecommand*{\abalph}[1]{% - \expandafter\protect\expandafter\@abalph{% - \expandafter\the\csname c@#1\endcsname}% -} + \ifnum\@strctr=1\relax + \ifnum#1=1000\relax + \eappto#2{\@thousandth}% + \else + \eappto#2{\eintausend}% + \fi + \fi +\fi +\@strctr=#1\relax +\@FCmodulo{\@strctr}{1000}% +\divide\@strctr by 100\relax +\ifnum\@strctr>1\relax % \end{macrocode} -%\end{macro} -%\begin{macro}{\ABAlph} -% As above, but upper case. +% now dealing with number in range [200,999] +% is that it, or is there more? % \begin{macrocode} -\providecommand*{\ABAlph}[1]{% - \expandafter\protect\expandafter\@ABAlph{% - \expandafter\the\csname c@#1\endcsname}% -} + \@tmpstrctr=#1\relax \@FCmodulo{\@tmpstrctr}{100}% + \ifnum\@tmpstrctr=0\relax + \ifnum\@strctr=1\relax + \eappto#2{\@hundredth}% + \else + \eappto#2{\@unitstring{\@strctr}\@hundredth}% + \fi + \else + \eappto#2{\@unitstring{\@strctr}hundert}% + \fi +\else + \ifnum\@strctr=1\relax % \end{macrocode} -%\end{macro} -%\begin{macro}{\hexadecimal} -% Hexadecimal: +% dealing with number in range [100,199] +% is that it, or is there more? % \begin{macrocode} -\providecommand*{\hexadecimal}[1]{% - \expandafter\protect\expandafter\@hexadecimal{% - \expandafter\the\csname c@#1\endcsname}% -} + \@tmpstrctr=#1\relax \@FCmodulo{\@tmpstrctr}{100}% + \ifnum\@tmpstrctr=0\relax + \eappto#2{\@hundredth}% + \else + \ifnum#1>1000\relax + \appto#2{einhundert}% + \else + \eappto#2{\einhundert}% + \fi + \fi + \fi +\fi +\@strctr=#1\relax +\@FCmodulo{\@strctr}{100}% +\ifthenelse{\@strctr=0 \and #1>0}{}{% +\@@numberunderhundredthgerman{\@strctr}{#2}% +}% +}% +\global\let\@@ordinalstringgerman\@@ordinalstringgerman % \end{macrocode} -%\end{macro} -%\begin{macro}{\Hexadecimal} -% As above, but in upper case. +% Load fc-germanb.def if not already loaded % \begin{macrocode} -\providecommand*{\Hexadecimal}[1]{% - \expandafter\protect\expandafter\@Hexadecimal{% - \expandafter\the\csname c@#1\endcsname}% -} +\FCloadlang{germanb}% % \end{macrocode} -%\end{macro} -%\begin{macro}{\octal} -% Octal: + +%\iffalse % \begin{macrocode} -\providecommand*{\octal}[1]{% - \expandafter\protect\expandafter\@octal{% - \expandafter\the\csname c@#1\endcsname}% -} +% % \end{macrocode} -%\end{macro} -%\begin{macro}{\decimal} -% Decimal: +%\fi +%\iffalse % \begin{macrocode} -\providecommand*{\decimal}[1]{% - \expandafter\protect\expandafter\@decimal{% - \expandafter\the\csname c@#1\endcsname}% -} +%<*fc-germanb.def> % \end{macrocode} -%\end{macro} -% -%\subsection{Multilinguage Definitions} -%\begin{macro}{\@setdef@ultfmtcount} -% If multilingual support is provided, make \cs{@numberstring} -% etc use the correct language (if defined). -% Otherwise use English definitions. \cs{@setdef@ultfmtcount} -% sets the macros to use English. +%\fi +% \subsubsection{fc-germanb.def} % \begin{macrocode} -\def\@setdef@ultfmtcount{% - \ifcsundef{@ordinalMenglish}{\FCloadlang{english}}{}% - \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 -} +\ProvidesFCLanguage{germanb}[2013/08/17]% % \end{macrocode} -%\end{macro} -% -%\begin{macro}{\fc@multiling} -%\changes{2.02}{2012-10-24}{new} -%\cs{fc@multiling}\marg{name}\marg{gender} -%\changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageWarning} to quote macros like -% shown in \texttt{clsguide.pdf}} +% Load fc-german.def if not already loaded % \begin{macrocode} -\newcommand*{\fc@multiling}[2]{% - \ifcsundef{@#1#2\languagename}% - {% try loading it - \FCloadlang{\languagename}% - }% - {% - }% - \ifcsundef{@#1#2\languagename}% - {% - \PackageWarning{fmtcount}% - {No support for \expandafter\protect\csname #1\endcsname\space for - language '\languagename'}% - \ifthenelse{\equal{\languagename}{\fc@mainlang}}% - {% - \FCloadlang{english}% - }% - {% - }% - \ifcsdef{@#1#2\fc@mainlang}% - {% - \csuse{@#1#2\fc@mainlang}% - }% - {% - \PackageWarningNoLine{fmtcount}% - {No languages loaded at all! Loading english definitions}% - \FCloadlang{english}% - \def\fc@mainlang{english}% - \csuse{@#1#2english}% - }% - }% - {% - \csuse{@#1#2\languagename}% - }% -} +\FCloadlang{german}% % \end{macrocode} -%\end{macro} -%\begin{macro}{\@set@mulitling@fmtcount} -% This defines the number and ordinal string macros to use -% \cs{languagename}: -%\changes{2.0}{2012-06-18}{changed errors to warnings for -%unsupported languages} +% Set |germanb| to be equivalent to |german|. % \begin{macrocode} -\def\@set@mulitling@fmtcount{% +\global\let\@ordinalMgermanb=\@ordinalMgerman +\global\let\@ordinalFgermanb=\@ordinalFgerman +\global\let\@ordinalNgermanb=\@ordinalNgerman +\global\let\@numberstringMgermanb=\@numberstringMgerman +\global\let\@numberstringFgermanb=\@numberstringFgerman +\global\let\@numberstringNgermanb=\@numberstringNgerman +\global\let\@NumberstringMgermanb=\@NumberstringMgerman +\global\let\@NumberstringFgermanb=\@NumberstringFgerman +\global\let\@NumberstringNgermanb=\@NumberstringNgerman +\global\let\@ordinalstringMgermanb=\@ordinalstringMgerman +\global\let\@ordinalstringFgermanb=\@ordinalstringFgerman +\global\let\@ordinalstringNgermanb=\@ordinalstringNgerman +\global\let\@OrdinalstringMgermanb=\@OrdinalstringMgerman +\global\let\@OrdinalstringFgermanb=\@OrdinalstringFgerman +\global\let\@OrdinalstringNgermanb=\@OrdinalstringNgerman % \end{macrocode} -% The masculine version of \cs{numberstring}: + +%\iffalse % \begin{macrocode} - \def\@numberstringM{% - \fc@multiling{numberstring}{M}% - }% +% % \end{macrocode} -% The feminine version of \cs{numberstring}: +%\fi +%\iffalse % \begin{macrocode} - \def\@numberstringF{% - \fc@multiling{numberstring}{F}% - }% +%<*fc-italian.def> % \end{macrocode} -% The neuter version of \cs{numberstring}: +%\fi +% \subsubsection{fc-italian} +% Italian support is now handled by interfacing to Enrico Gregorio's +% itnumpar package. % \begin{macrocode} - \def\@numberstringN{% - \fc@multiling{numberstring}{N}% - }% +\ProvidesFCLanguage{italian}[2013/08/17] + +\RequirePackage{itnumpar} + +\newcommand{\@numberstringMitalian}[2]{% + \edef#2{\noexpand\printnumeroinparole{#1}}% +} +\global\let\@numberstringMitalian\@numberstringMitalian + +\newcommand{\@numberstringFitalian}[2]{% + \edef#2{\noexpand\printnumeroinparole{#1}}} + +\global\let\@numberstringFitalian\@numberstringFitalian + +\newcommand{\@NumberstringMitalian}[2]{% + \edef#2{\noexpand\printNumeroinparole{#1}}% +} +\global\let\@NumberstringMitalian\@NumberstringMitalian + +\newcommand{\@NumberstringFitalian}[2]{% + \edef#2{\noexpand\printNumeroinparole{#1}}% +} +\global\let\@NumberstringFitalian\@NumberstringFitalian + +\newcommand{\@ordinalstringMitalian}[2]{% + \edef#2{\noexpand\printordinalem{#1}}% +} +\global\let\@ordinalstringMitalian\@ordinalstringMitalian + +\newcommand{\@ordinalstringFitalian}[2]{% + \edef#2{\noexpand\printordinalef{#1}}% +} +\global\let\@ordinalstringFitalian\@ordinalstringFitalian + +\newcommand{\@OrdinalstringMitalian}[2]{% + \edef#2{\noexpand\printOrdinalem{#1}}% +} +\global\let\@OrdinalstringMitalian\@OrdinalstringMitalian + +\newcommand{\@OrdinalstringFitalian}[2]{% + \edef#2{\noexpand\printOrdinalef{#1}}% +} +\global\let\@OrdinalstringFitalian\@OrdinalstringFitalian + +\newcommand{\@ordinalMitalian}[2]{% + \edef#2{#1\relax\noexpand\fmtord{o}}} + +\global\let\@ordinalMitalian\@ordinalMitalian + +\newcommand{\@ordinalFitalian}[2]{% + \edef#2{#1\relax\noexpand\fmtord{a}}} +\global\let\@ordinalFitalian\@ordinalFitalian % \end{macrocode} -% The masculine version of \cs{Numberstring}: + +%\iffalse % \begin{macrocode} - \def\@NumberstringM{% - \fc@multiling{Numberstring}{M}% - }% +% % \end{macrocode} -% The feminine version of \cs{Numberstring}: +%\fi +%\iffalse % \begin{macrocode} - \def\@NumberstringF{% - \fc@multiling{Numberstring}{F}% - }% +%<*fc-ngerman.def> % \end{macrocode} -% The neuter version of \cs{Numberstring}: +%\fi +% \subsubsection{fc-ngerman.def} % \begin{macrocode} - \def\@NumberstringN{% - \fc@multiling{Numberstring}{N}% - }% +\ProvidesFCLanguage{ngerman}[2012/06/18]% +\FCloadlang{german}% +\FCloadlang{ngermanb}% % \end{macrocode} -% The masculine version of \cs{ordinal}: +% Set |ngerman| to be equivalent to |german|. Is it okay to do +% this? (I don't know the difference between the two.) % \begin{macrocode} - \def\@ordinalM{% - \fc@multiling{ordinal}{M}% - }% +\global\let\@ordinalMngerman=\@ordinalMgerman +\global\let\@ordinalFngerman=\@ordinalFgerman +\global\let\@ordinalNngerman=\@ordinalNgerman +\global\let\@numberstringMngerman=\@numberstringMgerman +\global\let\@numberstringFngerman=\@numberstringFgerman +\global\let\@numberstringNngerman=\@numberstringNgerman +\global\let\@NumberstringMngerman=\@NumberstringMgerman +\global\let\@NumberstringFngerman=\@NumberstringFgerman +\global\let\@NumberstringNngerman=\@NumberstringNgerman +\global\let\@ordinalstringMngerman=\@ordinalstringMgerman +\global\let\@ordinalstringFngerman=\@ordinalstringFgerman +\global\let\@ordinalstringNngerman=\@ordinalstringNgerman +\global\let\@OrdinalstringMngerman=\@OrdinalstringMgerman +\global\let\@OrdinalstringFngerman=\@OrdinalstringFgerman +\global\let\@OrdinalstringNngerman=\@OrdinalstringNgerman % \end{macrocode} -% The feminine version of \cs{ordinal}: + +%\iffalse % \begin{macrocode} - \def\@ordinalF{% - \fc@multiling{ordinal}{F}% - }% +% % \end{macrocode} -% The neuter version of \cs{ordinal}: +%\fi +%\iffalse % \begin{macrocode} - \def\@ordinalN{% - \fc@multiling{ordinal}{N}% - }% +%<*fc-ngermanb.def> % \end{macrocode} -% The masculine version of \cs{ordinalstring}: +%\fi +% \subsubsection{fc-ngermanb.def} % \begin{macrocode} - \def\@ordinalstringM{% - \fc@multiling{ordinalstring}{M}% - }% +\ProvidesFCLanguage{ngermanb}[2013/08/17]% +\FCloadlang{german}% % \end{macrocode} -% The feminine version of \cs{ordinalstring}: +% Set |ngermanb| to be equivalent to |german|. Is it okay to do +% this? (I don't know the difference between the two.) % \begin{macrocode} - \def\@ordinalstringF{% - \fc@multiling{ordinalstring}{F}% - }% +\global\let\@ordinalMngermanb=\@ordinalMgerman +\global\let\@ordinalFngermanb=\@ordinalFgerman +\global\let\@ordinalNngermanb=\@ordinalNgerman +\global\let\@numberstringMngermanb=\@numberstringMgerman +\global\let\@numberstringFngermanb=\@numberstringFgerman +\global\let\@numberstringNngermanb=\@numberstringNgerman +\global\let\@NumberstringMngermanb=\@NumberstringMgerman +\global\let\@NumberstringFngermanb=\@NumberstringFgerman +\global\let\@NumberstringNngermanb=\@NumberstringNgerman +\global\let\@ordinalstringMngermanb=\@ordinalstringMgerman +\global\let\@ordinalstringFngermanb=\@ordinalstringFgerman +\global\let\@ordinalstringNngermanb=\@ordinalstringNgerman +\global\let\@OrdinalstringMngermanb=\@OrdinalstringMgerman +\global\let\@OrdinalstringFngermanb=\@OrdinalstringFgerman +\global\let\@OrdinalstringNngermanb=\@OrdinalstringNgerman % \end{macrocode} -% The neuter version of \cs{ordinalstring}: +% Load fc-ngerman.def if not already loaded % \begin{macrocode} - \def\@ordinalstringN{% - \fc@multiling{ordinalstring}{N}% - }% +\FCloadlang{ngerman}% % \end{macrocode} -% The masculine version of \cs{Ordinalstring}: + +%\iffalse % \begin{macrocode} - \def\@OrdinalstringM{% - \fc@multiling{Ordinalstring}{M}% - }% +% % \end{macrocode} -% The feminine version of \cs{Ordinalstring}: +%\fi +%\iffalse % \begin{macrocode} - \def\@OrdinalstringF{% - \fc@multiling{Ordinalstring}{F}% - }% +%<*fc-portuges.def> % \end{macrocode} -% The neuter version of \cs{Ordinalstring}: +%\fi +% \subsubsection{fc-portuges.def} +% Portuguse definitions % \begin{macrocode} - \def\@OrdinalstringN{% - \fc@multiling{Ordinalstring}{N}% - }% -} +\ProvidesFCLanguage{portuges}[2014/06/09]% % \end{macrocode} -%\end{macro} -% Check to see if \styfmt{babel}, \styfmt{polyglossia} or \styfmt{ngerman} packages have been loaded, and if -% yes set \styfmt{fmtcount} in multiling. +% 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} -\expandafter\@ifpackageloaded -\expandafter{\ifxetex polyglossia\else babel\fi}% -{% - \@set@mulitling@fmtcount +\newcommand*\@ordinalMportuges[2]{% + \ifnum#1=0\relax + \edef#2{\number#1}% + \else + \edef#2{\number#1\relax\noexpand\fmtord{o}}% + \fi }% -{% - \@ifpackageloaded{ngerman}% - {% - \FCloadlang{ngerman}% - \@set@mulitling@fmtcount - }% - {% +\global\let\@ordinalMportuges\@ordinalMportuges % \end{macrocode} -% In the case that neither babel/polyglossia, nor ngerman has been loaded, then we go to multiling if a -% language has been loaded by package option, and to delfault language otherwise. +% Feminine: % \begin{macrocode} - \iffmtcount@language@option - \@set@mulitling@fmtcount +\newcommand*\@ordinalFportuges[2]{% + \ifnum#1=0\relax + \edef#2{\number#1}% + \else + \edef#2{\number#1\relax\noexpand\fmtord{a}}% + \fi +}% +\global\let\@ordinalFportuges\@ordinalFportuges % \end{macrocode} -% Some sanity check at the beginning of document may help the end user understand what is wrong: +% Make neuter same as masculine: % \begin{macrocode} - \AtBeginDocument{% - \ifcsundef{languagename}% - {% - \PackageWarning{fmtcount}{% - `\protect\languagename' is undefined, you should use package babel/polyglossia when loading a - language via package option. Reverting to default language. - }% - \@setdef@ultfmtcount - }{% - \@FC@iflangloaded{\languagename}{}{% +\global\let\@ordinalNportuges\@ordinalMportuges % \end{macrocode} -% The current \cs{languagename} is not a language that has been previously loaded. The correction is to have -% \cs{languagename} let to \cs{fc@mainlang}. Please note that, as \cs{iffmtcount@language@option} is true, -% we know that \texttt{fmtcount} has loaded some language. +% 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): +%\changes{2.04}{2014-06-09}{Fixed bug that had incorrect number of +%parameters specified} % \begin{macrocode} - \PackageWarning{fmtcount}{% - Setting `\protect\languagename' to `\fc@mainlang'.\MessageBreak - Reason is that `\protect\languagename' was `\languagename',\MessageBreak - but `\languagename' was not loaded by fmtcount,\MessageBreak - whereas `\fc@mainlang' was the last language loaded by fmtcount ; - }% - \let\languagename\fc@mainlang - } - }% - } - \else - \@setdef@ultfmtcount - \fi - }% -} +\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 +}% +\global\let\@@unitstringportuges\@@unitstringportuges +% \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 +}% +\global\let\@@unitstringFportuges\@@unitstringFportuges % \end{macrocode} -% Backwards compatibility: +% Tens (argument must be a number from 0 to 10): % \begin{macrocode} -\let\@ordinal=\@ordinalM -\let\@ordinalstring=\@ordinalstringM -\let\@Ordinalstring=\@OrdinalstringM -\let\@numberstring=\@numberstringM -\let\@Numberstring=\@NumberstringM +\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 +}% +\global\let\@@tenstringportuges\@@tenstringportuges % \end{macrocode} -\iffalse Local variables: \fi -\iffalse mode: docTeX \fi -\iffalse End: \fi -%\iffalse +% Teens (argument must be a number from 0 to 9): % \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 +}% +\global\let\@@teenstringportuges\@@teenstringportuges % \end{macrocode} -%\fi -%\iffalse +% Hundreds: % \begin{macrocode} -%<*fc-american.def> +\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 +}% +\global\let\@@hundredstringportuges\@@hundredstringportuges % \end{macrocode} -%\fi -% \subsubsection{fc-american.def} -% American English definitions +% Hundreds (feminine): % \begin{macrocode} -\ProvidesFCLanguage{american}[2013/08/17]% +\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 +}% +\global\let\@@hundredstringFportuges\@@hundredstringFportuges % \end{macrocode} -% Loaded fc-USenglish.def if not already loaded +% Units (initial letter in upper case): % \begin{macrocode} -\FCloadlang{USenglish}% +\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 +}% +\global\let\@@Unitstringportuges\@@Unitstringportuges % \end{macrocode} -% These are all just synonyms for the commands provided by -% fc-USenglish.def. +% As above, but feminine: % \begin{macrocode} -\global\let\@ordinalMamerican\@ordinalMUSenglish -\global\let\@ordinalFamerican\@ordinalMUSenglish -\global\let\@ordinalNamerican\@ordinalMUSenglish -\global\let\@numberstringMamerican\@numberstringMUSenglish -\global\let\@numberstringFamerican\@numberstringMUSenglish -\global\let\@numberstringNamerican\@numberstringMUSenglish -\global\let\@NumberstringMamerican\@NumberstringMUSenglish -\global\let\@NumberstringFamerican\@NumberstringMUSenglish -\global\let\@NumberstringNamerican\@NumberstringMUSenglish -\global\let\@ordinalstringMamerican\@ordinalstringMUSenglish -\global\let\@ordinalstringFamerican\@ordinalstringMUSenglish -\global\let\@ordinalstringNamerican\@ordinalstringMUSenglish -\global\let\@OrdinalstringMamerican\@OrdinalstringMUSenglish -\global\let\@OrdinalstringFamerican\@OrdinalstringMUSenglish -\global\let\@OrdinalstringNamerican\@OrdinalstringMUSenglish +\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 +}% +\global\let\@@UnitstringFportuges\@@UnitstringFportuges % \end{macrocode} -%\iffalse +% Tens (with initial letter in upper case): % \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 +}% +\global\let\@@Tenstringportuges\@@Tenstringportuges % \end{macrocode} -%\fi -%\iffalse +% Teens (with initial letter in upper case): % \begin{macrocode} -%<*fc-british.def> +\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 +}% +\global\let\@@Teenstringportuges\@@Teenstringportuges % \end{macrocode} -%\fi -% \subsubsection{fc-british.def} -% British definitions +% Hundreds (with initial letter in upper case): % \begin{macrocode} -\ProvidesFCLanguage{british}[2013/08/17]% +\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 +}% +\global\let\@@Hundredstringportuges\@@Hundredstringportuges % \end{macrocode} -% Load fc-english.def, if not already loaded +% As above, but feminine: % \begin{macrocode} -\FCloadlang{english}% +\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 +}% +\global\let\@@HundredstringFportuges\@@HundredstringFportuges % \end{macrocode} -% These are all just synonyms for the commands provided by -% fc-english.def. +% 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} -\global\let\@ordinalMbritish\@ordinalMenglish -\global\let\@ordinalFbritish\@ordinalMenglish -\global\let\@ordinalNbritish\@ordinalMenglish -\global\let\@numberstringMbritish\@numberstringMenglish -\global\let\@numberstringFbritish\@numberstringMenglish -\global\let\@numberstringNbritish\@numberstringMenglish -\global\let\@NumberstringMbritish\@NumberstringMenglish -\global\let\@NumberstringFbritish\@NumberstringMenglish -\global\let\@NumberstringNbritish\@NumberstringMenglish -\global\let\@ordinalstringMbritish\@ordinalstringMenglish -\global\let\@ordinalstringFbritish\@ordinalstringMenglish -\global\let\@ordinalstringNbritish\@ordinalstringMenglish -\global\let\@OrdinalstringMbritish\@OrdinalstringMenglish -\global\let\@OrdinalstringFbritish\@OrdinalstringMenglish -\global\let\@OrdinalstringNbritish\@OrdinalstringMenglish +\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}% +}% +\global\let\@numberstringMportuges\@numberstringMportuges % \end{macrocode} -%\iffalse +% As above, but feminine form: % \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}% +}% +\global\let\@numberstringFportuges\@numberstringFportuges % \end{macrocode} -%\fi -%\iffalse +% Make neuter same as masculine: % \begin{macrocode} -%<*fc-english.def> +\global\let\@numberstringNportuges\@numberstringMportuges % \end{macrocode} -%\fi -% \subsubsection{fc-english.def} -% English definitions +% As above, but initial letters in upper case: % \begin{macrocode} -\ProvidesFCLanguage{english}[2013/08/17]% +\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}% +}% +\global\let\@NumberstringMportuges\@NumberstringMportuges % \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. +% As above, but feminine form: % \begin{macrocode} -\newcommand*\@ordinalMenglish[2]{% -\def\@fc@ord{}% -\@orgargctr=#1\relax -\@ordinalctr=#1% -\@FCmodulo{\@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 - \@FCmodulo{\@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}}% +\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}% }% -\global\let\@ordinalMenglish\@ordinalMenglish +\global\let\@NumberstringFportuges\@NumberstringFportuges % \end{macrocode} -% There is no gender difference in English, so make feminine and -% neuter the same as the masculine. +% Make neuter same as masculine: % \begin{macrocode} -\global\let\@ordinalFenglish=\@ordinalMenglish -\global\let\@ordinalNenglish=\@ordinalMenglish +\global\let\@NumberstringNportuges\@NumberstringMportuges % \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. +% As above, but for ordinals. % \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 +\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}% }% -\global\let\@@unitstringenglish\@@unitstringenglish +\global\let\@ordinalstringMportuges\@ordinalstringMportuges % \end{macrocode} -% Next the tens, again the argument should be between 0 and 9 -% inclusive. +% Feminine form: % \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 +\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}% }% -\global\let\@@tenstringenglish\@@tenstringenglish +\global\let\@ordinalstringFportuges\@ordinalstringFportuges % \end{macrocode} -% Finally the teens, again the argument should be between 0 and 9 -% inclusive. +% Make neuter same as masculine: % \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 -}% -\global\let\@@teenstringenglish\@@teenstringenglish +\global\let\@ordinalstringNportuges\@ordinalstringMportuges % \end{macrocode} -% As above, but with the initial letter in uppercase. The units: +% As above, but initial letters in upper case (masculine): % \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 +\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}% }% -\global\let\@@Unitstringenglish\@@Unitstringenglish +\global\let\@OrdinalstringMportuges\@OrdinalstringMportuges % \end{macrocode} -% The tens: +% Feminine form: % \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 +\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}% }% -\global\let\@@Tenstringenglish\@@Tenstringenglish +\global\let\@OrdinalstringFportuges\@OrdinalstringFportuges % \end{macrocode} -% The teens: +% Make neuter same as masculine: % \begin{macrocode} -\newcommand*\@@Teenstringenglish[1]{% +\global\let\@OrdinalstringNportuges\@OrdinalstringMportuges +% \end{macrocode} +% In order to do the ordinals, split into units, teens, tens +% and hundreds. Units: +% \begin{macrocode} +\newcommand*\@@unitthstringportuges[1]{% \ifcase#1\relax - Ten% - \or Eleven% - \or Twelve% - \or Thirteen% - \or Fourteen% - \or Fifteen% - \or Sixteen% - \or Seventeen% - \or Eighteen% - \or Nineteen% + zero% + \or primeiro% + \or segundo% + \or terceiro% + \or quarto% + \or quinto% + \or sexto% + \or s\'etimo% + \or oitavo% + \or nono% \fi }% -\global\let\@@Teenstringenglish\@@Teenstringenglish +\global\let\@@unitthstringportuges\@@unitthstringportuges % \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.) +% Tens: % \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 - \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 - \@FCmodulo{\@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 - \@FCmodulo{\@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 \@FCmodulo{\@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 \@FCmodulo{\@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 \@FCmodulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr-\@unitstring{\@strctr}}% +\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 -\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 - \@FCmodulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% +}% +\global\let\@@tenthstringportuges\@@tenthstringportuges +% \end{macrocode} +% Teens: +% \begin{macrocode} +\newcommand*\@@teenthstringportuges[1]{% + \@tenthstring{1}% + \ifnum#1>0\relax + -\@unitthstring{#1}% \fi -\fi }% -\global\let\@@numberstringenglish\@@numberstringenglish +\global\let\@@teenthstringportuges\@@teenthstringportuges % \end{macrocode} -% All lower case version, the second argument must be a -% control sequence. +% Hundreds: % \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}% +\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 }% -\global\let\@numberstringMenglish\@numberstringMenglish +\global\let\@@hundredthstringportuges\@@hundredthstringportuges % \end{macrocode} -% There is no gender in English, so make feminine and neuter the -% same -% as the masculine. +% Units (feminine): % \begin{macrocode} -\global\let\@numberstringFenglish=\@numberstringMenglish -\global\let\@numberstringNenglish=\@numberstringMenglish +\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 +}% +\global\let\@@unitthstringFportuges\@@unitthstringFportuges % \end{macrocode} -% This version makes the first letter of each word an uppercase -% character (except ``and''). The second argument must be a control -% sequence. +% Tens (feminine): % \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*\@@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 }% -\global\let\@NumberstringMenglish\@NumberstringMenglish +\global\let\@@tenthstringFportuges\@@tenthstringFportuges % \end{macrocode} -% There is no gender in English, so make feminine and neuter the -% same -% as the masculine. +% Hundreds (feminine): % \begin{macrocode} -\global\let\@NumberstringFenglish=\@NumberstringMenglish -\global\let\@NumberstringNenglish=\@NumberstringMenglish +\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 +}% +\global\let\@@hundredthstringFportuges\@@hundredthstringFportuges % \end{macrocode} -% Define a macro that produces an ordinal as a string. Again, break -% it up into units, teens and tens. First the units: +% As above, but with initial letter in upper case. Units: % \begin{macrocode} -\newcommand*\@@unitthstringenglish[1]{% +\newcommand*\@@Unitthstringportuges[1]{% \ifcase#1\relax - zeroth% - \or first% - \or second% - \or third% - \or fourth% - \or fifth% - \or sixth% - \or seventh% - \or eighth% - \or ninth% + Zero% + \or Primeiro% + \or Segundo% + \or Terceiro% + \or Quarto% + \or Quinto% + \or Sexto% + \or S\'etimo% + \or Oitavo% + \or Nono% \fi }% -\global\let\@@unitthstringenglish\@@unitthstringenglish +\global\let\@@Unitthstringportuges\@@Unitthstringportuges % \end{macrocode} -% Next the tens: +% Tens: % \begin{macrocode} -\newcommand*\@@tenthstringenglish[1]{% +\newcommand*\@@Tenthstringportuges[1]{% \ifcase#1\relax - \or tenth% - \or twentieth% - \or thirtieth% - \or fortieth% - \or fiftieth% - \or sixtieth% - \or seventieth% - \or eightieth% - \or ninetieth% + \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 }% -\global\let\@@tenthstringenglish\@@tenthstringenglish +\global\let\@@Tenthstringportuges\@@Tenthstringportuges % \end{macrocode} -% The teens: +% Hundreds: % \begin{macrocode} -\newcommand*\@@teenthstringenglish[1]{% +\newcommand*\@@Hundredthstringportuges[1]{% \ifcase#1\relax - tenth% - \or eleventh% - \or twelfth% - \or thirteenth% - \or fourteenth% - \or fifteenth% - \or sixteenth% - \or seventeenth% - \or eighteenth% - \or nineteenth% + \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 }% -\global\let\@@teenthstringenglish\@@teenthstringenglish +\global\let\@@Hundredthstringportuges\@@Hundredthstringportuges % \end{macrocode} -% As before, but with the first letter in upper case. The units: +% As above, but feminine. Units: % \begin{macrocode} -\newcommand*\@@Unitthstringenglish[1]{% +\newcommand*\@@UnitthstringFportuges[1]{% \ifcase#1\relax - Zeroth% - \or First% - \or Second% - \or Third% - \or Fourth% - \or Fifth% - \or Sixth% - \or Seventh% - \or Eighth% - \or Ninth% + Zera% + \or Primeira% + \or Segunda% + \or Terceira% + \or Quarta% + \or Quinta% + \or Sexta% + \or S\'etima% + \or Oitava% + \or Nona% \fi }% -\global\let\@@Unitthstringenglish\@@Unitthstringenglish +\global\let\@@UnitthstringFportuges\@@UnitthstringFportuges % \end{macrocode} -% The tens: +% Tens (feminine); % \begin{macrocode} -\newcommand*\@@Tenthstringenglish[1]{% +\newcommand*\@@TenthstringFportuges[1]{% \ifcase#1\relax - \or Tenth% - \or Twentieth% - \or Thirtieth% - \or Fortieth% - \or Fiftieth% - \or Sixtieth% - \or Seventieth% - \or Eightieth% - \or Ninetieth% + \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 }% -\global\let\@@Tenthstringenglish\@@Tenthstringenglish +\global\let\@@TenthstringFportuges\@@TenthstringFportuges % \end{macrocode} -% The teens: +% Hundreds (feminine): % \begin{macrocode} -\newcommand*\@@Teenthstringenglish[1]{% +\newcommand*\@@HundredthstringFportuges[1]{% \ifcase#1\relax - Tenth% - \or Eleventh% - \or Twelfth% - \or Thirteenth% - \or Fourteenth% - \or Fifteenth% - \or Sixteenth% - \or Seventeenth% - \or Eighteenth% - \or Nineteenth% + \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 }% -\global\let\@@Teenthstringenglish\@@Teenthstringenglish +\global\let\@@HundredthstringFportuges\@@HundredthstringFportuges % \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. +% 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*\@@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*\@@numberstringportuges[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}% + \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{}% -\fi \@strctr=#1\relax \divide\@strctr by 1000\relax \ifnum\@strctr>9\relax % \end{macrocode} % \#1 is greater or equal to 10000 % \begin{macrocode} - \divide\@strctr by 10 + \divide\@strctr by 10\relax \ifnum\@strctr>1\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@tenstring{\@strctr}}% - \@strctr=#1\relax - \divide\@strctr by 1000\relax + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@tenstring{\@strctr}}% + \@strctr=#1 \divide\@strctr by 1000\relax \@FCmodulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr-\@unitstring{\@strctr}}% + \ifnum\@strctr>0 + \ifnum\@strctr=1\relax + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\ \@andname}% + \fi + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% \fi \else - \@strctr=#1\relax \divide\@strctr by 1000\relax + \@strctr=#1\relax + \divide\@strctr by 1000\relax \@FCmodulo{\@strctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenstring{\@strctr}}% - \fi - \@strctr=#1\relax \@FCmodulo{\@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}% + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@teenstring{\@strctr}}% \fi + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\ \@thousand}% \else \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \@strctr=#1\relax \@FCmodulo{\@strctr}{1000}% - \let\@@fc@ordstr#2\relax - \ifnum\@strctr=0\relax - \edef#2{\@@fc@ordstr\ \@thousandth}% - \else - \edef#2{\@@fc@ordstr\ \@thousand}% + \ifnum\@strctr>1\relax + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% \fi + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@thousand}% \fi \fi \@strctr=#1\relax \@FCmodulo{\@strctr}{1000}% -\divide\@strctr by 100 +\divide\@strctr by 100\relax \ifnum\@strctr>0\relax - \ifnum#1>1000\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ }% + \ifnum#1>1000 \relax + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\ }% \fi - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \@strctr=#1\relax \@FCmodulo{\@strctr}{100}% - \let\@@fc@ordstr#2\relax - \ifnum\@strctr=0\relax - \edef#2{\@@fc@ordstr\ \@hundredth}% + \@tmpstrctr=#1\relax + \@FCmodulo{\@tmpstrctr}{1000}% + \let\@@fc@numstr#2\relax + \ifnum\@tmpstrctr=100\relax + \protected@edef#2{\@@fc@numstr\@tenstring{10}}% \else - \edef#2{\@@fc@ordstr\ \@hundred}% - \fi + \protected@edef#2{\@@fc@numstr\@hundredstring{\@strctr}}% + \fi% \fi \@strctr=#1\relax \@FCmodulo{\@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 + \protected@edef#2{\@@fc@numstr\ \@andname\ }% \fi \fi \ifnum\@strctr>19\relax - \@tmpstrctr=\@strctr \divide\@strctr by 10\relax - \@FCmodulo{\@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 + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@tenstring{\@strctr}}% \@strctr=#1\relax \@FCmodulo{\@strctr}{10}% - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr-\@unitthstring{\@strctr}}% + \ifnum\@strctr>0 + \ifnum\@strctr=1\relax + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\ \@andname}% + \else + \ifnum#1>100\relax + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\ \@andname}% + \fi + \fi + \let\@@fc@numstr#2\relax + \protected@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}}% + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@unitstring{\@strctr}}% \fi - \else - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \else %(>0,<10) + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@unitstring{\@strctr}}% \fi - \else + \else%>10 \@FCmodulo{\@strctr}{10}% - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\@teenthstring{\@strctr}}% + \let\@@fc@numstr#2\relax + \protected@edef#2{\@@fc@numstr\@teenstring{\@strctr}}% \fi \fi }% -\global\let\@@ordinalstringenglish\@@ordinalstringenglish -% \end{macrocode} -% All lower case version. Again, the second argument must be a -% control sequence in which the resulting text is stored. -% \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}% -}% -\global\let\@ordinalstringMenglish\@ordinalstringMenglish -% \end{macrocode} -% No gender in English, so make feminine and neuter same as -% masculine: -% \begin{macrocode} -\global\let\@ordinalstringFenglish=\@ordinalstringMenglish -\global\let\@ordinalstringNenglish=\@ordinalstringMenglish +\global\let\@@numberstringportuges\@@numberstringportuges % \end{macrocode} -% First letter of each word in upper case: +% As above, but for ordinals. % \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*\@@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 + \@FCmodulo{\@tmpstrctr}{10}% + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@teenthstring{\@tmpstrctr}}% + \else + \divide\@tmpstrctr by 10\relax + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% + \@tmpstrctr=\@strctr + \@FCmodulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@unitthstring{\@tmpstrctr}}% + \fi + \fi + \else + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% + \fi + \fi + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@thousandth}% +\fi +\@strctr=#1\relax +\@FCmodulo{\@strctr}{1000}% +\ifnum\@strctr>99\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 100\relax + \ifnum#1>1000\relax + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr-}% + \fi + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@hundredthstring{\@tmpstrctr}}% +\fi +\@FCmodulo{\@strctr}{100}% +\ifnum#1>99\relax + \ifnum\@strctr>0\relax + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr-}% + \fi +\fi +\ifnum\@strctr>9\relax + \@tmpstrctr=\@strctr + \divide\@tmpstrctr by 10\relax + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% + \@tmpstrctr=\@strctr + \@FCmodulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr-\@unitthstring{\@tmpstrctr}}% + \fi +\else + \ifnum\@strctr=0\relax + \ifnum#1=0\relax + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@unitstring{0}}% + \fi + \else + \let\@@fc@ordstr#2\relax + \protected@edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \fi +\fi +\fi +\fi }% -\global\let\@OrdinalstringMenglish\@OrdinalstringMenglish -% \end{macrocode} -% No gender in English, so make feminine and neuter same as -% masculine: -% \begin{macrocode} -\global\let\@OrdinalstringFenglish=\@OrdinalstringMenglish -\global\let\@OrdinalstringNenglish=\@OrdinalstringMenglish -% \end{macrocode} -%\iffalse -% \begin{macrocode} -% -% \end{macrocode} -%\fi -%\iffalse -% \begin{macrocode} -%<*fc-francais.def> -% \end{macrocode} -%\fi -% \subsubsection{fc-francais.def} -% \begin{macrocode} -\ProvidesFCLanguage{francais}[2013/08/17]% -\FCloadlang{french}% -% \end{macrocode} -% Set |francais| to be equivalent to |french|. -% \begin{macrocode} -\global\let\@ordinalMfrancais=\@ordinalMfrench -\global\let\@ordinalFfrancais=\@ordinalFfrench -\global\let\@ordinalNfrancais=\@ordinalNfrench -\global\let\@numberstringMfrancais=\@numberstringMfrench -\global\let\@numberstringFfrancais=\@numberstringFfrench -\global\let\@numberstringNfrancais=\@numberstringNfrench -\global\let\@NumberstringMfrancais=\@NumberstringMfrench -\global\let\@NumberstringFfrancais=\@NumberstringFfrench -\global\let\@NumberstringNfrancais=\@NumberstringNfrench -\global\let\@ordinalstringMfrancais=\@ordinalstringMfrench -\global\let\@ordinalstringFfrancais=\@ordinalstringFfrench -\global\let\@ordinalstringNfrancais=\@ordinalstringNfrench -\global\let\@OrdinalstringMfrancais=\@OrdinalstringMfrench -\global\let\@OrdinalstringFfrancais=\@OrdinalstringFfrench -\global\let\@OrdinalstringNfrancais=\@OrdinalstringNfrench +\global\let\@@ordinalstringportuges\@@ordinalstringportuges % \end{macrocode} - %\iffalse % \begin{macrocode} -% +% % \end{macrocode} %\fi %\iffalse % \begin{macrocode} -%<*fc-french.def> +%<*fc-portuguese.def> % \end{macrocode} %\fi -% \subsubsection{fc-french.def} -% Definitions for French. -% \begin{macrocode} -\ProvidesFCLanguage{french}[2012/10/24]% -% \end{macrocode} -% Package \styfmt{fcprefix} is needed to format the prefix \meta{$n$} in \meta{$n$}illion or -% \meta{$n$}illiard. Big numbers were developped based on reference: -% \uref{http://www.alain.be/boece/noms\_de\_nombre.html} -% (Package now loaded by \styfmt{fmtcount}) -% -% Options for controlling plural mark. First of all we define some temporary macro \cs{fc@french@set@plural} -% in order to factorize code that defines an plural mark option:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&key name,\\ -% \#2&key value,\\ -% \#3&configuration index for `\texttt{reformed}', \\ -% \#4&configuration index for `\texttt{traditional}',\\ -% \#5&configuration index for `\texttt{reformed o}', and\\ -% \#6&configuration index for `\texttt{traditional o}'. -% \end{tabularx} -% \begin{macrocode} -\def\fc@french@set@plural#1#2#3#4#5#6{% - \ifthenelse{\equal{#2}{reformed}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#3}% - }{% - \ifthenelse{\equal{#2}{traditional}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#4}% - }{% - \ifthenelse{\equal{#2}{reformed o}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#5}% - }{% - \ifthenelse{\equal{#2}{traditional o}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{#6}% - }{% - \ifthenelse{\equal{#2}{always}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{0}% - }{% - \ifthenelse{\equal{#2}{never}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{1}% - }{% - \ifthenelse{\equal{#2}{multiple}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{2}% - }{% - \ifthenelse{\equal{#2}{multiple g-last}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{3}% - }{% - \ifthenelse{\equal{#2}{multiple l-last}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{4}% - }{% - \ifthenelse{\equal{#2}{multiple lng-last}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{5}% - }{% - \ifthenelse{\equal{#2}{multiple ng-last}}{% - \expandafter\def\csname fc@frenchoptions@#1@plural\endcsname{6}% - }{% - \PackageError{fmtcount}{Unexpected argument}{% - `#2' was unexpected: french option `#1 plural' expects `reformed', `traditional', - `reformed o', `traditional o', `always', `never', `multiple', `multiple g-last', - `multiple l-last', `multiple lng-last', or `multiple ng-last'.% - }}}}}}}}}}}}} -% \end{macrocode} -% Now a shorthand \cs{@tempa} is defined just to define all the options controlling plural mark. This -% shorthand takes into account that `\texttt{reformed}' and `\texttt{traditional}' have the same effect, and -% so do `\texttt{reformed o}' and `\texttt{traditional o}'. -% \begin{macrocode} -\def\@tempa#1#2#3{% - \define@key{fcfrench}{#1 plural}[reformed]{% - \fc@french@set@plural{#1}{##1}{#2}{#2}{#3}{#3}% - }% -} -\@tempa{vingt}{4}{5} -\@tempa{cent}{4}{5} -\@tempa{mil}{0}{0} -\@tempa{n-illion}{2}{6} -\@tempa{n-illiard}{2}{6} -% \end{macrocode} -% For option `\texttt{all plural}' we cannot use the \cs{@tempa} shorthand, because `\texttt{all plural}' -% is just a multiplexer. -% \begin{macrocode} -\define@key{fcfrench}{all plural}[reformed]{% - \csname KV@fcfrench@vingt plural\endcsname{#1}% - \csname KV@fcfrench@cent plural\endcsname{#1}% - \csname KV@fcfrench@mil plural\endcsname{#1}% - \csname KV@fcfrench@n-illion plural\endcsname{#1}% - \csname KV@fcfrench@n-illiard plural\endcsname{#1}% -} -% \end{macrocode} -% Now options `\texttt{dash or space}', we have three possible key values:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% traditional& use dash for numbers below 100, except when `et' is used, and space otherwise\\ -% reformed& reform of 1990, use dash except with million \& milliard, and suchlikes, -% i.e. \meta{$n$}illion and \meta{$n$}illiard,\\ -% always& always use dashes to separate all words -% \end{tabularx} -% \begin{macrocode} -\define@key{fcfrench}{dash or space}[reformed]{% - \ifthenelse{\equal{#1}{traditional}}{% - \let\fc@frenchoptions@supermillion@dos\space% - \let\fc@frenchoptions@submillion@dos\space - }{% - \ifthenelse{\equal{#1}{reformed}\or\equal{#1}{1990}}{% - \let\fc@frenchoptions@supermillion@dos\space - \def\fc@frenchoptions@submillion@dos{-}% - }{% - \ifthenelse{\equal{#1}{always}}{% - \def\fc@frenchoptions@supermillion@dos{-}% - \def\fc@frenchoptions@submillion@dos{-}% - }{% - \PackageError{fmtcount}{Unexpected argument}{% - French option `dash or space' expects `always', `reformed' or `traditional' - } - }% - }% - }% -} -% \end{macrocode} -% Option `\texttt{scale}', can take 3 possible values:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% long& for which \meta{\(n\)}illions \& \meta{\(n\)}illiards are used with \(10^{6\times n} = 1 -% \textrm{\meta{$n$}}illion\), and \(10^{6\times n+3} = 1 \textrm{\meta{$n$}}illiard\)\\ -% short& for which \meta{$n$}illions only are used with \(10^{3\times n+3} = 1 -% \textrm{\meta{$n$}illion}\)\\ -% recursive& for which \(10^{18} = \textrm{un milliard de milliards}\) -% \end{tabularx} -% \begin{macrocode} -\define@key{fcfrench}{scale}[recursive]{% - \ifthenelse{\equal{#1}{long}}{% - \let\fc@poweroften\fc@@pot@longscalefrench - }{% - \ifthenelse{\equal{#1}{recursive}}{% - \let\fc@poweroften\fc@@pot@recursivefrench - }{% - \ifthenelse{\equal{#1}{short}}{% - \let\fc@poweroften\fc@@pot@shortscalefrench - }{% - \PackageError{fmtcount}{Unexpected argument}{% - French option `scale' expects `long', `recursive' or `short' - } - }% - }% - }% -} -% \end{macrocode} -% Option `\texttt{n-illiard upto}' is ignored if `\texttt{scale}' is different from `\texttt{long}'. It can -% take the following values:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% infinity&in that case \meta{$n$}illard are never disabled,\\ -% infty&this is just a shorthand for `\texttt{infinity}', and\\ -% \textrm{\(n\)}& any integer that is such that \(n>0\), and that \(\forall k\in\mathbb{N}, k\geq n\), -% number \(10^{6\times k+3}\) will be formatted as ``mille \meta{$n$}illions'' -% \end{tabularx} -% \begin{macrocode} -\define@key{fcfrench}{n-illiard upto}[infinity]{% - \ifthenelse{\equal{#1}{infinity}}{% - \def\fc@longscale@nilliard@upto{0}% - }{% - \ifthenelse{\equal{#1}{infty}}{% - \def\fc@longscale@nilliard@upto{0}% - }{% - \if Q\ifnum9<1#1Q\fi\else - \PackageError{fmtcount}{Unexpected argument}{% - French option `milliard threshold' expects `infinity', or equivalently `infty', or a non negative - integer.}% - \fi - \def\fc@longscale@nilliard@upto{#1}% - }}% -} -% \end{macrocode} -% Now, the options `\texttt{france}', `\texttt{swiss}' and `\texttt{belgian}' are defined to select the -% dialect to use. Macro \cs{@tempa} is just a local shorthand to define each one of this option. -% \begin{macrocode} -\def\@tempa#1{% - \define@key{fcfrench}{#1}[]{% - \PackageError{fmtcount}{Unexpected argument}{French option with key `#1' does not take - any value}}% - \expandafter\def\csname KV@fcfrench@#1@default\endcsname{% - \def\fmtcount@french{#1}}% -}% -\@tempa{france}\@tempa{swiss}\@tempa{belgian}% -% \end{macrocode} -% Now, option `\texttt{dialect}' is now defined so that `\texttt{france}', `\texttt{swiss}' and -% `\texttt{belgian}' can also be used as key values, which is more conventional although less concise. +% \subsubsection{fc-portuguese.def} % \begin{macrocode} -\define@key{fcfrench}{dialect}[france]{% - \ifthenelse{\equal{#1}{france} - \or\equal{#1}{swiss} - \or\equal{#1}{belgian}}{% - \def\fmtcount@french{#1}}{% - \PackageError{fmtcount}{Invalid value `#1' to french option dialect key} - {Option `french' can only take the values `france', - `belgian' or `swiss'}}} +\ProvidesFCLanguage{portuguese}[2014/06/09]% % \end{macrocode} -% The option \texttt{mil plural mark} allows to make the plural of \texttt{mil} to be regular, -% i.e. \texttt{mils}, instead of \texttt{mille}. By default it is `\texttt{le}'. +% Load fc-portuges.def if not already loaded % \begin{macrocode} -\define@key{fcfrench}{mil plural mark}[le]{% - \def\fc@frenchoptions@mil@plural@mark{#1}} -% \end{macrocode} -% Definition of case handling macros. This should be moved somewhere else to be commonalized between all -% languages. +\FCloadlang{portuges}% +% \end{macrocode} +% Set |portuguese| to be equivalent to |portuges|. % \begin{macrocode} -\def\fc@UpperCaseFirstLetter#1#2\@nil{% - \uppercase{#1}#2} - -\def\fc@CaseIden#1\@nil{% - #1% -} -\def\fc@UpperCaseAll#1\@nil{% - \uppercase{#1}% -} - -\let\fc@case\fc@CaseIden - +\global\let\@ordinalMportuguese=\@ordinalMportuges +\global\let\@ordinalFportuguese=\@ordinalFportuges +\global\let\@ordinalNportuguese=\@ordinalNportuges +\global\let\@numberstringMportuguese=\@numberstringMportuges +\global\let\@numberstringFportuguese=\@numberstringFportuges +\global\let\@numberstringNportuguese=\@numberstringNportuges +\global\let\@NumberstringMportuguese=\@NumberstringMportuges +\global\let\@NumberstringFportuguese=\@NumberstringFportuges +\global\let\@NumberstringNportuguese=\@NumberstringNportuges +\global\let\@ordinalstringMportuguese=\@ordinalstringMportuges +\global\let\@ordinalstringFportuguese=\@ordinalstringFportuges +\global\let\@ordinalstringNportuguese=\@ordinalstringNportuges +\global\let\@OrdinalstringMportuguese=\@OrdinalstringMportuges +\global\let\@OrdinalstringFportuguese=\@OrdinalstringFportuges +\global\let\@OrdinalstringNportuguese=\@OrdinalstringNportuges % \end{macrocode} -% \DescribeMacro\@ordinalMfrench + +%\iffalse % \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} -% \DescribeMacro\@ordinalFfrench +%\fi +%\iffalse % \begin{macrocode} -\newcommand*{\@ordinalFfrench}[2]{% -\iffmtord@abbrv - \edef#2{\number#1\relax\noexpand\fmtord{e}}% -\else - \ifnum#1=1 % - \edef#2{\number#1\relax\noexpand\fmtord{i\`ere}}% - \else - \edef#2{\number#1\relax\noexpand\fmtord{i\`eme}}% - \fi -\fi} +%<*fc-spanish.def> % \end{macrocode} -% In French neutral gender and masculine gender are formally identical. +%\fi +% \subsubsection{fc-spanish.def} +% Spanish definitions % \begin{macrocode} -\let\@ordinalNfrench\@ordinalMfrench +\ProvidesFCLanguage{spanish}[2013/08/17]% % \end{macrocode} -% \DescribeMacro\@@unitstringfrench +% 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*{\@@unitstringfrench}[1]{% -\noexpand\fc@case -\ifcase#1 % -z\'ero% -\or un% -\or deux% -\or trois% -\or quatre% -\or cinq% -\or six% -\or sept% -\or huit% -\or neuf% -\fi -\noexpand\@nil -} +\newcommand*\@ordinalMspanish[2]{% + \edef#2{\number#1\relax\noexpand\fmtord{o}}% +}% +\global\let\@ordinalMspanish\@ordinalMspanish % \end{macrocode} -% \DescribeMacro\@@tenstringfrench +% Feminine: % \begin{macrocode} -\newcommand*{\@@tenstringfrench}[1]{% -\noexpand\fc@case -\ifcase#1 % -\or dix% -\or vingt% -\or trente% -\or quarante% -\or cinquante% -\or soixante% -\or septante% -\or huitante% -\or nonante% -\or cent% -\fi -\noexpand\@nil -} +\newcommand{\@ordinalFspanish}[2]{% + \edef#2{\number#1\relax\noexpand\fmtord{a}}% +}% +\global\let\@ordinalFspanish\@ordinalFspanish % \end{macrocode} -% \DescribeMacro\@@teenstringfrench +% Make neuter same as masculine: % \begin{macrocode} -\newcommand*{\@@teenstringfrench}[1]{% -\noexpand\fc@case -\ifcase#1 % - dix% -\or onze% -\or douze% -\or treize% -\or quatorze% -\or quinze% -\or seize% -\or dix\noexpand\@nil-\noexpand\fc@case sept% -\or dix\noexpand\@nil-\noexpand\fc@case huit% -\or dix\noexpand\@nil-\noexpand\fc@case neuf% -\fi -\noexpand\@nil -} +\global\let\@ordinalNspanish\@ordinalMspanish % \end{macrocode} -% \DescribeMacro\@@seventiesfrench +% 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*{\@@seventiesfrench}[1]{% -\@tenstring{6}% -\ifnum#1=1 % -\fc@frenchoptions@submillion@dos\@andname\fc@frenchoptions@submillion@dos -\else --% -\fi -\@teenstring{#1}% -} +\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 +}% +\global\let\@@unitstringspanish\@@unitstringspanish % \end{macrocode} -% \DescribeMacro\@@eightiesfrench Macro \cs{@@eightiesfrench} is used to format numbers in the interval -% \([80\intv 89]\). Argument as follows:\newline -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&digit \(d_{w}\) such that the number to be formatted is \(80 + d_{w}\)\\ -% \end{tabularx} -% Implicit arguments as:\newline -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \cs{count0}&weight \(w\) of the number \(d_{w+1}d_{w}\) to be formatted\\ -% \cs{count1}&same as \cs{\#1}\\ -% \cs{count6}&input, counter giving the least weight of non zero digits in top level formatted number -% integral part, with rounding down to a multiple of 3,\\ -% \cs{count9}&input, counter giving the power type of the power of ten following the eighties to be -% formatted; that is `1' for ``mil'' and `2' for ``\meta{$n$}illion\textbar \meta{$n$}illiard''. -% \end{tabularx} +% Feminine: % \begin{macrocode} -\newcommand*\@@eightiesfrench[1]{% -\fc@case quatre\@nil-\noexpand\fc@case vingt% -\ifnum#1>0 % - \ifnum\fc@frenchoptions@vingt@plural=0 % vingt plural=always - s% +\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 - \noexpand\@nil - -\@unitstring{#1}% -\else - \ifcase\fc@frenchoptions@vingt@plural\space - s% 0: always - \or - % 1: never - \or - s% 2: multiple - \or - % 3: multiple g-last - \ifnum\count0=\count6\ifnum\count9=0 s\fi\fi - \or - % 4: multiple l-last - \ifnum\count9=1 % - \else - s% - \fi - \or - % 5: multiple lng-last - \ifnum\count9=1 % - \else - \ifnum\count0>0 % - s% - \fi - \fi - \or - % or 6: multiple ng-last - \ifnum\count0>0 % - s% - \fi +}% +\global\let\@@unitstringFspanish\@@unitstringFspanish +% \end{macrocode} +% Tens (argument must go from 1 to 10): +%\changes{2.0}{2012-06-18}{fixed spelling mistake (correction +%provided by Fernando Maldonado)} +% \begin{macrocode} +\newcommand*\@@tenstringspanish[1]{% + \ifcase#1\relax + \or diez% + \or veinte% + \or treinta% + \or cuarenta% + \or cincuenta% + \or sesenta% + \or setenta% + \or ochenta% + \or noventa% + \or cien% \fi - \noexpand\@nil -\fi -} -\newcommand*{\@@ninetiesfrench}[1]{% -\fc@case quatre\@nil-\noexpand\fc@case vingt% -\ifnum\fc@frenchoptions@vingt@plural=0 % vingt plural=always - s% -\fi -\noexpand\@nil --\@teenstring{#1}% -} -\newcommand*{\@@seventiesfrenchswiss}[1]{% -\@tenstring{7}% -\ifnum#1=1\ \@andname\ \fi -\ifnum#1>1-\fi -\ifnum#1>0 \@unitstring{#1}\fi -} -\newcommand*{\@@eightiesfrenchswiss}[1]{% -\@tenstring{8}% -\ifnum#1=1\ \@andname\ \fi -\ifnum#1>1-\fi -\ifnum#1>0 \@unitstring{#1}\fi -} -\newcommand*{\@@ninetiesfrenchswiss}[1]{% -\@tenstring{9}% -\ifnum#1=1\ \@andname\ \fi -\ifnum#1>1-\fi -\ifnum#1>0 \@unitstring{#1}\fi -} +}% +\global\let\@@tenstringspanish\@@tenstringspanish % \end{macrocode} -% \DescribeMacro\fc@french@common Macro \cs{fc@french@common} does all the preliminary settings common to all -% French dialects \& formatting options. +% Teens: % \begin{macrocode} -\newcommand*\fc@french@common{% - \let\@unitstring=\@@unitstringfrench - \let\@teenstring=\@@teenstringfrench - \let\@tenstring=\@@tenstringfrench - \def\@hundred{cent}% - \def\@andname{et}% -} +\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 +}% +\global\let\@@teenstringspanish\@@teenstringspanish % \end{macrocode} +% Twenties: % \begin{macrocode} -\DeclareRobustCommand{\@numberstringMfrenchswiss}[2]{% -\let\fc@case\fc@CaseIden -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\let\fc@nbrstr@preamble\@empty -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@numberstringMfrenchfrance}[2]{% -\let\fc@case\fc@CaseIden -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\@empty -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@numberstringMfrenchbelgian}[2]{% -\let\fc@case\fc@CaseIden -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\@empty -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\let\@numberstringMfrench=\@numberstringMfrenchfrance -\DeclareRobustCommand{\@numberstringFfrenchswiss}[2]{% -\let\fc@case\fc@CaseIden -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@numberstringFfrenchfrance}[2]{% -\let\fc@case\fc@CaseIden -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@numberstringFfrenchbelgian}[2]{% -\let\fc@case\fc@CaseIden -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\let\@numberstringFfrench=\@numberstringFfrenchfrance -\let\@ordinalstringNfrench\@ordinalstringMfrench -\DeclareRobustCommand{\@NumberstringMfrenchswiss}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\let\fc@nbrstr@preamble\@empty -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@NumberstringMfrenchfrance}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\@empty -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@NumberstringMfrenchbelgian}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\@empty -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\let\@NumberstringMfrench=\@NumberstringMfrenchfrance -\DeclareRobustCommand{\@NumberstringFfrenchswiss}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@NumberstringFfrenchfrance}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\DeclareRobustCommand{\@NumberstringFfrenchbelgian}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\let\fc@nbrstr@preamble\fc@@nbrstr@Fpreamble -\let\fc@nbrstr@postamble\@empty -\@@numberstringfrench{#1}{#2}} -\let\@NumberstringFfrench=\@NumberstringFfrenchfrance -\let\@NumberstringNfrench\@NumberstringMfrench -\DeclareRobustCommand{\@ordinalstringMfrenchswiss}[2]{% -\let\fc@case\fc@CaseIden -\let\fc@first=\fc@@firstfrench -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\@@ordinalstringfrench{#1}{#2}% -} -\newcommand*\fc@@firstfrench{premier} -\newcommand*\fc@@firstFfrench{premi\`ere} -\DeclareRobustCommand{\@ordinalstringMfrenchfrance}[2]{% -\let\fc@case\fc@CaseIden -\let\fc@first=\fc@@firstfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}} -\DeclareRobustCommand{\@ordinalstringMfrenchbelgian}[2]{% -\let\fc@case\fc@CaseIden -\let\fc@first=\fc@@firstfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}% -} -\let\@ordinalstringMfrench=\@ordinalstringMfrenchfrance -\DeclareRobustCommand{\@ordinalstringFfrenchswiss}[2]{% -\let\fc@case\fc@CaseIden -\let\fc@first=\fc@@firstFfrench -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\@@ordinalstringfrench{#1}{#2}% -} -\DeclareRobustCommand{\@ordinalstringFfrenchfrance}[2]{% -\let\fc@case\fc@CaseIden -\let\fc@first=\fc@@firstFfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}% -} -\DeclareRobustCommand{\@ordinalstringFfrenchbelgian}[2]{% -\let\fc@case\fc@CaseIden -\let\fc@first=\fc@@firstFfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}% -} -\let\@ordinalstringFfrench=\@ordinalstringFfrenchfrance -\let\@ordinalstringNfrench\@ordinalstringMfrench -\DeclareRobustCommand{\@OrdinalstringMfrenchswiss}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\let\fc@first=\fc@@firstfrench -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\@@ordinalstringfrench{#1}{#2}% -} -\DeclareRobustCommand{\@OrdinalstringMfrenchfrance}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\let\fc@first=\fc@@firstfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}% -} -\DeclareRobustCommand{\@OrdinalstringMfrenchbelgian}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\let\fc@first=\fc@@firstfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}% -} -\let\@OrdinalstringMfrench=\@OrdinalstringMfrenchfrance -\DeclareRobustCommand{\@OrdinalstringFfrenchswiss}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\let\fc@first=\fc@@firstfrench -\fc@french@common -\let\@seventies=\@@seventiesfrenchswiss -\let\@eighties=\@@eightiesfrenchswiss -\let\@nineties=\@@ninetiesfrenchswiss -\@@ordinalstringfrench{#1}{#2}% -} -\DeclareRobustCommand{\@OrdinalstringFfrenchfrance}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\let\fc@first=\fc@@firstFfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}% -} -\DeclareRobustCommand{\@OrdinalstringFfrenchbelgian}[2]{% -\let\fc@case\fc@UpperCaseFirstLetter -\let\fc@first=\fc@@firstFfrench -\fc@french@common -\let\@seventies=\@@seventiesfrench -\let\@eighties=\@@eightiesfrench -\let\@nineties=\@@ninetiesfrench -\@@ordinalstringfrench{#1}{#2}% -} -\let\@OrdinalstringFfrench=\@OrdinalstringFfrenchfrance -\let\@OrdinalstringNfrench\@OrdinalstringMfrench +\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 +}% +\global\let\@@twentystringspanish\@@twentystringspanish % \end{macrocode} -% \DescribeMacro\fc@@do@plural@mark Macro \cs{fc@@do@plural@mark} will expand to the plural mark of -% \meta{$n$}illiard, \meta{$n$}illion, mil, cent or vingt, whichever is applicable. First check that the macro -% is not yet defined. +% Feminine form: % \begin{macrocode} -\ifcsundef{fc@@do@plural@mark}{}% -{\PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@@do@plural@mark'}} +\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 +}% +\global\let\@@twentystringFspanish\@@twentystringFspanish % \end{macrocode} -% Arguments as follows:\newline -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&plural mark, `s' in general, but for mil it is \cs{fc@frenchoptions@mil@plural@mark}\\ -% \end{tabularx} -% Implicit arguments as follows:\newline -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \cs{count0}&input, counter giving the weight \(w\), this is expected to be multiple of 3,\\ -% \cs{count1}&input, counter giving the plural value of multiplied object \meta{$n$}illiard, -% \meta{$n$}illion, mil, cent or vingt, whichever is applicable, that is to say it is 1 when the considered -% objet is not multiplied, and 2 or more when it is multiplied,\\ -% \cs{count6}&input, counter giving the least weight of non zero digits in top level formatted number -% integral part, with rounding down to a multiple of 3,\\ -% \cs{count10}&input, counter giving the plural mark control option.\\ -% \end{tabularx} +% Hundreds: % \begin{macrocode} -\def\fc@@do@plural@mark#1{% - \ifcase\count10 % - #1% 0=always - \or% 1=never - \or% 2=multiple - \ifnum\count1>1 % - #1% - \fi - \or% 3= multiple g-last - \ifnum\count1>1 % - \ifnum\count0=\count6 % - #1% - \fi - \fi - \or% 4= multiple l-last - \ifnum\count1>1 % - \ifnum\count9=1 % - \else - #1% - \fi - \fi - \or% 5= multiple lng-last - \ifnum\count1>1 % - \ifnum\count9=1 % - \else - \if\count0>\count6 % - #1% - \fi - \fi - \fi - \or% 6= multiple ng-last - \ifnum\count1>1 % - \ifnum\count0>\count6 % - #1% - \fi - \fi +\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 +}% +\global\let\@@hundredstringspanish\@@hundredstringspanish +% \end{macrocode} +% Feminine form: +% \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 +}% +\global\let\@@hundredstringFspanish\@@hundredstringFspanish +% \end{macrocode} +% As above, but with initial letter uppercase: +% \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 +}% +\global\let\@@Unitstringspanish\@@Unitstringspanish +% \end{macrocode} +% Feminine form: +% \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 +}% +\global\let\@@UnitstringFspanish\@@UnitstringFspanish +% \end{macrocode} +% Tens: +% \begin{macrocode} +%\changes{2.0}{2012-06-18}{fixed spelling mistake (correction +%provided by Fernando Maldonado)} +\newcommand*\@@Tenstringspanish[1]{% + \ifcase#1\relax + \or Diez% + \or Veinte% + \or Treinta% + \or Cuarenta% + \or Cincuenta% + \or Sesenta% + \or Setenta% + \or Ochenta% + \or Noventa% + \or Cien% + \fi +}% +\global\let\@@Tenstringspanish\@@Tenstringspanish +% \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% + \fi +}% +\global\let\@@Teenstringspanish\@@Teenstringspanish +% \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 +}% +\global\let\@@Twentystringspanish\@@Twentystringspanish +% \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 +}% +\global\let\@@TwentystringFspanish\@@TwentystringFspanish +% \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 +}% +\global\let\@@Hundredstringspanish\@@Hundredstringspanish +% \end{macrocode} +% Feminine form: +% \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 -} -% \end{macrocode} -% \DescribeMacro\fc@@nbrstr@Fpreamble Macro \cs{fc@@nbrstr@Fpreamble} do the necessary preliminaries before -% formatting a cardinal with feminine gender. -% \begin{macrocode} -\ifcsundef{fc@@nbrstr@Fpreamble}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@@nbrstr@Fpreamble'}} +}% +\global\let\@@HundredstringFspanish\@@HundredstringFspanish % \end{macrocode} -% \DescribeMacro\fc@@nbrstr@Fpreamble +% 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} -\def\fc@@nbrstr@Fpreamble{% - \fc@read@unit{\count1}{0}% - \ifnum\count1=1 % - \let\fc@case@save\fc@case - \def\fc@case{\noexpand\fc@case}% - \def\@nil{\noexpand\@nil}% - \let\fc@nbrstr@postamble\fc@@nbrstr@Fpostamble - \fi -} +\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}% +}% +\global\let\@numberstringMspanish\@numberstringMspanish % \end{macrocode} -% \DescribeMacro\fc@@nbrstr@Fpostamble +% Feminine form: +%\changes{2.0}{2012-06-18}{changed andname to `b' (correction +%provided by Fernando Maldonado)} % \begin{macrocode} -\def\fc@@nbrstr@Fpostamble{% - \let\fc@case\fc@case@save - \expandafter\fc@get@last@word\expandafter{\@tempa}\@tempb\@tempc - \def\@tempd{un}% - \ifx\@tempc\@tempd - \let\@tempc\@tempa - \edef\@tempa{\@tempb\fc@case une\@nil}% - \fi -} +\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{b}% + \@@numberstringspanish{#1}{#2}% +}% +\global\let\@numberstringFspanish\@numberstringFspanish % \end{macrocode} -% \DescribeMacro\fc@@pot@longscalefrench Macro \cs{fc@@pot@longscalefrench} is used to produce -% powers of ten with long scale convention. The long scale convention is correct for French and elsewhere in -% Europe. First we check that the macro is not yet defined. +% Make neuter same as masculine: % \begin{macrocode} -\ifcsundef{fc@@pot@longscalefrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@@pot@longscalefrench'}} +\global\let\@numberstringNspanish\@numberstringMspanish % \end{macrocode} -% Argument are as follows:\def\interface{\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&input, plural value of \(d\), that is to say: let \(d\) be the number multiplying the considered power -% of ten, then the plural value \texttt{\#2} is expected to be \(0\) if \(d=0\), \(1\) if \(d=1\), or \(>1\) -% if \(d>1\)\\ -% \#2&output, counter, maybe \(0\) when power of ten is \(1\), \(1\) when power of ten starts with -% ``mil(le)'', or \(2\) when power of ten is a ``\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)''\\ -% \#3&output, macro into which to place the formatted power of ten -% \end{tabularx} -% Implicit arguments as follows:\newline -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \cs{count0}&input, counter giving the weight \(w\), this is expected to be multiple of 3\\ -% \end{tabularx} -% }\interface +% As above, but initial letters in upper case: % \begin{macrocode} -\def\fc@@pot@longscalefrench#1#2#3{% - {% +\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}% +}% +\global\let\@NumberstringMspanish\@NumberstringMspanish % \end{macrocode} -% First the input arguments are saved into local objects: \texttt{\#1} and \texttt{\#1} are respectively saved -% into \cs{@tempa} and \cs{@tempb}. +% Feminine form: +%\changes{2.0}{2012-06-18}{changed andname to `b' (correction +%provided by Fernando Maldonado)} % \begin{macrocode} - \edef\@tempb{\number#1}% +\DeclareRobustCommand{\@NumberstringFspanish}[2]{% + \let\@unitstring=\@@UnitstringFspanish + \let\@teenstring=\@@Teenstringspanish + \let\@tenstring=\@@Tenstringspanish + \let\@twentystring=\@@TwentystringFspanish + \let\@hundredstring=\@@HundredstringFspanish + \def\@andname{b}% + \def\@hundred{Cien}\def\@thousand{Mil}% + \@@numberstringspanish{#1}{#2}% +}% +\global\let\@NumberstringFspanish\@NumberstringFspanish % \end{macrocode} -% Let \cs{count1} be the plural value. +% Make neuter same as masculine: % \begin{macrocode} - \count1=\@tempb +\global\let\@NumberstringNspanish\@NumberstringMspanish % \end{macrocode} -% Let \(n\) and \(r\) the the quotient and remainder of division of weight \(w\) by \(6\), that is to say \(w -% = n\times 6 + r\) and \(0\leq r < 6\), then \cs{count2} is set to \(n\) and \cs{count3} is set to \(r\). +% As above, but for ordinals. % \begin{macrocode} - \count2\count0 % - \divide\count2 by 6 % - \count3\count2 % - \multiply\count3 by 6 % - \count3-\count3 % - \advance\count3 by \count0 % - \ifnum\count0>0 % +\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}% +}% +\global\let\@ordinalstringMspanish\@ordinalstringMspanish % \end{macrocode} -% If weight \(w\) (a.k.a. \cs{count0}) is such that \(w>0\), then \(w\geq 3\) because \(w\) is a multiple of -% \(3\). So we \emph{may} have to append ``mil(le)'' or ``\meta{$n$}illion(s)'' or ``\meta{$n$}illiard(s)''. +% Feminine form: % \begin{macrocode} - \ifnum\count1>0 % +\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}% +}% +\global\let\@ordinalstringFspanish\@ordinalstringFspanish % \end{macrocode} -% Plural value is \(>0\) so have at least one ``mil(le)'' or ``\meta{$n$}illion(s)'' or -% ``\meta{$n$}illiard(s)''. We need to distinguish between the case of ``mil(le)'' and that of -% ``\meta{$n$}illion(s)'' or ``\meta{$n$}illiard(s)'', so we \cs{def}ine \cs{@temph} to `\texttt{1}' for -% ``mil(le)'', and to `\texttt{2}' otherwise. +% Make neuter same as masculine: % \begin{macrocode} - \edef\@temph{% - \ifnum\count2=0 % weight=3 +\global\let\@ordinalstringNspanish\@ordinalstringMspanish % \end{macrocode} -% Here \(n=0\), with \(n=w\div 6\),but we also know that \(w\geq 3\), so we have \(w=3\) which means we are in -% the ``mil(le)'' case. +% As above, but with initial letters in upper case. % \begin{macrocode} - 1% - \else - \ifnum\count3>2 % +\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}% +} +\global\let\@OrdinalstringMspanish\@OrdinalstringMspanish % \end{macrocode} -% Here we are in the case of \(3\leq r < 6\), with \(r\) the remainder of division of weight \(w\) by \(6\), -% we should have ``\meta{$n$}illiard(s)'', but that may also be ``mil(le)'' instead depending on -% option `\texttt{n-illiard upto}', known as \cs{fc@longscale@nilliard@upto}. +% Feminine form: % \begin{macrocode} - \ifnum\fc@longscale@nilliard@upto=0 % +\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}% +}% +\global\let\@OrdinalstringFspanish\@OrdinalstringFspanish % \end{macrocode} -% Here option `\texttt{n-illiard upto}' is `\texttt{infinity}', so we always use ``\meta{$n$}illiard(s)''. +% Make neuter same as masculine: % \begin{macrocode} - 2% - \else +\global\let\@OrdinalstringNspanish\@OrdinalstringMspanish % \end{macrocode} -% Here option `\texttt{n-illiard upto}' indicate some threshold to which to compare \(n\) -% (a.k.a. \cs{count2}). +% Code for convert numbers into textual ordinals. As before, +% it is easier to split it into units, tens, teens and hundreds. +% Units: % \begin{macrocode} - \ifnum\count2>\fc@longscale@nilliard@upto - 1% - \else - 2% - \fi - \fi - \else - 2% - \fi - \fi - }% - \ifnum\@temph=1 % +\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 +}% +\global\let\@@unitthstringspanish\@@unitthstringspanish % \end{macrocode} -% Here \(10^w\) is formatted as ``mil(le)''. +% Tens: % \begin{macrocode} - \count10=\fc@frenchoptions@mil@plural\space - \edef\@tempe{% - \noexpand\fc@case - mil% - \fc@@do@plural@mark\fc@frenchoptions@mil@plural@mark - \noexpand\@nil - }% - \else - % weight >= 6 - \expandafter\fc@@latin@cardinal@pefix\expandafter{\the\count2}\@tempg - % now form the xxx-illion(s) or xxx-illiard(s) word - \ifnum\count3>2 % - \toks10{illiard}% - \count10=\csname fc@frenchoptions@n-illiard@plural\endcsname\space - \else - \toks10{illion}% - \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space - \fi - \edef\@tempe{% - \noexpand\fc@case - \@tempg - \the\toks10 % - \fc@@do@plural@mark s% - \noexpand\@nil - }% - \fi - \else +\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 +}% +\global\let\@@tenthstringspanish\@@tenthstringspanish % \end{macrocode} -% Here plural indicator of \(d\) indicates that \(d = 0\), so we have \(0\times10^{w}\), and it is not worth -% to format \(10^{w}\), because there are none of them. +% Teens: % \begin{macrocode} - \let\@tempe\@empty - \def\@temph{0}% - \fi - \else +\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 +}% +\global\let\@@teenthstringspanish\@@teenthstringspanish % \end{macrocode} -% Case of \(w=0\). +% Hundreds: % \begin{macrocode} - \let\@tempe\@empty - \def\@temph{0}% - \fi +\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 +}% +\global\let\@@hundredthstringspanish\@@hundredthstringspanish % \end{macrocode} -% Now place into \@cs{@tempa} the assignment of results \cs{@temph} and \cs{@tempe} to \texttt{\#2} and -% \texttt{\#3} for further propagation after closing brace. +% Units (feminine): % \begin{macrocode} - \expandafter\toks\expandafter1\expandafter{\@tempe}% - \toks0{#2}% - \edef\@tempa{\the\toks0 \@temph \def\noexpand#3{\the\toks1}}% - \expandafter - }\@tempa -} +\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 +}% +\global\let\@@unitthstringFspanish\@@unitthstringFspanish % \end{macrocode} -% \DescribeMacro\fc@@pot@shortscalefrench Macro \cs{fc@@pot@shortscalefrench} is used to produce -% powers of ten with short scale convention. This convention is the US convention and is not correct for -% French and elsewhere in Europe. First we check that the macro is not yet defined. +% Tens (feminine): % \begin{macrocode} -\ifcsundef{fc@@pot@shortscalefrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@@pot@shortscalefrench'}} +\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 +}% +\global\let\@@tenthstringFspanish\@@tenthstringFspanish % \end{macrocode} -% Arguments as follows --- same interface as for \cs{fc@@pot@longscalefrench}:\interface +% Teens (feminine) % \begin{macrocode} -\def\fc@@pot@shortscalefrench#1#2#3{% - {% +\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 +}% +\global\let\@@teenthstringFspanish\@@teenthstringFspanish % \end{macrocode} -% First save input arguments \texttt{\#1}, \texttt{\#2}, and \texttt{\#3} into local macros -% respectively \cs{@tempa}, \cs{@tempb}, \cs{@tempc} and \cs{@tempd}. +% Hundreds (feminine) % \begin{macrocode} - \edef\@tempb{\number#1}% +\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 +}% +\global\let\@@hundredthstringFspanish\@@hundredthstringFspanish % \end{macrocode} -% And let \cs{count1} be the plural value. +% As above, but with initial letters in upper case % \begin{macrocode} - \count1=\@tempb +\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 +}% +\global\let\@@Unitthstringspanish\@@Unitthstringspanish % \end{macrocode} -% Now, let \cs{count2} be the integer \(n\) generating the pseudo latin prefix, i.e. \(n\) is such that \(w = -% 3\times n + 3\). +% Tens: % \begin{macrocode} - \count2\count0 % - \divide\count2 by 3 % - \advance\count2 by -1 % +\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 +}% +\global\let\@@Tenthstringspanish\@@Tenthstringspanish % \end{macrocode} -% Here is the real job, the formatted power of ten will go to \cs{@tempe}, and its power type will go to -% \cs{@temph}. Please remember that the power type is an index in \([0\intv 2]\) indicating whether \(10^w\) -% is formatted as \meta{nothing}, ``mil(le)'' or ``\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)''. +% Teens: % \begin{macrocode} - \ifnum\count0>0 % If weight>=3, i.e we do have to append thousand or n-illion(s)/n-illiard(s) - \ifnum\count1>0 % we have at least one thousand/n-illion/n-illiard - \ifnum\count2=0 % - \def\@temph{1}% - \count1=\fc@frenchoptions@mil@plural\space - \edef\@tempe{% - mil% - \fc@@do@plural@mark\fc@frenchoptions@mil@plural@mark - }% - \else - \def\@temph{2}% - % weight >= 6 - \expandafter\fc@@latin@cardinal@pefix\expandafter{\the\count2}\@tempg - \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space - \edef\@tempe{% - \noexpand\fc@case - \@tempg - illion% - \fc@@do@plural@mark s% - \noexpand\@nil - }% - \fi - \else +\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 +}% +\global\let\@@Teenthstringspanish\@@Teenthstringspanish % \end{macrocode} -% Here we have \(d=0\), so nothing is to be formatted for \(d\times 10^w\). +% Hundreds % \begin{macrocode} - \def\@temph{0}% - \let\@tempe\@empty - \fi - \else +\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 +}% +\global\let\@@Hundredthstringspanish\@@Hundredthstringspanish % \end{macrocode} -% Here \(w=0\). +% As above, but feminine. % \begin{macrocode} - \def\@temph{0}% - \let\@tempe\@empty - \fi -% now place into \@cs{@tempa} the assignment of results \cs{@temph} and \cs{@tempe} to to \texttt{\#2} and -% \texttt{\#3} for further propagation after closing brace. +\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 +}% +\global\let\@@UnitthstringFspanish\@@UnitthstringFspanish +% \end{macrocode} +% Tens (feminine) % \begin{macrocode} - \expandafter\toks\expandafter1\expandafter{\@tempe}% - \toks0{#2}% - \edef\@tempa{\the\toks0 \@temph \def\noexpand#3{\the\toks1}}% - \expandafter - }\@tempa -} +\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 +}% +\global\let\@@TenthstringFspanish\@@TenthstringFspanish % \end{macrocode} -% \DescribeMacro\fc@@pot@recursivefrench Macro \cs{fc@@pot@recursivefrench} is used to produce -% power of tens that are of the form ``million de milliards de milliards'' for \(10^{24}\). First we check -% that the macro is not yet defined. +% Teens (feminine): % \begin{macrocode} -\ifcsundef{fc@@pot@recursivefrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@@pot@recursivefrench'}} +\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 +}% +\global\let\@@TeenthstringFspanish\@@TeenthstringFspanish % \end{macrocode} -% The arguments are as follows --- same interface as for \cs{fc@@pot@longscalefrench}:\interface +% Hundreds (feminine): % \begin{macrocode} -\def\fc@@pot@recursivefrench#1#2#3{% - {% +\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 +}% +\global\let\@@HundredthstringFspanish\@@HundredthstringFspanish % \end{macrocode} -% First the input arguments are saved into local objects: \texttt{\#1} and \texttt{\#1} are respectively saved -% into \cs{@tempa} and \cs{@tempb}. +% 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} - \edef\@tempb{\number#1}% - \let\@tempa\@@tempa +\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 % \end{macrocode} -% New get the inputs \texttt{\#1} and \texttt{\#1} into counters \cs{count0} and \cs{count1} as this is more -% practical. +% \#1 is greater or equal to 10000 % \begin{macrocode} - \count1=\@tempb\space + \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 + \@FCmodulo{\@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 + \@FCmodulo{\@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 \@FCmodulo{\@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 + \@FCmodulo{\@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 \@FCmodulo{\@strctr}{100}% +\ifnum#1>100\relax + \ifnum\@strctr>0\relax + \let\@@fc@numstr#2\relax % \end{macrocode} -% Now compute into \cs{count2} how many times ``de milliards'' has to be repeated. +%\changes{2.0}{2012-06-18}{removed andname (correction +%provided by Fernando Maldonado)} % \begin{macrocode} - \ifnum\count1>0 % - \count2\count0 % - \divide\count2 by 9 % - \advance\count2 by -1 % - \let\@tempe\@empty - \edef\@tempf{\fc@frenchoptions@supermillion@dos - de\fc@frenchoptions@supermillion@dos\fc@case milliards\@nil}% - \count11\count0 % - \ifnum\count2>0 % - \count3\count2 % - \count3-\count3 % - \multiply\count3 by 9 % - \advance\count11 by \count3 % - \loop - % (\count2, \count3) <- (\count2 div 2, \count2 mod 2) - \count3\count2 % - \divide\count3 by 2 % - \multiply\count3 by 2 % - \count3-\count3 % - \advance\count3 by \count2 % - \divide\count2 by 2 % - \ifnum\count3=1 % - \let\@tempg\@tempe - \edef\@tempe{\@tempg\@tempf}% - \fi - \let\@tempg\@tempf - \edef\@tempf{\@tempg\@tempg}% - \ifnum\count2>0 % - \repeat - \fi - \divide\count11 by 3 % - \ifcase\count11 % 0 .. 5 - % 0 => d milliard(s) (de milliards)* - \def\@temph{2}% - \count10=\csname fc@frenchoptions@n-illiard@plural\endcsname\space - \or % 1 => d mille milliard(s) (de milliards)* - \def\@temph{1}% - \count10=\fc@frenchoptions@mil@plural\space - \or % 2 => d million(s) (de milliards)* - \def\@temph{2}% - \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space - \or % 3 => d milliard(s) (de milliards)* - \def\@temph{2}% - \count10=\csname fc@frenchoptions@n-illiard@plural\endcsname\space - \or % 4 => d mille milliards (de milliards)* - \def\@temph{1}% - \count10=\fc@frenchoptions@mil@plural\space - \else % 5 => d million(s) (de milliards)* - \def\@temph{2}% - \count10=\csname fc@frenchoptions@n-illion@plural\endcsname\space + \edef#2{\@@fc@numstr\ }% + \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 \@FCmodulo{\@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 - \let\@tempg\@tempe - \edef\@tempf{% - \ifcase\count11 % 0 .. 5 - \or - mil\fc@@do@plural@mark \fc@frenchoptions@mil@plural@mark - \or - million\fc@@do@plural@mark s% - \or - milliard\fc@@do@plural@mark s% - \or - mil\fc@@do@plural@mark\fc@frenchoptions@mil@plural@mark - \noexpand\@nil\fc@frenchoptions@supermillion@dos - \noexpand\fc@case milliards% 4 - \or - million\fc@@do@plural@mark s% - \noexpand\@nil\fc@frenchoptions@supermillion@dos - de\fc@frenchoptions@supermillion@dos\noexpand\fc@case milliards% 5 - \fi - }% - \edef\@tempe{% - \ifx\@tempf\@empty\else - \expandafter\fc@case\@tempf\@nil + \else + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@unitstring{\@strctr}}% + \fi + \else + \ifnum\@strctr>19\relax + \@FCmodulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@twentystring{\@strctr}}% + \else + \@FCmodulo{\@strctr}{10}% + \let\@@fc@numstr#2\relax + \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \fi + \fi +\fi +}% +\global\let\@@numberstringspanish\@@numberstringspanish +% \end{macrocode} +% As above, but for ordinals +% \begin{macrocode} +\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 + \@FCmodulo{\@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 + \@FCmodulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\@unitthstring{\@tmpstrctr}}% \fi - \@tempg - }% + \fi \else - \def\@temph{0}% - \let\@tempe\@empty + \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 +\@FCmodulo{\@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 +\@FCmodulo{\@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 + \@FCmodulo{\@tmpstrctr}{10}% + \ifnum\@tmpstrctr>0\relax + \let\@@fc@ordstr#2\relax + \edef#2{\@@fc@ordstr\ \@unitthstring{\@tmpstrctr}}% + \fi +\else + \ifnum\@strctr>9\relax + \@FCmodulo{\@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 +}% +\global\let\@@ordinalstringspanish\@@ordinalstringspanish % \end{macrocode} -% now place into \@cs{@tempa} the assignment of results \cs{@temph} and \cs{@tempe} to to \texttt{\#2} and -% \texttt{\#3} for further propagation after closing brace. + +%\iffalse % \begin{macrocode} - \expandafter\toks\expandafter1\expandafter{\@tempe}% - \toks0{#2}% - \edef\@tempa{\the\toks0 \@temph \def\noexpand#3{\the\toks1}}% - \expandafter - }\@tempa -} +% % \end{macrocode} -% \DescribeMacro\fc@muladdfrench Macro \cs{fc@muladdfrench} is used to format the sum of a number \(a\) and -% the product of a number \(d\) by a power of ten \(10^w\). Number \(d\) is made of three consecutive digits -% \(d_{w+2}d_{w+1}d_w\) of respective weights \(w+2\), \(w+1\), and \(w\), while number \(a\) is made of all -% digits with weight \(w' > w+2\) that have already been formatted. First check that the macro is not yet -% defined. +%\fi +%\iffalse % \begin{macrocode} -\ifcsundef{fc@muladdfrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@muladdfrench'}} +%<*fc-UKenglish.def> % \end{macrocode} -% Arguments as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#2&input, plural indicator for number \(d\)\\ -% \#3&input, formatted number \(d\)\\ -% \#5&input, formatted number \(10^w\), i.e. power of ten which is multiplied by \(d\)\\ -% \end{tabularx} -% Implicit arguments from context:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \cs{@tempa}&input, formatted number \(a\)\\ -% &output, macro to which place the mul-add result\\ -% \cs{count8}&input, power type indicator for \(10^{w'}\), where \(w'\) is a weight of \(a\), this is an -% index in \([0\intv 2]\) that reflects whether \(10^{w'}\) is formatted by ``mil(le)'' --- for index \(=1\) -% --- or by ``\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)'' --- for index \(=2\)\\ -% \cs{count9}&input, power type indicator for \(10^w\), this is an index in \([0\intv 2]\) that reflect -% whether the weight \(w\) of \(d\) is formatted by ``meta{nothing}'' --- for index \(=0\), ``mil(le)'' --- -% for index -% \(=1\) --- or by ``\meta{$n$}illion(s)\textbar \meta{$n$}illiard(s)'' --- for index \(=2\)\\ -% \end{tabularx} +%\fi +% \subsubsection{fc-UKenglish.def} +% English definitions % \begin{macrocode} -\def\fc@muladdfrench#1#2#3{% - {% +\ProvidesFCLanguage{UKenglish}[2013/08/17]% % \end{macrocode} -% First we save input arguments \texttt{\#1} -- \texttt{\#3} to local macros \cs{@tempc}, \cs{@tempd} and -% \cs{@tempf}. +% Loaded fc-english.def if not already loaded % \begin{macrocode} - \edef\@@tempc{#1}% - \edef\@@tempd{#2}% - \edef\@tempf{#3}% - \let\@tempc\@@tempc - \let\@tempd\@@tempd +\FCloadlang{english}% % \end{macrocode} -% First we want to do the ``multiplication'' of \(d \Rightarrow \cs{@tempd}\) and of \(10^w \Rightarrow -% \cs{@tempf}\). So, prior to this we do some preprocessing of \(d \Rightarrow \cs{@tempd}\): we force -% \cs{@tempd} to \meta{empty} if both \(d=1\) and \(10^w\Rightarrow\) ``mil(le)'', this is because we, -% French, we do not say ``un mil'', but just ``mil''. +% These are all just synonyms for the commands provided by +% fc-english.def. % \begin{macrocode} - \ifnum\@tempc=1 % - \ifnum\count9=1 % - \let\@tempd\@empty - \fi - \fi -% \end{macrocode} -% Now we do the ``multiplication'' of \(d = \cs{@tempd}\) and of \(10^w = \cs{@tempf}\), and place the result -% into \cs{@tempg}. +\global\let\@ordinalMUKenglish\@ordinalMenglish +\global\let\@ordinalFUKenglish\@ordinalMenglish +\global\let\@ordinalNUKenglish\@ordinalMenglish +\global\let\@numberstringMUKenglish\@numberstringMenglish +\global\let\@numberstringFUKenglish\@numberstringMenglish +\global\let\@numberstringNUKenglish\@numberstringMenglish +\global\let\@NumberstringMUKenglish\@NumberstringMenglish +\global\let\@NumberstringFUKenglish\@NumberstringMenglish +\global\let\@NumberstringNUKenglish\@NumberstringMenglish +\global\let\@ordinalstringMUKenglish\@ordinalstringMenglish +\global\let\@ordinalstringFUKenglish\@ordinalstringMenglish +\global\let\@ordinalstringNUKenglish\@ordinalstringMenglish +\global\let\@OrdinalstringMUKenglish\@OrdinalstringMenglish +\global\let\@OrdinalstringFUKenglish\@OrdinalstringMenglish +\global\let\@OrdinalstringNUKenglish\@OrdinalstringMenglish +% \end{macrocode} +%\iffalse % \begin{macrocode} - \edef\@tempg{% - \@tempd - \ifx\@tempd\@empty\else - \ifx\@tempf\@empty\else - \ifcase\count9 % - \or - \fc@frenchoptions@submillion@dos - \or - \fc@frenchoptions@supermillion@dos - \fi - \fi - \fi - \@tempf - }% +% % \end{macrocode} -% Now to the ``addition'' of \(a\Rightarrow \cs{@tempa}\) and \(d\times 10^w\Rightarrow \cs{@tempg}\), and -% place the results into \cs{@temph}. +%\fi +%\iffalse % \begin{macrocode} - \edef\@temph{% - \@tempa - \ifx\@tempa\@empty\else - \ifx\@tempg\@empty\else - \ifcase\count8 % - \or - \fc@frenchoptions@submillion@dos - \or - \fc@frenchoptions@supermillion@dos - \fi - \fi - \fi - \@tempg - }% +%<*fc-USenglish.def> % \end{macrocode} -% Now propagate the result --- i.e. the expansion of \cs{@temph} --- into macro \cs{@tempa} after closing -% brace. +%\fi +% \subsubsection{fc-USenglish.def} +% US English definitions % \begin{macrocode} - \def\@tempb##1{\def\@tempa{\def\@tempa{##1}}}% - \expandafter\@tempb\expandafter{\@temph}% - \expandafter - }\@tempa -}% +\ProvidesFCLanguage{USenglish}[2013/08/17]% % \end{macrocode} -% \DescribeMacro\fc@lthundredstringfrench Macro \cs{fc@lthundredstringfrench} is used to format a number in -% interval \([0 \intv 99]\). First we check that it is not already defined. +% Loaded fc-english.def if not already loaded % \begin{macrocode} -\ifcsundef{fc@lthundredstringfrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@lthundredstringfrench'}} +\FCloadlang{english}% % \end{macrocode} -% The number to format is not passed as an argument to this macro, instead each digits of it is in a -% \cs{fc@digit@\meta{w}} macro after this number has been parsed. So the only thing that -% \cs{fc@lthundredstringfrench} needs is to know \meta{w} which is passed as \cs{count0} for the less -% significant digit.\newline -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&intput/output macro to which append the result -% \end{tabularx} -% Implicit input arguments as follows:\newline -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \cs{count0}&weight \(w\) of least significant digit \(d_{w}\). -% \end{tabularx} -% The formatted number is appended to the content of \#1, and the result is placed into \#1. +% These are all just synonyms for the commands provided by +% fc-english.def. (This needs fixing as there are some differences +% between UK and US number strings.) % \begin{macrocode} -\def\fc@lthundredstringfrench#1{% - {% +\global\let\@ordinalMUSenglish\@ordinalMenglish +\global\let\@ordinalFUSenglish\@ordinalMenglish +\global\let\@ordinalNUSenglish\@ordinalMenglish +\global\let\@numberstringMUSenglish\@numberstringMenglish +\global\let\@numberstringFUSenglish\@numberstringMenglish +\global\let\@numberstringNUSenglish\@numberstringMenglish +\global\let\@NumberstringMUSenglish\@NumberstringMenglish +\global\let\@NumberstringFUSenglish\@NumberstringMenglish +\global\let\@NumberstringNUSenglish\@NumberstringMenglish +\global\let\@ordinalstringMUSenglish\@ordinalstringMenglish +\global\let\@ordinalstringFUSenglish\@ordinalstringMenglish +\global\let\@ordinalstringNUSenglish\@ordinalstringMenglish +\global\let\@OrdinalstringMUSenglish\@OrdinalstringMenglish +\global\let\@OrdinalstringFUSenglish\@OrdinalstringMenglish +\global\let\@OrdinalstringNUSenglish\@OrdinalstringMenglish % \end{macrocode} -% First save arguments into local temporary macro. +%\iffalse % \begin{macrocode} - \let\@tempc#1% +% % \end{macrocode} -% Read units \(d_w\) to \cs{count1}. +%\fi +%\iffalse % \begin{macrocode} - \fc@read@unit{\count1}{\count0}% +%<*fcnumparser.sty> % \end{macrocode} -% Read tens \(d_{w+1}\) to \cs{count2}. +%\fi +%\subsection{fcnumparser.sty} % \begin{macrocode} - \count3\count0 % - \advance\count3 1 % - \fc@read@unit{\count2}{\count3}% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{fcnumparser}[2012/09/28] % \end{macrocode} -% Now do the real job, set macro \cs{@tempa} to \texttt{\#1} followed by \(d_{w+1}d_w\) formatted. +% \cs{fc@counter@parser} is just a shorthand to parse a number held in a counter. % \begin{macrocode} - \edef\@tempa{% - \@tempc - \ifnum\count2>1 % - % 20 .. 99 - \ifnum\count2>6 % - % 70 .. 99 - \ifnum\count2<8 % - % 70 .. 79 - \@seventies{\count1}% - \else - % 80..99 - \ifnum\count2<9 % - % 80 .. 89 - \@eighties{\count1}% - \else - % 90 .. 99 - \@nineties{\count1}% - \fi - \fi - \else - % 20..69 - \@tenstring{\count2}% - \ifnum\count1>0 % - % x1 .. x0 - \ifnum\count1=1 % - % x1 - \fc@frenchoptions@submillion@dos\@andname\fc@frenchoptions@submillion@dos - \else - % x2 .. x9 - -% - \fi - \@unitstring{\count1}% - \fi - \fi - \else - % 0 .. 19 - \ifnum\count2=0 % when tens = 0 - % 0 .. 9 - \ifnum\count1=0 % when units = 0 - % \count3=1 when #1 = 0, i.e. only for the unit of the top level number - \ifnum\count3=1 % - \ifnum\fc@max@weight=0 % - \@unitstring{0}% - \fi - \fi - \else - % 1 .. 9 - \@unitstring{\count1}% - \fi - \else - % 10 .. 19 - \@teenstring{\count1}% - \fi - \fi - }% +\def\fc@counter@parser#1{% + \expandafter\fc@number@parser\expandafter{\the#1.}% +} % \end{macrocode} -% Now propagate the expansion of \cs{@tempa} into \texttt{\#1} after closing brace. % \begin{macrocode} - \def\@tempb##1{\def\@tempa{\def#1{##1}}}% - \expandafter\@tempb\expandafter{\@tempa}% - \expandafter - }\@tempa -} +\newcount\fc@digit@counter + +\def\fc@end@{\fc@end} % \end{macrocode} -% \DescribeMacro\fc@ltthousandstringfrench Macro \cs{fc@ltthousandstringfrench} is used to format a number in -% interval \([0 \intv 999]\). First we check that it is not already defined. +% \DescribeMacro{\fc@number@analysis} First of all we need to separate the number between integer and fractional +% part. Number to be analysed is in `\texttt{\#1}'. Decimal separator may be . or , whichever first. At end of +% this macro, integer part goes to \cs{fc@integer@part} and fractional part goes to \cs{fc@fractional@part}. % \begin{macrocode} -\ifcsundef{fc@ltthousandstringfrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `fc@ltthousandstringfrench'}} +\def\fc@number@analysis#1\fc@nil{% % \end{macrocode} -% Output is empty for 0. Arguments as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#2&output, macro, formatted number \(d = d_{w+2}d_{w+1}d_w\) -% \end{tabularx} -% Implicit input arguments as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \cs{count0}&input weight \(10^{w}\) of number \(d_{w+2}d_{w+1}d_w\) to be formatted.\\ -% \cs{count5}&least weight of formatted number with a non null digit.\\ -% \cs{count9}&input, power type indicator of \(10^{w}\) \(0\Rightarrow\varnothing\), \(1\Rightarrow\textrm { -% ``mil(le)''}\), \(2\Rightarrow\textrm {\meta{$n$}illion(s)\textbar\meta{$n$}illiard(s)}\)\\ -% \end{tabularx} +% First check for the presence of a decimal point in the number. % \begin{macrocode} -\def\fc@ltthousandstringfrench#1{% - {% + \def\@tempb##1.##2\fc@nil{\def\fc@integer@part{##1}\def\@tempa{##2}}% + \@tempb#1.\fc@end\fc@nil + \ifx\@tempa\fc@end@ % \end{macrocode} -% Set counter \cs{count2} to digit \(d_{w+2}\), i.e. hundreds. +% Here \cs{@tempa} is \cs{ifx}-equal to \cs{fc@end}, which means that the number does not contain any decimal +% point. So we do the same trick to search for a comma. % \begin{macrocode} - \count4\count0 % - \advance\count4 by 2 % - \fc@read@unit{\count2 }{\count4 }% + \def\@tempb##1,##2\fc@nil{\def\fc@integer@part{##1}\def\@tempa{##2}}% + \@tempb#1,\fc@end\fc@nil + \ifx\@tempa\fc@end@ % \end{macrocode} -% Check that the two subsequent digits \(d_{w+1}d_w\) are non zero, place check-result into \cs{@tempa}. +% No comma either, so fractional part is set empty. % \begin{macrocode} - \advance\count4 by -1 % - \count3\count4 % - \advance\count3 by -1 % - \fc@check@nonzeros{\count3 }{\count4 }\@tempa + \def\fc@fractional@part{}% + \else % \end{macrocode} -% Compute plural mark of `cent' into \cs{@temps}. +% Comma has been found, so we just need to drop `\texttt{,}\cs{fc@end}' from the end of \cs{@tempa} to get the +% fractional part. % \begin{macrocode} - \edef\@temps{% - \ifcase\fc@frenchoptions@cent@plural\space - % 0 => always - s% - \or - % 1 => never - \or - % 2 => multiple - \ifnum\count2>1s\fi - \or - % 3 => multiple g-last - \ifnum\count2>1 \ifnum\@tempa=0 \ifnum\count0=\count6s\fi\fi\fi - \or - % 4 => multiple l-last - \ifnum\count2>1 \ifnum\@tempa=0 \ifnum\count9=0s\else\ifnum\count9=2s\fi\fi\fi\fi - \fi - }% - % compute spacing after cent(s?) into \@tempb - \expandafter\let\expandafter\@tempb - \ifnum\@tempa>0 \fc@frenchoptions@submillion@dos\else\@empty\fi - % now place into \@tempa the hundreds - \edef\@tempa{% - \ifnum\count2=0 % - \else - \ifnum\count2=1 % - \expandafter\fc@case\@hundred\@nil - \else - \@unitstring{\count2}\fc@frenchoptions@submillion@dos - \noexpand\fc@case\@hundred\@temps\noexpand\@nil - \fi - \@tempb - \fi - }% - % now append to \@tempa the ten and unit - \fc@lthundredstringfrench\@tempa + \def\@tempb##1,\fc@end{\def\fc@fractional@part{##1}}% + \expandafter\@tempb\@tempa + \fi + \else % \end{macrocode} -% Propagate expansion of \cs{@tempa} into macro \texttt{\#1} after closing brace. +% Decimal point has been found, so we just need to drop `\texttt{.}\cs{fc@end}' from the end \cs{@tempa} to +% get the fractional part. % \begin{macrocode} - \def\@tempb##1{\def\@tempa{\def#1{##1}}}% - \expandafter\@tempb\expandafter{\@tempa}% - \expandafter - }\@tempa + \def\@tempb##1.\fc@end{\def\fc@fractional@part{##1}}% + \expandafter\@tempb\@tempa + \fi } % \end{macrocode} -% \DescribeMacro\@@numberstringfrench Macro \cs{@@numberstringfrench} is the main engine for formatting -% cadinal numbers in French. First we check that the control sequence is not yet defined. +% \DescribeMacro{\fc@number@parser} Macro \cs{fc@number@parser} is the main engine to parse a number. Argument +% `\#1' is input and contains the number to be parsed. At end of this macro, each digit is stored separately +% in a \cs{fc@digit@}\meta{$n$}, and macros \cs{fc@min@weight} and \cs{fc@max@weight} are set to the bounds +% for \meta{$n$}. % \begin{macrocode} -\ifcsundef{@@numberstringfrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro `@@numberstringfrench'}} +\def\fc@number@parser#1{% % \end{macrocode} -% Arguments are as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&number to convert to string\\ -% \#2¯o into which to place the result -% \end{tabularx} +% First remove all the spaces in \texttt{\#1}, and place the result into \cs{@tempa}. % \begin{macrocode} -\def\@@numberstringfrench#1#2{% - {% + \let\@tempa\@empty + \def\@tempb##1##2\fc@nil{% + \def\@tempc{##1}% + \ifx\@tempc\space + \else + \expandafter\def\expandafter\@tempa\expandafter{\@tempa ##1}% + \fi + \def\@tempc{##2}% + \ifx\@tempc\@empty + \expandafter\@gobble + \else + \expandafter\@tempb + \fi + ##2\fc@nil + }% + \@tempb#1\fc@nil % \end{macrocode} -% First parse input number to be formatted and do some error handling. +% Get the sign into \cs{fc@sign} and the unsigned number part into \cs{fc@number}. % \begin{macrocode} - \edef\@tempa{#1}% - \expandafter\fc@number@parser\expandafter{\@tempa}% - \ifnum\fc@min@weight<0 % - \PackageError{fmtcount}{Out of range}% - {This macro does not work with fractional numbers}% + \def\@tempb##1##2\fc@nil{\def\fc@sign{##1}\def\fc@number{##2}}% + \expandafter\@tempb\@tempa\fc@nil + \expandafter\if\fc@sign+% + \def\fc@sign@case{1}% + \else + \expandafter\if\fc@sign-% + \def\fc@sign@case{2}% + \else + \def\fc@sign{}% + \def\fc@sign@case{0}% + \let\fc@number\@tempa \fi + \fi + \ifx\fc@number\@empty + \PackageError{fcnumparser}{Invalid number}{Number must contain at least one non blank + character after sign}% + \fi % \end{macrocode} -% In the sequel, \cs{@tempa} is used to accumulate the formatted number. Please note that \cs{space} after -% \cs{fc@sign@case} is eaten by preceding number collection. This \cs{space} is needed so that when -% \cs{fc@sign@case} expands to `\texttt{0}', then \cs{@tempa} is defined to `' (i.e. empty) rather than to -% `\cs{relax}'. +% Now, split \cs{fc@number} into \cs{fc@integer@part} and \cs{fc@fractional@part}. +% \begin{macrocode} + \expandafter\fc@number@analysis\fc@number\fc@nil +% \end{macrocode} +% Now, split \cs{fc@integer@part} into a sequence of \cs{fc@digit@}\meta{$n$} with \meta{$n$} ranging from +% \cs{fc@unit@weight} to \cs{fc@max@weight}. We will use macro \cs{fc@parse@integer@digits} for that, but that +% will place the digits into \cs{fc@digit@}\meta{$n$} with \meta{$n$} ranging from +% \(2\times\cs{fc@unit@weight}-\cs{fc@max@weight}\) upto \(\cs{fc@unit@weight}-1\). +% \begin{macrocode} + \expandafter\fc@digit@counter\fc@unit@weight + \expandafter\fc@parse@integer@digits\fc@integer@part\fc@end\fc@nil +% \end{macrocode} +% First we compute the weight of the most significant digit: after \cs{fc@parse@integer@digits}, +% \cs{fc@digit@counter} is equal to \(\cs{fc@unit@weight} -\mathrm{mw} -1\) and we want to set +% \cs{fc@max@weight} to \(\cs{fc@unit@weight} +\mathrm{mw}\) so we do: +% \begin{equation*} +% \cs{fc@max@weight}\leftarrow (-\cs{fc@digit@counter}) + 2\times\cs{fc@unit@weight} -1 +% \end{equation*} % \begin{macrocode} - \edef\@tempa{\ifcase\fc@sign@case\space\or\fc@case plus\@nil\or\fc@case moins\@nil\fi}% - \fc@nbrstr@preamble - \fc@@nbrstrfrench@inner - \fc@nbrstr@postamble + \fc@digit@counter -\fc@digit@counter + \advance\fc@digit@counter by \fc@unit@weight + \advance\fc@digit@counter by \fc@unit@weight + \advance\fc@digit@counter by -1 % + \edef\fc@max@weight{\the\fc@digit@counter}% % \end{macrocode} -% Propagate the result --- i.e. expansion of \cs{@tempa} --- into macro \texttt{\#2} after closing brace. +% Now we loop for \(i = \cs{fc@unit@weight}\) to \cs{fc@max@weight} in order to copy all the digits from +% \cs{fc@digit@}\meta{\(i + \mathrm{offset}\)} to \cs{fc@digit@}\meta{\(i\)}. First we compute +% \(\mathrm{offset}\) into \cs{@tempi}. % \begin{macrocode} - \def\@tempb##1{\def\@tempa{\def#2{##1}}}% - \expandafter\@tempb\expandafter{\@tempa}% + {% + \count0 \fc@unit@weight\relax + \count1 \fc@max@weight\relax + \advance\count0 by -\count1 % + \advance\count0 by -1 % + \def\@tempa##1{\def\@tempb{\def\@tempi{##1}}}% + \expandafter\@tempa\expandafter{\the\count0}% \expandafter - }\@tempa -} + }\@tempb % \end{macrocode} -% \DescribeMacro\fc@@nbrstrfrench@inner Common part of \cs{@@numberstringfrench} and \cs -% {@@ordinalstringfrench}. Arguments are as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \cs{@tempa}&input/output, macro to which the result is to be aggregated, initially empty or contains the -% sign indication.\\ -% \end{tabularx} +% Now we loop to copy the digits. To do that we define a macro \cs{@templ} for terminal recursion. % \begin{macrocode} -\def\fc@@nbrstrfrench@inner{% + \expandafter\fc@digit@counter\fc@unit@weight + \def\@templ{% + \ifnum\fc@digit@counter>\fc@max@weight + \let\next\relax + \else % \end{macrocode} -% Now loop, first we compute starting weight as -% \(3\times\left\lfloor\frac{\cs{fc@max@weight}}{3}\right\rfloor\) into \cs{count0}. +% Here is the loop body: % \begin{macrocode} - \count0=\fc@max@weight - \divide\count0 by 3 % - \multiply\count0 by 3 % + {% + \count0 \@tempi + \advance\count0 by \fc@digit@counter + \expandafter\def\expandafter\@tempd\expandafter{\csname fc@digit@\the\count0\endcsname}% + \expandafter\def\expandafter\@tempe\expandafter{\csname fc@digit@\the\fc@digit@counter\endcsname}% + \def\@tempa####1####2{\def\@tempb{\let####1####2}}% + \expandafter\expandafter\expandafter\@tempa\expandafter\@tempe\@tempd + \expandafter + }\@tempb + \advance\fc@digit@counter by 1 % + \fi + \next + }% + \let\next\@templ + \@templ % \end{macrocode} -% Now we compute final weight into \cs{count5}, and round down to multiple of \(3\) into -% \cs{count6}. Warning: \cs{count6} is an implicit input argument to macro \cs{fc@ltthousandstringfrench}. +% Split \cs{fc@fractional@part} into a sequence of \cs{fc@digit@}\meta{$n$} with \meta{$n$} ranging from +% \(\cs{fc@unit@weight}-1\) to \cs{fc@min@weight} by step of \(-1\). This is much more simpler because we get +% the digits with the final range of index, so no post-processing loop is needed. % \begin{macrocode} - \fc@intpart@find@last{\count5 }% - \count6\count5 % - \divide\count6 3 % - \multiply\count6 3 % - \count8=0 % - \loop + \expandafter\fc@digit@counter\fc@unit@weight + \expandafter\fc@parse@integer@digits\fc@fractional@part\fc@end\fc@nil + \edef\fc@min@weight{\the\fc@digit@counter}% +} % \end{macrocode} -% First we check whether digits in weight interval \([w \intv (w+2)]\) are all zero and place check result -% into macro \cs{@tempt}. +% \DescribeMacro{\fc@parse@integer@digits} Macro \cs{fc@parse@integer@digits} is used to % \begin{macrocode} - \count1\count0 % - \advance\count1 by 2 % - \fc@check@nonzeros{\count0 }{\count1 }\@tempt +\ifcsundef{fc@parse@integer@digits}{}{% + \PackageError{fcnumparser}{Duplicate definition}{Redefinition of + macro `fc@parse@integer@digits'}} +\def\fc@parse@integer@digits#1#2\fc@nil{% + \def\@tempa{#1}% + \ifx\@tempa\fc@end@ + \def\next##1\fc@nil{}% + \else + \let\next\fc@parse@integer@digits + \advance\fc@digit@counter by -1 + \expandafter\def\csname fc@digit@\the\fc@digit@counter\endcsname{#1}% + \fi + \next#2\fc@nil +} + + +\newcommand*{\fc@unit@weight}{0} + % \end{macrocode} -% Now we generate the power of ten \(10^w\), formatted power of ten goes to \cs{@tempb}, while power type -% indicator goes to \cs{count9}. +% Now we have macros to read a few digits from the \cs{fc@digit@}\meta{$n$} array and form a correspoding +% number.\newline \DescribeMacro{\fc@read@unit} \cs{fc@read@unit} just reads one digit and form an integer in +% the range \([0 \intv 9]\). First we check that the macro is not yet defined. % \begin{macrocode} - \fc@poweroften\@tempt{\count9 }\@tempb +\ifcsundef{fc@read@unit}{}{% + \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro `fc@read@unit'}} % \end{macrocode} -% Now we generate the formatted number \(d\) into macro \cs{@tempd} by which we need to multiply -% \(10^w\). Implicit input argument is \cs{count9} for power type of \(10^9\), and \cs{count6} +% Arguments as follows:\def\interface{\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&output counter: into which the read value is placed\\ +% \#2&input number: unit weight at which reach the value is to be read +% \end{tabularx}}\interface +% \#2 does not need to be comprised between \cs{fc@min@weight} and {fc@min@weight}, if outside this interval, +% then a zero is read. % \begin{macrocode} - \fc@ltthousandstringfrench\@tempd +\def\fc@read@unit#1#2{% + \ifnum#2>\fc@max@weight + #1=0\relax + \else + \ifnum#2<\fc@min@weight + #1=0\relax + \else + {% + \edef\@tempa{\number#2}% + \count0=\@tempa + \edef\@tempa{\csname fc@digit@\the\count0\endcsname}% + \def\@tempb##1{\def\@tempa{#1=##1\relax}}% + \expandafter\@tempb\expandafter{\@tempa}% + \expandafter + }\@tempa + \fi + \fi +} % \end{macrocode} -% Finally do the multiplication-addition. Implicit arguments are \cs{@tempa} for input/output growing -% formatted number, \cs{count8} for input previous power type, i.e. power type of \(10^{w+3}\), \cs{count9} -% for input current power type, i.e. power type of \(10^w\). +% \DescribeMacro{\fc@read@hundred} Macro \cs{fc@read@hundred} is used to read a pair of digits and form an +% integer in the range \([0 \intv 99]\). First we check that the macro is not yet defined. % \begin{macrocode} - \fc@muladdfrench\@tempt\@tempd\@tempb +\ifcsundef{fc@read@hundred}{}{% + \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro `fc@read@hundred'}} % \end{macrocode} -% Then iterate. +% Arguments as follows --- same interface as \cs{fc@read@unit}:\interface % \begin{macrocode} - \count8\count9 % - \advance\count0 by -3 % - \ifnum\count6>\count0 \else - \repeat +\def\fc@read@hundred#1#2{% + {% + \fc@read@unit{\count0}{#2}% + \def\@tempa##1{\fc@read@unit{\count1}{##1}}% + \count2=#2% + \advance\count2 by 1 % + \expandafter\@tempa{\the\count2}% + \multiply\count1 by 10 % + \advance\count1 by \count0 % + \def\@tempa##1{\def\@tempb{#1=##1\relax}} + \expandafter\@tempa\expandafter{\the\count1}% + \expandafter + }\@tempb } % \end{macrocode} -% \DescribeMacro\@@ordinalstringfrench Macro \cs{@@ordinalstringfrench} is the main engine for formatting -% ordinal numbers in French. First check it is not yet defined. +% \DescribeMacro{\fc@read@thousand} Macro \cs{fc@read@thousand} is used to read a trio of digits and form an +% integer in the range \([0 \intv 999]\). First we check that the macro is not yet defined. % \begin{macrocode} -\ifcsundef{@@ordinalstringfrench}{}{% - \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro - `@@ordinalstringfrench'}} +\ifcsundef{fc@read@thousand}{}{% + \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro + `fc@read@thousand'}} % \end{macrocode} -% Arguments are as follows:\newline\noindent -% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} -% \#1&number to convert to string\\ -% \#2¯o into which to place the result -% \end{tabularx} +% Arguments as follows --- same interface as \cs{fc@read@unit}:\interface % \begin{macrocode} -\def\@@ordinalstringfrench#1#2{% +\def\fc@read@thousand#1#2{% {% + \fc@read@unit{\count0}{#2}% + \def\@tempa##1{\fc@read@hundred{\count1}{##1}}% + \count2=#2% + \advance\count2 by 1 % + \expandafter\@tempa{\the\count2}% + \multiply\count1 by 10 % + \advance\count1 by \count0 % + \def\@tempa##1{\def\@tempb{#1=##1\relax}} + \expandafter\@tempa\expandafter{\the\count1}% + \expandafter + }\@tempb +} % \end{macrocode} -% First parse input number to be formatted and do some error handling. -% \begin{macrocode} - \edef\@tempa{#1}% - \expandafter\fc@number@parser\expandafter{\@tempa}% - \ifnum\fc@min@weight<0 % - \PackageError{fmtcount}{Out of range}% - {This macro does not work with fractional numbers}% - \fi - \ifnum\fc@sign@case>0 % - \PackageError{fmtcount}{Out of range}% - {This macro does with negative or explicitly marked as positive numbers}% - \fi -% \end{macrocode} -% Now handle the special case of first. We set \cs{count0} to \texttt{1} if we are in this case, and to -% \texttt{0} otherwise +% Note: one myriad is ten thousand. +% \DescribeMacro{\fc@read@thousand} Macro \cs{fc@read@myriad} is used to read a quatuor of digits and form an +% integer in the range \([0 \intv 9999]\). First we check that the macro is not yet defined. % \begin{macrocode} - \ifnum\fc@max@weight=0 % - \ifnum\csname fc@digit@0\endcsname=1 % - \count0=1 % - \else - \count0=0 % - \fi - \else - \count0=0 % - \fi - \ifnum\count0=1 % - \edef\@tempa{\expandafter\fc@case\fc@first\@nil}% - \else +\ifcsundef{fc@read@myriad}{}{% + \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro + `fc@read@myriad'}} % \end{macrocode} -% Now we tamper a little bit with the plural handling options to ensure that there is no final plural mark. +% Arguments as follows --- same interface as \cs{fc@read@unit}:\interface % \begin{macrocode} - \def\@tempa##1{% - \expandafter\edef\csname fc@frenchoptions@##1@plural\endcsname{% - \ifcase\csname fc@frenchoptions@##1@plural\endcsname\space - 0% 0: always => always - \or - 1% 1: never => never - \or - 6% 2: multiple => multiple ng-last - \or - 1% 3: multiple g-last => never - \or - 5% 4: multiple l-last => multiple lng-last - \or - 5% 5: multiple lng-last => multiple lng-last - \or - 6% 6: multiple ng-last => multiple ng-last - \fi - }% - }% - \@tempa{vingt}% - \@tempa{cent}% - \@tempa{mil}% - \@tempa{n-illion}% - \@tempa{n-illiard}% +\def\fc@read@myriad#1#2{% + {% + \fc@read@hundred{\count0}{#2}% + \def\@tempa##1{\fc@read@hundred{\count1}{##1}}% + \count2=#2 + \advance\count2 by 2 + \expandafter\@tempa{\the\count2}% + \multiply\count1 by 100 % + \advance\count1 by \count0 % + \def\@tempa##1{\def\@tempb{#1=##1\relax}}% + \expandafter\@tempa\expandafter{\the\count1}% + \expandafter + }\@tempb +} % \end{macrocode} -% Now make \cs{fc@case} and \cs{@nil} non expandable +% \DescribeMacro{\fc@check@nonzeros} Macro \cs{fc@check@nonzeros} is used to check whether the number +% represented by digits \cs{fc@digit@}\meta{$n$}, with \(n\) in some interval, is zero, one, or more than one. +% First we check that the macro is not yet defined. % \begin{macrocode} - \let\fc@case@save\fc@case - \def\fc@case{\noexpand\fc@case}% - \def\@nil{\noexpand\@nil}% +\ifcsundef{fc@check@nonzeros}{}{% + \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro + `fc@check@nonzeros'}} % \end{macrocode} -% In the sequel, \cs{@tempa} is used to accumulate the formatted number. +% Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&input number: minimum unit unit weight at which start to search the non-zeros\\ +% \#2&input number: maximum unit weight at which end to seach the non-zeros\\ +% \#3&output macro: let \(n\) be the number represented by digits the weight of which span from \texttt{\#1} +% to \texttt{\#2}, then \texttt{\#3} is set to the number min(n,9).\\ +% \end{tabularx} +% Actually \cs{fc@check@nonzeros} is just a wrapper to collect arguments, and the real job is delegated to +% \cs{fc@@check@nonzeros@inner} which is called inside a group. % \begin{macrocode} - \let\@tempa\@empty - \fc@@nbrstrfrench@inner +\def\fc@check@nonzeros#1#2#3{% + {% % \end{macrocode} -% Now restore \cs{fc@case} +% So first we save inputs into local macros used by \cs{fc@@check@nonzeros@inner} as input arguments % \begin{macrocode} - \let\fc@case\fc@case@save + \edef\@@tempa{\number#1}% + \edef\@tempb{\number#2}% + \count0=\@@tempa + \count1=\@tempb\relax % \end{macrocode} -% Now we add the ``i\`eme'' ending +% Then we do the real job % \begin{macrocode} - \expandafter\fc@get@last@word\expandafter{\@tempa}\@tempb\@tempc - \expandafter\fc@get@last@letter\expandafter{\@tempc}\@tempd\@tempe - \def\@tempf{e}% - \ifx\@tempe\@tempf - \edef\@tempa{\@tempb\expandafter\fc@case\@tempd i\`eme\@nil}% - \else - \def\@tempf{q}% - \ifx\@tempe\@tempf - \edef\@tempa{\@tempb\expandafter\fc@case\@tempd qui\`eme\@nil}% - \else - \def\@tempf{f}% - \ifx\@tempe\@tempf - \edef\@tempa{\@tempb\expandafter\fc@case\@tempd vi\`eme\@nil}% - \else - \edef\@tempa{\@tempb\expandafter\fc@case\@tempc i\`eme\@nil}% - \fi - \fi - \fi - \fi + \fc@@check@nonzeros@inner % \end{macrocode} -% Propagate the result --- i.e. expansion of \cs{@tempa} --- into macro \texttt{\#2} after closing brace. +% And finally, we propagate the output after end of group --- i.e. closing brace. % \begin{macrocode} - \def\@tempb##1{\def\@tempa{\def#2{##1}}}% - \expandafter\@tempb\expandafter{\@tempa}% - \expandafter + \def\@tempd##1{\def\@tempa{\def#3{##1}}}% + \expandafter\@tempd\expandafter{\@tempc}% + \expandafter }\@tempa } % \end{macrocode} -% Macro \cs{fc@frenchoptions@setdefaults} allows to set all options to default for the French. +% \DescribeMacro{\fc@@check@nonzeros@inner} Macro \cs{fc@@check@nonzeros@inner} Check wehther some part of the +% parsed value contains some non-zero digit At the call of this macro we expect that:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash}rX@{}} +% \cs{@tempa}&input/output macro:\newline\noindent +% \settowidth{\tabcolwidth}{output}% +% \begin{tabular*}{\hsize}{@{}>{\raggedleft\arraybackslash\itshape}r% +% p{\dimexpr\hsize-2\tabcolsep-\tabcolwidth}@{}} +% input&minimum unit unit weight at which start to search the non-zeros\\ +% output¯o may have been redefined +% \end{tabular*}\\ +% \cs{@tempb}&input/output macro:\newline\noindent +% \settowidth{\tabcolwidth}{output}% +% \begin{tabular*}{\hsize}{@{}>{\raggedleft\arraybackslash\itshape}r% +% p{\dimexpr\hsize-2\tabcolsep-\tabcolwidth}@{}} +% input&maximum unit weight at which end to seach the non-zeros\\ +% output¯o may have been redefined +% \end{tabular*}\\ +% \cs{@tempc}&ouput macro: 0 if all-zeros, 1 if at least one zero is found\\ +% \cs{count0}&output counter: \(\mathrm{weight}+1\) of the first found non zero starting from minimum +% \(\mathrm{weight}\). +% \end{tabularx} % \begin{macrocode} -\newcommand*\fc@frenchoptions@setdefaults{% - \csname KV@fcfrench@all plural\endcsname{reformed}% - \def\fc@frenchoptions@submillion@dos{-}% - \let\fc@frenchoptions@supermillion@dos\space - \let\fc@u@in@duo\@empty% Could be `u' - % \let\fc@poweroften\fc@@pot@longscalefrench - \let\fc@poweroften\fc@@pot@recursivefrench - \def\fc@longscale@nilliard@upto{0}% infinity - \def\fc@frenchoptions@mil@plural@mark{le}% +\def\fc@@check@nonzeros@inner{% + \ifnum\count0<\fc@min@weight + \count0=\fc@min@weight\relax + \fi + \ifnum\count1>\fc@max@weight\relax + \count1=\fc@max@weight + \fi + \count2\count0 % + \advance\count2 by 1 % + \ifnum\count0>\count1 % + \PackageError{fcnumparser}{Unexpected arguments}{Number in argument 2 of macro + `fc@check@nonzeros' must be at least equal to number in argument 1}% + \else + \fc@@check@nonzeros@inner@loopbody + \ifnum\@tempc>0 % + \ifnum\@tempc<9 % + \ifnum\count0>\count1 % + \else + \let\@tempd\@tempc + \fc@@check@nonzeros@inner@loopbody + \ifnum\@tempc=0 % + \let\@tempc\@tempd + \else + \def\@tempc{9}% + \fi + \fi + \fi + \fi + \fi } -\fc@frenchoptions@setdefaults % \end{macrocode} -\iffalse Local variables: \fi -\iffalse mode: docTeX \fi -\iffalse End: \fi -%\iffalse % \begin{macrocode} -% +\def\fc@@check@nonzeros@inner@loopbody{% + % \@tempc <- digit of weight \count0 + \expandafter\let\expandafter\@tempc\csname fc@digit@\the\count0\endcsname + \advance\count0 by 1 % + \ifnum\@tempc=0 % + \ifnum\count0>\count1 % + \let\next\relax + \else + \let\next\fc@@check@nonzeros@inner@loopbody + \fi + \else + \ifnum\count0>\count2 % + \def\@tempc{9}% + \fi + \let\next\relax + \fi + \next +} % \end{macrocode} -%\fi -%\iffalse +% \DescribeMacro{\fc@intpart@find@last} Macro \cs{fc@intpart@find@last} find the rightmost non zero digit in the +% integer part. First check that the macro is not yet defined. % \begin{macrocode} -%<*fc-frenchb.def> +\ifcsundef{fc@intpart@find@last}{}{% + \PackageError{fcnumparser}{Duplicate definition}{Redefinition of macro + `fc@intpart@find@last'}} % \end{macrocode} -%\fi -% \subsubsection{fc-frenchb.def} +% When macro is called, the number of interest is already parsed, that is to say each digit of weight \(w\) is +% stored in macro \cs{fc@digit@}\meta{$w$}. Macro \cs{fc@intpart@find@last} takes one single argument which +% is a counter to set to the result. % \begin{macrocode} -\ProvidesFCLanguage{frenchb}[2013/08/17]% -\FCloadlang{french}% +\def\fc@intpart@find@last#1{% + {% % \end{macrocode} -% Set |frenchb| to be equivalent to |french|. +% Counter \cs{count0} will hold the result. So we will loop on \cs{count0}, starting from +% \(\min\{u,w_{\mathrm{min}}\}\), where \(u\triangleq\cs{fc@unit@weight}\), and +% \(w_{\mathrm{min}}\triangleq\cs{fc@min@weight}\). So first set \cs{count0} to +% \(\min\{u,w_{\mathrm{min}}\}\): % \begin{macrocode} -\global\let\@ordinalMfrenchb=\@ordinalMfrench -\global\let\@ordinalFfrenchb=\@ordinalFfrench -\global\let\@ordinalNfrenchb=\@ordinalNfrench -\global\let\@numberstringMfrenchb=\@numberstringMfrench -\global\let\@numberstringFfrenchb=\@numberstringFfrench -\global\let\@numberstringNfrenchb=\@numberstringNfrench -\global\let\@NumberstringMfrenchb=\@NumberstringMfrench -\global\let\@NumberstringFfrenchb=\@NumberstringFfrench -\global\let\@NumberstringNfrenchb=\@NumberstringNfrench -\global\let\@ordinalstringMfrenchb=\@ordinalstringMfrench -\global\let\@ordinalstringFfrenchb=\@ordinalstringFfrench -\global\let\@ordinalstringNfrenchb=\@ordinalstringNfrench -\global\let\@OrdinalstringMfrenchb=\@OrdinalstringMfrench -\global\let\@OrdinalstringFfrenchb=\@OrdinalstringFfrench -\global\let\@OrdinalstringNfrenchb=\@OrdinalstringNfrench + \count0=\fc@unit@weight\space + \ifnum\count0<\fc@min@weight\space + \count0=\fc@min@weight\space + \fi % \end{macrocode} - -%\iffalse +% Now the loop. This is done by defining macro \cs{@templ} for final recursion. % \begin{macrocode} -% + \def\@templ{% + \ifnum\csname fc@digit@\the\count0\endcsname=0 % + \advance\count0 by 1 % + \ifnum\count0>\fc@max@weight\space + \let\next\relax + \fi + \else + \let\next\relax + \fi + \next + }% + \let\next\@templ + \@templ % \end{macrocode} -%\fi -%\iffalse +% Now propagate result after closing bracket into counter \texttt{\#1}. % \begin{macrocode} -%<*fc-german.def> + \toks0{#1}% + \edef\@tempa{\the\toks0=\the\count0}% + \expandafter + }\@tempa\space +} % \end{macrocode} -%\fi -% \subsubsection{fc-german.def} -% German definitions (thank you to K. H. Fricke for supplying -% this information) +% \DescribeMacro{\fc@get@last@word} Getting last word. Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&input: full sequence\\ +% \#2&output macro 1: all sequence without last word\\ +% \#3&output macro 2: last word\\ +% \end{tabularx} % \begin{macrocode} -\ProvidesFCLanguage{german}[2014/06/09]% +\ifcsundef{fc@get@last@word}{}{\PackageError{fcnumparser}{Duplicate definition}{Redefinition + of macro `fc@get@last@word'}}% +\def\fc@get@last@word#1#2#3{% + {% % \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: +% First we split \texttt{\#1} into two parts: everything that is upto \cs{fc@case} exclusive goes to +% \cs{toks0}, and evrything from \cs{fc@case} exclusive upto the final \cs{@nil} exclusive goes to \cs{toks1}. % \begin{macrocode} -\newcommand{\@ordinalMgerman}[2]{% - \edef#2{\number#1\relax.}% -}% -\global\let\@ordinalMgerman\@ordinalMgerman + \def\@tempa##1\fc@case##2\@nil\fc@end{% + \toks0{##1}% +% \end{macrocode} +% Actually a dummy \cs{fc@case} is appended to \cs{toks1}, because that makes easier further checking that it +% does not contains any other \cs{fc@case}. +% \begin{macrocode} + \toks1{##2\fc@case}% + }% + \@tempa#1\fc@end +% \end{macrocode} +% Now leading part upto last word should be in \cs{toks0}, and last word should be in \cs{toks1}. However we +% need to check that this is really the last word, i.e. we need to check that there is no \cs{fc@case} inside +% \cs{toks1} other than the tailing dummy one. To that purpose we will loop while we find that \cs{toks1} +% contains some \cs{fc@case}. First we define \cs{@tempa} to split \cs{the}\cs{toks1} between parts before and +% after some potential \cs{fc@case}. +% \begin{macrocode} + \def\@tempa##1\fc@case##2\fc@end{% + \toks2{##1}% + \def\@tempb{##2}% + \toks3{##2}% + }% % \end{macrocode} -% Feminine: +% \cs{@tempt} is just an aliases of \cs{toks0} to make its handling easier later on. % \begin{macrocode} -\newcommand{\@ordinalFgerman}[2]{% - \edef#2{\number#1\relax.}% -}% -\global\let\@ordinalFgerman\@ordinalFgerman + \toksdef\@tempt0 % % \end{macrocode} -% Neuter: +% Now the loop itself, this is done by terminal recursion with macro \cs{@templ}. % \begin{macrocode} -\newcommand{\@ordinalNgerman}[2]{% - \edef#2{\number#1\relax.}% -}% -\global\let\@ordinalNgerman\@ordinalNgerman + \def\@templ{% + \expandafter\@tempa\the\toks1 \fc@end + \ifx\@tempb\@empty % \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): +% \cs{@tempb} empty means that the only \cs{fc@case} found in \cs{the}\cs{toks1} is the dummy one. So we end +% the loop here, \cs{toks2} contains the last word. % \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% - \fi -}% -\global\let\@@unitstringgerman\@@unitstringgerman + \let\next\relax + \else % \end{macrocode} -% Tens (argument must go from 1 to 10): +% \cs{@tempb} is not empty, first we use % \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% - \fi -}% -\global\let\@@tenstringgerman\@@tenstringgerman + \expandafter\expandafter\expandafter\@tempt + \expandafter\expandafter\expandafter{% + \expandafter\the\expandafter\@tempt + \expandafter\fc@case\the\toks2}% + \toks1\toks3 % + \fi + \next + }% + \let\next\@templ + \@templ + \edef\@tempa{\def\noexpand#2{\the\toks0}\def\noexpand#3{\the\toks2}}% + \expandafter + }\@tempa +} % \end{macrocode} -% |\einhundert| is set to |einhundert| by default, user can -% redefine this command to just |hundert| if required, similarly -% for |\eintausend|. +% \DescribeMacro{\fc@get@last@word} Getting last letter. Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&input: full word\\ +% \#2&output macro 1: all word without last letter\\ +% \#3&output macro 2: last letter\\ +% \end{tabularx} % \begin{macrocode} -\providecommand*{\einhundert}{einhundert}% -\providecommand*{\eintausend}{eintausend}% -\global\let\einhundert\einhundert -\global\let\eintausend\eintausend +\ifcsundef{fc@get@last@letter}{}{\PackageError{fcnumparser}{Duplicate definition}{Redefinition + of macro `fc@get@last@letter'}}% +\def\fc@get@last@letter#1#2#3{% + {% % \end{macrocode} -% Teens: +% First copy input to local \cs{toks1}. What we are going to to is to bubble one by one letters from +% \cs{toks1} which initial contains the whole word, into \cs{toks0}. At the end of the macro \cs{toks0} will +% therefore contain the whole work but the last letter, and the last letter will be in \cs{toks1}. % \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% - \fi -}% -\global\let\@@teenstringgerman\@@teenstringgerman + \toks1{#1}% + \toks0{}% + \toksdef\@tempt0 % % \end{macrocode} -% The results are stored in the second argument, but doesn't -% display anything. +% We define \cs{@tempa} in order to pop the first letter from the remaining of word. % \begin{macrocode} -\DeclareRobustCommand{\@numberstringMgerman}[2]{% - \let\@unitstring=\@@unitstringgerman - \let\@teenstring=\@@teenstringgerman - \let\@tenstring=\@@tenstringgerman - \@@numberstringgerman{#1}{#2}% -}% -\global\let\@numberstringMgerman\@numberstringMgerman + \def\@tempa##1##2\fc@nil{% + \toks2{##1}% + \toks3{##2}% + \def\@tempb{##2}% + }% % \end{macrocode} -% Feminine and neuter forms: +% Now we define \cs{@templ} to do the loop by terminal recursion. % \begin{macrocode} -\global\let\@numberstringFgerman=\@numberstringMgerman -\global\let\@numberstringNgerman=\@numberstringMgerman + \def\@templ{% + \expandafter\@tempa\the\toks1 \fc@nil + \ifx\@tempb\@empty % \end{macrocode} -% As above, but initial letters in upper case: +% Stop loop, as \cs{toks1} has been detected to be one single letter. % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringMgerman}[2]{% - \@numberstringMgerman{#1}{\@@num@str}% - \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% -}% -\global\let\@NumberstringMgerman\@NumberstringMgerman + \let\next\relax + \else % \end{macrocode} -% Feminine and neuter form: +% Here we append to \cs{toks0} the content of \cs{toks2}, i.e. the next letter. % \begin{macrocode} -\global\let\@NumberstringFgerman=\@NumberstringMgerman -\global\let\@NumberstringNgerman=\@NumberstringMgerman + \expandafter\expandafter\expandafter\@tempt + \expandafter\expandafter\expandafter{% + \expandafter\the\expandafter\@tempt + \the\toks2}% % \end{macrocode} -% As above, but for ordinals. +% And the remaining letters go to \cs{toks1} for the next iteration. % \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}% -}% -\global\let\@ordinalstringMgerman\@ordinalstringMgerman + \toks1\toks3 % + \fi + \next + }% % \end{macrocode} -% Feminine form: +% Here run the loop. % \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}% -}% -\global\let\@ordinalstringFgerman\@ordinalstringFgerman + \let\next\@templ + \next % \end{macrocode} -% Neuter form: +% Now propagate the results into macros \texttt{\#2} and \texttt{\#3} after closing brace. % \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}% + \edef\@tempa{\def\noexpand#2{\the\toks0}\def\noexpand#3{\the\toks1}}% + \expandafter + }\@tempa }% -\global\let\@ordinalstringNgerman\@ordinalstringNgerman % \end{macrocode} -% As above, but with initial letters in upper case. +\iffalse Local variables: \fi +\iffalse mode: docTeX \fi +\iffalse End: \fi +%\iffalse % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringMgerman}[2]{% - \@ordinalstringMgerman{#1}{\@@num@str}% - \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% -}% -\global\let\@OrdinalstringMgerman\@OrdinalstringMgerman +% % \end{macrocode} -% Feminine form: +%\fi +%\iffalse % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringFgerman}[2]{% - \@ordinalstringFgerman{#1}{\@@num@str}% - \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% -}% -\global\let\@OrdinalstringFgerman\@OrdinalstringFgerman +%<*fcprefix.sty> % \end{macrocode} -% Neuter form: +%\fi +%\subsection{fcprefix.sty} +% Pseudo-latin prefixes. % \begin{macrocode} -\DeclareRobustCommand{\@OrdinalstringNgerman}[2]{% - \@ordinalstringNgerman{#1}{\@@num@str}% - \edef#2{\noexpand\MakeUppercase\expandonce\@@num@str}% -}% -\global\let\@OrdinalstringNgerman\@OrdinalstringNgerman +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{fcprefix}[2012/09/28] +\RequirePackage{ifthen} +\RequirePackage{keyval} +\RequirePackage{fcnumparser} % \end{macrocode} -% Code for converting numbers into textual ordinals. As before, -% it is easier to split it into units, tens and teens. -% Units: -%\changes{2.0}{2012-09-25}{fixed spelling mistake (correction -%provided by Dominik Wa\ss enhoven)} +% Option `\texttt{use duode and unde}' is to select whether \(18\) and suchlikes (\(\meta{x}8\), +% \(\meta{x}9\)) writes like duodevicies, or like octodecies. For French it should be `\texttt{below +% 20}'. Possible values are `\texttt{below 20}' and `\texttt{never}'. +% \begin{macrocode} +\define@key{fcprefix}{use duode and unde}[below20]{% + \ifthenelse{\equal{#1}{below20}}{% + \def\fc@duodeandunde{2}% + }{% + \ifthenelse{\equal{#1}{never}}{% + \def\fc@duodeandunde{0}% + }{% + \PackageError{fcprefix}{Unexpected option}{% + Option `use duode and unde' expects `below 20' or `never' }% + }% + }% +} +% \end{macrocode} +% Default is `\texttt{below 20}' like in French. % \begin{macrocode} -\newcommand*\@@unitthstringMgerman[1]{% - \ifcase#1% - nullter% - \or erster% - \or zweiter% - \or dritter% - \or vierter% - \or f\"unfter% - \or sechster% - \or siebter% - \or achter% - \or neunter% - \fi -}% -\global\let\@@unitthstringMgerman\@@unitthstringMgerman +\def\fc@duodeandunde{2} % \end{macrocode} -% Tens: +% Option `\texttt{numeral u in duo}', this can be `\texttt{true}' or `\texttt{false}' and is used to select +% whether 12 and suchlikes write like dodec\meta{xxx} or duodec\meta{xxx} for numerals. % \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% - \fi -}% -\global\let\@@tenthstringMgerman\@@tenthstringMgerman +\define@key{fcprefix}{numeral u in duo}[false]{% + \ifthenelse{\equal{#1}{false}}{% + \let\fc@u@in@duo\@empty + }{% + \ifthenelse{\equal{#1}{true}}{% + \def\fc@u@in@duo{u}% + }{% + \PackageError{fcprefix}{Unexpected option}{% + Option `numeral u in duo' expects `true' or `false' }% + }% + }% +} % \end{macrocode} -% Teens: +% Option `\texttt{e accute}', this can be `\texttt{true}' or `\texttt{false}' and is used to select whether +% letter `\texttt{e}' has an accute accent when it pronounce [e] in French. % \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% - \fi -}% -\global\let\@@teenthstringMgerman\@@teenthstringMgerman +\define@key{fcprefix}{e accute}[false]{% + \ifthenelse{\equal{#1}{false}}{% + \let\fc@prefix@eaccute\@firstofone + }{% + \ifthenelse{\equal{#1}{true}}{% + \let\fc@prefix@eaccute\'% + }{% + \PackageError{fcprefix}{Unexpected option}{% + Option `e accute' expects `true' or `false' }% + }% + }% +} % \end{macrocode} -% Units (feminine): +% Default is to set accute accent like in French. % \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 -}% -\global\let\@@unitthstringFgerman\@@unitthstringFgerman +\let\fc@prefix@eaccute\'% % \end{macrocode} -% Tens (feminine): +% Option `\texttt{power of millia}' tells how millia is raise to power n. It expects value:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% recursive&for which millia squared is noted as `milliamillia'\\ +% arabic&for which millia squared is noted as `millia\^{}2'\\ +% prefix&for which millia squared is noted as `bismillia' +% \end{tabularx} % \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 -}% -\global\let\@@tenthstringFgerman\@@tenthstringFgerman +\define@key{fcprefix}{power of millia}[prefix]{% + \ifthenelse{\equal{#1}{prefix}}{% + \let\fc@power@of@millia@init\@gobbletwo + \let\fc@power@of@millia\fc@@prefix@millia + }{% + \ifthenelse{\equal{#1}{arabic}}{% + \let\fc@power@of@millia@init\@gobbletwo + \let\fc@power@of@millia\fc@@arabic@millia + }{% + \ifthenelse{\equal{#1}{recursive}}{% + \let\fc@power@of@millia@init\fc@@recurse@millia@init + \let\fc@power@of@millia\fc@@recurse@millia + }{% + \PackageError{fcprefix}{Unexpected option}{% + Option `power of millia' expects `recursive', `arabic', or `prefix' }% + }% + }% + }% +} % \end{macrocode} -% Teens (feminine) +% Arguments as follows:\def\interface{\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1& output macro\\ +% \#2& number with current weight \(w\) +% \end{tabularx}}\interface % \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 -}% -\global\let\@@teenthstringFgerman\@@teenthstringFgerman +\def\fc@@recurse@millia#1#2{% + \let\@tempp#1% + \edef#1{millia\@tempp}% +} % \end{macrocode} -% Units (neuter): -%\changes{2.0}{2012-09-25}{fixed spelling mistake (correction -%provided by Dominik Wa\ss enhoven)} +% Arguments as follows --- same interface as \cs{fc@@recurse@millia}: \interface % \begin{macrocode} -\newcommand*\@@unitthstringNgerman[1]{% - \ifcase#1% - nulltes% - \or erstes% - \or zweites% - \or drittes% - \or viertes% - \or f\"unftes% - \or sechstes% - \or siebtes% - \or achtes% - \or neuntes% - \fi -}% -\global\let\@@unitthstringNgerman\@@unitthstringNgerman +\def\fc@@recurse@millia@init#1#2{% + {% % \end{macrocode} -% Tens (neuter): +% Save input argument current weight \(w\) into local macro \cs{@tempb}. % \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 -}% -\global\let\@@tenthstringNgerman\@@tenthstringNgerman + \edef\@tempb{\number#2}% % \end{macrocode} -% Teens (neuter) +% Now main loop from 0 to \(w\). Final value of \cs{@tempa} will be the result. % \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 -}% -\global\let\@@teenthstringNgerman\@@teenthstringNgerman + \count0=0 % + \let\@tempa\@empty + \loop + \ifnum\count0<\@tempb + \advance\count0 by 1 % + \expandafter\def + \expandafter\@tempa\expandafter{\@tempa millia}% + \repeat % \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|. +% Now propagate the expansion of \cs{@tempa} into \texttt{\#1} after closing bace. % \begin{macrocode} -\newcommand*\@@numberunderhundredgerman[2]{% -\ifnum#1<10\relax - \ifnum#1>0\relax - \eappto#2{\@unitstring{#1}}% - \fi -\else - \@tmpstrctr=#1\relax - \@FCmodulo{\@tmpstrctr}{10}% - \ifnum#1<20\relax - \eappto#2{\@teenstring{\@tmpstrctr}}% - \else - \ifnum\@tmpstrctr=0\relax - \else - \eappto#2{\@unitstring{\@tmpstrctr}und}% - \fi - \@tmpstrctr=#1\relax - \divide\@tmpstrctr by 10\relax - \eappto#2{\@tenstring{\@tmpstrctr}}% - \fi -\fi -}% -\global\let\@@numberunderhundredgerman\@@numberunderhundredgerman + \edef\@tempb{\def\noexpand#1{\@tempa}}% + \expandafter + }\@tempb +} % \end{macrocode} -% This stores the results in the second argument -% (which must be a control -% sequence), but it doesn't display anything. +% Arguments as follows --- same interface as \cs{fc@@recurse@millia}: \interface % \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}% +\def\fc@@arabic@millia#1#2{% + \ifnnum#2=0 % + \let#1\@empty + \else + \edef#1{millia\^{}\the#2}% \fi -\fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>1\relax +} % \end{macrocode} -% \#1 is $\geq 2000$, \cs{@strctr} now contains the number of thousands +% Arguments as follows --- same interface as \cs{fc@@recurse@millia}: \interface % \begin{macrocode} - \@@numberunderhundredgerman{\@strctr}{#2}% - \appto#2{tausend}% -\else +\def\fc@@prefix@millia#1#2{% + \fc@@latin@numeral@pefix{#2}{#1}% +} % \end{macrocode} -% \#1 lies in range [1000,1999] +% Default value of option `\texttt{power of millia}' is `\texttt{prefix}': % \begin{macrocode} - \ifnum\@strctr=1\relax - \eappto#2{\eintausend}% - \fi -\fi -\@strctr=#1\relax -\@FCmodulo{\@strctr}{1000}% -\divide\@strctr by 100\relax -\ifnum\@strctr>1\relax +\let\fc@power@of@millia@init\@gobbletwo +\let\fc@power@of@millia\fc@@prefix@millia % \end{macrocode} -% now dealing with number in range [200,999] +% \DescribeMacro{\fc@@latin@cardinal@pefix} Compute a cardinal prefix for n-illion, like \(1 \Rightarrow +% \textrm{`m'}\), \(2 \Rightarrow \textrm{`bi'}\), \(3 \Rightarrow \textrm{`tri'}\). The algorithm to derive +% this prefix is that of Russ Rowlett I founds its documentation on Alain Lassine's site: +% \url{http://www.alain.be/Boece/grands\_nombres.html}. First check that macro is not yet defined. % \begin{macrocode} - \eappto#2{\@unitstring{\@strctr}hundert}% -\else - \ifnum\@strctr=1\relax +\ifcsundef{fc@@latin@cardinal@pefix}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro `fc@@latin@cardinal@pefix'}} % \end{macrocode} -% dealing with number in range [100,199] +% Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&input number to be formated\\ +% \#2&outut macro name into which to place the formatted result +% \end{tabularx} % \begin{macrocode} - \ifnum#1>1000\relax +\def\fc@@latin@cardinal@pefix#1#2{% + {% % \end{macrocode} -% if original number $> 1000$, use einhundert +% First we put input argument into local macro @cs{@tempa} with full expansion. % \begin{macrocode} - \appto#2{einhundert}% - \else + \edef\@tempa{\number#1}% % \end{macrocode} -% otherwise use \cs{einhundert} +% Now parse number from expanded input. % \begin{macrocode} - \eappto#2{\einhundert}% - \fi - \fi -\fi -\@strctr=#1\relax -\@FCmodulo{\@strctr}{100}% -\ifnum#1=0\relax - \def#2{null}% -\else - \ifnum\@strctr=1\relax - \appto#2{eins}% - \else - \@@numberunderhundredgerman{\@strctr}{#2}% - \fi -\fi -}% -\global\let\@@numberstringgerman\@@numberstringgerman + \expandafter\fc@number@parser\expandafter{\@tempa}% + \count2=0 % % \end{macrocode} -% As above, but for ordinals +% \cs{@tempt} will hold the optional final \texttt{t}, \cs{@tempu} is used to initialize \cs{@tempt} to `t' +% when the firt non-zero 3digit group is met, which is the job made by \cs{@tempi}. % \begin{macrocode} -\newcommand*\@@numberunderhundredthgerman[2]{% -\ifnum#1<10\relax - \eappto#2{\@unitthstring{#1}}% -\else - \@tmpstrctr=#1\relax - \@FCmodulo{\@tmpstrctr}{10}% - \ifnum#1<20\relax - \eappto#2{\@teenthstring{\@tmpstrctr}}% - \else - \ifnum\@tmpstrctr=0\relax - \else - \eappto#2{\@unitstring{\@tmpstrctr}und}% - \fi - \@tmpstrctr=#1\relax - \divide\@tmpstrctr by 10\relax - \eappto#2{\@tenthstring{\@tmpstrctr}}% - \fi -\fi -}% -\global\let\@@numberunderhundredthgerman\@@numberunderhundredthgerman + \let\@tempt\@empty + \def\@tempu{t}% % \end{macrocode} +% \cs{@tempm} will hold the \texttt{millia\^}\(^{n\div 3}\) % \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 -\fi -\def#2{}% -\@strctr=#1\relax \divide\@strctr by 1000\relax -\ifnum\@strctr>1\relax + \let\@tempm\@empty % \end{macrocode} -% \#1 is $\geq 2000$, \cs{@strctr} now contains the number of thousands +% Loop by means of terminal recursion of herinafter defined macro \cs{@templ}. We loop by group of 3 digits. % \begin{macrocode} -\@@numberunderhundredgerman{\@strctr}{#2}% + \def\@templ{% + \ifnum\count2>\fc@max@weight + \let\next\relax + \else % \end{macrocode} -% is that it, or is there more? +% Loop body. Here we read a group of 3 consecutive digits \(d_2d_1d_0\) and place them respectively into +% \cs{count3}, \cs{count4}, and \cs{count5}. % \begin{macrocode} - \@tmpstrctr=#1\relax \@FCmodulo{\@tmpstrctr}{1000}% - \ifnum\@tmpstrctr=0\relax - \eappto#2{\@thousandth}% - \else - \appto#2{tausend}% - \fi -\else + \fc@read@unit{\count3}{\count2}% + \advance\count2 by 1 % + \fc@read@unit{\count4}{\count2}% + \advance\count2 by 1 % + \fc@read@unit{\count5}{\count2}% + \advance\count2 by 1 % % \end{macrocode} -% \#1 lies in range [1000,1999] +% If the 3 considered digits \(d_2d_1d_0\) are not all zero, then set \cs{@tempt} to `\texttt{t}' for the +% first time this event is met. % \begin{macrocode} - \ifnum\@strctr=1\relax - \ifnum#1=1000\relax - \eappto#2{\@thousandth}% - \else - \eappto#2{\eintausend}% - \fi - \fi -\fi -\@strctr=#1\relax -\@FCmodulo{\@strctr}{1000}% -\divide\@strctr by 100\relax -\ifnum\@strctr>1\relax + \edef\@tempn{% + \ifnum\count3=0\else 1\fi + \ifnum\count4=0\else 1\fi + \ifnum\count5=0\else 1\fi + }% + \ifx\@tempn\@empty\else + \let\@tempt\@tempu + \let\@tempu\@empty + \fi +% \end{macrocode} +% Now process the current group \(d_2d_1d_0\) of 3 digits. +% \begin{macrocode} + \let\@tempp\@tempa + \edef\@tempa{% +% \end{macrocode} +% Here we process \(d_{2}\) held by \cs{count5}, that is to say hundreds. +% \begin{macrocode} + \ifcase\count5 % + \or cen% + \or ducen% + \or trecen% + \or quadringen% + \or quingen% + \or sescen% + \or septigen% + \or octingen% + \or nongen% + \fi +% \end{macrocode} +% Here we process \(d_1d_0\) held by \cs{count4} \& \cs{count3}, that is to say tens and units. +% \begin{macrocode} + \ifnum\count4=0 % + % x0(0..9) + \ifnum\count2=3 % + % Absolute weight zero + \ifcase\count3 \@tempt + \or m% + \or b% + \or tr% + \or quadr% + \or quin\@tempt + \or sex\@tempt + \or sep\@tempt + \or oc\@tempt + \or non% + \fi + \else +% \end{macrocode} +% Here the weight of \cs{count3} is \(3\times n\), with \(n>0\), i.e. this is followed by a +% \texttt{millia\^}\(n\). +% \begin{macrocode} + \ifcase\count3 % + \or \ifnum\count2>\fc@max@weight\else un\fi + \or d\fc@u@in@duo o% + \or tre% + \or quattuor% + \or quin% + \or sex% + \or septen% + \or octo% + \or novem% + \fi + \fi + \else + % x(10..99) + \ifcase\count3 % + \or un% + \or d\fc@u@in@duo o% + \or tre% + \or quattuor% + \or quin% + \or sex% + \or septen% + \or octo% + \or novem% + \fi + \ifcase\count4 % + \or dec% + \or vigin\@tempt + \or trigin\@tempt + \or quadragin\@tempt + \or quinquagin\@tempt + \or sexagin\@tempt + \or septuagin\@tempt + \or octogin\@tempt + \or nonagin\@tempt + \fi + \fi % \end{macrocode} -% now dealing with number in range [200,999] -% is that it, or is there more? +% Insert the \texttt{millia\^}\(^{(n\div 3)}\) only if \(d_2d_1d_0\not=0\), i.e. if one of \cs{count3} +% \cs{count4} or \cs{count5} is non zero. % \begin{macrocode} - \@tmpstrctr=#1\relax \@FCmodulo{\@tmpstrctr}{100}% - \ifnum\@tmpstrctr=0\relax - \ifnum\@strctr=1\relax - \eappto#2{\@hundredth}% - \else - \eappto#2{\@unitstring{\@strctr}\@hundredth}% - \fi - \else - \eappto#2{\@unitstring{\@strctr}hundert}% - \fi -\else - \ifnum\@strctr=1\relax + \@tempm % \end{macrocode} -% dealing with number in range [100,199] -% is that it, or is there more? +% And append previous version of \cs{@tempa}. % \begin{macrocode} - \@tmpstrctr=#1\relax \@FCmodulo{\@tmpstrctr}{100}% - \ifnum\@tmpstrctr=0\relax - \eappto#2{\@hundredth}% - \else - \ifnum#1>1000\relax - \appto#2{einhundert}% - \else - \eappto#2{\einhundert}% - \fi - \fi - \fi -\fi -\@strctr=#1\relax -\@FCmodulo{\@strctr}{100}% -\ifthenelse{\@strctr=0 \and #1>0}{}{% -\@@numberunderhundredthgerman{\@strctr}{#2}% -}% -}% -\global\let\@@ordinalstringgerman\@@ordinalstringgerman + \@tempp + }% % \end{macrocode} -% Load fc-germanb.def if not already loaded +% ``Concatenate'' \texttt{millia} to \cs{@tempm}, so that \cs{@tempm} will expand to +% \texttt{millia\^}\(^{(n\div 3)+1}\) at the next iteration. Actually whether this is a concatenation or some +% \texttt{millia} prefixing depends of option `\texttt{power of millia}'. % \begin{macrocode} -\FCloadlang{germanb}% + \fc@power@of@millia\@tempm{\count2}% + \fi + \next + }% + \let\@tempa\@empty + \let\next\@templ + \@templ % \end{macrocode} - -%\iffalse +% Propagate expansion of \cs{@tempa} into \texttt{\#2} after closing bracket. % \begin{macrocode} -% + \def\@tempb##1{\def\@tempa{\def#2{##1}}}% + \expandafter\@tempb\expandafter{\@tempa}% + \expandafter + }\@tempa +} % \end{macrocode} -%\fi -%\iffalse +% \DescribeMacro{\fc@@latin@numeral@pefix} Compute a numeral prefix +% like `s\'emel', `bis', `ter', `quater', +% etc\ldots I found the algorithm to derive this prefix on Alain Lassine's site: +% \url{http://www.alain.be/Boece/nombres\_gargantuesques.html}. First check that the macro is not yet defined. % \begin{macrocode} -%<*fc-germanb.def> +\ifcsundef{fc@@latin@numeral@pefix}{}{% + \PackageError{fmtcount}{Duplicate definition}{Redefinition of macro + `fc@@latin@numeral@pefix'}} % \end{macrocode} -%\fi -% \subsubsection{fc-germanb.def} +% Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1& input number to be formatted,\\ +% \#2& outut macro name into which to place the result +% \end{tabularx} % \begin{macrocode} -\ProvidesFCLanguage{germanb}[2013/08/17]% +\def\fc@@latin@numeral@pefix#1#2{% + {% + \edef\@tempa{\number#1}% + \def\fc@unit@weight{0}% + \expandafter\fc@number@parser\expandafter{\@tempa}% + \count2=0 % % \end{macrocode} -% Load fc-german.def if not already loaded +% Macro \cs{@tempm} will hold the \texttt{millies\^}\(^{n\div 3}\). % \begin{macrocode} -\FCloadlang{german}% + \let\@tempm\@empty % \end{macrocode} -% Set |germanb| to be equivalent to |german|. +% Loop over digits. This is done by defining macro \cs{@templ} for terminal recursion. % \begin{macrocode} -\global\let\@ordinalMgermanb=\@ordinalMgerman -\global\let\@ordinalFgermanb=\@ordinalFgerman -\global\let\@ordinalNgermanb=\@ordinalNgerman -\global\let\@numberstringMgermanb=\@numberstringMgerman -\global\let\@numberstringFgermanb=\@numberstringFgerman -\global\let\@numberstringNgermanb=\@numberstringNgerman -\global\let\@NumberstringMgermanb=\@NumberstringMgerman -\global\let\@NumberstringFgermanb=\@NumberstringFgerman -\global\let\@NumberstringNgermanb=\@NumberstringNgerman -\global\let\@ordinalstringMgermanb=\@ordinalstringMgerman -\global\let\@ordinalstringFgermanb=\@ordinalstringFgerman -\global\let\@ordinalstringNgermanb=\@ordinalstringNgerman -\global\let\@OrdinalstringMgermanb=\@OrdinalstringMgerman -\global\let\@OrdinalstringFgermanb=\@OrdinalstringFgerman -\global\let\@OrdinalstringNgermanb=\@OrdinalstringNgerman + \def\@templ{% + \ifnum\count2>\fc@max@weight + \let\next\relax + \else % \end{macrocode} - -%\iffalse +% Loop body. Three consecutive digits \(d_{2}d_{1}d_{0}\) are read into counters \cs{count3}, \cs{count4}, and +% \cs{count5}. % \begin{macrocode} -% + \fc@read@unit{\count3}{\count2}% + \advance\count2 by 1 % + \fc@read@unit{\count4}{\count2}% + \advance\count2 by 1 % + \fc@read@unit{\count5}{\count2}% + \advance\count2 by 1 % % \end{macrocode} -%\fi -%\iffalse +% Check the use of \texttt{duodevicies} instead of \texttt{octodecies}. % \begin{macrocode} -%<*fc-italian.def> + \let\@tempn\@secondoftwo + \ifnum\count3>7 % + \ifnum\count4<\fc@duodeandunde + \ifnum\count4>0 % + \let\@tempn\@firstoftwo + \fi + \fi + \fi + \@tempn + {% use duodevicies for eighteen + \advance\count4 by 1 % + \let\@temps\@secondoftwo + }{% do not use duodevicies for eighteen + \let\@temps\@firstoftwo + }% + \let\@tempp\@tempa + \edef\@tempa{% + % hundreds + \ifcase\count5 % + \expandafter\@gobble + \or c% + \or duc% + \or trec% + \or quadring% + \or quing% + \or sesc% + \or septing% + \or octing% + \or nong% + \fi + {enties}% + \ifnum\count4=0 % % \end{macrocode} -%\fi -% \subsubsection{fc-italian} -% Italian support is now handled by interfacing to Enrico Gregorio's -% itnumpar package. +% Here \(d_{2}d_{1}d_{0}\) is such that \(d_{1} = 0\). % \begin{macrocode} -\ProvidesFCLanguage{italian}[2013/08/17] - -\RequirePackage{itnumpar} - -\newcommand{\@numberstringMitalian}[2]{% - \edef#2{\noexpand\printnumeroinparole{#1}}% -} -\global\let\@numberstringMitalian\@numberstringMitalian - -\newcommand{\@numberstringFitalian}[2]{% - \edef#2{\noexpand\printnumeroinparole{#1}}} - -\global\let\@numberstringFitalian\@numberstringFitalian - -\newcommand{\@NumberstringMitalian}[2]{% - \edef#2{\noexpand\printNumeroinparole{#1}}% -} -\global\let\@NumberstringMitalian\@NumberstringMitalian - -\newcommand{\@NumberstringFitalian}[2]{% - \edef#2{\noexpand\printNumeroinparole{#1}}% -} -\global\let\@NumberstringFitalian\@NumberstringFitalian - -\newcommand{\@ordinalstringMitalian}[2]{% - \edef#2{\noexpand\printordinalem{#1}}% -} -\global\let\@ordinalstringMitalian\@ordinalstringMitalian - -\newcommand{\@ordinalstringFitalian}[2]{% - \edef#2{\noexpand\printordinalef{#1}}% + \ifcase\count3 % + \or + \ifnum\count2=3 % + s\fc@prefix@eaccute emel% + \else + \ifnum\count2>\fc@max@weight\else un\fi + \fi + \or bis% + \or ter% + \or quater% + \or quinquies% + \or sexies% + \or septies% + \or octies% + \or novies% + \fi + \else +% \end{macrocode} +% Here \(d_{2}d_{1}d_{0}\) is such that \(d_{1} \geq 1\). +% \begin{macrocode} + \ifcase\count3 % + \or un% + \or d\fc@u@in@duo o% + \or ter% + \or quater% + \or quin% + \or sex% + \or septen% + \or \@temps{octo}{duod\fc@prefix@eaccute e}% x8 = two before next (x+1)0 + \or \@temps{novem}{und\fc@prefix@eaccute e}% x9 = one before next (x+1)0 + \fi + \ifcase\count4 % + % can't get here + \or d\fc@prefix@eaccute ec% + \or vic% + \or tric% + \or quadrag% + \or quinquag% + \or sexag% + \or septuag% + \or octog% + \or nonag% + \fi + ies% + \fi + % Insert the millies^(n/3) only if one of \count3 \count4 \count5 is non zero + \@tempm + % add up previous version of \@tempa + \@tempp + }% +% \end{macrocode} +% Concatenate \texttt{millies} to \cs{@tempm} so that it is equal to \texttt{millies\^}\(^{n\div 3}\) at the +% next iteration. Here we just have plain concatenation, contrary to cardinal for which a prefix can be used +% instead. +% \begin{macrocode} + \let\@tempp\@tempp + \edef\@tempm{millies\@tempp}% + \fi + \next + }% + \let\@tempa\@empty + \let\next\@templ + \@templ +% \end{macrocode} +% Now propagate expansion of \@tempa into \texttt{\#2} after closing bracket. +% \begin{macrocode} + \def\@tempb##1{\def\@tempa{\def#2{##1}}}% + \expandafter\@tempb\expandafter{\@tempa}% + \expandafter + }\@tempa } -\global\let\@ordinalstringFitalian\@ordinalstringFitalian - -\newcommand{\@OrdinalstringMitalian}[2]{% - \edef#2{\noexpand\printOrdinalem{#1}}% +% \end{macrocode} +% Stuff for calling macros. Construct \cs{fc@call}\meta{some macro} can be used to pass two arguments to +% \meta{some macro} with a configurable calling convention: +% \begin{itemize} +% \item the calling convention is such that there is one mandatory argument \meta{marg} and an optional +% argument \meta{oarg} +% \item either \cs{fc@call} is \cs{let} to be equal to \cs{fc@call@opt@arg@second}, and then calling +% convention is that the \meta{marg} is first and \meta{oarg} is second, +% \item or \cs{fc@call} is \cs{let} to be equal to \cs{fc@call@opt@arg@first}, and then calling convention is +% that the \meta{oarg} is first and \meta{aarg} is second, +% \item if \meta{oarg} is absent, then it is by convention set empty, +% \item \meta{some macro} is supposed to have two mandatory arguments of which \meta{oarg} is passed to the +% first, and \meta{marg} is passed to the second, and +% \item \meta{some macro} is called within a group. +% \end{itemize} +% \begin{macrocode} +\def\fc@call@opt@arg@second#1#2{% + \def\@tempb{% + \ifx[\@tempa + \def\@tempc[####1]{% + {#1{####1}{#2}}% + }% + \else + \def\@tempc{{#1{}{#2}}}% + \fi + \@tempc + }% + \futurelet\@tempa + \@tempb } -\global\let\@OrdinalstringMitalian\@OrdinalstringMitalian - -\newcommand{\@OrdinalstringFitalian}[2]{% - \edef#2{\noexpand\printOrdinalef{#1}}% +% \end{macrocode} +% \begin{macrocode} +\def\fc@call@opt@arg@first#1{% + \def\@tempb{% + \ifx[\@tempa + \def\@tempc[####1]####2{{#1{####1}{####2}}}% + \else + \def\@tempc####1{{#1{}{####1}}}% + \fi + \@tempc + }% + \futurelet\@tempa + \@tempb } -\global\let\@OrdinalstringFitalian\@OrdinalstringFitalian - -\newcommand{\@ordinalMitalian}[2]{% - \edef#2{#1\relax\noexpand\fmtord{o}}} -\global\let\@ordinalMitalian\@ordinalMitalian - -\newcommand{\@ordinalFitalian}[2]{% - \edef#2{#1\relax\noexpand\fmtord{a}}} -\global\let\@ordinalFitalian\@ordinalFitalian +\let\fc@call\fc@call@opt@arg@first % \end{macrocode} - -%\iffalse +% User API. +% +% \DescribeMacro{\@latinnumeralstringnum} Macro \cs{@latinnumeralstringnum}. Arguments as +% follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&local options\\ +% \#2& input number +% \end{tabularx} % \begin{macrocode} -% +\newcommand*{\@latinnumeralstringnum}[2]{% + \setkeys{fcprefix}{#1}% + \fc@@latin@numeral@pefix{#2}\@tempa + \@tempa +} % \end{macrocode} -%\fi -%\iffalse +% Arguments as follows:\newline\noindent +% \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} +% \#1&local options\\ +% \#2&input counter +% \end{tabularx} % \begin{macrocode} -%<*fc-ngerman.def> +\newcommand*{\@latinnumeralstring}[2]{% + \setkeys{fcprefix}{#1}% + \expandafter\let\expandafter + \@tempa\expandafter\csname c@#2\endcsname + \expandafter\fc@@latin@numeral@pefix\expandafter{\the\@tempa}\@tempa + \@tempa +} % \end{macrocode} -%\fi -% \subsubsection{fc-ngerman.def} % \begin{macrocode} -\ProvidesFCLanguage{ngerman}[2012/06/18]% -\FCloadlang{german}% -\FCloadlang{ngermanb}% +\newcommand*{\latinnumeralstring}{% + \fc@call\@latinnumeralstring +} % \end{macrocode} -% Set |ngerman| to be equivalent to |german|. Is it okay to do -% this? (I don't know the difference between the two.) % \begin{macrocode} -\global\let\@ordinalMngerman=\@ordinalMgerman -\global\let\@ordinalFngerman=\@ordinalFgerman -\global\let\@ordinalNngerman=\@ordinalNgerman -\global\let\@numberstringMngerman=\@numberstringMgerman -\global\let\@numberstringFngerman=\@numberstringFgerman -\global\let\@numberstringNngerman=\@numberstringNgerman -\global\let\@NumberstringMngerman=\@NumberstringMgerman -\global\let\@NumberstringFngerman=\@NumberstringFgerman -\global\let\@NumberstringNngerman=\@NumberstringNgerman -\global\let\@ordinalstringMngerman=\@ordinalstringMgerman -\global\let\@ordinalstringFngerman=\@ordinalstringFgerman -\global\let\@ordinalstringNngerman=\@ordinalstringNgerman -\global\let\@OrdinalstringMngerman=\@OrdinalstringMgerman -\global\let\@OrdinalstringFngerman=\@OrdinalstringFgerman -\global\let\@OrdinalstringNngerman=\@OrdinalstringNgerman +\newcommand*{\latinnumeralstringnum}{% + \fc@call\@latinnumeralstringnum +} % \end{macrocode} - +\iffalse Local variables: \fi +\iffalse mode: docTeX \fi +\iffalse End: \fi %\iffalse % \begin{macrocode} -% +% % \end{macrocode} %\fi %\iffalse % \begin{macrocode} -%<*fc-ngermanb.def> +%<*fmtcount.sty> % \end{macrocode} %\fi -% \subsubsection{fc-ngermanb.def} -% \begin{macrocode} -\ProvidesFCLanguage{ngermanb}[2013/08/17]% -\FCloadlang{german}% -% \end{macrocode} -% Set |ngermanb| to be equivalent to |german|. Is it okay to do -% this? (I don't know the difference between the two.) -% \begin{macrocode} -\global\let\@ordinalMngermanb=\@ordinalMgerman -\global\let\@ordinalFngermanb=\@ordinalFgerman -\global\let\@ordinalNngermanb=\@ordinalNgerman -\global\let\@numberstringMngermanb=\@numberstringMgerman -\global\let\@numberstringFngermanb=\@numberstringFgerman -\global\let\@numberstringNngermanb=\@numberstringNgerman -\global\let\@NumberstringMngermanb=\@NumberstringMgerman -\global\let\@NumberstringFngermanb=\@NumberstringFgerman -\global\let\@NumberstringNngermanb=\@NumberstringNgerman -\global\let\@ordinalstringMngermanb=\@ordinalstringMgerman -\global\let\@ordinalstringFngermanb=\@ordinalstringFgerman -\global\let\@ordinalstringNngermanb=\@ordinalstringNgerman -\global\let\@OrdinalstringMngermanb=\@OrdinalstringMgerman -\global\let\@OrdinalstringFngermanb=\@OrdinalstringFgerman -\global\let\@OrdinalstringNngermanb=\@OrdinalstringNgerman -% \end{macrocode} -% Load fc-ngerman.def if not already loaded +%\subsection{fmtcount.sty} +% This section deals with the code for |fmtcount.sty| % \begin{macrocode} -\FCloadlang{ngerman}% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{fmtcount}[2015/05/05 v3.01] +\RequirePackage{ifthen} % \end{macrocode} - -%\iffalse +% \changes{3.01}{2014-12-18}{Use \styfmt{xkeyval} instead of \styfmt{keyval}, so that we do not get in trouble +% with bracket spurious removals} % \begin{macrocode} -% +\RequirePackage{xkeyval} +\RequirePackage{etoolbox} +\RequirePackage{fcprefix} % \end{macrocode} -%\fi -%\iffalse +% \changes{3.00}{2014-07-18}{Add \cs{RequirePackage} for \texttt{ifxetex}} % \begin{macrocode} -%<*fc-portuges.def> +\RequirePackage{ifxetex} % \end{macrocode} -%\fi -% \subsubsection{fc-portuges.def} -% Portuguse definitions +% \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} -\ProvidesFCLanguage{portuges}[2014/06/09]% +\RequirePackage{amsgen} % \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: +% 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. +% \changes{3.01}{2014-12-18}{Make \cs{fmtord} language dependent.} +% \changes{3.01}{2014-12-21}{Substitute \cs{textsuperscript} for \cs{fc@textsuperscript}, and define +% \cs{fc@textsuperscript} as \cs{fup} when defined at beginning of document, or as \cs{textsuperscript} +% otherwise} +%\begin{macro}{\fc@orddef@ult} % \begin{macrocode} -\newcommand*\@ordinalMportuges[2]{% - \ifnum#1=0\relax - \edef#2{\number#1}% - \else - \edef#2{\number#1\relax\noexpand\fmtord{o}}% - \fi -}% -\global\let\@ordinalMportuges\@ordinalMportuges +\providecommand*{\fc@orddef@ult}[1]{\fc@textsuperscript{#1}} % \end{macrocode} -% Feminine: +%\end{macro} +%\begin{macro}{\fc@ord@multiling} % \begin{macrocode} -\newcommand*\@ordinalFportuges[2]{% - \ifnum#1=0\relax - \edef#2{\number#1}% - \else - \edef#2{\number#1\relax\noexpand\fmtord{a}}% - \fi -}% -\global\let\@ordinalFportuges\@ordinalFportuges +\providecommand*{\fc@ord@multiling}[1]{% + \ifcsundef{fc@\languagename @alias@of}{% % \end{macrocode} -% Make neuter same as masculine: +% Not a supported language, just use the default setting: % \begin{macrocode} -\global\let\@ordinalNportuges\@ordinalMportuges + \fc@orddef@ult{#1}}{% + \expandafter\let\expandafter\@tempa\csname fc@\languagename @alias@of\endcsname + \ifcsundef{fc@ord@\@tempa}{% % \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): -%\changes{2.04}{2014-06-09}{Fixed bug that had incorrect number of -%parameters specified} +% Not language specfic setting, just use the default setting: % \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 -}% -\global\let\@@unitstringportuges\@@unitstringportuges -% \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 -}% -\global\let\@@unitstringFportuges\@@unitstringFportuges + \fc@orddef@ult{#1}}{% % \end{macrocode} -% Tens (argument must be a number from 0 to 10): +% Language with specific setting, use that setting: % \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 -}% -\global\let\@@tenstringportuges\@@tenstringportuges +\csname fc@ord@\@tempa\endcsname{#1}}}} % \end{macrocode} -% Teens (argument must be a number from 0 to 9): +%\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} -\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 -}% -\global\let\@@teenstringportuges\@@teenstringportuges +\newcount\c@padzeroesN +\c@padzeroesN=1\relax +\providecommand*{\padzeroes}[1][17]{\c@padzeroesN=#1} % \end{macrocode} -% Hundreds: +%\end{macro} +% +%\begin{macro}{\FCloadlang} +%\changes{2.0}{2012-06-18}{new} +%\changes{2.02}{2012-10-24}{ensured catcode for @ set to `letter' +%before loading file} +%\begin{definition} +%\cs{FCloadlang}\marg{language} +%\end{definition} +% Load \styfmt{fmtcount} language file, +% \texttt{fc-}\meta{language}\texttt{.def}, unless already loaded. +% Unfortunately neither \styfmt{babel} nor \styfmt{polyglossia} keep a list of loaded +% dialects, so we can't load all the necessary def files in the +% preamble as we don't know which dialects the user requires. +% Therefore the dialect definitions get loaded when a command such +% as \cs{ordinalnum} is used, if they +% haven't already been loaded. % \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 -}% -\global\let\@@hundredstringportuges\@@hundredstringportuges +\newcount\fc@tmpcatcode +\def\fc@languages{}% +\def\fc@mainlang{}% +\newcommand*{\FCloadlang}[1]{% + \@FC@iflangloaded{#1}{}% + {% + \fc@tmpcatcode=\catcode`\@\relax + \catcode `\@ 11\relax + \InputIfFileExists{fc-#1.def}% + {% + \ifdefempty{\fc@languages}% + {% + \gdef\fc@languages{#1}% + }% + {% + \gappto\fc@languages{,#1}% + }% + \gdef\fc@mainlang{#1}% + }% + {}% + \catcode `\@ \fc@tmpcatcode\relax + }% +} % \end{macrocode} -% Hundreds (feminine): +%\end{macro} +%\begin{macro}{\@FC@iflangloaded} +%\changes{2.0}{2012-06-18}{new} +%\begin{definition} +%\cs{@FC@iflangloaded}\marg{language}\marg{true}\marg{false} +%\end{definition} +%If fmtcount language definition file \texttt{fc-}\meta{language}\texttt{.def} has +%been loaded, do \meta{true} otherwise do \meta{false} % \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 -}% -\global\let\@@hundredstringFportuges\@@hundredstringFportuges +\newcommand{\@FC@iflangloaded}[3]{% + \ifcsundef{ver@fc-#1.def}{#3}{#2}% +} % \end{macrocode} -% Units (initial letter in upper case): +%\end{macro} +%\begin{macro}{\ProvidesFCLanguage} +%\changes{2.0}{2012-06-18}{new} +% Declare fmtcount language definition file. Adapted from +% \ics{ProvidesFile}. % \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 -}% -\global\let\@@Unitstringportuges\@@Unitstringportuges +\newcommand*{\ProvidesFCLanguage}[1]{% + \ProvidesFile{fc-#1.def}% +} % \end{macrocode} -% As above, but feminine: +%\end{macro} +% +% We need that flag to remember that a language has been loaded via package option, so that in the end we can +% set \styfmt{fmtcount} in multiling % \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 -}% -\global\let\@@UnitstringFportuges\@@UnitstringFportuges +\newif\iffmtcount@language@option +\fmtcount@language@optionfalse % \end{macrocode} -% Tens (with initial letter in upper case): +%\begin{macro}{\fc@supported@language@list} +% Declare list of supported languages, as a comma separated list. No space, no empty items. Each item is a +% language for which fmtcount is able to load language specific definitions. \texttt{Aliases but be +% \textit{after} their meaning, for instance `american' being an alias of `USenglish', it has to appear +% after it in the list}. The raison d'\^etre of this list is to commonalize iteration on languages for the +% two following purposes: +% \begin{itemize} +% \item loading language definition as a result of the language being used by +% \styfmt{babel}/\styfmt{polyglossia} +% \item loading language definition as a result of package option +% \end{itemize} +% These two purposes cannot be handled in the same pass, we need two different passes otherwise there would +% be some corner cases when a package would be required --- as a result of loading language definition for +% one language --- between a \cs{DeclareOption} and a \cs{ProcessOption} which is forbidden by \LaTeXe. +%\changes{3.00}{2014-07-18}{new} % \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 -}% -\global\let\@@Tenstringportuges\@@Tenstringportuges +\newcommand*\fc@supported@language@list{% +english,% +UKenglish,% +british,% +USenglish,% +american,% +spanish,% +portuges,% +french,% +frenchb,% +francais,% +german,% +germanb,% +ngerman,% +ngermanb,% +italian} % \end{macrocode} -% Teens (with initial letter in upper case): +%\end{macro} +%\begin{macro}{\fc@iterate@on@languages} +%\begin{definition} +%\cs{fc@iterate@on@languages}\marg{body} +%\end{definition} +% Now make some language iterator, note that for the following to work properly +% \cs{fc@supported@language@list} must not be empty. \meta{body} is a macro that takes one argument, and +% \cs{fc@iterate@on@languages} applies it iteratively : +%\changes{3.00}{2014-07-18}{new} % \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% +\newcommand*\fc@iterate@on@languages[1]{% + \ifx\fc@supported@language@list\@empty +% \end{macrocode} +% That case should never happen ! +% \begin{macrocode} + \PackageError{fmtcount}{Macro `\protect\@fc@iterate@on@languages' is empty}{You should never get here: + Something is broken within \texttt{fmtcount}, please report the issue on + \texttt{https://github.com/search?q=fmtcount\&ref=cmdform\&type=Issues}}% + \else + \let\fc@iterate@on@languages@body#1 + \expandafter\@fc@iterate@on@languages\fc@supported@language@list,\@nil,% \fi +} +\def\@fc@iterate@on@languages#1,{% + {% + \def\@tempa{#1}% + \ifx\@tempa\@nnil + \let\@tempa\@empty + \else + \def\@tempa{% + \fc@iterate@on@languages@body{#1}% + \@fc@iterate@on@languages + }% + \fi + \expandafter + }\@tempa }% -\global\let\@@Teenstringportuges\@@Teenstringportuges % \end{macrocode} -% Hundreds (with initial letter in upper case): +%\end{macro} +%\begin{macro}{\@fc@loadifbabelorpolyglossialdf} +%\begin{definition} +%\cs{@fc@loadifbabelorpolyglossialdf}\marg{language} +%\end{definition} +%Loads fmtcount language file, +%\texttt{fc-}\meta{language}\texttt{.def}, +% if one of the following condition is met: +% \begin{itemize} +% \item \styfmt{babel} language definition file \meta{language}\texttt{.ldf} has been loaded --- conditionally +% to compilation with \texttt{latex}, not \texttt{xelatex}. +% \item \styfmt{polyglossia} language definition file \texttt{gloss-}\meta{language}\texttt{.ldf} has been +% loaded --- conditionally to compilation with \texttt{xelatex}, not \texttt{latex}. +% \item \meta{language} option has been passed to package \styfmt{fmtcount}. +% \end{itemize} +% +%\changes{2.03}{2012-11-11}{renamed \cs{@fc@loadifbabelldf} to +% \cs{@fc@loadifbabelorpolyglossialdf}} +%\changes{2.03}{2012-11-11}{added check for polyglossia language} +%\changes{3.00}{2014-07-18}{use \cs{ifxetex} to discriminate between \styfmt{babel} and \styfmt{polyglossia}} % \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% +\newcommand*{\@fc@loadifbabelorpolyglossialdf}[1]{% + \ifxetex + \IfFileExists{gloss-#1.ldf}{\ifcsundef{#1@loaded}{}{\FCloadlang{#1}}}{}% + \else + \ifcsundef{ver@#1.ldf}{}{\FCloadlang{#1}}% \fi -}% -\global\let\@@Hundredstringportuges\@@Hundredstringportuges +} % \end{macrocode} -% As above, but feminine: +%\end{macro} +% +% Load appropriate language definition files: +%\changes{1.1}{14 June 2007}{added check for UKenglish, +% british and USenglish babel settings} +%\changes{2.0}{2012-06-18}{changed check for \cs{l@}\meta{language} +% to check for \cs{date}\meta{language}} +%\changes{3.00}{2014-07-18}{use iterator rather than doing it flat on each language} +%\changes{3.01}{2014-12-18}{Define language aliases to \cs{fmtord} +% option dependent on ``true'' language .} % \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 -}% -\global\let\@@HundredstringFportuges\@@HundredstringFportuges +\fc@iterate@on@languages\@fc@loadifbabelorpolyglossialdf % \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.) +% By default all languages are unique --- i.e. aliases not yet defined. % \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}% -}% -\global\let\@numberstringMportuges\@numberstringMportuges +\def\fc@iterate@on@languages@body#1{% + \expandafter\def\csname fc@#1@alias@of\endcsname{#1}} +\expandafter\@fc@iterate@on@languages\fc@supported@language@list,\@nil,% % \end{macrocode} -% As above, but feminine form: +% Now define those languages that are aliases of another +% language. This is done with: \cs{@tempa}\marg{alias}\marg{language} % \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}% +\def\@tempa#1#2{% + \expandafter\def\csname fc@#1@alias@of\endcsname{#2}% }% -\global\let\@numberstringFportuges\@numberstringFportuges +\@tempa{frenchb}{french} +\@tempa{francais}{french} +\@tempa{germanb}{german} +\@tempa{ngermanb}{german} +\@tempa{ngerman}{german} +\@tempa{british}{english} +\@tempa{american}{USenglish} % \end{macrocode} -% Make neuter same as masculine: +% Now, thanks to the aliases, we are going to define one option for each language, so that each language can +% have its own settings. % \begin{macrocode} -\global\let\@numberstringNportuges\@numberstringMportuges +\def\fc@iterate@on@languages@body#1{% + \define@key{fmtcount}{#1}[]{% + \@FC@iflangloaded{#1}% + {% + \setkeys{fc\csname fc@#1@alias@of\endcsname}{##1}% + }{% + \PackageError{fmtcount}% + {Language `#1' not defined}% + {You need to load \ifxetex polyglossia\else babel\fi\space before loading fmtcount}% + }% + }% + \ifthenelse{\equal{\csname fc@#1@alias@of\endcsname}{#1}}{% + \define@key{fc\csname fc@#1@alias@of\endcsname}{fmtord}{% + \ifthenelse{\equal{##1}{raise}\or\equal{##1}{level}}{% + \expandafter\let\expandafter\@tempa\csname fc@set@ord@as@##1\endcsname + \expandafter\@tempa\csname fc@ord@#1\endcsname + }{% + \ifthenelse{\equal{##1}{undefine}}{% + \expandafter\let\csname fc@ord@#1\endcsname\undefined + }{% + \PackageError{fmtcount}% + {Invalid value `##1' to fmtord key}% + {Option `fmtord' can only take the values `level', `raise' + or `undefine'}% + }} + }% + }{% % \end{macrocode} -% As above, but initial letters in upper case: +% When the language \#1 is an alias, do the same as the language of which it is an alias: % \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}% -}% -\global\let\@NumberstringMportuges\@NumberstringMportuges + \expandafter\let\expandafter\@tempa\csname KV@\csname fc@#1@alias@of\endcsname @fmtord\endcsname + \expandafter\let\csname KV@#1@fmtord\endcsname\@tempa + }% +} +\expandafter\@fc@iterate@on@languages\fc@supported@language@list,\@nil,% % \end{macrocode} -% As above, but feminine form: +%\begin{option}{fmtord} +% Key to determine how to display the ordinal +% \changes{3.01}{2014-12-18}{Apply option directly, rather than doing a border effect on \cs{fmtcount@fmtord}, +% and then postprocessing depending on \cs{fmtcount@fmtord} at the end of \cs{fmtcountsetoptions}} % \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}% -}% -\global\let\@NumberstringFportuges\@NumberstringFportuges +\def\fc@set@ord@as@level#1{% + \def#1##1{##1}% +} +\def\fc@set@ord@as@raise#1{% + \let#1\fc@textsuperscript +} +\define@key{fmtcount}{fmtord}{% + \ifthenelse{\equal{#1}{level} + \or\equal{#1}{raise}}% + {% + \csname fc@set@ord@as@#1\endcsname\fc@orddef@ult + \def\fmtcount@fmtord{#1}% + }% + {% + \PackageError{fmtcount}% + {Invalid value `#1' to fmtord key}% + {Option `fmtord' can only take the values `level' or `raise'}% + }% +} % \end{macrocode} -% Make neuter same as masculine: +%\end{option} +%\begin{macro}{\iffmtord@abbrv} +% Key to determine whether the ordinal superscript should be +% abbreviated (language dependent, currently only affects French +% ordinals, non-abbreviated French ordinals ending --- i.e. `ier' and +% `i\`eme' --- are considered faulty.) % \begin{macrocode} -\global\let\@NumberstringNportuges\@NumberstringMportuges +\newif\iffmtord@abbrv % \end{macrocode} -% As above, but for ordinals. +% \changes{3.01}{2014-11-12}{Make `true' the default for option +% `abbr', as in French this is the correct behaviour, and currently +% only French uses that} % \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}% -}% -\global\let\@ordinalstringMportuges\@ordinalstringMportuges +\fmtord@abbrvtrue +\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 `abbrv' can only take the values `true' or + `false'}% + }% +} % \end{macrocode} -% Feminine form: +%\end{macro} +%\begin{option}{prefix} +%\changes{2.0}{2012-06-18}{new} % \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}% -}% -\global\let\@ordinalstringFportuges\@ordinalstringFportuges +\define@key{fmtcount}{prefix}[scale=long]{% + \RequirePackage{fmtprefix}% + \fmtprefixsetoption{#1}% +} % \end{macrocode} -% Make neuter same as masculine: +%\end{option} +%\begin{macro}{\fmtcountsetoptions} +% Define command to set options. +% \changes{3.01}{2014-12-18}{ Move French specific stuff to \styfmt{french.def}.} % \begin{macrocode} -\global\let\@ordinalstringNportuges\@ordinalstringMportuges +\def\fmtcountsetoptions{% + \def\fmtcount@fmtord{}% + \setkeys{fmtcount}}% % \end{macrocode} -% As above, but initial letters in upper case (masculine): +%\end{macro} +% Load configuration 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. +%\changes{2.0}{2012-06-18}{Now no message if fmtcount.cfg not found} % \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}% +\InputIfFileExists{fmtcount.cfg}% +{% + \PackageInfo{fmtcount}{Using configuration file fmtcount.cfg}% }% -\global\let\@OrdinalstringMportuges\@OrdinalstringMportuges +{% +} % \end{macrocode} -% Feminine form: +%\begin{macro}{\fmtcount@loaded@by@option@lang@list} +% \changes{3.01}{2014-10-15}{Declare language option so that actual loading happens after \cs{ProcessOptions}, +% and the \cs{ProcessOption} only registers the language for loading.} % \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}% -}% -\global\let\@OrdinalstringFportuges\@OrdinalstringFportuges +\newcommand*{\fmtcount@loaded@by@option@lang@list}{} % \end{macrocode} -% Make neuter same as masculine: +%\end{macro} +%\begin{option}{\meta{language}} +%Option \meta{language} causes language \meta{language} to be registered for loading. % \begin{macrocode} -\global\let\@OrdinalstringNportuges\@OrdinalstringMportuges +\newcommand*\@fc@declare@language@option[1]{% + \DeclareOption{#1}{% + \ifx\fmtcount@loaded@by@option@lang@list\@empty + \def\fmtcount@loaded@by@option@lang@list{#1}% + \else + \edef\fmtcount@loaded@by@option@lang@list{\fmtcount@loaded@by@option@lang@list,#1}% + \fi + }}% +\fc@iterate@on@languages\@fc@declare@language@option % \end{macrocode} -% In order to do the ordinals, split into units, teens, tens -% and hundreds. Units: +%\end{option} +% +%\begin{option}{level} % \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 -}% -\global\let\@@unitthstringportuges\@@unitthstringportuges +\DeclareOption{level}{\def\fmtcount@fmtord{level}% + \def\fc@orddef@ult#1{#1}} +% \end{macrocode} +%\end{option} +%\begin{option}{raise} +% \begin{macrocode} +\DeclareOption{raise}{\def\fmtcount@fmtord{raise}% + \def\fc@orddef@ult#1{\fc@textsuperscript{#1}}} % \end{macrocode} -% Tens: +%\end{option} +% Process package options +% \changes{3.00}{2014-07-18}{Add \cs{relax} after \cs{ProcessOptions} like shown in \texttt{clsguide.pdf}} % \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 -}% -\global\let\@@tenthstringportuges\@@tenthstringportuges +\ProcessOptions\relax % \end{macrocode} -% Teens: +% \changes{3.01}{2014-10-15}{Load languages that have been registered for loading by package option.} +% Now we do the loading of all languages that have been set by option to be loaded. % \begin{macrocode} -\newcommand*\@@teenthstringportuges[1]{% - \@tenthstring{1}% - \ifnum#1>0\relax - -\@unitthstring{#1}% - \fi -}% -\global\let\@@teenthstringportuges\@@teenthstringportuges +\ifx\fmtcount@loaded@by@option@lang@list\@empty\else +\def\fc@iterate@on@languages@body#1{% + \@FC@iflangloaded{#1}{}{% + \fmtcount@language@optiontrue + \FCloadlang{#1}% + }} +\expandafter\@fc@iterate@on@languages\fmtcount@loaded@by@option@lang@list,\@nil,% +\fi % \end{macrocode} -% Hundreds: +%\begin{macro}{\@FCmodulo} +%\begin{definition} +%\cs{@FCmodulo}\marg{count reg}\marg{n} +%\end{definition} +%\changes{2.04}{2014-06-09}{renamed \cs{@modulo} to \cs{@FCmodulo}} +% Sets the count register to be its value modulo \meta{n}. +% This is used for the +% date, time, ordinal and numberstring commands. (The +% \styfmt{fmtcount} package was originally part of the +% \sty{datetime} package.) % \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 -}% -\global\let\@@hundredthstringportuges\@@hundredthstringportuges +\newcount\@DT@modctr +\newcommand*{\@FCmodulo}[2]{% + \@DT@modctr=#1\relax + \divide \@DT@modctr by #2\relax + \multiply \@DT@modctr by #2\relax + \advance #1 by -\@DT@modctr +} % \end{macrocode} -% Units (feminine): +%\end{macro} +% The following registers are needed by |\@ordinal| etc % \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 -}% -\global\let\@@unitthstringFportuges\@@unitthstringFportuges +\newcount\@ordinalctr +\newcount\@orgargctr +\newcount\@strctr +\newcount\@tmpstrctr % \end{macrocode} -% Tens (feminine): +%Define commands that display numbers in different bases. +% Define counters and conditionals needed. % \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 -}% -\global\let\@@tenthstringFportuges\@@tenthstringFportuges +\newif\if@DT@padzeroes +\newcount\@DT@loopN +\newcount\@DT@X % \end{macrocode} -% Hundreds (feminine): +%\begin{macro}{\binarynum} +% Converts a decimal number to binary, and display. % \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 -}% -\global\let\@@hundredthstringFportuges\@@hundredthstringFportuges +\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} -% As above, but with initial letter in upper case. Units: +%\end{macro} +%\begin{macro}{\octalnum} +% Converts a decimal number to octal, and displays. % \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*{\@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 -}% -\global\let\@@Unitthstringportuges\@@Unitthstringportuges +} +\let\octalnum=\@octal % \end{macrocode} -% Tens: +%\end{macro} +%\begin{macro}{\@@hexadecimalnum} +% Converts number from 0 to 15 into lowercase hexadecimal notation. % \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 -}% -\global\let\@@Tenthstringportuges\@@Tenthstringportuges +\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 +} % \end{macrocode} -% Hundreds: +%\end{macro} +%\begin{macro}{\hexadecimalnum} +% Converts a decimal number to a lowercase hexadecimal number, +% and displays it. % \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 -}% -\global\let\@@Hundredthstringportuges\@@Hundredthstringportuges +\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} -% As above, but feminine. Units: +%\end{macro} +%\begin{macro}{\@@Hexadecimalnum} +% Converts number from 0 to 15 into uppercase hexadecimal notation. % \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 -}% -\global\let\@@UnitthstringFportuges\@@UnitthstringFportuges +\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 +} % \end{macrocode} -% Tens (feminine); +%\end{macro} +%\begin{macro}{\Hexadecimalnum} +% Uppercase hexadecimal % \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 -}% -\global\let\@@TenthstringFportuges\@@TenthstringFportuges +\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} -% Hundreds (feminine): +%\end{macro} +%\begin{macro}{\aaalphnum} +% Lowercase alphabetical representation (a \ldots\ z aa \ldots\ zz) % \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 -}% -\global\let\@@HundredthstringFportuges\@@HundredthstringFportuges +\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} -% 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.) +%\end{macro} +%\begin{macro}{\AAAlphnum} +% Uppercase alphabetical representation (a \ldots\ z aa \ldots\ zz) % \begin{macrocode} -\newcommand*\@@numberstringportuges[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>9\relax +\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} -% \#1 is greater or equal to 10000 +%\end{macro} +%\begin{macro}{\abalphnum} +% Lowercase alphabetical representation % \begin{macrocode} - \divide\@strctr by 10\relax - \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1 \divide\@strctr by 1000\relax - \@FCmodulo{\@strctr}{10}% - \ifnum\@strctr>0 - \ifnum\@strctr=1\relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\ \@andname}% - \fi - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\ \@unitstring{\@strctr}}% - \fi - \else - \@strctr=#1\relax - \divide\@strctr by 1000\relax - \@FCmodulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\@teenstring{\@strctr}}% - \fi - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\ \@thousand}% -\else - \ifnum\@strctr>0\relax - \ifnum\@strctr>1\relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\@unitstring{\@strctr}\ }% - \fi - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\@thousand}% - \fi -\fi -\@strctr=#1\relax \@FCmodulo{\@strctr}{1000}% -\divide\@strctr by 100\relax -\ifnum\@strctr>0\relax - \ifnum#1>1000 \relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\ }% - \fi - \@tmpstrctr=#1\relax - \@FCmodulo{\@tmpstrctr}{1000}% - \let\@@fc@numstr#2\relax - \ifnum\@tmpstrctr=100\relax - \protected@edef#2{\@@fc@numstr\@tenstring{10}}% +\newcommand*{\@abalph}[1]{% + \ifnum#1>17576\relax + \PackageError{fmtcount}% + {Value of counter too large for \protect\@abalph}% + {Maximum value 17576}% \else - \protected@edef#2{\@@fc@numstr\@hundredstring{\@strctr}}% - \fi% -\fi -\@strctr=#1\relax \@FCmodulo{\@strctr}{100}% -\ifnum#1>100\relax - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\ \@andname\ }% - \fi -\fi -\ifnum\@strctr>19\relax - \divide\@strctr by 10\relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\@tenstring{\@strctr}}% - \@strctr=#1\relax \@FCmodulo{\@strctr}{10}% - \ifnum\@strctr>0 - \ifnum\@strctr=1\relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\ \@andname}% - \else - \ifnum#1>100\relax - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\ \@andname}% - \fi - \fi - \let\@@fc@numstr#2\relax - \protected@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 - \protected@edef#2{\@@fc@numstr\@unitstring{\@strctr}}% - \fi - \else %(>0,<10) - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\@unitstring{\@strctr}}% - \fi - \else%>10 - \@FCmodulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \protected@edef#2{\@@fc@numstr\@teenstring{\@strctr}}% + \@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 -\fi -}% -\global\let\@@numberstringportuges\@@numberstringportuges +} + +\let\abalphnum=\@abalph % \end{macrocode} -% As above, but for ordinals. +%\end{macro} +%\begin{macro}{\ABAlphnum} +% Uppercase alphabetical representation % \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 - \@FCmodulo{\@tmpstrctr}{10}% - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@teenthstring{\@tmpstrctr}}% - \else - \divide\@tmpstrctr by 10\relax - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% - \@tmpstrctr=\@strctr - \@FCmodulo{\@tmpstrctr}{10}% - \ifnum\@tmpstrctr>0\relax - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@unitthstring{\@tmpstrctr}}% - \fi - \fi - \else - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@unitstring{\@strctr}}% - \fi - \fi - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@thousandth}% -\fi -\@strctr=#1\relax -\@FCmodulo{\@strctr}{1000}% -\ifnum\@strctr>99\relax - \@tmpstrctr=\@strctr - \divide\@tmpstrctr by 100\relax - \ifnum#1>1000\relax - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr-}% - \fi - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@hundredthstring{\@tmpstrctr}}% -\fi -\@FCmodulo{\@strctr}{100}% -\ifnum#1>99\relax - \ifnum\@strctr>0\relax - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr-}% - \fi -\fi -\ifnum\@strctr>9\relax - \@tmpstrctr=\@strctr - \divide\@tmpstrctr by 10\relax - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@tenthstring{\@tmpstrctr}}% - \@tmpstrctr=\@strctr - \@FCmodulo{\@tmpstrctr}{10}% - \ifnum\@tmpstrctr>0\relax - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr-\@unitthstring{\@tmpstrctr}}% +\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 -\else - \ifnum\@strctr=0\relax - \ifnum#1=0\relax - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@unitstring{0}}% - \fi +} + +\let\ABAlphnum=\@ABAlph +% \end{macrocode} +%\end{macro} +%\begin{macro}{\@fmtc@count} +% Recursive command to count number of characters in argument. +% \cs{@strctr} should be set to zero before calling it. +% \begin{macrocode} +\def\@fmtc@count#1#2\relax{% + \if\relax#1% \else - \let\@@fc@ordstr#2\relax - \protected@edef#2{\@@fc@ordstr\@unitthstring{\@strctr}}% + \advance\@strctr by 1\relax + \@fmtc@count#2\relax \fi -\fi -\fi -\fi -}% -\global\let\@@ordinalstringportuges\@@ordinalstringportuges +} +% \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} +%\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. +% \changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageWarning} to quote macros like +% shown in \texttt{clsguide.pdf}} +% \begin{macrocode} +\ifcsundef{ordinal} + {\let\ordinal\FCordinal}% + {% + \PackageWarning{fmtcount}% + {\protect\ordinal \space already defined use + \protect\FCordinal \space instead.} + } +% \end{macrocode} +%\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} +\newcommand*{\ordinalnum}[1]{% + \new@ifnextchar[% + {\@ordinalnum{#1}}% + {\@ordinalnum{#1}[m]}% +} +% \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}): +% \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 + }% +} +% \end{macrocode} +%\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} -%\iffalse +%\end{macro} +%\begin{macro}{\storeordinalnum} +% Store ordinal (first argument +% is identifying name, second argument is a number or +% count register.) % \begin{macrocode} -% +\newcommand*{\storeordinalnum}[2]{% + \@ifnextchar[% + {\@storeordinalnum{#1}{#2}}% + {\@storeordinalnum{#1}{#2}[m]}% +} % \end{macrocode} -%\fi -%\iffalse +%\end{macro} +%\begin{macro}{\@storeordinalnum} +% Store ordinal according to gender: % \begin{macrocode} -%<*fc-portuguese.def> +\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} -%\fi -% \subsubsection{fc-portuguese.def} +%\end{macro} +%\begin{macro}{\FMCuse} +% Get stored information: % \begin{macrocode} -\ProvidesFCLanguage{portuguese}[2014/06/09]% +\newcommand*{\FMCuse}[1]{\csname @fcs@#1\endcsname} % \end{macrocode} -% Load fc-portuges.def if not already loaded +%\end{macro} +%\begin{macro}{\ordinalstring} +% Display ordinal as a string (argument is a counter) % \begin{macrocode} -\FCloadlang{portuges}% +\newcommand*{\ordinalstring}[1]{% + \expandafter\protect\expandafter\ordinalstringnum{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Set |portuguese| to be equivalent to |portuges|. +%\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}} +%\changes{1.33}{2009/10/15}{Made robust} % \begin{macrocode} -\global\let\@ordinalMportuguese=\@ordinalMportuges -\global\let\@ordinalFportuguese=\@ordinalFportuges -\global\let\@ordinalNportuguese=\@ordinalNportuges -\global\let\@numberstringMportuguese=\@numberstringMportuges -\global\let\@numberstringFportuguese=\@numberstringFportuges -\global\let\@numberstringNportuguese=\@numberstringNportuges -\global\let\@NumberstringMportuguese=\@NumberstringMportuges -\global\let\@NumberstringFportuguese=\@NumberstringFportuges -\global\let\@NumberstringNportuguese=\@NumberstringNportuges -\global\let\@ordinalstringMportuguese=\@ordinalstringMportuges -\global\let\@ordinalstringFportuguese=\@ordinalstringFportuges -\global\let\@ordinalstringNportuguese=\@ordinalstringNportuges -\global\let\@OrdinalstringMportuguese=\@OrdinalstringMportuges -\global\let\@OrdinalstringFportuguese=\@OrdinalstringFportuges -\global\let\@OrdinalstringNportuguese=\@OrdinalstringNportuges +\newcommand{\ordinalstringnum}[1]{% + \new@ifnextchar[% + {\@ordinal@string{#1}}% + {\@ordinal@string{#1}[m]}% +} % \end{macrocode} - -%\iffalse +%\end{macro} +%\begin{macro}{\@ordinal@string} +% Display ordinal as a string according to gender. +% \changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageError} to quote macros like +% shown in \texttt{clsguide.pdf}} +% \changes{3.00}{2014-07-18}{Correct detailed error message, so `n' is one of available gender options} % \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 \protect\ordinalstring}% + {Available options are m, f or n}% + }% + \protect\@ordinalstringM{#1}{\@fc@ordstr}% + }% + }% + \@fc@ordstr + }% +} % \end{macrocode} -%\fi -%\iffalse +%\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} -%<*fc-spanish.def> +\newcommand*{\storeordinalstring}[2]{% + \expandafter\protect\expandafter\storeordinalstringnum{#1}{% + \expandafter\the\csname c@#2\endcsname}% +} % \end{macrocode} -%\fi -% \subsubsection{fc-spanish.def} -% Spanish definitions +%\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} -\ProvidesFCLanguage{spanish}[2013/08/17]% +\newcommand*{\storeordinalstringnum}[2]{% + \@ifnextchar[% + {\@store@ordinal@string{#1}{#2}}% + {\@store@ordinal@string{#1}{#2}[m]}% +} % \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: +%\end{macro} +%\begin{macro}{\@store@ordinal@string} +% Store textual representation of number according to gender. +% \changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageWarning} to quote macros like +% shown in \texttt{clsguide.pdf}} % \begin{macrocode} -\newcommand*\@ordinalMspanish[2]{% - \edef#2{\number#1\relax\noexpand\fmtord{o}}% -}% -\global\let\@ordinalMspanish\@ordinalMspanish +\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 \protect\ordinalstring}% + {Available options are m, f or n}% + }% + \protect\@ordinalstringM{#2}{\@fc@ordstr}% + }% + }% + \expandafter\let\csname @fcs@#1\endcsname\@fc@ordstr +} % \end{macrocode} -% Feminine: +%\end{macro} +%\begin{macro}{\Ordinalstring} +% Display ordinal as a string with initial letters in upper case +% (argument is a counter) % \begin{macrocode} -\newcommand{\@ordinalFspanish}[2]{% - \edef#2{\number#1\relax\noexpand\fmtord{a}}% -}% -\global\let\@ordinalFspanish\@ordinalFspanish +\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 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} -\global\let\@ordinalNspanish\@ordinalMspanish +\newcommand*{\Ordinalstringnum}[1]{% + \new@ifnextchar[% + {\@Ordinal@string{#1}}% + {\@Ordinal@string{#1}[m]}% +} % \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): +%\end{macro} +%\begin{macro}{\@Ordinal@string} +% Display ordinal as a string with initial letters in upper case +% according to gender % \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 -}% -\global\let\@@unitstringspanish\@@unitstringspanish +\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} -% Feminine: +%\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*\@@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 -}% -\global\let\@@unitstringFspanish\@@unitstringFspanish +\newcommand*{\storeOrdinalstring}[2]{% + \expandafter\protect\expandafter\storeOrdinalstringnum{#1}{% + \expandafter\the\csname c@#2\endcsname}% +} % \end{macrocode} -% Tens (argument must go from 1 to 10): -%\changes{2.0}{2012-06-18}{fixed spelling mistake (correction -%provided by Fernando Maldonado)} +%\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*\@@tenstringspanish[1]{% - \ifcase#1\relax - \or diez% - \or veinte% - \or treinta% - \or cuarenta% - \or cincuenta% - \or sesenta% - \or setenta% - \or ochenta% - \or noventa% - \or cien% - \fi -}% -\global\let\@@tenstringspanish\@@tenstringspanish +\newcommand*{\storeOrdinalstringnum}[2]{% + \@ifnextchar[% + {\@store@Ordinal@string{#1}{#2}}% + {\@store@Ordinal@string{#1}{#2}[m]}% +} % \end{macrocode} -% Teens: +%\end{macro} +%\begin{macro}{\@store@Ordinal@string} +% Store textual representation of number according to gender, +% with initial letters in upper case. % \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% - \fi -}% -\global\let\@@teenstringspanish\@@teenstringspanish +\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} -% Twenties: +%\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*\@@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 -}% -\global\let\@@twentystringspanish\@@twentystringspanish +\newcommand*{\storeORDINALstring}[2]{% + \expandafter\protect\expandafter\storeORDINALstringnum{#1}{% + \expandafter\the\csname c@#2\endcsname}% +} % \end{macrocode} -% Feminine form: +%\end{macro} +%\begin{macro}{\storeORDINALstringnum} +% As above, but the second argument is a count register or a +% number. % \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 -}% -\global\let\@@twentystringFspanish\@@twentystringFspanish +\newcommand*{\storeORDINALstringnum}[2]{% + \@ifnextchar[% + {\@store@ORDINAL@string{#1}{#2}}% + {\@store@ORDINAL@string{#1}{#2}[m]}% +} % \end{macrocode} -% Hundreds: +%\end{macro} +%\begin{macro}{\@store@ORDINAL@string} +% Gender is specified as an optional argument at the end. % \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 -}% -\global\let\@@hundredstringspanish\@@hundredstringspanish +\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}% + }% + }% % \end{macrocode} -% Feminine form: +% \changes{3.01}{2014-11-10}{Protect \cs{`}.} % \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 -}% -\global\let\@@hundredstringFspanish\@@hundredstringFspanish + \expandafter\protected@edef\csname @fcs@#1\endcsname{% + \noexpand\MakeUppercase{\@fc@ordstr}% + }% +} % \end{macrocode} -% As above, but with initial letter uppercase: +%\end{macro} +%\begin{macro}{\ORDINALstring} +% Display upper case textual representation of an ordinal. The +% argument must be a counter. % \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 -}% -\global\let\@@Unitstringspanish\@@Unitstringspanish +\newcommand*{\ORDINALstring}[1]{% + \expandafter\protect\expandafter\ORDINALstringnum{% + \expandafter\the\csname c@#1\endcsname + }% +} % \end{macrocode} -% Feminine form: +%\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} -\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 -}% -\global\let\@@UnitstringFspanish\@@UnitstringFspanish +\newcommand*{\ORDINALstringnum}[1]{% + \new@ifnextchar[% + {\@ORDINAL@string{#1}}% + {\@ORDINAL@string{#1}[m]}% +} % \end{macrocode} -% Tens: +%\end{macro} +%\begin{macro}{\@ORDINAL@string} +% Gender is specified as an optional argument at the end. % \begin{macrocode} -%\changes{2.0}{2012-06-18}{fixed spelling mistake (correction -%provided by Fernando Maldonado)} -\newcommand*\@@Tenstringspanish[1]{% - \ifcase#1\relax - \or Diez% - \or Veinte% - \or Treinta% - \or Cuarenta% - \or Cincuenta% - \or Sesenta% - \or Setenta% - \or Ochenta% - \or Noventa% - \or Cien% - \fi -}% -\global\let\@@Tenstringspanish\@@Tenstringspanish +\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} -% Teens: +%\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} -\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 -}% -\global\let\@@Teenstringspanish\@@Teenstringspanish +\newcommand*{\storenumberstring}[2]{% + \expandafter\protect\expandafter\storenumberstringnum{#1}{% + \expandafter\the\csname c@#2\endcsname}% +} % \end{macrocode} -% Twenties: +%\end{macro} +%\begin{macro}{\storenumberstringnum} +% As above, but second argument is a number or count register. % \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 -}% -\global\let\@@Twentystringspanish\@@Twentystringspanish +\newcommand{\storenumberstringnum}[2]{% + \@ifnextchar[% + {\@store@number@string{#1}{#2}}% + {\@store@number@string{#1}{#2}[m]}% +} % \end{macrocode} -% Feminine form: +%\end{macro} +%\begin{macro}{\@store@number@string} +% Gender is given as optional argument, \emph{at the end}. % \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 -}% -\global\let\@@TwentystringFspanish\@@TwentystringFspanish +\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} -% Hundreds: +%\end{macro} +%\begin{macro}{\numberstring} +% Display textual representation of a number. The argument +% must be a counter. % \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 -}% -\global\let\@@Hundredstringspanish\@@Hundredstringspanish +\newcommand*{\numberstring}[1]{% + \expandafter\protect\expandafter\numberstringnum{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Feminine form: +%\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} -\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 -}% -\global\let\@@HundredstringFspanish\@@HundredstringFspanish +\newcommand*{\numberstringnum}[1]{% + \new@ifnextchar[% + {\@number@string{#1}}% + {\@number@string{#1}[m]}% +} % \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} +% +%\begin{macro}{\@number@string} +% Gender is specified as an optional argument \emph{at the end}. % \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}% -}% -\global\let\@numberstringMspanish\@numberstringMspanish +\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} -% Feminine form: -%\changes{2.0}{2012-06-18}{changed andname to `b' (correction -%provided by Fernando Maldonado)} +%\end{macro} +%\begin{macro}{\storeNumberstring} +% Store textual representation of number. First argument is +% identifying name, second argument is a counter. % \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{b}% - \@@numberstringspanish{#1}{#2}% -}% -\global\let\@numberstringFspanish\@numberstringFspanish +\newcommand*{\storeNumberstring}[2]{% + \expandafter\protect\expandafter\storeNumberstringnum{#1}{% + \expandafter\the\csname c@#2\endcsname}% +} % \end{macrocode} -% Make neuter same as masculine: +%\end{macro} +%\begin{macro}{\storeNumberstringnum} +% As above, but second argument is a count register or number. % \begin{macrocode} -\global\let\@numberstringNspanish\@numberstringMspanish +\newcommand{\storeNumberstringnum}[2]{% + \@ifnextchar[% + {\@store@Number@string{#1}{#2}}% + {\@store@Number@string{#1}{#2}[m]}% +} % \end{macrocode} -% As above, but initial letters in upper case: +%\end{macro} +%\begin{macro}{\@store@Number@string} +% Gender is specified as an optional argument \emph{at the end}: % \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}% -}% -\global\let\@NumberstringMspanish\@NumberstringMspanish +\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} -% Feminine form: -%\changes{2.0}{2012-06-18}{changed andname to `b' (correction -%provided by Fernando Maldonado)} +%\end{macro} +%\begin{macro}{\Numberstring} +% Display textual representation of number. The argument must be +% a counter. % \begin{macrocode} -\DeclareRobustCommand{\@NumberstringFspanish}[2]{% - \let\@unitstring=\@@UnitstringFspanish - \let\@teenstring=\@@Teenstringspanish - \let\@tenstring=\@@Tenstringspanish - \let\@twentystring=\@@TwentystringFspanish - \let\@hundredstring=\@@HundredstringFspanish - \def\@andname{b}% - \def\@hundred{Cien}\def\@thousand{Mil}% - \@@numberstringspanish{#1}{#2}% -}% -\global\let\@NumberstringFspanish\@NumberstringFspanish +\newcommand*{\Numberstring}[1]{% + \expandafter\protect\expandafter\Numberstringnum{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Make neuter same as masculine: +%\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} -\global\let\@NumberstringNspanish\@NumberstringMspanish +\newcommand*{\Numberstringnum}[1]{% + \new@ifnextchar[% + {\@Number@string{#1}}% + {\@Number@string{#1}[m]}% +} % \end{macrocode} -% As above, but for ordinals. +%\end{macro} +%\begin{macro}{\@Number@string} +% Gender is specified as an optional argument at the end. % \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}% -}% -\global\let\@ordinalstringMspanish\@ordinalstringMspanish +\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} -% Feminine form: +%\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{\@ordinalstringFspanish}[2]{% - \let\@unitthstring=\@@unitthstringFspanish - \let\@unitstring=\@@unitstringFspanish - \let\@teenthstring=\@@teenthstringFspanish - \let\@tenthstring=\@@tenthstringFspanish - \let\@hundredthstring=\@@hundredthstringFspanish - \def\@thousandth{mil\'esima}% - \@@ordinalstringspanish{#1}{#2}% -}% -\global\let\@ordinalstringFspanish\@ordinalstringFspanish +\newcommand{\storeNUMBERstring}[2]{% + \expandafter\protect\expandafter\storeNUMBERstringnum{#1}{% + \expandafter\the\csname c@#2\endcsname}% +} % \end{macrocode} -% Make neuter same as masculine: +%\end{macro} +%\begin{macro}{\storeNUMBERstringnum} +% As above, but the second argument is a count register or a +% number. % \begin{macrocode} -\global\let\@ordinalstringNspanish\@ordinalstringMspanish +\newcommand{\storeNUMBERstringnum}[2]{% + \@ifnextchar[% + {\@store@NUMBER@string{#1}{#2}}% + {\@store@NUMBER@string{#1}{#2}[m]}% +} % \end{macrocode} -% As above, but with initial letters in upper case. +%\end{macro} +%\begin{macro}{\@store@NUMBER@string} +% Gender is specified as an optional argument at the end. % \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}% +\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}% + }% } -\global\let\@OrdinalstringMspanish\@OrdinalstringMspanish % \end{macrocode} -% Feminine form: +%\end{macro} +%\begin{macro}{\NUMBERstring} +% Display upper case textual representation of a number. The +% argument must be a counter. % \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}% -}% -\global\let\@OrdinalstringFspanish\@OrdinalstringFspanish +\newcommand*{\NUMBERstring}[1]{% + \expandafter\protect\expandafter\NUMBERstringnum{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Make neuter same as 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} -\global\let\@OrdinalstringNspanish\@OrdinalstringMspanish +\newcommand*{\NUMBERstringnum}[1]{% + \new@ifnextchar[% + {\@NUMBER@string{#1}}% + {\@NUMBER@string{#1}[m]}% +} % \end{macrocode} -% Code for convert numbers into textual ordinals. As before, -% it is easier to split it into units, tens, teens and hundreds. -% Units: +%\end{macro} +%\begin{macro}{\@NUMBER@string} +% Gender is specified as an optional argument at the end. % \begin{macrocode} -\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 -}% -\global\let\@@unitthstringspanish\@@unitthstringspanish +\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} -% Tens: +%\end{macro} +%\begin{macro}{\binary} +% Number representations in other bases. Binary: % \begin{macrocode} -\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 -}% -\global\let\@@tenthstringspanish\@@tenthstringspanish +\providecommand*{\binary}[1]{% + \expandafter\protect\expandafter\@binary{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Teens: +%\end{macro} +%\begin{macro}{\aaalph} +% Like \ics{alph}, but goes beyond 26. +% (a \ldots\ z aa \ldots zz \ldots) % \begin{macrocode} -\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 -}% -\global\let\@@teenthstringspanish\@@teenthstringspanish +\providecommand*{\aaalph}[1]{% + \expandafter\protect\expandafter\@aaalph{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Hundreds: +%\end{macro} +%\begin{macro}{\AAAlph} +% As before, but upper case. % \begin{macrocode} -\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 -}% -\global\let\@@hundredthstringspanish\@@hundredthstringspanish +\providecommand*{\AAAlph}[1]{% + \expandafter\protect\expandafter\@AAAlph{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Units (feminine): +%\end{macro} +%\begin{macro}{\abalph} +% Like \ics{alph}, but goes beyond 26. +% (a \ldots\ z ab \ldots az \ldots) % \begin{macrocode} -\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 -}% -\global\let\@@unitthstringFspanish\@@unitthstringFspanish +\providecommand*{\abalph}[1]{% + \expandafter\protect\expandafter\@abalph{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Tens (feminine): +%\end{macro} +%\begin{macro}{\ABAlph} +% As above, but upper case. % \begin{macrocode} -\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 -}% -\global\let\@@tenthstringFspanish\@@tenthstringFspanish +\providecommand*{\ABAlph}[1]{% + \expandafter\protect\expandafter\@ABAlph{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Teens (feminine) +%\end{macro} +%\begin{macro}{\hexadecimal} +% Hexadecimal: % \begin{macrocode} -\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 -}% -\global\let\@@teenthstringFspanish\@@teenthstringFspanish +\providecommand*{\hexadecimal}[1]{% + \expandafter\protect\expandafter\@hexadecimal{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Hundreds (feminine) +%\end{macro} +%\begin{macro}{\Hexadecimal} +% As above, but in upper case. % \begin{macrocode} -\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 -}% -\global\let\@@hundredthstringFspanish\@@hundredthstringFspanish +\providecommand*{\Hexadecimal}[1]{% + \expandafter\protect\expandafter\@Hexadecimal{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% As above, but with initial letters in upper case +%\end{macro} +%\begin{macro}{\octal} +% Octal: % \begin{macrocode} -\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 -}% -\global\let\@@Unitthstringspanish\@@Unitthstringspanish +\providecommand*{\octal}[1]{% + \expandafter\protect\expandafter\@octal{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Tens: +%\end{macro} +%\begin{macro}{\decimal} +% Decimal: % \begin{macrocode} -\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 -}% -\global\let\@@Tenthstringspanish\@@Tenthstringspanish +\providecommand*{\decimal}[1]{% + \expandafter\protect\expandafter\@decimal{% + \expandafter\the\csname c@#1\endcsname}% +} % \end{macrocode} -% Teens: +%\end{macro} +% +%\subsection{Multilinguage Definitions} +%\begin{macro}{\@setdef@ultfmtcount} +% If multilingual support is provided, make \cs{@numberstring} +% etc use the correct language (if defined). +% Otherwise use English definitions. \cs{@setdef@ultfmtcount} +% sets the macros to use English. % \begin{macrocode} -\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 -}% -\global\let\@@Teenthstringspanish\@@Teenthstringspanish +\def\@setdef@ultfmtcount{% + \ifcsundef{@ordinalMenglish}{\FCloadlang{english}}{}% + \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 + \let\fmtord\fc@orddef@ult +} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\fc@multiling} +%\changes{2.02}{2012-10-24}{new} +%\cs{fc@multiling}\marg{name}\marg{gender} +%\changes{3.00}{2014-07-18}{Use \cs{protect}, not \cs{string} in \cs{PackageWarning} to quote macros like +% shown in \texttt{clsguide.pdf}} +% \begin{macrocode} +\newcommand*{\fc@multiling}[2]{% + \ifcsundef{@#1#2\languagename}% + {% try loading it + \FCloadlang{\languagename}% + }% + {% + }% + \ifcsundef{@#1#2\languagename}% + {% + \PackageWarning{fmtcount}% + {No support for \expandafter\protect\csname #1\endcsname\space for + language '\languagename'}% + \ifthenelse{\equal{\languagename}{\fc@mainlang}}% + {% + \FCloadlang{english}% + }% + {% + }% + \ifcsdef{@#1#2\fc@mainlang}% + {% + \csuse{@#1#2\fc@mainlang}% + }% + {% + \PackageWarningNoLine{fmtcount}% + {No languages loaded at all! Loading english definitions}% + \FCloadlang{english}% + \def\fc@mainlang{english}% + \csuse{@#1#2english}% + }% + }% + {% + \csuse{@#1#2\languagename}% + }% +} % \end{macrocode} -% Hundreds +%\end{macro} +%\begin{macro}{\@set@mulitling@fmtcount} +% This defines the number and ordinal string macros to use +% \cs{languagename}: +%\changes{2.0}{2012-06-18}{changed errors to warnings for +%unsupported languages} % \begin{macrocode} -\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 -}% -\global\let\@@Hundredthstringspanish\@@Hundredthstringspanish +\def\@set@mulitling@fmtcount{% % \end{macrocode} -% As above, but feminine. +% The masculine version of \cs{numberstring}: % \begin{macrocode} -\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 -}% -\global\let\@@UnitthstringFspanish\@@UnitthstringFspanish + \def\@numberstringM{% + \fc@multiling{numberstring}{M}% + }% % \end{macrocode} -% Tens (feminine) +% The feminine version of \cs{numberstring}: % \begin{macrocode} -\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 -}% -\global\let\@@TenthstringFspanish\@@TenthstringFspanish + \def\@numberstringF{% + \fc@multiling{numberstring}{F}% + }% % \end{macrocode} -% Teens (feminine): +% The neuter version of \cs{numberstring}: % \begin{macrocode} -\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 -}% -\global\let\@@TeenthstringFspanish\@@TeenthstringFspanish + \def\@numberstringN{% + \fc@multiling{numberstring}{N}% + }% % \end{macrocode} -% Hundreds (feminine): +% The masculine version of \cs{Numberstring}: % \begin{macrocode} -\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 -}% -\global\let\@@HundredthstringFspanish\@@HundredthstringFspanish + \def\@NumberstringM{% + \fc@multiling{Numberstring}{M}% + }% % \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.) +% The feminine version of \cs{Numberstring}: % \begin{macrocode} -\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 + \def\@NumberstringF{% + \fc@multiling{Numberstring}{F}% + }% % \end{macrocode} -% \#1 is greater or equal to 10000 +% The neuter version of \cs{Numberstring}: % \begin{macrocode} - \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 - \@FCmodulo{\@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 - \@FCmodulo{\@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 \@FCmodulo{\@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 - \@FCmodulo{\@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 \@FCmodulo{\@strctr}{100}% -\ifnum#1>100\relax - \ifnum\@strctr>0\relax - \let\@@fc@numstr#2\relax + \def\@NumberstringN{% + \fc@multiling{Numberstring}{N}% + }% % \end{macrocode} -%\changes{2.0}{2012-06-18}{removed andname (correction -%provided by Fernando Maldonado)} +% The masculine version of \cs{ordinal}: % \begin{macrocode} - \edef#2{\@@fc@numstr\ }% - \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 \@FCmodulo{\@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 - \@FCmodulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@twentystring{\@strctr}}% - \else - \@FCmodulo{\@strctr}{10}% - \let\@@fc@numstr#2\relax - \edef#2{\@@fc@numstr\@teenstring{\@strctr}}% - \fi - \fi -\fi -}% -\global\let\@@numberstringspanish\@@numberstringspanish + \def\@ordinalM{% + \fc@multiling{ordinal}{M}% + }% % \end{macrocode} -% As above, but for ordinals +% The feminine version of \cs{ordinal}: % \begin{macrocode} -\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 - \@FCmodulo{\@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 - \@FCmodulo{\@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 -\@FCmodulo{\@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 -\@FCmodulo{\@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 - \@FCmodulo{\@tmpstrctr}{10}% - \ifnum\@tmpstrctr>0\relax - \let\@@fc@ordstr#2\relax - \edef#2{\@@fc@ordstr\ \@unitthstring{\@tmpstrctr}}% - \fi -\else - \ifnum\@strctr>9\relax - \@FCmodulo{\@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 -}% -\global\let\@@ordinalstringspanish\@@ordinalstringspanish + \def\@ordinalF{% + \fc@multiling{ordinal}{F}% + }% % \end{macrocode} - -%\iffalse +% The neuter version of \cs{ordinal}: % \begin{macrocode} -% + \def\@ordinalN{% + \fc@multiling{ordinal}{N}% + }% % \end{macrocode} -%\fi -%\iffalse +% The masculine version of \cs{ordinalstring}: % \begin{macrocode} -%<*fc-UKenglish.def> + \def\@ordinalstringM{% + \fc@multiling{ordinalstring}{M}% + }% % \end{macrocode} -%\fi -% \subsubsection{fc-UKenglish.def} -% English definitions +% The feminine version of \cs{ordinalstring}: % \begin{macrocode} -\ProvidesFCLanguage{UKenglish}[2013/08/17]% + \def\@ordinalstringF{% + \fc@multiling{ordinalstring}{F}% + }% % \end{macrocode} -% Loaded fc-english.def if not already loaded +% The neuter version of \cs{ordinalstring}: % \begin{macrocode} -\FCloadlang{english}% + \def\@ordinalstringN{% + \fc@multiling{ordinalstring}{N}% + }% % \end{macrocode} -% These are all just synonyms for the commands provided by -% fc-english.def. +% The masculine version of \cs{Ordinalstring}: % \begin{macrocode} -\global\let\@ordinalMUKenglish\@ordinalMenglish -\global\let\@ordinalFUKenglish\@ordinalMenglish -\global\let\@ordinalNUKenglish\@ordinalMenglish -\global\let\@numberstringMUKenglish\@numberstringMenglish -\global\let\@numberstringFUKenglish\@numberstringMenglish -\global\let\@numberstringNUKenglish\@numberstringMenglish -\global\let\@NumberstringMUKenglish\@NumberstringMenglish -\global\let\@NumberstringFUKenglish\@NumberstringMenglish -\global\let\@NumberstringNUKenglish\@NumberstringMenglish -\global\let\@ordinalstringMUKenglish\@ordinalstringMenglish -\global\let\@ordinalstringFUKenglish\@ordinalstringMenglish -\global\let\@ordinalstringNUKenglish\@ordinalstringMenglish -\global\let\@OrdinalstringMUKenglish\@OrdinalstringMenglish -\global\let\@OrdinalstringFUKenglish\@OrdinalstringMenglish -\global\let\@OrdinalstringNUKenglish\@OrdinalstringMenglish -% \end{macrocode} -%\iffalse + \def\@OrdinalstringM{% + \fc@multiling{Ordinalstring}{M}% + }% +% \end{macrocode} +% The feminine version of \cs{Ordinalstring}: % \begin{macrocode} -% + \def\@OrdinalstringF{% + \fc@multiling{Ordinalstring}{F}% + }% % \end{macrocode} -%\fi -%\iffalse +% The neuter version of \cs{Ordinalstring}: % \begin{macrocode} -%<*fc-USenglish.def> + \def\@OrdinalstringN{% + \fc@multiling{Ordinalstring}{N}% + }% % \end{macrocode} -%\fi -% \subsubsection{fc-USenglish.def} -% US English definitions +% Make \cs{fmtord} language dependent: +% \changes{3.01}{2014-12-18}{Make \cs{fmtord} language dependent.} % \begin{macrocode} -\ProvidesFCLanguage{USenglish}[2013/08/17]% + \let\fmtord\fc@ord@multiling +} % \end{macrocode} -% Loaded fc-english.def if not already loaded +%\end{macro} +% Check to see if \styfmt{babel}, \styfmt{polyglossia} or \styfmt{ngerman} packages have been loaded, and if +% yes set \styfmt{fmtcount} in multiling. % \begin{macrocode} -\FCloadlang{english}% +\expandafter\@ifpackageloaded +\expandafter{\ifxetex polyglossia\else babel\fi}% +{% + \@set@mulitling@fmtcount +}% +{% + \@ifpackageloaded{ngerman}% + {% + \FCloadlang{ngerman}% + \@set@mulitling@fmtcount + }% + {% % \end{macrocode} -% These are all just synonyms for the commands provided by -% fc-english.def. (This needs fixing as there are some differences -% between UK and US number strings.) +% In the case that neither babel/polyglossia, nor ngerman has been loaded, then we go to multiling if a +% language has been loaded by package option, and to delfault language otherwise. % \begin{macrocode} -\global\let\@ordinalMUSenglish\@ordinalMenglish -\global\let\@ordinalFUSenglish\@ordinalMenglish -\global\let\@ordinalNUSenglish\@ordinalMenglish -\global\let\@numberstringMUSenglish\@numberstringMenglish -\global\let\@numberstringFUSenglish\@numberstringMenglish -\global\let\@numberstringNUSenglish\@numberstringMenglish -\global\let\@NumberstringMUSenglish\@NumberstringMenglish -\global\let\@NumberstringFUSenglish\@NumberstringMenglish -\global\let\@NumberstringNUSenglish\@NumberstringMenglish -\global\let\@ordinalstringMUSenglish\@ordinalstringMenglish -\global\let\@ordinalstringFUSenglish\@ordinalstringMenglish -\global\let\@ordinalstringNUSenglish\@ordinalstringMenglish -\global\let\@OrdinalstringMUSenglish\@OrdinalstringMenglish -\global\let\@OrdinalstringFUSenglish\@OrdinalstringMenglish -\global\let\@OrdinalstringNUSenglish\@OrdinalstringMenglish + \iffmtcount@language@option + \@set@mulitling@fmtcount +% \end{macrocode} +% Some sanity check at the beginning of document may help the end user understand what is wrong: +% \begin{macrocode} + \AtBeginDocument{% + \ifcsundef{languagename}% + {% + \PackageWarning{fmtcount}{% + `\protect\languagename' is undefined, you should use package babel/polyglossia when loading a + language via package option. Reverting to default language. + }% + \@setdef@ultfmtcount + }{% + \@FC@iflangloaded{\languagename}{}{% +% \end{macrocode} +% The current \cs{languagename} is not a language that has been previously loaded. The correction is to have +% \cs{languagename} let to \cs{fc@mainlang}. Please note that, as \cs{iffmtcount@language@option} is true, +% we know that \texttt{fmtcount} has loaded some language. +% \begin{macrocode} + \PackageWarning{fmtcount}{% + Setting `\protect\languagename' to `\fc@mainlang'.\MessageBreak + Reason is that `\protect\languagename' was `\languagename',\MessageBreak + but `\languagename' was not loaded by fmtcount,\MessageBreak + whereas `\fc@mainlang' was the last language loaded by fmtcount ; + }% + \let\languagename\fc@mainlang + } + }% + } + \else + \@setdef@ultfmtcount + \fi + }% +} % \end{macrocode} +% \changes{3.01}{2014-12-21}{Substitute \cs{textsuperscript} for \cs{fc@textsuperscript}, and define +% \cs{fc@textsuperscript} as \cs{fup} when defined at beginning of document, or as \cs{textsuperscript} +% otherwise} +% \begin{macrocode} +\AtBeginDocument{% + \ifcsundef{FBsupR}{\let\fc@textsuperscript\textsuperscript}{\let\fc@textsuperscript\fup}% +} +% \end{macrocode} +% Backwards compatibility: +% \begin{macrocode} +\let\@ordinal=\@ordinalM +\let\@ordinalstring=\@ordinalstringM +\let\@Ordinalstring=\@OrdinalstringM +\let\@numberstring=\@numberstringM +\let\@Numberstring=\@NumberstringM +% \end{macrocode} +\iffalse Local variables: \fi +\iffalse mode: docTeX \fi +\iffalse End: \fi %\iffalse % \begin{macrocode} -% +% % \end{macrocode} %\fi %\Finale diff --git a/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins b/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins index 40258ccff79..5a40522adae 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 2014/7/28 7:55 +% fmtcount.ins generated using makedtx version 0.94b 2015/5/8 16:50 \input docstrip \preamble fmtcount.dtx - Copyright 2014 Nicola Talbot and Vincent Belaïche + Copyright 2015 Nicola Talbot and Vincent Belaïche This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 @@ -18,19 +18,13 @@ The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. - This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. + This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. \endpreamble \askforoverwritefalse -\generate{\file{fcnumparser.sty}{\usepreamble\defaultpreamble -\usepostamble\defaultpostamble\from{fmtcount.dtx}{fcnumparser.sty,package}} -\file{fcprefix.sty}{\usepreamble\defaultpreamble -\usepostamble\defaultpostamble\from{fmtcount.dtx}{fcprefix.sty,package}} -\file{fmtcount.sty}{\usepreamble\defaultpreamble -\usepostamble\defaultpostamble\from{fmtcount.dtx}{fmtcount.sty,package}} -\file{fc-american.def}{\usepreamble\defaultpreamble +\generate{\file{fc-american.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-american.def,package}} \file{fc-british.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{fmtcount.dtx}{fc-british.def,package}} @@ -62,6 +56,12 @@ \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{fcnumparser.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{fmtcount.dtx}{fcnumparser.sty,package}} +\file{fcprefix.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{fmtcount.dtx}{fcprefix.sty,package}} +\file{fmtcount.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{fmtcount.dtx}{fmtcount.sty,package}} } \endbatchfile diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-UKenglish.def b/Master/texmf-dist/tex/latex/fmtcount/fc-UKenglish.def index b514c4a21c5..9a7ccc3c5d9 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-UKenglish.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-UKenglish.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-UKenglish.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{UKenglish}[2013/08/17]% \FCloadlang{english}% \global\let\@ordinalMUKenglish\@ordinalMenglish diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-USenglish.def b/Master/texmf-dist/tex/latex/fmtcount/fc-USenglish.def index 19c7bd4efcc..711a25082ba 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-USenglish.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-USenglish.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-USenglish.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{USenglish}[2013/08/17]% \FCloadlang{english}% \global\let\@ordinalMUSenglish\@ordinalMenglish diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-american.def b/Master/texmf-dist/tex/latex/fmtcount/fc-american.def index da645326fd2..d143d70ca68 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-american.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-american.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-american.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{american}[2013/08/17]% \FCloadlang{USenglish}% \global\let\@ordinalMamerican\@ordinalMUSenglish diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-british.def b/Master/texmf-dist/tex/latex/fmtcount/fc-british.def index ab6e3fae49a..787ce1dea3a 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-british.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-british.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-british.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{british}[2013/08/17]% \FCloadlang{english}% \global\let\@ordinalMbritish\@ordinalMenglish diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-english.def b/Master/texmf-dist/tex/latex/fmtcount/fc-english.def index 0b5f820ff30..1b4d41824b4 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-english.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-english.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-english.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{english}[2013/08/17]% \newcommand*\@ordinalMenglish[2]{% \def\@fc@ord{}% diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-francais.def b/Master/texmf-dist/tex/latex/fmtcount/fc-francais.def index 356a5064561..607da3c3229 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-francais.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-francais.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-francais.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{francais}[2013/08/17]% \FCloadlang{french}% \global\let\@ordinalMfrancais=\@ordinalMfrench diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-french.def b/Master/texmf-dist/tex/latex/fmtcount/fc-french.def index 43180885d80..af6c49a242f 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-french.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-french.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-french.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{french}[2012/10/24]% \def\fc@french@set@plural#1#2#3#4#5#6{% \ifthenelse{\equal{#2}{reformed}}{% @@ -165,6 +168,7 @@ \def\fmtcount@french{#1}}% }% \@tempa{france}\@tempa{swiss}\@tempa{belgian}% +\def\fmtcount@french{france}% \define@key{fcfrench}{dialect}[france]{% \ifthenelse{\equal{#1}{france} \or\equal{#1}{swiss} @@ -189,22 +193,34 @@ \newcommand*{\@ordinalMfrench}[2]{% \iffmtord@abbrv - \edef#2{\number#1\relax\noexpand\fmtord{e}}% + \ifnum#1=1 % + \edef#2{\number#1\relax\noexpand\fmtord{er}}% + \else + \edef#2{\number#1\relax\noexpand\fmtord{e}}% + \fi \else - \ifnum#1=1\relax + \PackageWarning{fmtcount}{Non abbreviated ordinal finals (`eme) are + considered incorrect in French.}% + \ifnum#1=1 % \edef#2{\number#1\relax\noexpand\fmtord{er}}% \else - \edef#2{\number#1\relax\noexpand\fmtord{eme}}% + \protected@edef#2{\number#1\relax\noexpand\fmtord{\protect\`eme}}% \fi \fi} \newcommand*{\@ordinalFfrench}[2]{% \iffmtord@abbrv - \edef#2{\number#1\relax\noexpand\fmtord{e}}% + \ifnum#1=1 % + \edef#2{\number#1\relax\noexpand\fmtord{re}}% + \else + \edef#2{\number#1\relax\noexpand\fmtord{e}}% + \fi \else + \PackageWarning{fmtcount}{Non abbreviated ordinal finals (`eme) are + considered incorrect in French.}% \ifnum#1=1 % - \edef#2{\number#1\relax\noexpand\fmtord{i\`ere}}% + \protected@edef#2{\number#1\relax\noexpand\fmtord{\protect\`ere}}% \else - \edef#2{\number#1\relax\noexpand\fmtord{i\`eme}}% + \protected@edef#2{\number#1\relax\noexpand\fmtord{\protect\`eme}}% \fi \fi} \let\@ordinalNfrench\@ordinalMfrench @@ -463,7 +479,7 @@ z\'ero% \@@ordinalstringfrench{#1}{#2}% } \newcommand*\fc@@firstfrench{premier} -\newcommand*\fc@@firstFfrench{premi\`ere} +\newcommand*\fc@@firstFfrench{premi\protect\`ere} \DeclareRobustCommand{\@ordinalstringMfrenchfrance}[2]{% \let\fc@case\fc@CaseIden \let\fc@first=\fc@@firstfrench @@ -1080,7 +1096,7 @@ z\'ero% \count0=0 % \fi \ifnum\count0=1 % - \edef\@tempa{\expandafter\fc@case\fc@first\@nil}% + \protected@edef\@tempa{\expandafter\fc@case\fc@first\@nil}% \else \def\@tempa##1{% \expandafter\edef\csname fc@frenchoptions@##1@plural\endcsname{% @@ -1116,17 +1132,17 @@ z\'ero% \expandafter\fc@get@last@letter\expandafter{\@tempc}\@tempd\@tempe \def\@tempf{e}% \ifx\@tempe\@tempf - \edef\@tempa{\@tempb\expandafter\fc@case\@tempd i\`eme\@nil}% + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempd i\protect\`eme\@nil}% \else \def\@tempf{q}% \ifx\@tempe\@tempf - \edef\@tempa{\@tempb\expandafter\fc@case\@tempd qui\`eme\@nil}% + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempd qui\protect\`eme\@nil}% \else \def\@tempf{f}% \ifx\@tempe\@tempf - \edef\@tempa{\@tempb\expandafter\fc@case\@tempd vi\`eme\@nil}% + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempd vi\protect\`eme\@nil}% \else - \edef\@tempa{\@tempb\expandafter\fc@case\@tempc i\`eme\@nil}% + \protected@edef\@tempa{\@tempb\expandafter\fc@case\@tempc i\protect\`eme\@nil}% \fi \fi \fi @@ -1147,6 +1163,14 @@ z\'ero% \def\fc@frenchoptions@mil@plural@mark{le}% } \fc@frenchoptions@setdefaults +\def\@ordinalstringMfrench{\csuse{@ordinalstringMfrench\fmtcount@french}}% +\def\@ordinalstringFfrench{\csuse{@ordinalstringFfrench\fmtcount@french}}% +\def\@OrdinalstringMfrench{\csuse{@OrdinalstringMfrench\fmtcount@french}}% +\def\@OrdinalstringFfrench{\csuse{@OrdinalstringFfrench\fmtcount@french}}% +\def\@numberstringMfrench{\csuse{@numberstringMfrench\fmtcount@french}}% +\def\@numberstringFfrench{\csuse{@numberstringFfrench\fmtcount@french}}% +\def\@NumberstringMfrench{\csuse{@NumberstringMfrench\fmtcount@french}}% +\def\@NumberstringFfrench{\csuse{@NumberstringFfrench\fmtcount@french}}% \iffalse Local variables: \fi \iffalse mode: docTeX \fi \iffalse End: \fi diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-frenchb.def b/Master/texmf-dist/tex/latex/fmtcount/fc-frenchb.def index 65ee11c0e15..026b4e50437 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-frenchb.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-frenchb.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-frenchb.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{frenchb}[2013/08/17]% \FCloadlang{french}% \global\let\@ordinalMfrenchb=\@ordinalMfrench diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-german.def b/Master/texmf-dist/tex/latex/fmtcount/fc-german.def index 6f951e27153..3f0d859f0fc 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-german.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-german.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-german.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{german}[2014/06/09]% \newcommand{\@ordinalMgerman}[2]{% \edef#2{\number#1\relax.}% diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-germanb.def b/Master/texmf-dist/tex/latex/fmtcount/fc-germanb.def index 7dd3ce7e4b4..3b3bdc4460c 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-germanb.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-germanb.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-germanb.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{germanb}[2013/08/17]% \FCloadlang{german}% \global\let\@ordinalMgermanb=\@ordinalMgerman diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-italian.def b/Master/texmf-dist/tex/latex/fmtcount/fc-italian.def index f9b728231d8..22a43458001 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-italian.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-italian.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-italian.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{italian}[2013/08/17] \RequirePackage{itnumpar} diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-ngerman.def b/Master/texmf-dist/tex/latex/fmtcount/fc-ngerman.def index a0e81dd3541..c9d38dd6604 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-ngerman.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-ngerman.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-ngerman.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{ngerman}[2012/06/18]% \FCloadlang{german}% \FCloadlang{ngermanb}% diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-ngermanb.def b/Master/texmf-dist/tex/latex/fmtcount/fc-ngermanb.def index c3bfe07f7f2..1be2a82515d 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-ngermanb.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-ngermanb.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-ngermanb.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{ngermanb}[2013/08/17]% \FCloadlang{german}% \global\let\@ordinalMngermanb=\@ordinalMgerman diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-portuges.def b/Master/texmf-dist/tex/latex/fmtcount/fc-portuges.def index 52262fa5745..0a4f696ef75 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-portuges.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-portuges.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-portuges.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{portuges}[2014/06/09]% \newcommand*\@ordinalMportuges[2]{% \ifnum#1=0\relax diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-portuguese.def b/Master/texmf-dist/tex/latex/fmtcount/fc-portuguese.def index 60bdc54d659..18bb7e9f948 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-portuguese.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-portuguese.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-portuguese.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{portuguese}[2014/06/09]% \FCloadlang{portuges}% \global\let\@ordinalMportuguese=\@ordinalMportuges diff --git a/Master/texmf-dist/tex/latex/fmtcount/fc-spanish.def b/Master/texmf-dist/tex/latex/fmtcount/fc-spanish.def index 1d59ac7ae85..3a8c9eb2b37 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fc-spanish.def +++ b/Master/texmf-dist/tex/latex/fmtcount/fc-spanish.def @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fc-spanish.def,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \ProvidesFCLanguage{spanish}[2013/08/17]% \newcommand*\@ordinalMspanish[2]{% \edef#2{\number#1\relax\noexpand\fmtord{o}}% diff --git a/Master/texmf-dist/tex/latex/fmtcount/fcnumparser.sty b/Master/texmf-dist/tex/latex/fmtcount/fcnumparser.sty index e55bea04492..b65bfd53cf0 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fcnumparser.sty +++ b/Master/texmf-dist/tex/latex/fmtcount/fcnumparser.sty @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fcnumparser.sty,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fcnumparser}[2012/09/28] \def\fc@counter@parser#1{% diff --git a/Master/texmf-dist/tex/latex/fmtcount/fcprefix.sty b/Master/texmf-dist/tex/latex/fmtcount/fcprefix.sty index 44b7832fbcb..e82d9a8b367 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fcprefix.sty +++ b/Master/texmf-dist/tex/latex/fmtcount/fcprefix.sty @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fcprefix.sty,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,6 +48,9 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fcprefix}[2012/09/28] \RequirePackage{ifthen} diff --git a/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty b/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty index df80c35e55e..6d55bef08fc 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty +++ b/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty @@ -7,7 +7,7 @@ %% fmtcount.dtx (with options: `fmtcount.sty,package') %% %% fmtcount.dtx -%% Copyright 2014 Nicola Talbot and Vincent Belaïche +%% Copyright 2015 Nicola Talbot and Vincent Belaïche %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -21,7 +21,7 @@ %% %% The Current Maintainer of this work is Nicola Talbot and Vincent Belaïche. %% -%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fcnumparser.sty, fcprefix.sty, fmtcount.sty, fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def. +%% This work consists of the files fmtcount.dtx and fmtcount.ins and the derived files fc-american.def, fc-british.def, fc-english.def, fc-francais.def, fc-french.def, fc-frenchb.def, fc-german.def, fc-germanb.def, fc-italian.def, fc-ngerman.def, fc-ngermanb.def, fc-portuges.def, fc-portuguese.def, fc-spanish.def, fc-UKenglish.def, fc-USenglish.def, fcnumparser.sty, fcprefix.sty, fmtcount.sty. %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -48,15 +48,25 @@ %%\begin{definition}[\DescribeMacro{\latinnumeralstringnum}] %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} +%% Local Variables: +%% coding: utf-8 +%% End: \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fmtcount}[2014/07/18 v3.00] +\ProvidesPackage{fmtcount}[2015/05/05 v3.01] \RequirePackage{ifthen} -\RequirePackage{keyval} +\RequirePackage{xkeyval} \RequirePackage{etoolbox} \RequirePackage{fcprefix} \RequirePackage{ifxetex} \RequirePackage{amsgen} -\providecommand*{\fmtord}[1]{\textsuperscript{#1}} +\providecommand*{\fc@orddef@ult}[1]{\fc@textsuperscript{#1}} +\providecommand*{\fc@ord@multiling}[1]{% + \ifcsundef{fc@\languagename @alias@of}{% + \fc@orddef@ult{#1}}{% + \expandafter\let\expandafter\@tempa\csname fc@\languagename @alias@of\endcsname + \ifcsundef{fc@ord@\@tempa}{% + \fc@orddef@ult{#1}}{% +\csname fc@ord@\@tempa\endcsname{#1}}}} \newcount\c@padzeroesN \c@padzeroesN=1\relax \providecommand*{\padzeroes}[1][17]{\c@padzeroesN=#1} @@ -139,34 +149,72 @@ italian} \fi } \fc@iterate@on@languages\@fc@loadifbabelorpolyglossialdf -\def\fmtcount@french{france} -\define@key{fmtcount}{french}[france]{% - \@FC@iflangloaded{french}% - {% - \setkeys{fcfrench}{#1}% +\def\fc@iterate@on@languages@body#1{% + \expandafter\def\csname fc@#1@alias@of\endcsname{#1}} +\expandafter\@fc@iterate@on@languages\fc@supported@language@list,\@nil,% +\def\@tempa#1#2{% + \expandafter\def\csname fc@#1@alias@of\endcsname{#2}% +}% +\@tempa{frenchb}{french} +\@tempa{francais}{french} +\@tempa{germanb}{german} +\@tempa{ngermanb}{german} +\@tempa{ngerman}{german} +\@tempa{british}{english} +\@tempa{american}{USenglish} +\def\fc@iterate@on@languages@body#1{% + \define@key{fmtcount}{#1}[]{% + \@FC@iflangloaded{#1}% + {% + \setkeys{fc\csname fc@#1@alias@of\endcsname}{##1}% + }{% + \PackageError{fmtcount}% + {Language `#1' not defined}% + {You need to load \ifxetex polyglossia\else babel\fi\space before loading fmtcount}% + }% }% - {% - \PackageError{fmtcount}% - {Language `french' not defined}% - {You need to load babel before loading fmtcount}% + \ifthenelse{\equal{\csname fc@#1@alias@of\endcsname}{#1}}{% + \define@key{fc\csname fc@#1@alias@of\endcsname}{fmtord}{% + \ifthenelse{\equal{##1}{raise}\or\equal{##1}{level}}{% + \expandafter\let\expandafter\@tempa\csname fc@set@ord@as@##1\endcsname + \expandafter\@tempa\csname fc@ord@#1\endcsname + }{% + \ifthenelse{\equal{##1}{undefine}}{% + \expandafter\let\csname fc@ord@#1\endcsname\undefined + }{% + \PackageError{fmtcount}% + {Invalid value `##1' to fmtord key}% + {Option `fmtord' can only take the values `level', `raise' + or `undefine'}% + }} + }% + }{% + \expandafter\let\expandafter\@tempa\csname KV@\csname fc@#1@alias@of\endcsname @fmtord\endcsname + \expandafter\let\csname KV@#1@fmtord\endcsname\@tempa }% } +\expandafter\@fc@iterate@on@languages\fc@supported@language@list,\@nil,% +\def\fc@set@ord@as@level#1{% + \def#1##1{##1}% +} +\def\fc@set@ord@as@raise#1{% + \let#1\fc@textsuperscript +} \define@key{fmtcount}{fmtord}{% \ifthenelse{\equal{#1}{level} - \or\equal{#1}{raise} - \or\equal{#1}{user}}% + \or\equal{#1}{raise}}% {% + \csname fc@set@ord@as@#1\endcsname\fc@orddef@ult \def\fmtcount@fmtord{#1}% }% {% \PackageError{fmtcount}% {Invalid value `#1' to fmtord key}% - {Option `fmtord' can only take the values `level', `raise' - or `user'}% + {Option `fmtord' can only take the values `level' or `raise'}% }% } \newif\iffmtord@abbrv -\fmtord@abbrvfalse +\fmtord@abbrvtrue \define@key{fmtcount}{abbrv}[true]{% \ifthenelse{\equal{#1}{true}\or\equal{#1}{false}}% {% @@ -175,7 +223,7 @@ italian} {% \PackageError{fmtcount}% {Invalid value `#1' to fmtord key}% - {Option `fmtord' can only take the values `true' or + {Option `abbrv' can only take the values `true' or `false'}% }% } @@ -183,59 +231,38 @@ italian} \RequirePackage{fmtprefix}% \fmtprefixsetoption{#1}% } -\newcommand*{\fmtcountsetoptions}[1]{% +\def\fmtcountsetoptions{% \def\fmtcount@fmtord{}% - \setkeys{fmtcount}{#1}% - \@FC@iflangloaded{french}{\ifcsundef{@ordinalstringMfrench}% - {% - \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}}% - }% - {% - }% - } -} + \setkeys{fmtcount}}% \InputIfFileExists{fmtcount.cfg}% {% \PackageInfo{fmtcount}{Using configuration file fmtcount.cfg}% }% {% } +\newcommand*{\fmtcount@loaded@by@option@lang@list}{} \newcommand*\@fc@declare@language@option[1]{% \DeclareOption{#1}{% - \@FC@iflangloaded{#1}{}{% - \fmtcount@language@optiontrue - \FCloadlang{#1}% - }}}% + \ifx\fmtcount@loaded@by@option@lang@list\@empty + \def\fmtcount@loaded@by@option@lang@list{#1}% + \else + \edef\fmtcount@loaded@by@option@lang@list{\fmtcount@loaded@by@option@lang@list,#1}% + \fi + }}% \fc@iterate@on@languages\@fc@declare@language@option \DeclareOption{level}{\def\fmtcount@fmtord{level}% - \def\fmtord#1{#1}} + \def\fc@orddef@ult#1{#1}} \DeclareOption{raise}{\def\fmtcount@fmtord{raise}% - \def\fmtord#1{\textsuperscript{#1}}} + \def\fc@orddef@ult#1{\fc@textsuperscript{#1}}} \ProcessOptions\relax +\ifx\fmtcount@loaded@by@option@lang@list\@empty\else +\def\fc@iterate@on@languages@body#1{% + \@FC@iflangloaded{#1}{}{% + \fmtcount@language@optiontrue + \FCloadlang{#1}% + }} +\expandafter\@fc@iterate@on@languages\fmtcount@loaded@by@option@lang@list,\@nil,% +\fi \newcount\@DT@modctr \newcommand*{\@FCmodulo}[2]{% \@DT@modctr=#1\relax @@ -712,7 +739,7 @@ italian} \protect\@ordinalstringM{#2}{\@fc@ordstr}% }% }% - \expandafter\edef\csname @fcs@#1\endcsname{% + \expandafter\protected@edef\csname @fcs@#1\endcsname{% \noexpand\MakeUppercase{\@fc@ordstr}% }% } @@ -1004,6 +1031,7 @@ italian} \def\@ordinalM{\@ordinalMenglish}% \let\@ordinalF=\@ordinalM \let\@ordinalN=\@ordinalM + \let\fmtord\fc@orddef@ult } \newcommand*{\fc@multiling}[2]{% \ifcsundef{@#1#2\languagename}% @@ -1085,6 +1113,7 @@ italian} \def\@OrdinalstringN{% \fc@multiling{Ordinalstring}{N}% }% + \let\fmtord\fc@ord@multiling } \expandafter\@ifpackageloaded \expandafter{\ifxetex polyglossia\else babel\fi}% @@ -1125,6 +1154,9 @@ italian} \fi }% } +\AtBeginDocument{% + \ifcsundef{FBsupR}{\let\fc@textsuperscript\textsuperscript}{\let\fc@textsuperscript\fup}% +} \let\@ordinal=\@ordinalM \let\@ordinalstring=\@ordinalstringM \let\@Ordinalstring=\@OrdinalstringM -- cgit v1.2.3