From b4fc5f639874db951177ec539299d20908adb654 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 9 Jan 2006 00:44:40 +0000 Subject: doc 4 git-svn-id: svn://tug.org/texlive/trunk@80 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/fmtcount/CHANGES | 11 + Master/texmf-dist/doc/latex/fmtcount/README | 53 + Master/texmf-dist/doc/latex/fmtcount/fc-lang.tex | 238 +++ Master/texmf-dist/doc/latex/fmtcount/fc-samp.pdf | Bin 0 -> 34541 bytes Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex | 127 ++ Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf | Bin 0 -> 117682 bytes Master/texmf-dist/doc/latex/fmtcount/fmtcount.perl | 1788 ++++++++++++++++++++ Master/texmf-dist/doc/latex/fmtcount/manual.html | 439 +++++ 8 files changed, 2656 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/fmtcount/CHANGES create mode 100644 Master/texmf-dist/doc/latex/fmtcount/README create mode 100644 Master/texmf-dist/doc/latex/fmtcount/fc-lang.tex create mode 100644 Master/texmf-dist/doc/latex/fmtcount/fc-samp.pdf create mode 100644 Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex create mode 100644 Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf create mode 100644 Master/texmf-dist/doc/latex/fmtcount/fmtcount.perl create mode 100644 Master/texmf-dist/doc/latex/fmtcount/manual.html (limited to 'Master/texmf-dist/doc/latex/fmtcount') diff --git a/Master/texmf-dist/doc/latex/fmtcount/CHANGES b/Master/texmf-dist/doc/latex/fmtcount/CHANGES new file mode 100644 index 00000000000..0decf94d737 --- /dev/null +++ b/Master/texmf-dist/doc/latex/fmtcount/CHANGES @@ -0,0 +1,11 @@ +fmtcount package versions: + +Version 1.03: Minor bug fixes (concerning fmtcount.cfg and the effect of \padzeroes). + +Version 1.02: Added multilingual support + +Version 1.01: Added support for LaTeX2HTML + +Version 1.0: separated counter related code from +datetime. + diff --git a/Master/texmf-dist/doc/latex/fmtcount/README b/Master/texmf-dist/doc/latex/fmtcount/README new file mode 100644 index 00000000000..eede71472c8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/fmtcount/README @@ -0,0 +1,53 @@ +LaTeX Package : fmtcount v 1.03 + +Last Modified : 20 June 2005 + +Author : Nicola Talbot + +Files : fmtcount.dtx - documented source file + fmtcount.ins - installation script + + +The package fmtcount.sty provides commands +that display the value of a LaTeX counter in a variety +of formats (ordinal, text, hexadecimal, decimal, +octal, binary etc). This package was originally provided +with the datetime package, but is now distributed separately. + +See the documentation for more details. + +To extract the code do: + +latex fmtcount.ins + +This will create the files: fmtcount.sty (the LaTeX package), +fmtcount.perl (the LaTeX2HTML package) +and fc-*.def (the language definition files used by +fmtcount.sty). It will also create two sample files: +fc-samp.tex and fc-lang.tex. The first will work with +LaTeX2HTML, the other won't. + +Move the .sty and .def files to somewhere LaTeX will find it +(e.g. texmf/tex/latex/fmtcount/) and remember to update the TeX +database. + +Copy the fmtcount.perl file to somewhere where LaTeX2HTML will +find it (e.g. latex2html/styles/). + +To extract the documentation do: + +latex fmtcount.dtx +makeindex -s gglo.ist -t fmtcount.glg -o fmtcount.gls fmtcount.glo +latex fmtcount.dtx +latex fmtcount.dtx + +Place the resulting file (fmtcount.dvi) into the documentation +directory (e.g. texmf/doc/latex/fmtcount/). + +Read the file CHANGES for version changes. + +This material is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for +the details of that license. + +http://theoval.cmp.uea.ac.uk/~nlct/ diff --git a/Master/texmf-dist/doc/latex/fmtcount/fc-lang.tex b/Master/texmf-dist/doc/latex/fmtcount/fc-lang.tex new file mode 100644 index 00000000000..798fbfee3ac --- /dev/null +++ b/Master/texmf-dist/doc/latex/fmtcount/fc-lang.tex @@ -0,0 +1,238 @@ +%% +%% This is file `fc-lang.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% fmtcount.dtx (with options: `fc-lang.tex,package') +%% Copyright (C) 2005 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \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 +%% Lower-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 +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} + % This is an interactive script. Run it through \LaTeX + % and enter appropriate responses. + +\documentclass[a4paper]{article} + +\usepackage[french,english,spanish,portuges]{babel} +\usepackage{fmtcount} + +\newcounter{startval} +\newcounter{endval} +\newcounter{stepsize} +\newcounter{N} +\newcount\myctr +\newcount\langid + +\begin{document} + +\section{Displaying the value of a counter} + +\typeout{This is an interactive script, testing the fmtcount package.} + +\langid=-1 + +\loop +\typeout{Which language?^^J} +\typeout{[1] English} +\typeout{[2] Portuguese} +\typeout{[3] Spanish} +\typeout{[4] French} +\typeout{[5] French (Swiss)} +\typeout{[6] French (Belgium)} + +\typein[\response]{} + +\ifthenelse{\equal{\response}{1}}{\langid=1}{ +\ifthenelse{\equal{\response}{2}}{\langid=2}{ +\ifthenelse{\equal{\response}{3}}{\langid=3}{ +\ifthenelse{\equal{\response}{4}}{\langid=4\fmtcountsetoptions{french}}{ +\ifthenelse{\equal{\response}{5}}{\langid=5\fmtcountsetoptions{french=swiss}}{ +\ifthenelse{\equal{\response}{6}}{\langid=6\fmtcountsetoptions{french=belgian}} +{\langid=-1 +\typeout{Invalid response '\response', please select a number from 1 to 6}}}}}}} +\ifnum\langid=-1 +\repeat + +\ifcase\langid +\or \selectlanguage{english} +Current language: English. +\or \selectlanguage{portuges} +Current language: Portuguese. +\or \selectlanguage{spanish} +Current language: Spanish. +\or \selectlanguage{french} +Current language: French. +\or \selectlanguage{french} +Current language: French (Swiss). +\or \selectlanguage{french} +Current language: French (Belgium). +\fi + +\def\startval{-1} + +\loop +\typein[\startval]{Start value? (Integer from 0 to 99000) +[Default 1]} +\ifthenelse{\equal{\startval}{}}{\def\startval{1}}{} +\ifnum\startval<0\def\startval{-1}\fi +\ifnum\startval>99999\def\startval{-1}\fi +\ifnum\startval=-1 +\repeat + +\def\endval{-1} + +\loop +\typein[\endval]{End value? (Integer from 0 to 99999) +[Default 1000]} +\ifthenelse{\equal{\endval}{}}{\def\endval{1000}}{} +\ifnum\endval<0\def\endval{-1}\fi +\ifnum\endval>99000\def\endval{-1}\fi +\ifnum\endval=-1 +\repeat + +\def\stepsize{0} + +\loop +\typein[\stepsize]{Step size? (Non zero integer) +[Default 1]} +\ifthenelse{\equal{\stepsize}{}}{\def\stepsize{1}}{} +\ifnum\stepsize=0 +\repeat + +\typeout{From {\startval} to {\endval} step {\stepsize}} + +\ifnum\startval<\endval +\ifnum\stepsize<0 +\PackageError{fc-lang}{Infinite loop not permitted!}{} +\def\endval{\startval} +\fi +\fi + +\ifnum\startval>\endval +\ifnum\stepsize>0 +\PackageError{fc-lang}{Infinite loop not permitted!}{} +\def\endval{\startval} +\fi +\fi + +\myctr=-1 +\loop +\typeout{Which format?^^J} +\typeout{[1] ordinalstring} +\typeout{[2] Ordinalstring} +\typeout{[3] numberstring} +\typeout{[4] Numberstring} + +\typein[\response]{Default: 1} + +\ifthenelse{\equal{\response}{}}{\def\response{1}}{}%default val +\ifthenelse{\equal{\response}{1}}{\myctr=1}{ +\ifthenelse{\equal{\response}{2}}{\myctr=2}{ +\ifthenelse{\equal{\response}{3}}{\myctr=3}{ +\ifthenelse{\equal{\response}{4}}{\myctr=4}{\myctr=-1 +\typeout{Invalid response '\response', please select a number from 1 to 4}}}}} +\ifnum\myctr=-1 +\repeat + +\ifcase\myctr +\or\def\stringtype{ordinalstring} +\or\def\stringtype{Ordinalstring} +\or\def\stringtype{numberstring} +\or\def\stringtype{Numberstring} +\fi + +\ifnum\langid>3 +\myctr=-1 +\loop +\typeout{Ordinal type?^^J} +\typeout{[1] eme} +\typeout{[2] e} +\typein[\response]{Default: 1} +\ifthenelse{\equal{\response}{}}{\def\response{1}}{}%default +\ifthenelse{\equal{\response}{1}}{% +\fmtcountsetoptions{abbrv=false}\myctr=1}{% +\ifthenelse{\equal{\response}{2}}{% +\fmtcountsetoptions{abbrv}\myctr=2}{% +\myctr=-1}} +\ifnum\myctr=-1 +\repeat +\fi + +\myctr=-1 +\loop +\typeout{Ordinal format?^^J} +\typeout{[1] raised} +\typeout{[2] level} +\typein[\response]{Default: 1} +\ifthenelse{\equal{\response}{1}\or\equal{\response}{}}{% +\fmtcountsetoptions{fmtord=raise}\myctr=1}{% +\ifthenelse{\equal{\response}{2}}{% +\fmtcountsetoptions{fmtord=level}\myctr=2}{% +\myctr=-1}} +\ifnum\myctr=-1 +\repeat + +\ifnum\langid=1 +\myctr=1 +\else +\loop +\typein[\response]{Gender? (m or f) [Default: m]} +\ifthenelse{\equal{\response}{m}\or\equal{\response}{}}{\myctr=1}{ +\ifthenelse{\equal{\response}{f}}{\myctr=2}{\myctr=-1 +\typeout{Invalid response '\response'}}} +\ifnum\myctr=-1 +\repeat +\fi + +\ifcase\myctr +\or \def\gender{m} +\or \def\gender{f} +\fi + +\setcounter{startval}{\startval} +\setcounter{endval}{\endval} +\setcounter{stepsize}{\stepsize} + +\stepcounter{endval} +\begin{ttfamily} +\noindent +\makebox[0.25in][c]{N} +\makebox[0.5in][c]{ordinal}\quad +\stringtype +\par +\myctr=\value{startval} +\loop +\noindent +\setcounter{N}{\myctr} +\makebox[0.25in][r]{\arabic{N}} +\makebox[0.5in][r]{\ordinal{N}[\gender]}\quad +\csname\stringtype\endcsname{N}[\gender]. +\par +\advance\myctr by \value{stepsize}\relax +\ifnum\myctr<\value{endval} +\repeat + +\end{ttfamily} + +\end{document} +\endinput +%% +%% End of file `fc-lang.tex'. diff --git a/Master/texmf-dist/doc/latex/fmtcount/fc-samp.pdf b/Master/texmf-dist/doc/latex/fmtcount/fc-samp.pdf new file mode 100644 index 00000000000..4316679d0cc Binary files /dev/null and b/Master/texmf-dist/doc/latex/fmtcount/fc-samp.pdf differ diff --git a/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex b/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex new file mode 100644 index 00000000000..2fb8b23549c --- /dev/null +++ b/Master/texmf-dist/doc/latex/fmtcount/fc-samp.tex @@ -0,0 +1,127 @@ +%% +%% This is file `fc-samp.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% fmtcount.dtx (with options: `fc-samp.tex,package') +%% Copyright (C) 2005 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \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 +%% Lower-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 +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\documentclass[a4paper]{article} + +\usepackage[french]{babel} +\usepackage{fmtcount} +\newcounter{N} + +\newcommand{\printrow}[1]{% +\newline +\setcounter{N}{#1} +\makebox[0.25in][r]{\theN\quad} +\makebox[0.75in][r]{\hexadecimal{N}\quad} +\makebox[0.75in][r]{\ordinal{N}\quad} +\makebox[2in][l]{\numberstring{N}} +} + +\renewcommand{\thesection}{\ordinal{section}} + +\begin{document} + +\section{Displaying the value of a counter} +\label{ex} + +\begin{ttfamily} +\noindent +\makebox[0.25in][c]{N} +\makebox[0.75in][c]{hexadecimal} +\makebox[0.75in][c]{ordinal} +numberstring +\printrow{0} +\printrow{1} +\printrow{2} +\printrow{3} +\printrow{4} +\printrow{5} +\printrow{6} +\printrow{7} +\printrow{8} +\printrow{9} +\printrow{10} +\printrow{11} +\printrow{12} +\printrow{13} +\printrow{14} +\printrow{15} +\printrow{16} +\printrow{17} +\printrow{18} +\printrow{19} +\printrow{20} +\printrow{21} +\printrow{22} +\printrow{23} +\printrow{24} +\printrow{25} +\printrow{30} +\printrow{40} +\printrow{50} +\printrow{60} +\printrow{70} +\printrow{71} +\printrow{75} +\printrow{80} +\printrow{81} +\printrow{85} +\printrow{90} +\printrow{91} +\printrow{95} +\printrow{100} +\printrow{101} +\printrow{110} +\printrow{125} +\printrow{150} +\printrow{170} +\printrow{180} +\printrow{190} +\printrow{200} +\printrow{250} +\printrow{300} +\printrow{400} +\printrow{500} +\printrow{600} +\printrow{700} +\printrow{800} +\printrow{900} +\printrow{1000} +\printrow{99999} +\end{ttfamily} + +\section{Cross-Referencing} + +Referencing a label: \ref{ex}. + +Passing numbers explicitly: \ordinalnum{10}, +\Numberstringnum{10}, \Ordinalstringnum{10}. + +\end{document} +\endinput +%% +%% End of file `fc-samp.tex'. diff --git a/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf b/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf new file mode 100644 index 00000000000..cf5aaa39b24 Binary files /dev/null and b/Master/texmf-dist/doc/latex/fmtcount/fmtcount.pdf differ diff --git a/Master/texmf-dist/doc/latex/fmtcount/fmtcount.perl b/Master/texmf-dist/doc/latex/fmtcount/fmtcount.perl new file mode 100644 index 00000000000..941b48fa98c --- /dev/null +++ b/Master/texmf-dist/doc/latex/fmtcount/fmtcount.perl @@ -0,0 +1,1788 @@ +# File : fmtcount.perl +# Author : Nicola Talbot +# Date : 3 Mar 2005 +# Version : 1.02 +# Description : LaTeX2HTML implementation of fmtcount package + +package main; + +sub do_fmtcount_raise{ + local($tmp)=""; + + $tmp .= 'sub do_cmd_fmtord{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($num) = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($num=$2));'; + $tmp .= 'join("", "",$num,"",$_);'; + $tmp .='}'; + + eval($tmp); +} + +sub do_fmtcount_level{ + local($tmp)=""; + + $tmp .= 'sub do_cmd_fmtord{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($num) = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($num=$2));'; + $tmp .= 'join("", $num,$_);'; + $tmp .='}'; + + eval($tmp); +} + +if (not defined &do_cmd_fmtord) +{ + &do_fmtcount_raise(@_); +} + +$frenchdialect = 'france'; +$ordinalabbrv = 0; + +sub get_ordinal_suffix_english{ + local($num,$gender) = @_; + local($suffix); + + if ((($num % 10) == 1) && ($num%100 != 11)) + { + $suffix = 'st'; + } + elsif ((($num % 10) == 2) && ($num%100 != 12)) + { + $suffix = 'nd'; + } + elsif ((($num % 10) == 3) && ($num%100 != 13)) + { + $suffix = 'rd'; + } + else + { + $suffix = 'th'; + } + + $suffix; +} + +sub get_ordinal_suffix_french{ + local($num,$gender) = @_; + local($_); + + if ($ordinalabbrv > 0) + { + $_ = 'e'; + } + else + { + if ($num == 1) + { + $_ = ($gender eq 'f' ? 'ere' : 'er'); + } + else + { + $_ = 'eme'; + } + } +} + +sub get_ordinal_suffix_spanish{ + local($num,$gender) = @_; + + ($gender eq 'f' ? 'a' : 'o'); +} + +sub get_ordinal_suffix_portuges{ + local($num,$gender) = @_; + + ($gender eq 'f' ? 'a' : 'o'); +} + +sub get_ordinal_suffix{ + local($num,$gender) = @_; + local($suffix,$suffixsub); + + $suffixsub = "get_ordinal_suffix_$default_language"; + + if (defined ($suffixsub)) + { + $suffix = &$suffixsub($num,$gender); + } + else + { + $suffix = &get_ordinal_suffix_english($num,$gender); + } + + $suffix; +} + +sub getordinal{ + local($num,$gender) = @_; + local($suffix) = &get_ordinal_suffix($num,$gender); + + if ($suffix eq '') + { + $num; + } + else + { + local($br_id) = ++$global{'max_id'}; + $num . "\\fmtord${OP}$br_id${CP}$suffix${OP}$br_id${CP}"; + } +} + +sub do_cmd_ordinalnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + local($gender)='m'; + local($suffix)=''; + + if ($_[0]=~s/\[([mf])\]//) + { + $gender = $1; + } + + $suffix = &get_ordinal_suffix($num,$gender); + + local($br_id) = ++$global{'max_id'}; + join('', $num, "\\fmtord${OP}$br_id${CP}$suffix${OP}$br_id${CP}", $_[0]); +} + +sub do_cmd_ordinal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + local($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $str eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{ORDINAL{', $ctr, '}}', $_[0]); + } + else + { + join('', &getordinal($val, $gender), $_[0]); + } +} + +@unitthstring = ('zeroth', + 'first', + 'second', + 'third', + 'fourth', + 'fifth', + 'sixth', + 'seventh', + 'eighth', + 'ninth'); + +@tenthstring = ('', + 'tenth', + 'twentieth', + 'thirtieth', + 'fortieth', + 'fiftieth', + 'sixtieth', + 'seventieth', + 'eightieth', + 'ninetieth'); + +@teenthstring = ('tenth', + 'eleventh', + 'twelfth', + 'thirteenth', + 'fourteenth', + 'fifteenth', + 'sixteenth', + 'seventeenth', + 'eighteenth', + 'nineteenth'); + +@unitstring = ('zero', + 'one', + 'two', + 'three', + 'four', + 'five', + 'six', + 'seven', + 'eight', + 'nine'); + +@teenstring = ('ten', + 'eleven', + 'twelve', + 'thirteen', + 'fourteen', + 'fifteen', + 'sixteen', + 'seventeen', + 'eighteen', + 'nineteen'); +@tenstring = ('', + 'ten', + 'twenty', + 'thirty', + 'forty', + 'fifty', + 'sixty', + 'seventy', + 'eighty', + 'ninety'); + +$hundredname = "hundred"; +$hundredthname = "hundredth"; +$thousandname = "thousand"; +$thousandthname = "thousandth"; + +sub get_numberstringenglish{ + local($num) = @_; + local($name)=""; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = &get_numberstringenglish($num/1000); + $name .= $thousands . " $thousandname"; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = &get_numberstringenglish($num/100); + $name .= $hundreds . " $hundredname"; + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " and "; } + + if ($num >= 20) + { + $name .= $tenstring[$num/10]; + + if ($num%10 > 0) { $name .= '-'; } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenstring[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstring[$num%10]; + } + } + + $name; +} + +@unitthstringfrench = ('zeroi\`eme', + 'uni\`eme', + 'deuxi\`eme', + 'troisi\`eme', + 'quatri\`eme', + 'cinqui\`eme', + 'sixi\`eme', + 'septi\`eme', + 'huiti\`eme', + 'neuvi\`eme'); + +@tenthstringfrench = ('', + 'dixi\`eme', + 'vingti\`eme', + 'trentri\`eme', + 'quaranti\`eme', + 'cinquanti\`eme', + 'soixanti\`eme', + 'septenti\`eme', + 'huitanti\`eme', + 'nonenti\`eme'); + +@teenthstringfrench = ('dixi\`eme', + 'onzi\`eme', + 'douzi\`eme', + 'treizi\`eme', + 'quatorzi\`eme', + 'quinzi\`eme', + 'seizi\`eme', + 'dix-septi\`eme', + 'dix-huiti\`eme', + 'dix-neuvi\`eme'); + +@unitstringfrench = ('zero', + 'un', + 'deux', + 'trois', + 'quatre', + 'cinq', + 'six', + 'sept', + 'huit', + 'neuf'); + +@teenstringfrench = ('dix', + 'onze', + 'douze', + 'treize', + 'quatorze', + 'quinze', + 'seize', + 'dix-sept', + 'dix-huit', + 'dix-neuf'); + +@tenstringfrench = ('', + 'dix', + 'vingt', + 'trente', + 'quarante', + 'cinquante', + 'soixante', + 'septente', + 'huitante', + 'nonente'); + +$hundrednamefrench = "cent"; +$hundredthnamefrench = "centi\\`eme"; +$thousandnamefrench = "mille"; +$thousandthnamefrench = "mili\\`eme"; + +@unitthstringspanish = ('cero', + 'primero', + 'segundo', + 'tercero', + 'cuarto', + 'quinto', + 'sexto', + 's\\\'eptimo', + 'octavo', + 'noveno'); + +@tenthstringspanish = ('', + 'd\\\'ecimo', + 'vig\\\'esimo', + 'trig\\\'esimo', + 'cuadrag\\\'esimo', + 'quincuag\\\'esimo', + 'sexag\\\'esimo', + 'septuag\\\'esimo', + 'octog\\\'esimo', + 'nonag\\\'esimo'); + +@teenthstringspanish = ('d\\\'ecimo', + 'und\\\'ecimo', + 'duod\\\'ecimo', + 'decimotercero', + 'decimocuarto', + 'decimoquinto', + 'decimosexto', + 'decimos\\\'eptimo', + 'decimoctavo', + 'decimonoveno'); + +@hundredthstringspanish = ('', + 'cent\\\'esimo', + 'ducent\\\'esimo', + 'tricent\\\'esimo', + 'cuadringent\\\'esimo', + 'quingent\\\'esimo', + 'sexcent\\\'esimo', + 'septing\\\'esimo', + 'octingent\\\'esimo', + 'noningent\\\'esimo'); + +@unitstringspanish = ('cero', + 'uno', + 'dos', + 'tres', + 'cuatro', + 'cinco', + 'seis', + 'siete', + 'ocho', + 'nueve'); + +@teenstringspanish = ('diez', + 'once', + 'doce', + 'trece', + 'catorce', + 'quince', + 'diecis\\\'eis', + 'diecisiete', + 'dieciocho', + 'diecinueve'); + +@twentystringspanish = ('viente', + 'vientiuno', + 'vientid\\\'os', + 'vientitr\\\'es', + 'vienticuatro', + 'vienticinco', + 'vientis\\\'eis', + 'vientisiete', + 'vientiocho', + 'vientinueve'); + +@tenstringspanish = ('', + 'diez', + 'viente', + 'treinta', + 'cuarenta', + 'cincuenta', + 'sesenta', + 'setenta', + 'ochenta', + 'noventa'); + +@hundredstringspanish = ('', + 'ciento', + 'doscientos', + 'trescientos', + 'cuatrocientos', + 'quinientos', + 'seiscientos', + 'setecientos', + 'ochocientos', + 'novecientos'); + +$hundrednamespanish = "cien"; +$hundredthnamespanish = "centi\\`eme"; +$thousandnamespanish = "mil"; +$thousandthnamespanish = "mil\\'esimo"; + +@unitthstringportuges = ('zero', + 'primeiro', + 'segundo', + 'terceiro', + 'quatro', + 'quinto', + 'sexto', + 's\\\'etimo', + 'oitavo', + 'nono'); + +@tenthstringportuges = ('', + 'd\\\'ecimo', + 'vig\\\'esimo', + 'trig\\\'esimo', + 'quadrag\\\'esimo', + 'q\"uinquag\\\'esimo', + 'sexag\\\'esimo', + 'setuag\\\'esimo', + 'octog\\\'esimo', + 'nonag\\\'esimo'); + +@hundredthstringportuges = ('', + 'cent\\\'esimo', + 'ducent\\\'esimo', + 'trecent\\\'esimo', + 'quadringent\\\'esimo', + 'q\"uingent\\\'esimo', + 'seiscent\\\'esimo', + 'setingent\\\'esimo', + 'octingent\\\'esimo', + 'nongent\\\'esimo'); + +@unitstringportuges = ('zero', + 'um', + 'dois', + 'tr\`es', + 'quatro', + 'cinco', + 'seis', + 'sete', + 'oito', + 'nove'); + +@teenstringportuges = ('dez', + 'onze', + 'doze', + 'treze', + 'quatorze', + 'quinze', + 'dezesseis', + 'dezessete', + 'dezoito', + 'dezenove'); + +@tenstringportuges = ('', + 'dez', + 'vinte', + 'trinta', + 'quaranta', + 'cinq\"uenta', + 'sessenta', + 'setenta', + 'oitenta', + 'noventa'); + +@hundredstringportuges = ('', + 'cento', + 'duzentos', + 'trezentos', + 'quatrocentos', + 'quinhentos', + 'seiscentos', + 'setecentos', + 'oitocentos', + 'novecentos'); + +$hundrednameportuges = "cem"; +$thousandnameportuges = "mil"; +$thousandthnameportuges = "mil\\'esimo"; + +sub get_numberstringfrench{ + local($num,$gender) = @_; + local($name)=""; + + if ($gender eq 'f') + { + $unitstringfrench[1] = 'une'; + } + else + { + $unitstringfrench[1] = 'un'; + } + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringfrench($num/1000,$gender).' '; + } + + $name .= $thousands . $thousandnamefrench; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num >= 200) + { + $hundreds = &get_numberstringfrench($num/100,$gender).' '; + } + + $name .= $hundreds . $hundrednamefrench; + $num = $num%100; + + if (($_[0]%100 == 0) && ($_[0]/100 > 1)) + { + $name .= 's'; + } + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " "; } + + if ($num >= 20) + { + if ($frenchdialect eq 'france' and $num >= 70) + { + if ($num < 80) + { + $name .= $tenstringfrench[6]; + + if ($num%10 == 1) + { + $name .= ' et '; + } + else + { + $name .= '-'; + } + + $num = 10+($num%10); + } + else + { + $name .= 'quatre-vingt' . ($num==80?'s':'-'); + + if ($num >= 90) + { + $num = 10+($num%10); + } + } + } + elsif ($frenchdialect eq 'belgian' + && ($num >= 80) && ($num < 90)) + { + $name .= 'quatre-vingt' . ($num==80?'s':'-'); + } + else + { + $name .= $tenstringfrench[$num/10]; + + if ($num%10 == 1) { $name .= ' et ';} + elsif ($num%10 > 0) { $name .= '-'; } + } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenstringfrench[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstringfrench[$num%10]; + } + } + + $name; +} + +sub get_numberstringspanish{ + local($num,$gender) = @_; + local($name)=""; + + if ($gender eq 'f') + { + $unitstringspanish[1] = 'una'; + } + else + { + $unitstringspanish[1] = 'uno'; + } + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringspanish($num/1000,$gender).' '; + } + + $name .= $thousands . $thousandnamespanish; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num > 100) + { + $hundreds = $hundredstringspanish[$num/100]; + } + else + { + $hundreds = 'cien'; + } + + $name .= $hundreds; + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " y "; } + + if ($num >= 30) + { + $name .= $tenstringspanish[$num/10]; + + if ($num%10 > 0) { $name .= ' y '; } + } + + if (($num >=20) && ($num < 30)) + { + $name .= $twentystringspanish[$num%10]; + } + elsif (($num >= 10) && ($num < 20)) + { + $name .= $teenstringspanish[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstringspanish[$num%10]; + } + } + + $name; +} + +sub get_numberstringportuges{ + local($num,$gender) = @_; + local($name)=""; + + if ($gender eq 'f') + { + $unitstringportuges[0] = 'zera'; + $unitstringportuges[1] = 'uma'; + $unitstringportuges[2] = 'duas'; + } + else + { + $unitstringportuges[0] = 'zero'; + $unitstringportuges[1] = 'um'; + $unitstringportuges[2] = 'dois'; + } + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringportuges($num/1000,$gender).' '; + } + + $name .= $thousands . $thousandnameportuges; + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num > 100) + { + $hundreds = $hundredstringportuges[$num/100]; + + if ($gender eq 'f') + { + $hundreds =~s/o(s?)$/a\1/; + } + } + else + { + $hundreds = $hundrednameportuges; + } + + $name .= $hundreds; + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " e "; } + + if ($num >= 20) + { + $name .= $tenstringportuges[$num/10]; + + if ($num%10 == 1) { $name .= ' e ';} + elsif ($num%10 > 0) { $name .= ' '; } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenstringportuges[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitstringportuges[$num%10]; + } + } + + $name; +} + +sub get_numberstring{ + local($val,$gender) = @_; + + if ($default_language eq 'french') + { + &get_numberstringfrench($val,$gender); + } + elsif ($default_language eq 'spanish') + { + &get_numberstringspanish($val,$gender); + } + elsif ($default_language eq 'portuges') + { + &get_numberstringportuges($val,$gender); + } + else + { + &get_numberstringenglish($val); + } +} + +sub do_cmd_numberstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (($_[0]=~s/$next_pair_pr_rx//o)&&($num=$2)); + + if ($_[0] =~ s/\[(m|f)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_numberstring($num,$gender), $_[0]); +} + +sub do_cmd_numberstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + local($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{NUMBERSTRING{', $ctr, '}}', $_[0]); + } + else + { + join('', &get_numberstring($val, $gender), $_[0]); + } +} + +sub get_Numberstring{ + local($val,$gender) = @_; + local($string) = &get_numberstring($val,$gender); + $string =~ s/([a-z])([^\s\-]+)/\u\1\2/g; + + if ($default_language eq 'french') + { + $string =~ s/ Et / et /g; + } + elsif ($default_language eq 'spanish') + { + $string =~ s/ Y / y /g; + } + elsif ($default_language eq 'portuges') + { + $string =~ s/ E / e /g; + } + else + { + $string =~ s/ And / and /g; + } + + $string; +} + +sub do_cmd_Numberstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (($_[0]=~s/$next_pair_pr_rx//o)&&($num=$2)); + + if ($_[0] =~ s/\[(m|f)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_Numberstring($num,$gender), $_[0]); +} + +sub do_cmd_Numberstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + local($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{NNUMBERSTRING{', $ctr, '}}', $_[0]); + } + else + { + join('', &get_Numberstring($val, $gender), $_[0]); + } +} + +sub get_ordinalstringenglish{ + local($num) = @_; + local($name)=""; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = &get_numberstring($num/1000); + $name .= $thousands; + + if ($num%1000 > 0) + { + $name .= " $thousandname"; + } + else + { + $name .= " $thousandthname"; + } + + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = &get_numberstring($num/100); + $name .= $hundreds; + + if ($num%100 > 0) + { + $name .= " $hundredname"; + } + else + { + $name .= " $hundredthname"; + } + + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " and "; } + + if ($num >= 20) + { + if ($num%10 > 0) + { + $name .= $tenstring[$num/10] . '-'; + } + else + { + $name .= $tenthstring[$num/10]; + } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenthstring[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitthstring[$num%10]; + } + } + + $name; +} + +sub get_ordinalstringfrench{ + local($num,$gender) = @_; + local($name)=""; + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + local($thousands) = ''; + + if ($num >= 2000) + { + $thousands = &get_numberstringfrench($num/1000,$gender).' '; + } + + $num = $num%1000; + + if ($num > 0) + { + $name .= $thousands . $thousandnamefrench; + } + else + { + $name .= $thousands . $thousandthnamefrench; + } + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = ''; + + if ($num >= 200) + { + $hundreds = &get_numberstringfrench($num/100,$gender).' '; + } + + $num = $num%100; + + if ($num > 0) + { + $name .= $hundreds . $hundrednamefrench; + } + else + { + $name .= $hundreds . $hundredthnamefrench; + } + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " "; } + + if ($num >= 20) + { + if ($frenchdialect eq 'france' and $num >= 70) + { + if ($num < 80) + { + if ($num%10 > 0) + { + $name .= $tenstringfrench[6]; + } + else + { + $name .= $tenthstringfrench[6]; + } + + if ($num%10 == 1) + { + $name .= ' et '; + } + else + { + $name .= '-'; + } + + $num = 10+($num%10); + } + else + { + $name .= 'quatre-vingt' . ($num==80?'i\`eme':'-'); + + if ($num >= 90) + { + $num = 10+($num%10); + } + } + } + elsif ($frenchdialect eq 'belgian' and $num >= 80) + { + $name .= 'quatre-vingt' . ($num==80?'i\`eme':'-'); + + if ($num >= 90) + { + $num = 10+($num%10); + } + } + else + { + if ($num%10 > 0) + { + $name .= $tenstringfrench[$num/10]; + } + else + { + $name .= $tenthstringfrench[$num/10]; + } + + if ($num%10 == 1) { $name .= ' et ';} + elsif ($num%10 > 0) { $name .= '-'; } + } + } + + if (($num >= 10) && ($num < 20)) + { + $name .= $teenthstringfrench[$num%10]; + } + elsif ($_[0] == 1) + { + $name = 'premi\`ere'; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $name .= $unitthstringfrench[$num%10]; + } + } + + $name; +} + +sub get_ordinalstringspanish{ + local($num,$gender) = @_; + local($name)=""; + local($str); + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + if ($num >= 2000) + { + local($thousands) = &get_ordinalstringspanish($num/1000); + + if ($gender eq 'f') + { + $thousands =~s/o(s?)$/a\1/; + } + + $name .= $thousands. " "; + } + else + { + $name = ""; + } + + $name .= "$thousandthnamespanish"; + + if ($gender eq 'f') + { + $name =~s/o$/a/; + } + + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = $hundredthstringspanish[$num/100]; + + if ($gender eq 'f') + { + $hundreds =~s/o$/a/; + } + + $name .= $hundreds; + + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= " "; } + + local($lastbit)=""; + + if ($num >= 20) + { + $lastbit = $tenthstringspanish[$num/10]; + + if ($num%10 > 0) + { + $lastbit .= ' '; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + + $lastbit = ""; + } + + if (($num >= 10) && ($num < 20)) + { + $lastbit = $teenthstringspanish[$num%10]; + } + elsif (($num%10 > 0) || ($_[0] == 0)) + { + $lastbit = $unitthstringspanish[$num%10]; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + } + + $name; +} + +sub get_ordinalstringportuges{ + local($num,$gender) = @_; + local($name)=""; + local($str); + + unless (($num >= 1000000) || ($num < 0)) + { + if ($num >= 1000) + { + if ($num >= 2000) + { + local($thousands) = &get_ordinalstringportuges($num/1000); + + if ($gender eq 'f') + { + $thousands =~s/o(s?)$/a\1/; + } + + $name .= $thousands. " "; + } + else + { + $name = ""; + } + + $name .= "$thousandthnameportuges"; + + if ($gender eq 'f') + { + $name =~s/o$/a/; + } + + $num = $num%1000; + } + + if ($num >= 100) + { + if ($_[0] >= 1000) { $name .= " "; } + + local($hundreds) = $hundredthstringportuges[$num/100]; + + if ($gender eq 'f') + { + $hundreds =~s/o$/a/; + } + + $name .= $hundreds; + + $num = $num%100; + } + + if (($_[0] > 100) && ($_[0]%100 > 0)) { $name .= "-"; } + + local($lastbit)=""; + + if ($num >= 10) + { + $lastbit = $tenthstringportuges[$num/10]; + + if ($num%10 > 0) + { + $lastbit .= '-'; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + + $lastbit = ""; + } + + if (($num%10 > 0) || ($_[0] == 0)) + { + $lastbit = $unitthstringportuges[$num%10]; + } + + if ($gender eq 'f') + { + $lastbit =~s/o([ s]*)$/a\1/; + } + + $name .= $lastbit; + } + + $name; +} + +sub get_ordinalstring{ + local($val,$gender) = @_; + + if ($default_language eq 'french') + { + &get_ordinalstringfrench($val,$gender); + } + elsif ($default_language eq 'spanish') + { + &get_ordinalstringspanish($val,$gender); + } + elsif ($default_language eq 'portuges') + { + &get_ordinalstringportuges($val,$gender); + } + else + { + &get_ordinalstringenglish($val); + } +} + +sub do_cmd_ordinalstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (($_[0]=~s/$next_pair_pr_rx//o)&&($num=$2)); + + if ($_[0] =~ s/\[(m|f)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_ordinalstring($num,$gender), $_[0]); +} + +sub do_cmd_ordinalstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + local($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{ORDINALSTRING{', $ctr, '}}', $_[0]); + } + else + { + join('', &get_ordinalstring($val, $gender), $_[0]); + } +} + +sub get_Ordinalstring{ + local($val,$gender) = @_; + local($string) = &get_ordinalstring($val,$gender); + $string =~ s/([a-z])([^\s\-]+)/\u\1\2/g; + + if ($default_language eq 'french') + { + $string =~ s/ Et / et /g; + } + else + { + $string =~ s/ And / and /g; + } + + $string; +} + +sub do_cmd_Ordinalstringnum{ + local($_) = @_; + local($num,$gender); + $num = &missing_braces + unless (($_[0]=~s/$next_pair_pr_rx//o)&&($num=$2)); + + if ($_[0] =~ s/\[(m|f)\]//) + { + $gender = $1; + } + else + { + $gender = 'm'; + } + + join('', &get_Ordinalstring($num,$gender), $_[0]); +} + +sub do_cmd_Ordinalstring{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + local($gender)='m'; + + $_[0] =~ s/${OP}$id${CP}$ctr${OP}$id${CP}//; + + if ($_[0]=~s/\[(.)\]//) + { + $gender = $1; + } + + if ($ctr eq 'DAY' or $ctr eq 'MONTH' or $ctr eq 'YEAR') + { + # this is a cludge to make it work with newdateformat + join('', '{OORDINALSTRING{', $ctr, '}}', $_[0]); + } + else + { + join('', &get_Ordinalstring($val, $gender), $_[0]); + } +} + +sub do_cmd_fmtcountsetoptions{ + local($_) = @_; + local($options) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($options=$2)); + + if ($options =~ m/french=?(\w*)(,|$)/) + { + if ($1 eq 'france' or $1 eq 'swiss' or $1 eq 'belgian') + { + $frenchdialect = $1; + + print "Using French dialect: $1" if ($VERBOSITY > 0) ; + } + elsif ($1 eq '') + { + $frenchdialect = 'france'; + + print "Using French dialect: france" if ($VERBOSITY > 0); + } + else + { + &write_warnings("unknown french dialect '$1'"); + } + } + + if ($options =~ m/abbrv=?(\w*)(,|$)/) + { + if ($1 eq 'true' or $1 eq '') + { + $ordinalabbrv = 1; + + print "Setting abbrv=true" if ($VERBOSITY > 0); + } + elsif ($1 eq 'false') + { + $ordinalabbrv = 0; + + print "Setting abbrv=false" if ($VERBOSITY > 0); + } + else + { + &write_warnings("fmtcountsetoptions key abbrv: unknown value '$1'."); + } + } + + if ($options =~ m/fmtord=(\w*)(,|$)/) + { + if ($1 eq 'raise') + { + &do_fmtcount_raise(); + + print "Using raised ordinals" if ($VERBOSITY > 0); + } + elsif ($1 eq 'level') + { + &do_fmtcount_level(); + + print "Using level ordinals" if ($VERBOSITY > 0); + } + elsif ($1 eq 'user') + { + # do nothing + + print "Using user defined fmtord" if ($VERBOSITY > 0); + } + else + { + &write_warnings("unknown fmtcount option fmtord=$1"); + } + } + + $_[0]; +} + +$padzeroes = 0; + +sub do_cmd_padzeroes{ + local($_) = @_; + local($val,$pat) = &get_next_optional_argument; + + if ($val eq '') + { + $padzeroes = 17; + } + else + { + $padzeroes = $val; + } + + $_; +} + +sub get_binary{ + local($num) = @_; + local($val) = ""; + + for (my $i=17; $i>=0; $i--) + { + if (($i < $padzeroes) || ($num & (1 << $i)) || !($val eq "")) + { + $val .= ($num & (1 << $i) ? 1 : 0); + } + } + + $val; +} + +sub do_cmd_binary{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_binary($val), $_); +} + +sub do_cmd_binarynum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', &get_binary($num), $_); +} + +sub get_decimal{ + local($num) = @_; + + sprintf "%0${padzeroes}d", $num; +} + +sub do_cmd_decimal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_decimal($val), $_); +} + +sub do_cmd_decimalnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', &get_decimal($num), $_); +} + +sub get_hexadecimal{ + local($num) = @_; + + sprintf "%0${padzeroes}lx", $num; +} + +sub do_cmd_hexadecimal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_hexadecimal($val), $_); +} + +sub do_cmd_hexadecimalnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', &get_hexadecimal($num), $_); +} + +sub get_Hexadecimal{ + local($num) = @_; + + sprintf "%0${padzeroes}lX", $num; +} + +sub do_cmd_Hexadecimal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_Hexadecimal($val), $_); +} + +sub do_cmd_Hexadecimalnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', &get_Hexadecimal($num), $_); +} + +sub get_octal{ + local($num) = @_; + + sprintf "%0${padzeroes}lo", $num; +} + +sub do_cmd_octal{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_octal($val), $_); +} + +sub do_cmd_octalnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', &get_octal($num), $_); +} + +sub get_aaalph{ + local($num) = @_; + local($rep) = int($num/26) + 1; + local($c) = chr(ord('a')-1+$num%26); + + local($_) = $c x $rep; +} + +sub do_cmd_aaalph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_aaalph($val), $_); +} + +sub get_AAAlph{ + local($num) = @_; + local($rep) = int($num/26) + 1; + local($c) = chr(ord('A')-1+$num%26); + + local($_) = $c x $rep; +} + +sub do_cmd_AAAlph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', &get_AAAlph($val), $_); +} + +sub do_cmd_aaalphnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', (sprintf "%${padzeroes}s", &get_aaalph($num)), $_); +} + +sub do_cmd_AAAlphnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', uc(sprintf "%${padzeroes}s", &get_aaalph($num)), $_); +} + +sub get_abalph{ + local($num) = @_; + local($str); + + if ($num == 0) + { + $str = ''; + } + elsif ($num > 0 && $num <= 26) + { + $str = chr(ord('a')-1+$num); + } + else + { + $str = &get_abalph(int($num/26)) . chr(ord('a')-1+($num%26)); + } + + $str; +} + +sub do_cmd_abalph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', (sprintf "%${padzeroes}s", &get_abalph($val)), $_); +} + +sub do_cmd_abalphnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', (sprintf "%${padzeroes}s", &get_abalph($num)), $_); +} + +sub do_cmd_ABAlph{ + local($ctr, $val, $id, $_) = &read_counter_value($_[0]); + + join('', uc(sprintf "%${padzeroes}s", &get_abalph($val)), $_); +} + +sub do_cmd_ABAlphnum{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + join('', uc(sprintf "%${padzeroes}s", &get_abalph($num)), $_); +} + +sub get_twodigit{ + local($num) = @_; + + sprintf "%02d", $num; +} + +sub do_cmd_twodigit{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + # this is a cludge + if ($num eq "THEDAY" or $num eq "THEYEAR" or $num eq "THEMONTH") + { + join('', 'TWODIGIT{', $num, '}', $_[0]); + } + else + { + join('', get_twodigit($num), $_[0]); + } +} + +# this was put here to help with the definition of \datelatin + +sub do_cmd_romannumeral{ + local($_) = @_; + local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2)); + + # this is a cludge + if ($num eq "THEDAY" or $num eq "THEYEAR" or $num eq "THEMONTH") + { + join('', 'ROMANNUMERAL{', $num, '}', $_[0]); + } + else + { + join('', &froman($num), $_[0]); + } +} + +# load configuration file if it exists +# Note: The configuration file should be loaded before +# the package options are executed. + +# why doesn't this work? If I call this subroutine it +# causes an infinite loop. + +sub load_fmtcount_cfg{ + local($file,$found); + + $file = &fulltexpath('fmtcount.cfg'); + + $found = (-f $file); + + if (!$found) + { + foreach $texpath (split /$envkey/, $TEXINPUTS) + { + $file = "$texpath${dd}fmtcount.cfg"; + + last if ($found = (-f $file)); + } + } + + if ($found) + { + print "\nusing configuration file $file\n"; + + &slurp_input($file); + &pre_process; + &substitute_meta_cmds if (%new_command || %new_environment); + &wrap_shorthand_environments; + $_ = &translate_commands(&translate_environments($_)); + + print "\n processed size: ".length($_)."\n" if ($VERBOSITY>1) + } + else + { + print "\nNo configuation file fmtcount.cfg found\n" if ($VERBOSITY>1) + } +} + +1; diff --git a/Master/texmf-dist/doc/latex/fmtcount/manual.html b/Master/texmf-dist/doc/latex/fmtcount/manual.html new file mode 100644 index 00000000000..9fa76258784 --- /dev/null +++ b/Master/texmf-dist/doc/latex/fmtcount/manual.html @@ -0,0 +1,439 @@ + + + + + +fmtcount.sty v1.03: Displaying the Values of LaTeX Counters + + + + + + + + + + + + +Dr Nicola Talbot +| +School of Computing Sciences +| +University of East Anglia + +

