From f084f6c5ea5c0e70e3db167a3696fe45e5babaef Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 30 Jul 2014 01:59:27 +0000 Subject: fmtcount (29Jul) git-svn-id: svn://tug.org/texlive/trunk@34771 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/fmtcount/CHANGES | 3 +- Master/texmf-dist/doc/latex/fmtcount/README | 4 +- Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex | 1 + Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf | Bin 547614 -> 525553 bytes .../texmf-dist/source/latex/fmtcount/fmtcount.dtx | 324 ++++++++++++++++----- .../texmf-dist/source/latex/fmtcount/fmtcount.ins | 2 +- Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty | 124 ++++++-- 7 files changed, 347 insertions(+), 111 deletions(-) diff --git a/Master/texmf-dist/doc/latex/fmtcount/CHANGES b/Master/texmf-dist/doc/latex/fmtcount/CHANGES index 4b2bab78530..e63267c0b2a 100644 --- a/Master/texmf-dist/doc/latex/fmtcount/CHANGES +++ b/Master/texmf-dist/doc/latex/fmtcount/CHANGES @@ -3,8 +3,7 @@ fmtcount package versions: Version 2.04: * Renamed \@modulo to \@FCmodulo to avoid conflict with other - packages. (If you use datetime.sty, ensure you have at least - datetime version 2.59 installed.) + packages. * Fixed "eins" bug in fc-german.def diff --git a/Master/texmf-dist/doc/latex/fmtcount/README b/Master/texmf-dist/doc/latex/fmtcount/README index 717d61d148e..081c38f578e 100644 --- a/Master/texmf-dist/doc/latex/fmtcount/README +++ b/Master/texmf-dist/doc/latex/fmtcount/README @@ -1,6 +1,6 @@ -LaTeX Package : fmtcount v2.04 +LaTeX Package : fmtcount v3.00 -Last Modified : 2014-06-18 +Last Modified : 2014-07-18 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 443b60e2c94..cbc8141779f 100644 --- a/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex +++ b/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex @@ -2,6 +2,7 @@ \documentclass[a4paper]{article} \usepackage{fmtcount} +% FCloadlang \newcounter{N} \padzeroes[5] diff --git a/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf b/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf index 860fabd43e4..c916e486947 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 10e9dac5fa3..77ebb29e78c 100644 --- a/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx +++ b/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx @@ -1,12 +1,12 @@ %\iffalse -% fmtcount.dtx generated using makedtx version 1.1 (c) Nicola Talbot +% fmtcount.dtx generated using makedtx version 0.94b (c) Nicola Talbot % Command line args: % -src "(.+)\.(sty)=>\1.\2" % -src "(.+)\.(def)=>\1.\2" % -doc "fmtcount-manual.tex" % -author "Nicola Talbot and Vincent Belaïche" % fmtcount -% Created on 2014/6/18 14:52 +% Created on 2014/7/28 7:55 %\fi %\iffalse %<*package> @@ -42,9 +42,36 @@ \usepackage{tabularx,supertabular,multirow} \usepackage[T1]{fontenc} \usepackage{cmap} +\usepackage{fmtcount}% needed \newcommand*\uref[1]{\href{#1}{#1}} \DeclareMathOperator{\intv}{..} \newcommand*\interface{} +\makeatletter +\newcommand*{\LanguagePackageOptionList}{{% + \def\@tempf##1{\texttt{##1}}% how to format each option + % we don't use \cs{newtoks} because anyway this is within a group + \toks0{}% + \def\@tempd{\toks0}% token in which we accumulate result + \def\@tempc{\toks1}% token in which we place next dialect + \count0 0 % to distinguish first and second iteration, we need to do tricks because we want to insert `and' + % before the last item in the list. + \def\@tempb##1{% + \ifnum\count0=0 % + \else\ifnum\count0=1 % + \expandafter\@tempd\expandafter{\the\toks1}% + \else + \edef\@tempa{\the\toks0, \the\toks1}% + \expandafter\@tempd\expandafter{\@tempa}% + \fi\fi + \expandafter\@tempc\expandafter{\@tempf{##1}}% + \advance\count0 by 1 % + }% + \fc@iterate@on@languages\@tempb + \edef\@tempa{\the\toks0, and \the\toks1}% + \expandafter +}\@tempa} +\makeatother + \usepackage[colorlinks, bookmarks, bookmarksopen, @@ -52,7 +79,7 @@ pdftitle={fmtcount.sty: Displaying the Values of LaTeX Counters}, pdfkeywords={LaTeX,counter}]{hyperref} -\CheckSum{9726} +\CheckSum{9801} \doxitem{Option}{option}{options} @@ -71,7 +98,7 @@ % \url{www.dickimaw-books.com} % \and % Vincent Bela\"iche} -% \date{2014-06-18 (version 2.04)\relax +% \date{2014-07-18 (version 3.00)\relax %} % \maketitle % \tableofcontents @@ -426,16 +453,19 @@ %produce: DU. % %\section{Package Options} +%\label{sec:package-options} % %The following options can be passed to this package: % -%\begin{tabular}{ll} -% \pkgopt{raise} & make ordinal st,nd,rd,th appear as superscript\\ -% \pkgopt{level} & make ordinal st,nd,rd,th appear level with rest of -%text -%\end{tabular} +%\begin{description} +%\item[\meta{dialect}] load language \meta{dialect}, supported \meta{dialect} are the same as passed to +% \cs{FCloadlang}, see~\ref{sec:multilingual-support} +%\item[\pkgopt{raise}] make ordinal st,nd,rd,th appear as superscript +%\item[\pkgopt{level}] make ordinal st,nd,rd,th appear level with rest of text +%\end{description} +% % -%\noindent These can also be set using the command: +%\noindent Options \pkgopt{raise} and \pkgopt{level} can also be set using the command: % %\begin{definition}[\DescribeMacro{\fmtcountsetoptions}] %\cs{fmtcountsetoptions}\verb"{fmtord="\meta{type}\verb'}' @@ -444,6 +474,7 @@ %\texttt{raise}. % %\section{Multilingual Support} +%\label{sec:multilingual-support} % %Version 1.02 of the \sty{fmtcount} package now has %limited multilingual support. The following languages are @@ -459,8 +490,9 @@ %\begin{definition}[\DescribeMacro{\FCloadlang}] %\cs{FCloadlang}\marg{dialect} %\end{definition} -%in the preamble. The \meta{dialect} should match the options passed -%to \sty{babel} or \sty{polyglossia}. If you don't use this, +%in the preamble. The \meta{dialect} should match the options passed to \sty{babel} or +%\sty{polyglossia}. \sty{fmtcount} currently supports the following \meta{dialect}: +%\LanguagePackageOptionList. If you don't use this, %\sty{fmtcount} will attempt to detect the required dialects, but %this isn't guaranteed to work. % @@ -529,7 +561,7 @@ %L'effet de l'option \texttt{dialect} est illustré ainsi:\newline %\begin{tabularx}{\linewidth}{@{}lX@{}} % \pkgopt{france}& soixante-dix pour 70, quatre-vingts pour 80, et -% quate-vingts-dix pour 90,\\ +% quatre-vingts-dix pour 90,\\ % \pkgopt{belgian} & septante pour 70, quatre-vingts pour 80, et % nonante pour 90, \\ % \pkgopt{swiss} &septante pour 70, huitante\footnote{voir @@ -846,7 +878,7 @@ \def\fc@end@{\fc@end} % \end{macrocode} -% \DescribeMacro\fc@number@analysis First of all we need to separate the number between integer and fractional +% \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} @@ -886,7 +918,7 @@ \fi } % \end{macrocode} -% \DescribeMacro\fc@number@parser Macro \cs{fc@number@parser} is the main engine to parse a number. Argument +% \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$}. @@ -1006,7 +1038,7 @@ \edef\fc@min@weight{\the\fc@digit@counter}% } % \end{macrocode} -% \DescribeMacro\fc@parse@integer@digits Macro \cs{fc@parse@integer@digits} is used to +% \DescribeMacro{\fc@parse@integer@digits} Macro \cs{fc@parse@integer@digits} is used to % \begin{macrocode} \ifcsundef{fc@parse@integer@digits}{}{% \PackageError{fcnumparser}{Duplicate definition}{Redefinition of @@ -1028,7 +1060,7 @@ % \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 +% 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}{}{% @@ -1061,7 +1093,7 @@ \fi } % \end{macrocode} -% \DescribeMacro\fc@read@hundred Macro \cs{fc@read@hundred} is used to read a pair of digits and form an +% \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} \ifcsundef{fc@read@hundred}{}{% @@ -1084,7 +1116,7 @@ }\@tempb } % \end{macrocode} -% \DescribeMacro\fc@read@thousand Macro \cs{fc@read@thousand} is used to read a trio of digits and form an +% \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{fc@read@thousand}{}{% @@ -1109,7 +1141,7 @@ } % \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 +% \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} \ifcsundef{fc@read@myriad}{}{% @@ -1133,7 +1165,7 @@ }\@tempb } % \end{macrocode} -% \DescribeMacro\fc@check@nonzeros Macro \cs{fc@check@nonzeros} is used to check whether the number +% \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} @@ -1173,7 +1205,7 @@ }\@tempa } % \end{macrocode} -% \DescribeMacro\fc@@check@nonzeros@inner Macro \cs{fc@@check@nonzeros@inner} Check wehther some part of the +% \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 @@ -1246,7 +1278,7 @@ \next } % \end{macrocode} -% \DescribeMacro\fc@intpart@find@last Macro \cs{fc@intpart@find@last} find the rightmost non zero digit in the +% \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}{}{% @@ -1294,7 +1326,7 @@ }\@tempa\space } % \end{macrocode} -% \DescribeMacro\fc@get@last@word Getting last word. Arguments as follows:\newline\noindent +% \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\\ @@ -1364,7 +1396,7 @@ }\@tempa } % \end{macrocode} -% \DescribeMacro\fc@get@last@word Getting last letter. Arguments as follows:\newline\noindent +% \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\\ @@ -1594,7 +1626,7 @@ \let\fc@power@of@millia@init\@gobbletwo \let\fc@power@of@millia\fc@@prefix@millia % \end{macrocode} -% \DescribeMacro\fc@@latin@cardinal@pefix Compute a cardinal prefix for n-illion, like \(1 \Rightarrow +% \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. @@ -1769,7 +1801,7 @@ }\@tempa } % \end{macrocode} -% \DescribeMacro\fc@@latin@numeral@pefix Compute a numeral prefix +% \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. @@ -1969,7 +2001,7 @@ % \end{macrocode} % User API. % -% \DescribeMacro\@latinnumeralstringnum Macro \cs{@latinnumeralstringnum}. Arguments as +% \DescribeMacro{\@latinnumeralstringnum} Macro \cs{@latinnumeralstringnum}. Arguments as % follows:\newline\noindent % \begin{tabularx}{\linewidth}{@{}>{\raggedleft\arraybackslash\ttfamily}rX@{}} % \#1&local options\\ @@ -2023,12 +2055,16 @@ % This section deals with the code for |fmtcount.sty| % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fmtcount}[2014/06/18 v2.04] +\ProvidesPackage{fmtcount}[2014/07/18 v3.00] \RequirePackage{ifthen} \RequirePackage{keyval} \RequirePackage{etoolbox} \RequirePackage{fcprefix} % \end{macrocode} +% \changes{3.00}{2014-07-18}{Add \cs{RequirePackage} for \texttt{ifxetex}} +% \begin{macrocode} +\RequirePackage{ifxetex} +% \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} @@ -2063,15 +2099,15 @@ %\end{macro} % %\begin{macro}{\FCloadlang} -%changes{2.0}{2012-06-18}{new} -%changes{2.02}{2012-10-24}{ensured catcode for @ set to `letter' +%\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 babel nor polyglossia keep a list of 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 @@ -2104,7 +2140,7 @@ % \end{macrocode} %\end{macro} %\begin{macro}{\@FC@iflangloaded} -%changes{2.0}{2012-06-18}{new} +%\changes{2.0}{2012-06-18}{new} %\begin{definition} %\cs{@FC@iflangloaded}\marg{language}\marg{true}\marg{false} %\end{definition} @@ -2117,7 +2153,7 @@ % \end{macrocode} %\end{macro} %\begin{macro}{\ProvidesFCLanguage} -%changes{2.0}{2012-06-18}{new} +%\changes{2.0}{2012-06-18}{new} % Declare fmtcount language definition file. Adapted from % \ics{ProvidesFile}. % \begin{macrocode} @@ -2127,21 +2163,108 @@ % \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 +% \begin{macrocode} +\newif\iffmtcount@language@option +\fmtcount@language@optionfalse +% \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} +% \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} +% \begin{macrocode} +\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 +}% +% \end{macrocode} +%\end{macro} %\begin{macro}{\@fc@loadifbabelorpolyglossialdf} %\begin{definition} -%\cs{@fc@loadigbabelldf}\marg{language} +%\cs{@fc@loadifbabelorpolyglossialdf}\marg{language} %\end{definition} %Loads fmtcount language file, %\texttt{fc-}\meta{language}\texttt{.def}, -% if babel language definition file -% \meta{language}\texttt{.ldf} has been loaded. +% 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*{\@fc@loadifbabelorpolyglossialdf}[1]{% - \ifcsundef{ver@#1.ldf}{}{\FCloadlang{#1}}% - \IfFileExists{gloss-#1.ldf}{\ifcsundef{#1@loaded}{}{\FCloadlang{#1}}}{}% + \ifxetex + \IfFileExists{gloss-#1.ldf}{\ifcsundef{#1@loaded}{}{\FCloadlang{#1}}}{}% + \else + \ifcsundef{ver@#1.ldf}{}{\FCloadlang{#1}}% + \fi } % \end{macrocode} %\end{macro} @@ -2151,33 +2274,18 @@ % 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} % \begin{macrocode} -\@fc@loadifbabelorpolyglossialdf{english} -\@fc@loadifbabelorpolyglossialdf{UKenglish} -\@fc@loadifbabelorpolyglossialdf{british} -\@fc@loadifbabelorpolyglossialdf{USenglish} -\@fc@loadifbabelorpolyglossialdf{american} -\@fc@loadifbabelorpolyglossialdf{spanish} -\@fc@loadifbabelorpolyglossialdf{portuges} -\@fc@loadifbabelorpolyglossialdf{french} -\@fc@loadifbabelorpolyglossialdf{frenchb} -\@fc@loadifbabelorpolyglossialdf{francais} -\@fc@loadifbabelorpolyglossialdf{german}% -\@fc@loadifbabelorpolyglossialdf{germanb}% -\@fc@loadifbabelorpolyglossialdf{ngerman}% -\@fc@loadifbabelorpolyglossialdf{ngermanb}% -\@fc@loadifbabelorpolyglossialdf{italian} +\fc@iterate@on@languages\@fc@loadifbabelorpolyglossialdf % \end{macrocode} %\begin{macro}{\fmtcount@french} -% Define keys for use with |\fmtcountsetoptions|. -% Key to switch French dialects (Does babel store -%this kind of information?) +% Define keys for use with |\fmtcountsetoptions|. Key to switch French dialects (Does \styfmt{babel} store +% this kind of information?) % \begin{macrocode} \def\fmtcount@french{france} % \end{macrocode} %\end{macro} %\begin{option}{french} -%\changes{2.04}{2014-06-18}{swapped second and third arguments} % \begin{macrocode} \define@key{fmtcount}{french}[france]{% \@FC@iflangloaded{french}% @@ -2292,6 +2400,18 @@ {% } % \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}% @@ -2304,15 +2424,16 @@ \def\fmtord#1{\textsuperscript{#1}}} % \end{macrocode} %\end{option} -% Process package options +% Process package options +% \changes{3.00}{2014-07-18}{Add \cs{relax} after \cs{ProcessOptions} like shown in \texttt{clsguide.pdf}} % \begin{macrocode} -\ProcessOptions +\ProcessOptions\relax % \end{macrocode} %\begin{macro}{\@FCmodulo} %\begin{definition} %\cs{@FCmodulo}\marg{count reg}\marg{n} %\end{definition} -%\changes{2.04}{2014-06-18}{renamed \cs{@modulo} to \cs{@FCmodulo}} +%\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 @@ -2661,13 +2782,15 @@ % 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}% - {\string\ordinal \space already defined use - \string\FCordinal \space instead.} + {\protect\ordinal \space already defined use + \protect\FCordinal \space instead.} } % \end{macrocode} %\end{macro} @@ -2798,6 +2921,9 @@ %\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]{% {% @@ -2815,8 +2941,8 @@ {}% {% \PackageError{fmtcount}% - {Invalid gender option `#2' to \string\ordinalstring}% - {Available options are m, f or f}% + {Invalid gender option `#2' to \protect\ordinalstring}% + {Available options are m, f or n}% }% \protect\@ordinalstringM{#1}{\@fc@ordstr}% }% @@ -2850,6 +2976,8 @@ %\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} \def\@store@ordinal@string#1#2[#3]{% \ifthenelse{\equal{#3}{f}}% @@ -2866,7 +2994,7 @@ {}% {% \PackageError{fmtcount}% - {Invalid gender option `#3' to \string\ordinalstring}% + {Invalid gender option `#3' to \protect\ordinalstring}% {Available options are m, f or n}% }% \protect\@ordinalstringM{#2}{\@fc@ordstr}% @@ -3479,9 +3607,9 @@ % %\subsection{Multilinguage Definitions} %\begin{macro}{\@setdef@ultfmtcount} -% If multilingual support is provided, make \verb"\@numberstring" +% If multilingual support is provided, make \cs{@numberstring} % etc use the correct language (if defined). -% Otherwise use English definitions. "\@setdef@ultfmtcount" +% Otherwise use English definitions. \cs{@setdef@ultfmtcount} % sets the macros to use English. % \begin{macrocode} \def\@setdef@ultfmtcount{% @@ -3506,8 +3634,10 @@ %\end{macro} % %\begin{macro}{\fc@multiling} -%changes{2.02}{2012-10-24}{new} +%\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}% @@ -3519,7 +3649,7 @@ \ifcsundef{@#1#2\languagename}% {% \PackageWarning{fmtcount}% - {No support for \expandafter\string\csname#1\endcsname\space for + {No support for \expandafter\protect\csname #1\endcsname\space for language '\languagename'}% \ifthenelse{\equal{\languagename}{\fc@mainlang}}% {% @@ -3645,9 +3775,11 @@ } % \end{macrocode} %\end{macro} -% Check to see if babel or ngerman packages have been loaded. +% 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} -\@ifpackageloaded{babel}% +\expandafter\@ifpackageloaded +\expandafter{\ifxetex polyglossia\else babel\fi}% {% \@set@mulitling@fmtcount }% @@ -3658,7 +3790,43 @@ \@set@mulitling@fmtcount }% {% - \@setdef@ultfmtcount +% \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. +% \begin{macrocode} + \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} @@ -3670,7 +3838,9 @@ \let\@numberstring=\@numberstringM \let\@Numberstring=\@NumberstringM % \end{macrocode} - +\iffalse Local variables: \fi +\iffalse mode: docTeX \fi +\iffalse End: \fi %\iffalse % \begin{macrocode} % @@ -5629,7 +5799,7 @@ z\'ero% \fi }% % \end{macrocode} -% Now propagate the expansion of \cs{@tempa} into \texttt{\#2} after closing brace. +% 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}% @@ -5710,7 +5880,7 @@ z\'ero% % now append to \@tempa the ten and unit \fc@lthundredstringfrench\@tempa % \end{macrocode} -% Propagate expansion of \cs{@tempa} into macro \texttt{\#2} after closing brace. +% Propagate expansion of \cs{@tempa} into macro \texttt{\#1} after closing brace. % \begin{macrocode} \def\@tempb##1{\def\@tempa{\def#1{##1}}}% \expandafter\@tempb\expandafter{\@tempa}% @@ -5776,7 +5946,7 @@ z\'ero% \divide\count0 by 3 % \multiply\count0 by 3 % % \end{macrocode} -% Now we compute final weight into \cs{count5}, and round down too multiple of \(3\) into +% 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} \fc@intpart@find@last{\count5 }% diff --git a/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins b/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins index 399d7d770a4..40258ccff79 100644 --- a/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins +++ b/Master/texmf-dist/source/latex/fmtcount/fmtcount.ins @@ -1,4 +1,4 @@ -% fmtcount.ins generated using makedtx version 1.1 2014/6/18 14:52 +% fmtcount.ins generated using makedtx version 0.94b 2014/7/28 7:55 \input docstrip \preamble diff --git a/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty b/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty index 8c2ee534e9d..df80c35e55e 100644 --- a/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty +++ b/Master/texmf-dist/tex/latex/fmtcount/fmtcount.sty @@ -49,11 +49,12 @@ %%\cs{latinnumeralstringnum}\marg{number}\oarg{prefix options} %%\end{definition} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fmtcount}[2014/06/18 v2.04] +\ProvidesPackage{fmtcount}[2014/07/18 v3.00] \RequirePackage{ifthen} \RequirePackage{keyval} \RequirePackage{etoolbox} \RequirePackage{fcprefix} +\RequirePackage{ifxetex} \RequirePackage{amsgen} \providecommand*{\fmtord}[1]{\textsuperscript{#1}} \newcount\c@padzeroesN @@ -88,25 +89,56 @@ \newcommand*{\ProvidesFCLanguage}[1]{% \ProvidesFile{fc-#1.def}% } +\newif\iffmtcount@language@option +\fmtcount@language@optionfalse +\newcommand*\fc@supported@language@list{% +english,% +UKenglish,% +british,% +USenglish,% +american,% +spanish,% +portuges,% +french,% +frenchb,% +francais,% +german,% +germanb,% +ngerman,% +ngermanb,% +italian} +\newcommand*\fc@iterate@on@languages[1]{% + \ifx\fc@supported@language@list\@empty + \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 +}% \newcommand*{\@fc@loadifbabelorpolyglossialdf}[1]{% - \ifcsundef{ver@#1.ldf}{}{\FCloadlang{#1}}% - \IfFileExists{gloss-#1.ldf}{\ifcsundef{#1@loaded}{}{\FCloadlang{#1}}}{}% -} -\@fc@loadifbabelorpolyglossialdf{english} -\@fc@loadifbabelorpolyglossialdf{UKenglish} -\@fc@loadifbabelorpolyglossialdf{british} -\@fc@loadifbabelorpolyglossialdf{USenglish} -\@fc@loadifbabelorpolyglossialdf{american} -\@fc@loadifbabelorpolyglossialdf{spanish} -\@fc@loadifbabelorpolyglossialdf{portuges} -\@fc@loadifbabelorpolyglossialdf{french} -\@fc@loadifbabelorpolyglossialdf{frenchb} -\@fc@loadifbabelorpolyglossialdf{francais} -\@fc@loadifbabelorpolyglossialdf{german}% -\@fc@loadifbabelorpolyglossialdf{germanb}% -\@fc@loadifbabelorpolyglossialdf{ngerman}% -\@fc@loadifbabelorpolyglossialdf{ngermanb}% -\@fc@loadifbabelorpolyglossialdf{italian} + \ifxetex + \IfFileExists{gloss-#1.ldf}{\ifcsundef{#1@loaded}{}{\FCloadlang{#1}}}{}% + \else + \ifcsundef{ver@#1.ldf}{}{\FCloadlang{#1}}% + \fi +} +\fc@iterate@on@languages\@fc@loadifbabelorpolyglossialdf \def\fmtcount@french{france} \define@key{fmtcount}{french}[france]{% \@FC@iflangloaded{french}% @@ -192,11 +224,18 @@ }% {% } +\newcommand*\@fc@declare@language@option[1]{% + \DeclareOption{#1}{% + \@FC@iflangloaded{#1}{}{% + \fmtcount@language@optiontrue + \FCloadlang{#1}% + }}}% +\fc@iterate@on@languages\@fc@declare@language@option \DeclareOption{level}{\def\fmtcount@fmtord{level}% \def\fmtord#1{#1}} \DeclareOption{raise}{\def\fmtcount@fmtord{raise}% \def\fmtord#1{\textsuperscript{#1}}} -\ProcessOptions +\ProcessOptions\relax \newcount\@DT@modctr \newcommand*{\@FCmodulo}[2]{% \@DT@modctr=#1\relax @@ -445,8 +484,8 @@ {\let\ordinal\FCordinal}% {% \PackageWarning{fmtcount}% - {\string\ordinal \space already defined use - \string\FCordinal \space instead.} + {\protect\ordinal \space already defined use + \protect\FCordinal \space instead.} } \newcommand*{\ordinalnum}[1]{% \new@ifnextchar[% @@ -536,8 +575,8 @@ {}% {% \PackageError{fmtcount}% - {Invalid gender option `#2' to \string\ordinalstring}% - {Available options are m, f or f}% + {Invalid gender option `#2' to \protect\ordinalstring}% + {Available options are m, f or n}% }% \protect\@ordinalstringM{#1}{\@fc@ordstr}% }% @@ -569,7 +608,7 @@ {}% {% \PackageError{fmtcount}% - {Invalid gender option `#3' to \string\ordinalstring}% + {Invalid gender option `#3' to \protect\ordinalstring}% {Available options are m, f or n}% }% \protect\@ordinalstringM{#2}{\@fc@ordstr}% @@ -976,7 +1015,7 @@ \ifcsundef{@#1#2\languagename}% {% \PackageWarning{fmtcount}% - {No support for \expandafter\string\csname#1\endcsname\space for + {No support for \expandafter\protect\csname #1\endcsname\space for language '\languagename'}% \ifthenelse{\equal{\languagename}{\fc@mainlang}}% {% @@ -1047,7 +1086,8 @@ \fc@multiling{Ordinalstring}{N}% }% } -\@ifpackageloaded{babel}% +\expandafter\@ifpackageloaded +\expandafter{\ifxetex polyglossia\else babel\fi}% {% \@set@mulitling@fmtcount }% @@ -1058,7 +1098,31 @@ \@set@mulitling@fmtcount }% {% - \@setdef@ultfmtcount + \iffmtcount@language@option + \@set@mulitling@fmtcount + \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}{}{% + \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 }% } \let\@ordinal=\@ordinalM @@ -1066,7 +1130,9 @@ \let\@Ordinalstring=\@OrdinalstringM \let\@numberstring=\@numberstringM \let\@Numberstring=\@NumberstringM - +\iffalse Local variables: \fi +\iffalse mode: docTeX \fi +\iffalse End: \fi \endinput %% %% End of file `fmtcount.sty'. -- cgit v1.2.3