diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/lamstex/inputs/cardord.tex |
Initial commit
Diffstat (limited to 'macros/lamstex/inputs/cardord.tex')
-rw-r--r-- | macros/lamstex/inputs/cardord.tex | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/macros/lamstex/inputs/cardord.tex b/macros/lamstex/inputs/cardord.tex new file mode 100644 index 0000000000..469e2ac9ba --- /dev/null +++ b/macros/lamstex/inputs/cardord.tex @@ -0,0 +1,66 @@ +\catcode`\@=11 +\def\cardnine@#1{\ifcase#1\or one\or two\or three\or four\or five\or + six\or seven\or eight\or nine\fi} +\def\cardinal#1{\count@#1\relax + \ifnum\count@>99 \number\count@ + \else + \ifnum\count@=\z@ zero% + \else + \ifnum\count@<\ten@\cardnine@\count@ + \else + \ifnum\count@<20 + \advance\count@-\ten@ + \ifcase\count@ ten\or eleven\or twelve\or thirteen\or fourteen\or + fifteen\or sixteen\or seventeen\or eighteen\or nineteen\fi + \else + \count@@\count@\count@@@\count@@ + \divide\count@\ten@\multiply\count@\ten@ + \advance\count@@@-\count@\divide\count@\ten@ + \ifcase\count@\or\or twenty\or thirty\or forty\or fifty\or sixty\or + seventy\or eighty\or ninety\fi + \ifnum\count@@@=\z@\else-\cardnine@\count@@@\fi + \fi + \fi + \fi + \fi} +\def\ordnine@#1{\ifcase#1\or first\or second\or third\or fourth\or fifth\or + sixth\or seventh\or eighth\or ninth\fi} +\def\ordsuffix@{\count@@@@\count@ + \divide\count@\ten@ + \count@@@\count@\count@@\count@ + \divide\count@@\ten@\multiply\count@@\ten@ + \advance\count@@@-\count@@ + \ifnum\count@@@=\@ne th% + \else + \count@@@\count@@@@ + \count@@\count@@@@ + \divide\count@@\ten@\multiply\count@@\ten@ + \advance\count@@@-\count@@ + \ifcase\count@@@ th\or st\or nd\or rd\else th\fi + \fi} +\def\nordinal#1{\count@#1\relax\number\count@\ordsuffix@} +\def\spordinal#1{\count@#1\relax\number\count@$^{\text{\ordsuffix@}}$} +\def\ordinal#1{\count@#1\relax + \ifnum\count@>99 \number\count@\ordsuffix@ + \else + \ifnum\count@=\z@ zeroth% + \else + \ifnum\count@<\ten@\ordnine@\count@ + \else + \ifnum\count@<20 \advance\count@-\ten@ + \ifcase\count@ tenth\or eleventh\or twelfth\or thirteenth\or + fourteenth\or fifteenth\or sixteenth\or seventeenth\or eighteenth\or + nineteenth\fi + \else + \count@@\count@ + \divide\count@\ten@\multiply\count@\ten@ + \count@@@\count@@\advance\count@@@-\count@ + \divide\count@\ten@ + \ifcase\count@\or\or twent\or thirt\or fort\or fift\or sixt\or sevent\or + eight\or ninet\fi + \ifnum\count@@@=\z@ ieth\else y-\ordnine@\count@@@\fi + \fi + \fi + \fi + \fi} +\catcode`\@=\active |