+ +

fmtcount.sty v1.03: Displaying the Values of +LaTeX Counters

+
+ +

N.L.C. Talbot

+

1 July 2005

+
+
+ +

+Contents +

+ + + + +

+Introduction +

+The fmtcount package provides commands to display +the values of LaTeX counters in a variety of formats. It also +provides equivalent commands for actual numbers rather than +counter names. Limited multilingual support is available. + +

+ +

+Installation +

+ +

+This package is distributed with the files fmtcount.dtx +and fmtcount.ins. To extract the code do: +

+latex fmtcount.ins
+
+This will create the files fmtcount.sty and +fmtcount.perl, along with several .def files. +Place fmtcount.sty and the .def files somewhere +where LaTeX will find them (e.g. texmf/tex/latex/fmtcount/) and place fmtcount.perl somewhere where LaTeX2HTML +will find it (e.g. latex2html/styles). Remember to refresh +the TeX database (using texhash under Linux, for +other operating systems check the manual.) + +

+ +

+Available Commands +

+ +

+The commands can be divided into two categories: those that +take the name of a counter as the argument, and those +that take a number as the argument. + +

+The macro \ordinal{counter} will + print the value of a LaTeX counter counter as an ordinal, + + where the macro \fmtord{text} is used to format the st,nd,rd,th bit. + By default the ordinal is formatted as a superscript, if the package option level + is used, it is level with the text. + For example, if the current section is 3, then \ordinal{section} will produce + the output: 3rd. + +

