summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-01-09 01:37:25 +0000
committerKarl Berry <karl@freefriends.org>2007-01-09 01:37:25 +0000
commit75749358b57f757623123e34d01f1d7c02379873 (patch)
treebe185fa3c9d6f086db3554f34624cb4bed30411e /Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx
parenta9502e7a832eee7a924f5f6bdaccddef01bf5b74 (diff)
fmtcount update (7jan07)
git-svn-id: svn://tug.org/texlive/trunk@3260 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx')
-rw-r--r--Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx192
1 files changed, 132 insertions, 60 deletions
diff --git a/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx b/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx
index 0c2b01910aa..ba813b38d30 100644
--- a/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx
+++ b/Master/texmf-dist/source/latex/fmtcount/fmtcount.dtx
@@ -12,7 +12,7 @@
% -author "Nicola Talbot"
% -dir "source"
% fmtcount
-% Created on 2006/7/29 14:54
+% Created on 2007/1/6 16:52
%\fi
%\iffalse
%<*package>
@@ -35,7 +35,7 @@
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
-% Copyright (C) 2006 Nicola Talbot, all rights reserved.
+% Copyright (C) 2007 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
@@ -59,10 +59,10 @@
%
%\RecordChanges
%\OnlyDescription
-%\def\filedate{29 July 2006}
-%\def\fileversion{1.04}
+%\def\filedate{6 January 2007}
+%\def\fileversion{1.06}
%\def\filename{fmtcount.dtx}
-%\def\docdate{29 July 2006}
+%\def\docdate{6 January 2007}
%
% \title{fmtcount.sty v\fileversion: Displaying the Values of
%\LaTeX\ Counters}
@@ -370,6 +370,10 @@
%I would like to thank my mother for the French and Portuguese
%support and my Spanish dictionary for the Spanish support.
%
+%\section{Troubleshooting}
+%
+%There is a FAQ available at: \url{http://theoval.cmp.uea.ac.uk/~nlct/latex/packages/faq/}.
+%
% \section{Contact Details}
% Dr Nicola Talbot\\
% School of Computing Sciences\\
@@ -381,9 +385,11 @@
%
%\StopEventually{}
%\section{The Code}
+%\iffalse
% \begin{macrocode}
%<*fc-english.def>
% \end{macrocode}
+%\fi
% English definitions
% \begin{macrocode}
\ProvidesFile{fc-english}[2005/04/29]
@@ -775,12 +781,16 @@ this number}%
\let\@OrdinalstringFenglish=\@OrdinalstringMenglish
% \end{macrocode}
+%\iffalse
% \begin{macrocode}
%</fc-english.def>
% \end{macrocode}
+%\fi
+%\iffalse
% \begin{macrocode}
%<*fc-french.def>
% \end{macrocode}
+%\fi
% French
% \begin{macrocode}
\ProvidesFile{fc-french.def}[2005/04/29]
@@ -1724,12 +1734,16 @@ this number}%
\fi
}
% \end{macrocode}
+%\iffalse
% \begin{macrocode}
%</fc-french.def>
% \end{macrocode}
+%\fi
+%\iffalse
% \begin{macrocode}
%<*fc-portuges.def>
% \end{macrocode}
+%\fi
% Portuguse
% \begin{macrocode}
\ProvidesFile{fc-portuges.def}[2005/04/29]
@@ -2291,12 +2305,16 @@ this number}%
\fi
}
% \end{macrocode}
+%\iffalse
% \begin{macrocode}
%</fc-portuges.def>
% \end{macrocode}
+%\fi
+%\iffalse
% \begin{macrocode}
%<*fc-spanish.def>
% \end{macrocode}
+%\fi
% Spanish
% \begin{macrocode}
\ProvidesFile{fc-spanish.def}[2005/04/29]
@@ -2977,25 +2995,35 @@ this number}%
\fi
}
% \end{macrocode}
+%\iffalse
% \begin{macrocode}
%</fc-spanish.def>
% \end{macrocode}
+%\fi
+%\iffalse
% \begin{macrocode}
%<*fmtcount.sty>
% \end{macrocode}
+%\fi
%\subsection{fmtcount.sty}
% This section deals with the code for |fmtcount.sty|
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{fmtcount}[2006/07/29 v1.04]
+\ProvidesPackage{fmtcount}[2007/01/06 v1.06]
\RequirePackage{ifthen}
\RequirePackage{keyval}
% \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{macrocode}
\providecommand{\fmtord}[1]{\textsuperscript{#1}}
-
+% \end{macrocode}
+% Define |\padzeroes| to specify how many digits should be
+% displayed.
+% \begin{macrocode}
\newcount\c@padzeroesN
\c@padzeroesN=1\relax
\providecommand{\padzeroes}[1][17]{\c@padzeroesN=#1}
@@ -3010,7 +3038,8 @@ this number}%
\@ifundefined{dateportuges}{}{\input{fc-portuges.def}}
\@ifundefined{datefrench}{}{\input{fc-french.def}}
% \end{macrocode}
-%Provide Command to switch dialects (Does babel store
+% Define keys for use with |\fmtcountsetoptions|.
+% Key to switch French dialects (Does babel store
%this kind of information?)
% \begin{macrocode}
\def\fmtcount@french{france}
@@ -3026,7 +3055,9 @@ to load babel before loading fmtcount}}{
{Option `french' can only take the values `france',
`belgian' or `swiss'}}
}}
-
+% \end{macrocode}
+% Key to determine how to display the ordinal
+% \begin{macrocode}
\define@key{fmtcount}{fmtord}{%
\ifthenelse{\equal{#1}{level}
\or\equal{#1}{raise}
@@ -3035,7 +3066,10 @@ to load babel before loading fmtcount}}{
\PackageError{fmtcount}{Invalid value `#1' to fmtord key}
{Option `fmtord' can only take the values `level', `raise'
or `user'}}}
-
+% \end{macrocode}
+% Key to determine whether the ordinal should be abbreviated
+% (language dependent, currently only affects French ordinals.)
+% \begin{macrocode}
\newif\iffmtord@abbrv
\fmtord@abbrvfalse
\define@key{fmtcount}{abbrv}[true]{%
@@ -3044,19 +3078,29 @@ or `user'}}}
\PackageError{fmtcount}{Invalid value `#1' to fmtord key}
{Option `fmtord' can only take the values `true' or
`false'}}}
-
+% \end{macrocode}
+% Define command to set options.
+% \begin{macrocode}
\newcommand{\fmtcountsetoptions}[1]{%
\def\fmtcount@fmtord{}%
\setkeys{fmtcount}{#1}%
\@ifundefined{datefrench}{}{%
-\edef\@ordinalstringMfrench{\noexpand\csname @ordinalstringMfrench\fmtcount@french\noexpand\endcsname}%
-\edef\@ordinalstringFfrench{\noexpand\csname @ordinalstringFfrench\fmtcount@french\noexpand\endcsname}%
-\edef\@OrdinalstringMfrench{\noexpand\csname @OrdinalstringMfrench\fmtcount@french\noexpand\endcsname}%
-\edef\@OrdinalstringFfrench{\noexpand\csname @OrdinalstringFfrench\fmtcount@french\noexpand\endcsname}%
-\edef\@numberstringMfrench{\noexpand\csname @numberstringMfrench\fmtcount@french\noexpand\endcsname}%
-\edef\@numberstringFfrench{\noexpand\csname @numberstringFfrench\fmtcount@french\noexpand\endcsname}%
-\edef\@NumberstringMfrench{\noexpand\csname @NumberstringMfrench\fmtcount@french\noexpand\endcsname}%
-\edef\@NumberstringFfrench{\noexpand\csname @NumberstringFfrench\fmtcount@french\noexpand\endcsname}%
+\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}}{%
@@ -3080,12 +3124,14 @@ or `user'}}}
\def\fmtord#1{#1}}
\DeclareOption{raise}{\def\fmtcount@fmtord{raise}%
\def\fmtord#1{\textsuperscript{#1}}}
-
+% \end{macrocode}
+% Process package options
+% \begin{macrocode}
\ProcessOptions
-
% \end{macrocode}
% Define macro that performs modulo arthmetic. This is used for the
-% date, time, ordinal and numberstring commands.
+% date, time, ordinal and numberstring commands. (The fmtcount
+% package was originally part of the datetime package.)
% \begin{macrocode}
\newcount\@DT@modctr
\def\@modulo#1#2{%
@@ -3094,7 +3140,6 @@ or `user'}}}
\multiply \@DT@modctr by #2\relax
\advance #1 by -\@DT@modctr}
% \end{macrocode}
-% Define the macro to format the |st|, |nd|, |rd| or |th| of an ordinal.
% The following registers are needed by |\@ordinal| etc
% \begin{macrocode}
\newcount\@ordinalctr
@@ -3103,10 +3148,14 @@ or `user'}}}
\newcount\@tmpstrctr
% \end{macrocode}
%Define commands that display numbers in different bases.
+% Define counters and conditionals needed.
% \begin{macrocode}
\newif\if@DT@padzeroes
\newcount\@DT@loopN
\newcount\@DT@X
+% \end{macrocode}
+% Binary
+% \begin{macrocode}
\newcommand{\@binary}[1]{%
\@DT@padzeroestrue
\@DT@loopN=17\relax
@@ -3129,7 +3178,7 @@ or `user'}}}
\let\binarynum=\@binary
% \end{macrocode}
-%
+% Octal
% \begin{macrocode}
\newcommand{\@octal}[1]{%
\ifnum#1>32768
@@ -3156,7 +3205,7 @@ or `user'}}}
\fi}
\let\octalnum=\@octal
% \end{macrocode}
-%
+% Lowercase hexadecimal
% \begin{macrocode}
\newcommand{\@@hexadecimal}[1]{\ifcase#10\or1\or2\or3\or4\or5\or6\or7\or8\or9\or a\or b\or c\or d\or e\or f\fi}
@@ -3181,8 +3230,11 @@ or `user'}}}
\@@hexadecimal\@DT@X}
\let\hexadecimalnum=\@hexadecimal
-
-\newcommand{\@@Hexadecimal}[1]{\ifcase#10\or1\or2\or3\or4\or5\or6\or7\or8\or9\or A\or B\or C\or D\or E\or F\fi}
+% \begin{macrocode}
+% Uppercase hexadecimal
+% \end{macrocode}
+\newcommand{\@@Hexadecimal}[1]{\ifcase#10\or1\or2\or3\or4\or5\or6\or
+7\or8\or9\or A\or B\or C\or D\or E\or F\fi}
\newcommand{\@Hexadecimal}[1]{%
\@DT@padzeroestrue
@@ -3206,7 +3258,7 @@ or `user'}}}
\let\Hexadecimalnum=\@Hexadecimal
% \end{macrocode}
-%
+% Uppercase alphabetical representation (a \ldots\ z aa \ldots\ zz)
% \begin{macrocode}
\newcommand{\@aaalph}[1]{%
\@DT@loopN=#1\relax
@@ -3227,7 +3279,9 @@ or `user'}}}
}
\let\aaalphnum=\@aaalph
-
+% \end{macrocode}
+% Uppercase alphabetical representation (a \ldots\ z aa \ldots\ zz)
+% \begin{macrocode}
\newcommand{\@AAAlph}[1]{%
\@DT@loopN=#1\relax
\advance\@DT@loopN by -1\relax
@@ -3248,7 +3302,7 @@ or `user'}}}
\let\AAAlphnum=\@AAAlph
% \end{macrocode}
-%
+% Lowercase alphabetical representation
% \begin{macrocode}
\newcommand{\@abalph}[1]{%
\ifnum#1>17576
@@ -3273,7 +3327,9 @@ or `user'}}}
\fi}
\let\abalphnum=\@abalph
-
+% \end{macrocode}
+% Uppercase alphabetical representation
+% \begin{macrocode}
\newcommand{\@ABAlph}[1]{%
\ifnum#1>17576
\PackageError{fmtcount}{Value of counter too large for \protect\@ABAlph}{Maximum value 17576}
@@ -3297,30 +3353,30 @@ or `user'}}}
\fi}
\let\ABAlphnum=\@ABAlph
-
-\newcommand{\@decimal}[1]{%
-\ifnum#1>10000
-\PackageError{fmtcount}{Value of counter too large for \protect\@decimal}{Maximum value 10000}\number#1\relax
+% \end{macrocode}
+% Recursive command to count number of characters in argument.
+% |\@strctr| should be set to zero before calling it.
+% \begin{macrocode}
+\def\@fmtc@count#1#2\relax{%
+\if\relax#1
\else
-\@DT@padzeroestrue
-\@DT@loopN=6\relax
-\@strctr=\@DT@loopN
-\whiledo{\(\@strctr<\c@padzeroesN\) \TE@or \(\@strctr=\c@padzeroesN\)}{0\advance\@strctr by 1}%
-\@strctr=10000\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 10\relax
-\advance\@DT@loopN by -1\relax
-\ifnum\@strctr>1
-\repeat
-\the\@DT@X
+\advance\@strctr by 1\relax
+\@fmtc@count#2\relax
\fi}
+% \end{macrocode}
+% Internal decimal macro:
+% \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}%
+\fi
+\number#1\relax
+}
\let\decimalnum=\@decimal
% \end{macrocode}
@@ -3449,9 +3505,8 @@ Available options are m or f}}%
\def\@ordinalM{\@ordinalMenglish}
\let\@ordinalF=\@ordinalM}
-\@ifundefined{languagename}{%
-\@setdef@ultfmtcount}{
-\ifthenelse{\equal{\languagename}{nohyphenation}}{\@setdef@ultfmtcount}{
+\@ifpackageloaded{babel}{
+\ifthenelse{\equal{\languagename}{nohyphenation}\or\equal{languagename}{english}}{\@setdef@ultfmtcount}{
\def\@numberstringM{\@ifundefined{@numberstringM\languagename}{%
\PackageError{fmtcount}{No support for language '\languagename'}{%
The fmtcount package currently does not support language
@@ -3511,7 +3566,8 @@ The fmtcount package currently does not support language
The fmtcount package currently does not support language
'\languagename' for command \string\@OrdinalstringF}}{%
\csname @OrdinalstringF\languagename\endcsname}}
-}}
+}}{%
+\@setdef@ultfmtcount}
% \end{macrocode}
% Backwards compatibility:
% \begin{macrocode}
@@ -3521,12 +3577,16 @@ The fmtcount package currently does not support language
\let\@numberstring=\@numberstringM
\let\@Numberstring=\@NumberstringM
% \end{macrocode}
+%\iffalse
% \begin{macrocode}
%</fmtcount.sty>
% \end{macrocode}
+%\fi
+%\iffalse
% \begin{macrocode}
%<*fmtcount.perl>
% \end{macrocode}
+%\fi
% \begin{macrocode}
# File : fmtcount.perl
# Author : Nicola Talbot
@@ -5323,22 +5383,28 @@ sub load_fmtcount_cfg{
1;
% \end{macrocode}
+%\iffalse
% \begin{macrocode}
%</fmtcount.perl>
% \end{macrocode}
+%\fi
+%\iffalse
% \begin{macrocode}
%<*fc-samp.tex>
% \end{macrocode}
+%\fi
\documentclass[a4paper]{article}
-\usepackage[french]{babel}
+%\usepackage[french]{babel}
\usepackage{fmtcount}
\newcounter{N}
+\padzeroes[5]
+
\newcommand{\printrow}[1]{%
\newline
\setcounter{N}{#1}
-\makebox[0.25in][r]{\theN\quad}
+\makebox[0.75in][r]{\decimal{N}\quad}
\makebox[0.75in][r]{\hexadecimal{N}\quad}
\makebox[0.75in][r]{\ordinal{N}\quad}
\makebox[2in][l]{\numberstring{N}}
@@ -5353,7 +5419,7 @@ sub load_fmtcount_cfg{
\begin{ttfamily}
\noindent
-\makebox[0.25in][c]{N}
+\makebox[0.75in][c]{decimal}
\makebox[0.75in][c]{hexadecimal}
\makebox[0.75in][c]{ordinal}
numberstring
@@ -5425,12 +5491,16 @@ Passing numbers explicitly: \ordinalnum{10},
\Numberstringnum{10}, \Ordinalstringnum{10}.
\end{document}
+%\iffalse
% \begin{macrocode}
%</fc-samp.tex>
% \end{macrocode}
+%\fi
+%\iffalse
% \begin{macrocode}
%<*fc-lang.tex>
% \end{macrocode}
+%\fi
% This is an interactive script. Run it through \LaTeX
% and enter appropriate responses.
@@ -5638,8 +5708,10 @@ Current language: French (Belgium).
\end{ttfamily}
\end{document}
+%\iffalse
% \begin{macrocode}
%</fc-lang.tex>
% \end{macrocode}
+%\fi
%\Finale
\endinput