+The macro \ordinalnum is like \ordinal +but takes an actual number rather than a counter as the +argument. For example: \ordinalnum{3} will +produce: 3rd. + +

+The macro \numberstring{counter} will print the value + of counter as text. E.g. \numberstring{section} will produce: + three. + + The macro \Numberstring{counter} does the same as + \numberstring, but with initial letters in uppercase. For + example, \Numberstring{section} will produce: Three. + +

+The macros \numberstringnum and +\Numberstringnum work like +\numberstring and +\Numberstring, respectively, but take an actual number +rather than a counter as the argument. For example: +\Numberstringnum{105} will produce: One Hundred and Five. + +

+The macro \ordinalstring{counter} will print the + value of counter as a textual ordinal. E.g. \ordinalstring{section} will produce: third. + + The macro \Ordinalstring{counter} does the same as + \ordinalstring, but with initial letters in uppercase. For example, + \Ordinalstring{section} will produce: Third. + +

+The macros \ordinalstringnum and +\Ordinalstringnum work like +\Ordinalstring and +\Ordinalstring, respectively, but take an actual number +rather than a counter as the argument. For example, +\ordinalstringnum{3} will produce: third. + +

+The macro \binary{counter} will print the +value of counter as a binary number. +E.g. \binary{section} will produce: 11. The declaration +\padzeroes[n] +will ensure numbers are written to n digits, padding with +zeroes if necessary. E.g. \padzeroes[8]\binary{section} +will produce: 00000011. + The default value for n is 17. + +

+The macro \binarynum is like \binary +but takes an actual number rather than a counter as the +argument. For example: \binarynum{5} will +produce: 101. + +

+The macro \octal{counter} will print the +value of counter as an octal number. For example, if you +have a counter called, say mycounter, and you set the +value to 125, then \octal{mycounter} will produce: 177. + Again, the number will be padded with zeroes if necessary, +depending on whether \padzeroes has been used. + +

+The macro \octalnum is like \octal +but takes an actual number rather than a counter as the +argument. For example: \octalnum{125} will +produce: 177. + +

+The macro \hexadecimal{counter} will print +the value of counter as a hexadecimal number. Going back +to the previous example, \hexadecimal{mycounter} will + produce: 7d. Again, the number will be padded with zeroes if +necessary, depending on whether \padzeroes has been used. + + \Hexadecimal{counter} does the same thing, +but uses uppercase characters, e.g. + \Hexadecimal{mycounter} will produce: 7D. + +

+The macros \hexadecimalnum and +\Hexadecimalnum are like +\hexadecimal and \Hexadecimal +but take an actual number rather than a counter as the +argument. For example: \hexadecimalnum{125} will +produce: 7d, and \Hexadecimalnum{125} will +produce: 7D. + +

+The macro \decimal{counter} is similar to +\arabic but the number can be padded with zeroes + depending on whether \padzeroes has been used. +For example: \padzeroes[8]\decimal{section} will + produce: 00000005. + +

+The macro \decimalnum is like \decimal +but takes an actual number rather than a counter as the +argument. For example: \padzeroes[8]\decimalnum{5} will +produce: 00000005. + +

+The macro \aaalph{counter} will print the +value of counter as: a b ... z aa bb ... zz etc. + For example, \aaalpha{mycounter} will produce: uuuuu if +mycounter is set to 125. + + \AAAlph{counter} does the same thing, but +uses uppercase characters, e.g. + \AAAlph{mycounter} will produce: UUUUU. + +

+The macros \aaalphnum and +\AAAlphnum are like +\aaalph and \AAAlph +but take an actual number rather than a counter as the +argument. For example: \aaalphnum{125} will +produce: uuuuu, and \AAAlphnum{125} will +produce: UUUUU. + +

+The macro \abalph{counter} will print the +value of counter as: a b ... z aa ab ... az etc. + For example, \abalpha{mycounter} will produce: du if +mycounter is set to 125. + + \ABAlph{counter} does the same thing, but +uses uppercase characters, e.g. + \ABAlph{mycounter} will produce: DU. + +

+The macros \abalphnum and +\ABAlphnum are like +\abalph and \ABAlph +but take an actual number rather than a counter as the +argument. For example: \abalphnum{125} will +produce: du, and \ABAlphnum{125} will +produce: DU. + +

+ +

+Package Options +

+ +

+The following options can be passed to this package: + +

+ + + + + + + +
raisemake ordinal st,nd,rd,th appear as superscript
levelmake ordinal st,nd,rd,th appear level with rest of +text
+ +

+These can also be set using the command: + +

+ +\fmtcountsetoptions{fmtord=type} + +

+where type is either level or +raise. + +

+ +

+Multilingual Support +

+ +

+Version 1.02 of the fmtcount package now has +limited multilingual support. The following languages are +implemented: English, Spanish, Portuguese, French, French (Swiss) +and French (Belgian). The package checks to see if the +command \datelanguage is defined1, and will +load the code for those languages. The commands \ordinal, +\ordinalstring and \numberstring (and their +variants) will then be formatted in the currently +selected language. + +

+If the French language is selected, the French (France) version +will be used by default (e.g. soxiante-dix for 70). To +select the Swiss or Belgian variants (e.g. septente for 70) use: +\fmtcountsetoptions{french=dialect} +where dialect is either swiss or belgian. +You can also use this command to change the action of +\ordinal. +\fmtcountsetoptions{abbrv=true} to produce ordinals +of the form 2e or +\fmtcountsetoptions{abbrv=false} to produce ordinals +of the form 2eme (default). + +

+The french and abbrv settings only have an +effect if the French language has been defined. + +

+The male gender for all languages is used by default, however +the feminine form can be obtained by passing f as +an optional argument to \ordinal, \ordinalnum etc. +For example: \numberstring{section}[f]. Note that the +optional argument comes after the compulsory argument. + +

+Let me know if you find any spelling mistakes (has been known +to happen in English, let alone other languages I'm not so +familiar with.) + +

+ +

+Configuration File fmtcount.cfg +

+ +

+You can save your preferred default settings to a file called +fmtcount.cfg, and place it on the TeX path. These +settings will then be loaded by the fmtcount +package. + +

+Note that if you are using the datetime package, +the datetime.cfg configuration file will override +the fmtcount.cfg configuration file. +For example, if datetime.cfg has the line: +

+\renewcommand{\fmtord}[1]{\textsuperscript{\underline{#1}}}
+
+and if fmtcount.cfg has the line: +
+\fmtcountsetoptions{fmtord=level}
+
+then the former definition of \fmtord will take +precedence. + +

+ +

+LaTeX2HTML style +

+ +

+The LaTeX2HTML style file fmtcount.perl is provided. +The following limitations apply: + +

+ +

+ +

+ +

+Acknowledgements +

+ +

+I would like to thank my mother for the French and Portuguese +support and my Spanish dictionary for the Spanish support. + +

+ +

+Contact Details +

+ Dr Nicola Talbot +
+School of Computing Sciences +
+University of East Anglia +
+Norwich. NR4 7TJ. +
+United Kingdom. +
http://theoval.cmp.uea.ac.uk/~nlct/ +

Footnotes

+
+
... defined1
+
this +will be true if you have loaded babel + +
+
+

+
+Dr Nicola L C Talbot +2005-07-04 +
+ + -- cgit v1.2.3