| 1 |
% \iffalse meta-comment |
| 2 |
% Line endings: UNIX |
| 3 |
% Tab size: 4 |
| 4 |
% |
| 5 |
% Copyright 2004 Jonathan Sauer |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 9 |
% of this license or (at your option) any later version. |
| 10 |
% The latest version of this license is in |
| 11 |
% |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 15 |
% version 2003/12/01 or later. |
| 16 |
% |
| 17 |
% This work has the LPPL maintenance status "maintained". |
| 18 |
% |
| 19 |
% The Current Maintainer of this work is Jonathan Sauer |
| 20 |
% (<[email protected]>). |
| 21 |
% |
| 22 |
% This work consists of the files zahl2string.dtx and zahl2string.ins |
| 23 |
% and the derived file zahl2string.sty. |
| 24 |
% |
| 25 |
% \fi |
| 26 |
% |
| 27 |
% \iffalse |
| 28 |
% |
| 29 |
%<*driver> |
| 30 |
\documentclass{ltxdoc} |
| 31 |
\usepackage{zahl2string} |
| 32 |
\EnableCrossrefs |
| 33 |
\CodelineIndex |
| 34 |
\RecordChanges |
| 35 |
% Modification of verbatim for tabs in listings |
| 36 |
\makeatletter |
| 37 |
{\catcode`\ =\active% |
| 38 |
\catcode`\^^I=\active% |
| 39 |
\gdef\@vobeyspaces{% |
| 40 |
\catcode`\ \active\let \@xobeysp% |
| 41 |
\catcode`\^^I\active\def^^I{~~}% |
| 42 |
}}% |
| 43 |
\makeatother |
| 44 |
\begin{document} |
| 45 |
\DocInput{\jobname.dtx} |
| 46 |
\end{document} |
| 47 |
%</driver> |
| 48 |
% |
| 49 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 50 |
%<package>\ProvidesPackage{zahl2string} |
| 51 |
%<package> [2004/11/25 v1.2.1 format a number as german words] |
| 52 |
% |
| 53 |
% \fi |
| 54 |
% |
| 55 |
% \CheckSum{331} |
| 56 |
% \CharacterTable |
| 57 |
% {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 |
| 58 |
% 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 |
| 59 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 60 |
% Exclamation \! Double quote \" Hash (number) \# |
| 61 |
% Dollar \$ Percent \% Ampersand \& |
| 62 |
% Acute accent \' Left paren \( Right paren \) |
| 63 |
% Asterisk \* Plus \+ Comma \, |
| 64 |
% Minus \- Point \. Solidus \/ |
| 65 |
% Colon \: Semicolon \; Less than \< |
| 66 |
% Equals \= Greater than \> Question mark \? |
| 67 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 68 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 69 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 70 |
% Right brace \} Tilde \~} |
| 71 |
% |
| 72 |
% \DoNotIndex{\",\@empty,\@M,\@m,\@tempa,\csname,\DeclareOption} |
| 73 |
% \DoNotIndex{\DeclareRobustCommand,\def} |
| 74 |
% \DoNotIndex{\else,\endcsname,\expandafter,\fi,\if,\ifcase} |
| 75 |
% \DoNotIndex{\ifnum,\let,\MakeUppercase,\newcommand,\number,\or} |
| 76 |
% \DoNotIndex{\PackageError,\PackageWarning,\ProcessOptions} |
| 77 |
% \DoNotIndex{\protected@edef,\relax,\space,\ss,\string,\z@} |
| 78 |
% \DoNotIndex{\@ne,\@nil,\-} |
| 79 |
% |
| 80 |
% \GetFileInfo{\jobname.sty} |
| 81 |
% |
| 82 |
% \changes{1.1}{2004/08/08}{Range expanded to 999,999,999.} |
| 83 |
% \changes{1.2.1}{2004/10/20}{@Numstring and @Ordstring made robust.} |
| 84 |
% |
| 85 |
% \title{The \textsf{zahl2string} package\thanks{This document |
| 86 |
% corresponds to \textsf{\filename}~\fileversion, dated \filedate.}} |
| 87 |
% |
| 88 |
% \author{Jonathan Sauer \\ \texttt{[email protected]}} |
| 89 |
% |
| 90 |
% \date{\filedate} |
| 91 |
% |
| 92 |
% \maketitle |
| 93 |
% |
| 94 |
% \begin{abstract} |
| 95 |
% This file describes the \textsf{zahl2string} package that provides |
| 96 |
% macros for formatting numbers as german words, i.e. `1' gets |
| 97 |
% formatted as `eins'. |
| 98 |
% |
| 99 |
% \end{abstract} |
| 100 |
% |
| 101 |
% \tableofcontents |
| 102 |
% |
| 103 |
% \section{Introduction} |
| 104 |
% |
| 105 |
% Sometimes, for example when formatting a chapter title, you do not |
| 106 |
% want to say `Kapitel 1' (`Chapter 1') but `Kapitel eins' (`Chapter |
| 107 |
% one') or `Erstes Kapitel' (`First chapter'). This package provides |
| 108 |
% macros to format a \LaTeX-counter or more generally speaking a |
| 109 |
% number as a german word. |
| 110 |
% |
| 111 |
% |
| 112 |
% \section{Description of the macros} |
| 113 |
% |
| 114 |
% All macros format numbers in the range 0 to 999,999,999. Larger |
| 115 |
% numbers are formatted as an arabic number, smaller numbers are |
| 116 |
% formatted as zero. This can be changed using the package options |
| 117 |
% described on page \pageref{sec:Options}. |
| 118 |
% |
| 119 |
% \subsection{\LaTeX\ macros} |
| 120 |
% |
| 121 |
% The four macros |\numstring|, |\Numstring|, |\ordstring| and |
| 122 |
% |\Ordstring| are macros taking a \LaTeX-counter as their only |
| 123 |
% argument. |
| 124 |
% |
| 125 |
% \DescribeMacro{\numstring} Usage: |\numstring| \marg{LaTeX counter}. |
| 126 |
% |
| 127 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as a |
| 128 |
% word. |
| 129 |
% |
| 130 |
% \DescribeMacro{\Numstring} Usage: |\Numstring| \marg{LaTeX counter}. |
| 131 |
% |
| 132 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as words, |
| 133 |
% where the first letter is a capital letter. |
| 134 |
% |
| 135 |
% \DescribeMacro{\ordstring} Usage: |\ordstring| \marg{LaTeX counter}. |
| 136 |
% |
| 137 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as an ordinal |
| 138 |
% word. |
| 139 |
% |
| 140 |
% \DescribeMacro{\Ordstring} Usage: |\Ordstring| \marg{LaTeX counter}. |
| 141 |
% |
| 142 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as an ordinal |
| 143 |
% word, where the first letter is a capital letter. |
| 144 |
% |
| 145 |
% |
| 146 |
% |
| 147 |
% \subsection{General macros} |
| 148 |
% |
| 149 |
% The four macros |\@numstring|, |\@Numstring|, |\@ordstring| and |
| 150 |
% |\@Ordstring| as well as their aliases |\numstr|, |\Numstr|, |
| 151 |
% |\ordstr| and |\Ordstr| are macros taking a number or a \TeX\ count |
| 152 |
% register as their only argument. |
| 153 |
% |
| 154 |
% \DescribeMacro{\@numstring} \DescribeMacro{\numstr} Usage: |
| 155 |
% |\@numstring| \marg{number} / |\numstr| \marg{number}. |
| 156 |
% |
| 157 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 158 |
% 999,999,999 as words. |
| 159 |
% |
| 160 |
% \DescribeMacro{\@Numstring} \DescribeMacro{\Numstr} Usage: |
| 161 |
% |\@Numstring| \marg{number} / |\Numstr| \marg{number}. |
| 162 |
% |
| 163 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 164 |
% 999,999,999 as words, where the first letter is a capital letter. |
| 165 |
% |
| 166 |
% \DescribeMacro{\@ordstring} \DescribeMacro{\ordstr} Usage: |
| 167 |
% |\@ordstring| \marg{number} / |\ordstr| \marg{number}. |
| 168 |
% |
| 169 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 170 |
% 999,999,999 as an ordinal word. |
| 171 |
% |
| 172 |
% \DescribeMacro{\@Ordstring} \DescribeMacro{\Ordstr} Usage: |
| 173 |
% |\@Ordstring| \marg{number} / |\Ordstr| \marg{number}. |
| 174 |
% |
| 175 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 176 |
% 999,999,999 as an ordinal word, where the first letter is a capital |
| 177 |
% letter. |
| 178 |
% |
| 179 |
% ^^A For debugging discretionary hyphens: |
| 180 |
% ^^A\def\-{.\discretionary{}{}{}} |
| 181 |
% |
| 182 |
% |
| 183 |
% |
| 184 |
% \section{Examples} |
| 185 |
% |
| 186 |
% \newcommand{\zahlexamples}[1]{ |
| 187 |
% 0 $\Longrightarrow$ #1{0} |
| 188 |
% |
| 189 |
% 7 $\Longrightarrow$ #1{7} |
| 190 |
% |
| 191 |
% 13 $\Longrightarrow$ #1{13} |
| 192 |
% |
| 193 |
% 23 $\Longrightarrow$ #1{23} |
| 194 |
% |
| 195 |
% 42 $\Longrightarrow$ #1{42} |
| 196 |
% |
| 197 |
% 99 $\Longrightarrow$ #1{99} |
| 198 |
% |
| 199 |
% 127 $\Longrightarrow$ #1{127} |
| 200 |
% |
| 201 |
% 999 $\Longrightarrow$ #1{999} |
| 202 |
% |
| 203 |
% 1000 $\Longrightarrow$ #1{1000} |
| 204 |
% |
| 205 |
% 1001 $\Longrightarrow$ #1{1001} |
| 206 |
% |
| 207 |
% 2004 $\Longrightarrow$ #1{2004} |
| 208 |
% |
| 209 |
% 2017 $\Longrightarrow$ #1{2017} |
| 210 |
% |
| 211 |
% 2029 $\Longrightarrow$ #1{2029} |
| 212 |
% |
| 213 |
% 9999 $\Longrightarrow$ #1{9999} |
| 214 |
% |
| 215 |
% 10000 $\Longrightarrow$ #1{10000} |
| 216 |
% |
| 217 |
% 101101 $\Longrightarrow$ #1{101101} |
| 218 |
% |
| 219 |
% 999999 $\Longrightarrow$ #1{999999} |
| 220 |
% |
| 221 |
% 1000000 $\Longrightarrow$ #1{1000000} |
| 222 |
% |
| 223 |
% 1234567 $\Longrightarrow$ #1{1234567} |
| 224 |
% |
| 225 |
% 123456789 $\Longrightarrow$ #1{123456789} |
| 226 |
% |
| 227 |
% 101101101 $\Longrightarrow$ #1{101101101} |
| 228 |
% |
| 229 |
% 999999999 $\Longrightarrow$ #1{999999999} |
| 230 |
% } |
| 231 |
% |
| 232 |
% \addvspace{\baselineskip}\noindent Some examples using |\numstring|, |
| 233 |
% |\numstr| and |\@numstring|: |
| 234 |
% |
| 235 |
% \zahlexamples{\numstr} |
| 236 |
% |
| 237 |
% \addvspace{\baselineskip}\noindent Some examples using |\ordstring|, |
| 238 |
% |\ordstr| and |\@ordstring|: |
| 239 |
% |
| 240 |
% \zahlexamples{\ordstr} |
| 241 |
% |
| 242 |
% |
| 243 |
% \addvspace{\baselineskip}\noindent Formatting the current page |
| 244 |
% number (a \LaTeX\ counter) results in: Dies ist Seite |
| 245 |
% \numstring{page} (|\numstring{page}|). Dies ist die \ordstring{page} |
| 246 |
% Seite (|\ordstring{page}|). Seite: \Numstring{page} |
| 247 |
% (|\Numstring{page}|). \Ordstring{page} Seite (|\Ordstring{page}|). |
| 248 |
% |
| 249 |
% |
| 250 |
% |
| 251 |
% \section{Options}\label{sec:Options} |
| 252 |
% |
| 253 |
% The package has the following option: |
| 254 |
% |
| 255 |
% \begin{description} |
| 256 |
% \item[showrangeerrors] If a number larger than 999,999,999 |
| 257 |
% is to be formatted, normally the number |
| 258 |
% is not formatted as words, but using |
| 259 |
% arabic digits. This option changes this |
| 260 |
% behaviour to display an error instead, |
| 261 |
% thus notifying you when you format too |
| 262 |
% large a number |
| 263 |
% |
| 264 |
% \end{description} |
| 265 |
% |
| 266 |
% |
| 267 |
% |
| 268 |
% \section{Creating your own formatting} |
| 269 |
% |
| 270 |
% You can modify output of the \textsf{zahl2string} macros in a |
| 271 |
% limited way by providing your own macros for formatting the numbers |
| 272 |
% between `1' and `19. \emph{But note} that if you simply want to add |
| 273 |
% something to the suffix, , i.e. if you want to format numbers with |
| 274 |
% the suffix `tens' (`erstens', `zweitens' \ldots), then you can |
| 275 |
% simply say |\ordstr{|\meta{number}|}ns|, resulting in i.e. |
| 276 |
% `\ordstr{42}ns'. |
| 277 |
% |
| 278 |
% |
| 279 |
% If on the other hand you want to create a more complicated |
| 280 |
% formatting, then you have to do the following: |
| 281 |
% |
| 282 |
% \begin{itemize} |
| 283 |
% \item Create a macro for formatting the numbers `1' to `19', |
| 284 |
% i.e. |\my@neunzehnte|. See the predefined macros in |
| 285 |
% section \ref{sec:LabFor} on page \pageref{sec:LabFor}, |
| 286 |
% |\ns@neunzehn|, |\ns@neunzehns|, |\ns@neunzehne| and |
| 287 |
% |\ns@neunzehnord| for examples and notes. |
| 288 |
% |
| 289 |
% This macro has one parameter, the number (up to two |
| 290 |
% digits, in the range of `0' to `19'. `0' must expand to the |
| 291 |
% generic suffix, i.e. `stens'; `19' to `19' simply format |
| 292 |
% the number. |
| 293 |
% |
| 294 |
% Do not forget to insert discretionary hyphens using |\-|, |
| 295 |
% or hyphenation will not be perfect! |
| 296 |
% |
| 297 |
% \item Create another macro you want to call, i.e. |\mynumstring|. |
| 298 |
% This macro takes one parameter, the number, and calls |
| 299 |
% |\ns@numstr| using the following parameters: |
| 300 |
% |
| 301 |
% \begin{enumerate} |
| 302 |
% \item The number to be formatted (the parameter to |
| 303 |
% |\mynumstring|). |
| 304 |
% |
| 305 |
% \item The macro for formatting numbers `1' to `19', |
| 306 |
% i.e. |\my@neunzehnte|. |
| 307 |
% |
| 308 |
% \item The value that represents the number zero, |
| 309 |
% i.e. `nulltens'. |
| 310 |
% |
| 311 |
% \item The suffix for numbers larger than 999,999,999, |
| 312 |
% i.e. `tens'. |
| 313 |
% |
| 314 |
% \end{enumerate} |
| 315 |
% |
| 316 |
% \item Call the macro |\mynumstring| with the number to format. |
| 317 |
% |
| 318 |
% \end{itemize} |
| 319 |
% If you want to create a macro to format a \LaTeX-counter, create an |
| 320 |
% additional macro, i.e. |\myLnumstring|, that calls |\mynumstring| by |
| 321 |
% saying: |
| 322 |
% |
| 323 |
% \begin{verbatim} |
| 324 |
% \newcommand{\myLnumstring}[1]{% |
| 325 |
% \expandafter\mynumstring\csname c@#1\endcsname% |
| 326 |
% } |
| 327 |
% \end{verbatim} |
| 328 |
% See also the notes and predefined macros in section \ref{sec:LabFor} |
| 329 |
% on page \pageref{sec:LabFor}. |
| 330 |
% |
| 331 |
% |
| 332 |
% |
| 333 |
% \section{Notes/Limitations} |
| 334 |
% |
| 335 |
% \begin{itemize} |
| 336 |
% |
| 337 |
% \item Ordinal numbers larger than 999999 do not look that |
| 338 |
% good, as i.e. 1000000 gets formatted as |
| 339 |
% `\ordstr{1000000}' instead of `einmillionste'. |
| 340 |
% |
| 341 |
% \end{itemize} |
| 342 |
% |
| 343 |
% |
| 344 |
% |
| 345 |
% \StopEventually{} |
| 346 |
% |
| 347 |
% \section{Implementation} |
| 348 |
% |
| 349 |
% \subsection{Main macros} |
| 350 |
% |
| 351 |
% |
| 352 |
% \begin{macro}{\numstring} |
| 353 |
% |
| 354 |
% Usage: |\numstring| \marg{LaTeX counter}. |
| 355 |
% |
| 356 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as words. |
| 357 |
% |
| 358 |
% \begin{macrocode} |
| 359 |
\newcommand{\numstring}[1]{% |
| 360 |
\expandafter\@numstring\csname c@#1\endcsname% |
| 361 |
} |
| 362 |
% \end{macrocode} |
| 363 |
% \end{macro} |
| 364 |
% |
| 365 |
% |
| 366 |
% \begin{macro}{\Numstring} |
| 367 |
% |
| 368 |
% Usage: |\Numstring| \marg{LaTeX counter}. |
| 369 |
% |
| 370 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as words. The |
| 371 |
% first letter is uppercase. |
| 372 |
% |
| 373 |
% \begin{macrocode} |
| 374 |
\newcommand{\Numstring}[1]{% |
| 375 |
\expandafter\@Numstring\csname c@#1\endcsname% |
| 376 |
} |
| 377 |
% \end{macrocode} |
| 378 |
% \end{macro} |
| 379 |
% |
| 380 |
% |
| 381 |
% \begin{macro}{\ordstring} |
| 382 |
% |
| 383 |
% Usage: |\ordstring| \marg{LaTeX counter}. |
| 384 |
% |
| 385 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as an ordinal |
| 386 |
% word. |
| 387 |
% |
| 388 |
% \begin{macrocode} |
| 389 |
\newcommand{\ordstring}[1]{% |
| 390 |
\expandafter\@ordstring\csname c@#1\endcsname% |
| 391 |
} |
| 392 |
% \end{macrocode} |
| 393 |
% \end{macro} |
| 394 |
% |
| 395 |
% |
| 396 |
% \begin{macro}{\Ordstring} |
| 397 |
% |
| 398 |
% Usage: |\Ordstring| \marg{LaTeX counter}. |
| 399 |
% |
| 400 |
% Formats a \LaTeX\ counter in the range of 0 to 999,999,999 as an ordinal |
| 401 |
% word. The first letter is uppercase. |
| 402 |
% |
| 403 |
% \begin{macrocode} |
| 404 |
\newcommand{\Ordstring}[1]{% |
| 405 |
\expandafter\@Ordstring\csname c@#1\endcsname% |
| 406 |
} |
| 407 |
% \end{macrocode} |
| 408 |
% \end{macro} |
| 409 |
% |
| 410 |
% |
| 411 |
% \begin{macro}{\@numstring} |
| 412 |
% |
| 413 |
% Usage: |\@numstring| \marg{number or \TeX\ count register}. |
| 414 |
% |
| 415 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 416 |
% 999,999,999 as words. |
| 417 |
% |
| 418 |
% \begin{macrocode} |
| 419 |
\newcommand{\@numstring}[1]{% |
| 420 |
\ns@numstr{#1}\ns@neunzehns{null}{}% |
| 421 |
} |
| 422 |
% \end{macrocode} |
| 423 |
% |
| 424 |
% \end{macro} |
| 425 |
% |
| 426 |
% |
| 427 |
% \begin{macro}{\@Numstring} |
| 428 |
% |
| 429 |
% Usage: |\@Numstring| \marg{number or \TeX\ count register}. |
| 430 |
% |
| 431 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 432 |
% 999,999,999 as words. The first letter is uppercase. |
| 433 |
% |
| 434 |
% \begin{macrocode} |
| 435 |
\newcommand\@Numstring[1]{% |
| 436 |
\expandafter\@@Numstring\expandafter{\number#1}% |
| 437 |
} |
| 438 |
% \end{macrocode} |
| 439 |
% |
| 440 |
% \end{macro} |
| 441 |
% |
| 442 |
% |
| 443 |
% \begin{macro}{\@@Numstring} |
| 444 |
% |
| 445 |
% Support macro for |\@Numstring| to make |\@Numstring| robust. |
| 446 |
% |
| 447 |
% \changes{1.2.1}{2004/10/20}{Added} |
| 448 |
% |
| 449 |
% \begin{macrocode} |
| 450 |
\DeclareRobustCommand{\@@Numstring}[1]{% |
| 451 |
\protected@edef\@tempa{\@numstring{#1}}% |
| 452 |
\expandafter\MakeUppercase\@tempa% |
| 453 |
} |
| 454 |
% \end{macrocode} |
| 455 |
% \end{macro} |
| 456 |
% |
| 457 |
% |
| 458 |
% \begin{macro}{\@ordstring} |
| 459 |
% |
| 460 |
% Usage: |\@ordstring| \marg{number or \TeX\ count register}. |
| 461 |
% |
| 462 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 463 |
% 999,999,999 as an ordinalword, i.e. `erste', `zweite' et cetera. |
| 464 |
% |
| 465 |
% \begin{macrocode} |
| 466 |
\newcommand{\@ordstring}[1]{% |
| 467 |
\ns@numstr{#1}\ns@neunzehnord{null\-te}{te}% |
| 468 |
} |
| 469 |
% \end{macrocode} |
| 470 |
% |
| 471 |
% \end{macro} |
| 472 |
% |
| 473 |
% |
| 474 |
% \begin{macro}{\@Ordstring} |
| 475 |
% |
| 476 |
% Usage: |\@Ordstring| \marg{number or \TeX\ count register}. |
| 477 |
% |
| 478 |
% Formats a number or a \TeX\ count register in the range of 0 to |
| 479 |
% 999,999,999 as an ordinalword, i.e. `Erste', `Zweite' et cetera. The |
| 480 |
% first letter is uppercase. |
| 481 |
% |
| 482 |
% \begin{macrocode} |
| 483 |
\newcommand{\@Ordstring}[1]{% |
| 484 |
\expandafter\@@Ordstring\expandafter{\number#1}% |
| 485 |
} |
| 486 |
% \end{macrocode} |
| 487 |
% |
| 488 |
% \end{macro} |
| 489 |
% |
| 490 |
% |
| 491 |
% \begin{macro}{\@@Ordstring} |
| 492 |
% |
| 493 |
% Support macro for |\@Ordstring| to make |\@Ordstring| robust. |
| 494 |
% |
| 495 |
% \changes{1.2.1}{2004/10/20}{Added} |
| 496 |
% |
| 497 |
% \begin{macrocode} |
| 498 |
\DeclareRobustCommand{\@@Ordstring}[1]{% |
| 499 |
\protected@edef\@tempa{\@ordstring{#1}}% |
| 500 |
\expandafter\MakeUppercase\@tempa% |
| 501 |
} |
| 502 |
% \end{macrocode} |
| 503 |
% \end{macro} |
| 504 |
% |
| 505 |
% |
| 506 |
% |
| 507 |
% We provide public aliases for the macros. The macros beginning with |
| 508 |
% |@| are still necessary in order to be able to format the page |
| 509 |
% number as a string. (see \textsf{ltpageno.dtx}) |
| 510 |
% |
| 511 |
% \changes{1.2}{2004/09/08}{Added} |
| 512 |
% |
| 513 |
% \begin{macrocode} |
| 514 |
\let\numstr\@numstring% |
| 515 |
\let\Numstr\@Numstring% |
| 516 |
\let\ordstr\@ordstring% |
| 517 |
\let\Ordstr\@Ordstring% |
| 518 |
% \end{macrocode} |
| 519 |
% |
| 520 |
% |
| 521 |
% \subsection{Option processing} |
| 522 |
% |
| 523 |
% \changes{1.1}{2004/08/13}{Options `publicnumstr' and `showrangeerrors' |
| 524 |
% added.} |
| 525 |
% \changes{1.2}{2004/09/08}{Option `publicnumstr' deprecated} |
| 526 |
% |
| 527 |
% \begin{macrocode} |
| 528 |
\DeclareOption{publicnumstr}{% |
| 529 |
\PackageWarning{zahl2string}{Option `publicnumstr' is % |
| 530 |
deprecated and will be removed in version 1.3}% |
| 531 |
} |
| 532 |
% \end{macrocode} |
| 533 |
% |
| 534 |
% |
| 535 |
% \begin{macro}{\ns@numoutofrange} |
| 536 |
% |
| 537 |
% Formats a number that is too large to be formatted as words. |
| 538 |
% |
| 539 |
% Usage: |\ns@numoutofrange| \marg{number} \marg{suffix}. |
| 540 |
% |
| 541 |
% This macro is redefined to show an error message using the package |
| 542 |
% option |showrangeerrors|. |
| 543 |
% |
| 544 |
% \begin{macrocode} |
| 545 |
\def\ns@numoutofrange#1#2{% |
| 546 |
\number#1#2% |
| 547 |
} |
| 548 |
% \end{macrocode} |
| 549 |
% \end{macro} |
| 550 |
% |
| 551 |
|
| 552 |
% \begin{macrocode} |
| 553 |
\DeclareOption{showrangeerrors}{% |
| 554 |
\def\ns@numoutofrange#1#2{% |
| 555 |
\PackageError{zahl2string}{The number `#1' is too large % |
| 556 |
to be formatted using zahl2string}{The largest possible % |
| 557 |
number is 999,999,999.} |
| 558 |
}% |
| 559 |
} |
| 560 |
% \end{macrocode} |
| 561 |
% |
| 562 |
% |
| 563 |
% |
| 564 |
% \begin{macrocode} |
| 565 |
\ProcessOptions\relax |
| 566 |
% \end{macrocode} |
| 567 |
% |
| 568 |
% |
| 569 |
% |
| 570 |
% \subsection{Internal macros} |
| 571 |
% |
| 572 |
% \subsubsection{Splitting and formatting a number} |
| 573 |
% |
| 574 |
% \begin{macro}{\ns@numstr} |
| 575 |
% |
| 576 |
% Base macro for formatting a number. |
| 577 |
% |
| 578 |
% Usage: |\ns@numstr| \marg{number} \marg{macro} \marg{nullvalue} |
| 579 |
% \marg{suffix}, where \meta{macro} is the macro to use for the |
| 580 |
% numbers between |1| and |19|, as these require some special |
| 581 |
% treatment, \meta{nullvalue} is the value this macro expands to when |
| 582 |
% \meta{number} is zero, and \meta{suffix} is text added as a suffix |
| 583 |
% to a number larger than 999,999,999. |
| 584 |
% |
| 585 |
% \changes{1.1}{2004/08/08}{Macro added} |
| 586 |
% |
| 587 |
% \begin{macrocode} |
| 588 |
\def\ns@numstr#1#2#3#4{% |
| 589 |
\ifnum\number#1<\@ne% |
| 590 |
#3% |
| 591 |
\else\ifnum\number#1<1000000000 % |
| 592 |
\expandafter\ns@numstring\expandafter{\number#1}#2% |
| 593 |
\else% |
| 594 |
\ns@numoutofrange{#1}{#4}% |
| 595 |
\fi\fi% |
| 596 |
} |
| 597 |
% \end{macrocode} |
| 598 |
% \end{macro} |
| 599 |
% |
| 600 |
% |
| 601 |
% \begin{macro}{\ns@numstring} |
| 602 |
% |
| 603 |
% \changes{1.1}{2004/08/14}{Reimplemented to avoid using up TeX's |
| 604 |
% space for control sequences} |
| 605 |
% |
| 606 |
% Formats a number as words. |
| 607 |
% |
| 608 |
% Usage: |\ns@numstring| \marg{number} \marg{macro}, where |
| 609 |
% \meta{macro} is the macro to use for the numbers between |1| and |
| 610 |
% |19|, as these require some special treatment. |
| 611 |
% |
| 612 |
% \emph{Note: \meta{number} must be a real number consisting of digits |
| 613 |
% in the range 0 to 9! It must not be a \TeX\ count register!} |
| 614 |
% |
| 615 |
% How does this work? Modulo operations are not trivial in \TeX\ as in |
| 616 |
% order to achieve $a \bmod b$ you have to calculate $a - (a \div b) |
| 617 |
% \times b$. This is complicated and also not expandable, so another |
| 618 |
% solution has to be found. |
| 619 |
% |
| 620 |
% \TeX's capabilities of parsing text using macro arguments are fairly |
| 621 |
% strong, so why not use them? It would be much easier if it would be |
| 622 |
% possible of defining a macro with, say, six parameters, where each |
| 623 |
% parameter is one digit of the number to be formatted. Then it would |
| 624 |
% be possible to directly access each digit (or several digits |
| 625 |
% combined by grouping several parameters) without having to perform |
| 626 |
% lengthy modulo calculations. |
| 627 |
% |
| 628 |
% Adding leading zeros to a number is easily done by comparing it |
| 629 |
% using |\ifnum| and adding zeros if the number is too small. However, |
| 630 |
% the macro must not receive the |\ifnum| et.al. tokens as a |
| 631 |
% parameter, but the result of the expansion, that is the number with |
| 632 |
% leading zeros. |
| 633 |
% |
| 634 |
% |\expandafter| would not suffice, as it expands a macro only once, |
| 635 |
% not fully. |\edef| would accomplish the task at hand, however |
| 636 |
% |\edef| is not fully expandable. |
| 637 |
% |
| 638 |
% So what do we do? We take advantage of the fact that when expanding |
| 639 |
% an |\ifcase|, \TeX\ goes on expanding until it has made sure that |
| 640 |
% the number for the |\ifcase| is complete. So immediately after the |
| 641 |
% |\ifcase| we launch into several nested |\ifnum|s, which \TeX\ |
| 642 |
% expands dutifully in order to determine the number to use. |
| 643 |
% |
| 644 |
% What these nested |\ifnum|s do is the following: Depending on the |
| 645 |
% length of \meta{number}, they expand to a digit between one and |
| 646 |
% nine, one being the digit if \meta{number} is less than 10 and nine |
| 647 |
% being the digit if \meta{number} is larger than 99,999,999. |
| 648 |
% |
| 649 |
% Then \TeX\ uses this digit between one and nine to jump to the |
| 650 |
% appropriate part of the |\ifcase|-clause. There \meta{number} is |
| 651 |
% prefixed with the necessary amount of zeros to result in a number |
| 652 |
% exactly nine digits long: For the digit one (resulting from the |
| 653 |
% nested |\ifnum|s), eight leading zeros have to be prefixed, as |
| 654 |
% \meta{number} is only one digit long, for the digit two, seven zeros |
| 655 |
% are prefixed, as \meta{number} is less than 100 (but more than 9) et |
| 656 |
% cetera, until for digit nine no zeros have to be prefixed, as |
| 657 |
% \meta{number} is already nine digits long. |
| 658 |
% |
| 659 |
% Let's have an example: Suppose \meta{number} is 42. Then the result |
| 660 |
% of the nested |\ifnum|s is 2, as \meta{number} is not less than 10 |
| 661 |
% but less than 100 (the second |\ifnum| is true). This 2 leads to |
| 662 |
% jumping to part after the second |\or| (before the first |\or| is |
| 663 |
% the part for the number 0, in this case left blank, and after the |
| 664 |
% first |\or| for the number 1), which is |0000000#1|. |#1| is 42. So |
| 665 |
% the result is: |000000042|, a number prefixed with leading zeros and |
| 666 |
% exactly nine digits long. |
| 667 |
% |
| 668 |
% Another example: Suppose \meta{number} is 12,345,678. Then the |
| 669 |
% result of the nested |\ifnum|s is 8, as the eigths |\ifnum| is true |
| 670 |
% (less than 100,000,000 but not less than 10,000,000). Then only one |
| 671 |
% zero is prefixed, resulting in |012345678|. |
| 672 |
% |
| 673 |
% However, we are not finished yet, as \TeX\ does not expand further. |
| 674 |
% So we are left (picking up the second example above) with this: |
| 675 |
% |012345678\or12345678\or| (the second incarnation of |12345678| is |
| 676 |
% due to the ninth part of the |\ifcase| clause, |\or#1|). |
| 677 |
% |
| 678 |
% We do not need all this |\or| baggage, we only want the number. But |
| 679 |
% \TeX\ is good at matching text using macros with delimited |
| 680 |
% parameters, so we just define |\ns@@numstring| in a way that gobbles |
| 681 |
% up the first |\or| and whatever follows. |
| 682 |
% |
| 683 |
% And we are done: We have a number padded perfectly with leading |
| 684 |
% zeros to a length of nine digits! |
| 685 |
% |
| 686 |
% \paragraph{Implementation note} In Version 1.0, we used |\csname| |
| 687 |
% \ldots\ |\endcsname| to add the leading zeros, as |\csname| \ldots\ |
| 688 |
% |\endcsname| expands everything inbetween until only unexpandable |
| 689 |
% tokens remain, in this case digits (the |\ifnum|s are expanded). |
| 690 |
% Afterwards, the resulting control sequence was converted into |
| 691 |
% separate tokens using |\string| and finally, the backslash at the |
| 692 |
% beginning was gobbled by |\ns@@numstring| as its first (and unused) |
| 693 |
% argument. |
| 694 |
% |
| 695 |
% Unfortunately, this had its price: For every number we formatted |
| 696 |
% using |\ns@numstring| and that had not been formatted before, a new |
| 697 |
% entry was inserted into the hash table \TeX\ uses to store all |
| 698 |
% control sequences. So if you had a document where you formatted a |
| 699 |
% lot of numbers this way, you would run out of hash table space, and |
| 700 |
% \TeX\ would complain. (The number of hash table entries used is |
| 701 |
% indicated in the |log|-file as `multiletter control sequences'.) |
| 702 |
% |
| 703 |
% This was less than optimal, so we changed the implementation to this |
| 704 |
% |\ifcase|-|\ifnum| construct. |
| 705 |
% |
| 706 |
% \begin{macrocode} |
| 707 |
\def\ns@numstring#1#2{% |
| 708 |
\expandafter\ns@@numstring% |
| 709 |
\ifcase% |
| 710 |
\ifnum#1<10 1% |
| 711 |
% \end{macrocode} |
| 712 |
% |
| 713 |
% Why are the constants predefined by the \LaTeX-kernel used instead |
| 714 |
% of numbers? Because they save tokens: |1000| are four tokens, |\@m| |
| 715 |
% is only one. |
| 716 |
% |
| 717 |
% \begin{macrocode} |
| 718 |
\else\ifnum#1<100 2% |
| 719 |
\else\ifnum#1<\@m 3% |
| 720 |
\else\ifnum#1<\@M 4% |
| 721 |
\else\ifnum#1<100000 5% |
| 722 |
\else\ifnum#1<1000000 6% |
| 723 |
\else\ifnum#1<10000000 7% |
| 724 |
\else\ifnum#1<100000000 8% |
| 725 |
\else9% |
| 726 |
\fi\fi\fi\fi\fi\fi\fi\fi % |
| 727 |
\or00000000#1% case 1: Add 8 leading zeros |
| 728 |
\or0000000#1% case 2: Add 7 leading zeros |
| 729 |
\or000000#1% case 3: Add 6 leading zeros |
| 730 |
\or00000#1% case 4: Add 5 leading zeros |
| 731 |
\or0000#1% case 5: Add 4 leading zeros |
| 732 |
\or000#1% case 6: Add 3 leading zeros |
| 733 |
\or00#1% case 7: Add 2 leading zeros |
| 734 |
\or0#1% case 8: Add 1 leading zero |
| 735 |
\or#1% case 9: Add no leading zeros |
| 736 |
% \end{macrocode} |
| 737 |
% |
| 738 |
% The next |\or| is only necessary because |\ns@@numstring| needs an |
| 739 |
% |\or| as a delimiter of the number: |
| 740 |
% |
| 741 |
% \begin{macrocode} |
| 742 |
\or% |
| 743 |
% \end{macrocode} |
| 744 |
% |
| 745 |
% The last parameter to |\ns@@numstring| is \meta{macro}; we delimit |
| 746 |
% it using |\@nil|: |
| 747 |
% |
| 748 |
% \begin{macrocode} |
| 749 |
\@nil#2% |
| 750 |
% \end{macrocode} |
| 751 |
% |
| 752 |
% Finally we end the |\ifcase| (note that this is \emph{after} the |
| 753 |
% number has been formatted): |
| 754 |
% |
| 755 |
% \begin{macrocode} |
| 756 |
\fi% |
| 757 |
} |
| 758 |
% \end{macrocode} |
| 759 |
% |
| 760 |
% \end{macro} |
| 761 |
% |
| 762 |
% |
| 763 |
% \begin{macro}{\ns@@numstring} |
| 764 |
% |
| 765 |
% Expands to a number in words between |1| and |999,999,999|. |
| 766 |
% |
| 767 |
% Usage: |\ns@@numstring| \marg{9. digit} \marg{8. digit} \marg{7. |
| 768 |
% digit} \marg{6. digit} \marg{5. digit} \marg{4. digit} \marg{3rd - |
| 769 |
% 1st digit} \marg{(ignored)} \marg{macro}, where \meta{macro} is, as |
| 770 |
% is the case with |\ns@numstring|, the macro to use for the numbers |
| 771 |
% between |1| and |19|, as these require some special treatment. |
| 772 |
% |
| 773 |
% |\or| and the following |#8| (\meta{ignored}) gobble up whatever was |
| 774 |
% left from the expansion of |\ifcase| in |\ns@numstring|. |\@nil| |
| 775 |
% acts as a delimiter for the last parameter, \meta{macro}. |
| 776 |
% |
| 777 |
% \changes{1.1}{2004/08/08}{Formatting of millions added.} |
| 778 |
% \changes{1.1}{2004/08/14}{Changed to match reeimplementation of |
| 779 |
% ns@numstring.} |
| 780 |
% |
| 781 |
% \begin{macrocode} |
| 782 |
\def\ns@@numstring#1#2#3#4#5#6#7\or#8\@nil#9{% |
| 783 |
\ifnum#1#2#3>\z@ |
| 784 |
\ns@million#1#2#3% |
| 785 |
% \end{macrocode} |
| 786 |
% |
| 787 |
% We insert a space if a number follows: |
| 788 |
% |
| 789 |
% \begin{macrocode} |
| 790 |
\ifnum#4#5#6>\z@\space\fi% |
| 791 |
\fi% |
| 792 |
\ifnum#4#5#6>\z@% |
| 793 |
\ns@hundred#4#5#6{#1#2#3}{#4#5}\ns@neunzehn% |
| 794 |
% \end{macrocode} |
| 795 |
% |
| 796 |
% If there has been a number larger than one before the `tausend', |
| 797 |
% insert a discretionary hyphen before: |
| 798 |
% |
| 799 |
% \begin{macrocode} |
| 800 |
\ifnum#4#5#6>\@ne\-\fi% |
| 801 |
tau\-send% |
| 802 |
% \end{macrocode} |
| 803 |
% |
| 804 |
% If there will be a number after the `tausend', insert a |
| 805 |
% discretionary hyphen after: |
| 806 |
% |
| 807 |
% \begin{macrocode} |
| 808 |
\ifnum#7>\z@\-\fi% |
| 809 |
\fi% |
| 810 |
\ns@hundred#7{#4#5#6}1#9% |
| 811 |
} |
| 812 |
% \end{macrocode} |
| 813 |
% |
| 814 |
% \end{macro} |
| 815 |
% |
| 816 |
% |
| 817 |
% \begin{macro}{\ns@million} |
| 818 |
% |
| 819 |
% Expands to millions. |
| 820 |
% |
| 821 |
% Usage: |\ns@million| \marg{third digit} \marg{second digit} |
| 822 |
% \marg{first digit}. |
| 823 |
% |
| 824 |
% \changes{1.1}{2004/08/08}{Macro added.} |
| 825 |
% |
| 826 |
% \begin{macrocode} |
| 827 |
\def\ns@million#1#2#3{% |
| 828 |
\ifnum#1#2#3=\@ne% |
| 829 |
\ns@hundred#1#2#301\ns@neunzehne% |
| 830 |
\space% |
| 831 |
Mil\-lion% |
| 832 |
\else% |
| 833 |
\ns@hundred#1#2#301\ns@neunzehns% |
| 834 |
\space% |
| 835 |
Mil\-lio\-nen% |
| 836 |
\fi% |
| 837 |
} |
| 838 |
% \end{macrocode} |
| 839 |
% \end{macro} |
| 840 |
% |
| 841 |
% |
| 842 |
% \begin{macro}{\ns@hundred} |
| 843 |
% |
| 844 |
% Expands to a number in words between |1| and |100|. |
| 845 |
% |
| 846 |
% Usage: |\ns@hundred| \marg{third digit} \marg{second digit} |
| 847 |
% \marg{first digit} \marg{shownumber} \marg{showone} |
| 848 |
% \marg{macro}. |
| 849 |
% |
| 850 |
% \meta{shownumber} defines if the number before the |hundert| |
| 851 |
% (`hundred') should be shown, i.e. |einhundert| (`onehundred') |
| 852 |
% instead of |hundert|. |0| is |false|, everything else |true|. |
| 853 |
% Can contain more than one digit. |
| 854 |
% |
| 855 |
% \meta{showone} defines if \meta{macro} should be called for the |
| 856 |
% number |1|. |0| is |false|, everything else |true|. Can contain more |
| 857 |
% than one digit. |
| 858 |
% |
| 859 |
% What does all this code do? First the third digit (`hundred'), |
| 860 |
% contained in |#1|, is expanded -- if it is not zero. However, there |
| 861 |
% is a catch: If the third digit is one, this digit is only included |
| 862 |
% in the result of this macro if |#4| says so. The reason is that |
| 863 |
% normally you would say |hunderteins| (`101') instead of |
| 864 |
% |einhunderteins| -- but not if there is a fourth digit. Then the |
| 865 |
% digit has to be included in the output of the macro, i.e. |
| 866 |
% |tausendeinhunderteins| |
| 867 |
% |
| 868 |
% So we want to include the digit in the output of the macro, if |#3| |
| 869 |
% is larger than one \emph{or} |#4| is larger than zero. We could use |
| 870 |
% two |\ifnum|s to accomplish this, but it can be combined into a |
| 871 |
% single |\ifnum|, saving tokens and time: |
| 872 |
% |
| 873 |
% We check if |#4#1| is larger than one. That means that if |#1|, the |
| 874 |
% third digit, is larger than one, it is included in the output. But |
| 875 |
% that also means that if |#4| is not zero, |#4#1| is always at least |
| 876 |
% |10|, which is also larger than one and exactly what we want. |
| 877 |
% |
| 878 |
% After successfully processing the third digit, the remaining last |
| 879 |
% two digits (|#2| and |#3|) are not really complicated anymore. We |
| 880 |
% perform some special treatment of the numbers between |1| and |19| |
| 881 |
% as these numbers are not constructed systematically. Here we have to |
| 882 |
% perform a check similar to the one performed for the third digit: We |
| 883 |
% have to check if we have to output the number if it is |1|, using |
| 884 |
% the same trick for a logical |or| as before, only this time with |
| 885 |
% |#5|, |#2| and |#3|. |
| 886 |
% |
| 887 |
% The macro to output |1| to |19| is parametrized as |#6| in order to |
| 888 |
% be able to use different macros for normal numbers and ordinal |
| 889 |
% numbers. |
| 890 |
% |
| 891 |
% If the last two digits are larger than |19|, we first output the |
| 892 |
% third digit using |\ns@neunzehn|, followed by |und| (`and') and then |
| 893 |
% the second digit. Here we don't have to use the parametrized macro |
| 894 |
% as before, as the ordinal suffix is appended at the end of the |
| 895 |
% number, not inbetween. |
| 896 |
% |
| 897 |
% But where to get the suffix from? We could pass it as a macro, but |
| 898 |
% that would be tedious. So we simply define the macro to output the |
| 899 |
% numbers |1| to |19| (|\ns@neunzehns| for normal numbers and |
| 900 |
% |\ns@neunzehnord| for ordinal numbers) to output the suffix if |
| 901 |
% called with |0| as its parameter. |
| 902 |
% |
| 903 |
% And we are done! |
| 904 |
% |
| 905 |
% \begin{macrocode} |
| 906 |
\def\ns@hundred#1#2#3#4#5#6{% |
| 907 |
% \end{macrocode} |
| 908 |
% |
| 909 |
% We expand the third digit: |
| 910 |
% |
| 911 |
% \begin{macrocode} |
| 912 |
\ifnum#1>\z@% |
| 913 |
% \end{macrocode} |
| 914 |
% |
| 915 |
% Logical |OR| hidden in |#4#1| (see above): |
| 916 |
% |
| 917 |
% \begin{macrocode} |
| 918 |
\ifnum#4#1>\@ne\ns@neunzehn#1\-\fi% |
| 919 |
hun\-dert% |
| 920 |
% \end{macrocode} |
| 921 |
% |
| 922 |
% We insert a discretionary hyphen, if a number follows: |
| 923 |
% |
| 924 |
% \begin{macrocode} |
| 925 |
\ifnum#2#3>\z@\-\fi% |
| 926 |
\fi% |
| 927 |
% \end{macrocode} |
| 928 |
% |
| 929 |
% We expand the first an second digit: |
| 930 |
% |
| 931 |
% \begin{macrocode} |
| 932 |
\ifnum#2#3<20 % |
| 933 |
% \end{macrocode} |
| 934 |
% |
| 935 |
% Again: Logical |OR| in |#5#2#3|: |
| 936 |
% |
| 937 |
% \begin{macrocode} |
| 938 |
\ifnum#5#2#3>\@ne#6{#2#3}\fi% |
| 939 |
\else% |
| 940 |
\ifnum#3>\z@\ns@neunzehn#3\-und\-\fi% |
| 941 |
\ns@neunzig#2% |
| 942 |
#60% |
| 943 |
\fi% |
| 944 |
} |
| 945 |
% \end{macrocode} |
| 946 |
% |
| 947 |
% \end{macro} |
| 948 |
% |
| 949 |
% |
| 950 |
% \subsubsection{Macros for formatting `1' to `19'}\label{sec:LabFor} |
| 951 |
% |
| 952 |
% Very important: The position for |0| must expand to the suffix of |
| 953 |
% the number (\emph{any number}), see the explanations for |
| 954 |
% |\ns@hundred| above. If it expands to a text (as opposed to |
| 955 |
% |\@empty|), this text must be prefixed by a discretionary hyphen! |
| 956 |
% |
| 957 |
% |
| 958 |
% \begin{macro}{\ns@neunzehn} |
| 959 |
% |
| 960 |
% Expands to |ein| (`1') to |neunzehn| (`19'). |
| 961 |
% |
| 962 |
% \changes{1.1}{2004/08/08}{Hyphenation added.} |
| 963 |
% |
| 964 |
% \begin{macrocode} |
| 965 |
\def\ns@neunzehn#1{% |
| 966 |
\ifcase#1\@empty\or ein\or zwei\or drei\or vier\or f\"unf\or sechs\or% |
| 967 |
sie\-ben\or acht\or neun\or zehn\or elf\or zw\"olf\or drei\-zehn\or% |
| 968 |
vier\-zehn\or f\"unf\-zehn\or sech\-zehn\or sieb\-zehn\or% |
| 969 |
acht\-zehn\or neun\-zehn\fi% |
| 970 |
} |
| 971 |
% \end{macrocode} |
| 972 |
% |
| 973 |
% \end{macro} |
| 974 |
% |
| 975 |
% |
| 976 |
% \begin{macro}{\ns@neunzehns} |
| 977 |
% |
| 978 |
% Expands to |eins| (`1') to |neunzehn| (`19'). |0| expands to |
| 979 |
% |\@empty|. |
| 980 |
% |
| 981 |
% Why |\@empty| instead of nothing? Because then \TeX\ would insert a |
| 982 |
% |\relax| before the first |\or| in order to finish expansion of the |
| 983 |
% number. This |\relax| would remain in the output and would stay |
| 984 |
% there even when |\edef|ed, whereas |\@empty| expands to nothing. |
| 985 |
% |
| 986 |
% This is necessary for |\Numstring| and |\Ordstring|, as they convert |
| 987 |
% the first token of the |\edef|ed result of |\numstring| and |
| 988 |
% |\ordstring| to uppercase, and they need this token to be the first |
| 989 |
% letter of the number, not |\relax|. |
| 990 |
% |
| 991 |
% \begin{macrocode} |
| 992 |
\def\ns@neunzehns#1{% |
| 993 |
\ifcase#1\@empty\or eins\else\ns@neunzehn{#1}\fi% |
| 994 |
} |
| 995 |
% \end{macrocode} |
| 996 |
% |
| 997 |
% \end{macro} |
| 998 |
% |
| 999 |
% |
| 1000 |
\def\ns@neunzehne#1{% |
| 1001 |
\ifcase#1\@empty\or ei\-ne\else\ns@neunzehn{#1}\fi% |
| 1002 |
} |
| 1003 |
% |
| 1004 |
% |
| 1005 |
% \begin{macro}{\ns@neunzehnord} |
| 1006 |
% |
| 1007 |
% Expands to |erste| (`1st') to |neunzehnte| (`19th'). |0| expands to |
| 1008 |
% |ste|. |
| 1009 |
% |
| 1010 |
% \changes{1.1}{2004/08/08}{Hyphenation added.} |
| 1011 |
% |
| 1012 |
% \begin{macrocode} |
| 1013 |
\def\ns@neunzehnord#1{% |
| 1014 |
\ifcase#1\-ste\or er\-ste\or zwei\-te\or drit\-te\or vier\-te\or% |
| 1015 |
f\"unf\-te\or sech\-ste\or sieb\-te\or ach\-te\or neun\-te\or% |
| 1016 |
zehn\-te\or elf\-te\or zw\"olf\-te\or drei\-zehn\-te\or% |
| 1017 |
vier\-zehn\-te\or f\"unf\-zehn\-te\or sech\-zehn\-te\or% |
| 1018 |
sieb\-zehn\-te\or acht\-zehn\-te\or neun\-zehn\-te\fi% |
| 1019 |
} |
| 1020 |
% \end{macrocode} |
| 1021 |
% |
| 1022 |
% \end{macro} |
| 1023 |
% |
| 1024 |
% |
| 1025 |
% \begin{macro}{\ns@neunzig} |
| 1026 |
% |
| 1027 |
% Expands to |zwanzig| (twenty) to |neunzig| (ninety) in steps of ten. |
| 1028 |
% |
| 1029 |
% \changes{1.1}{2004/08/08}{Hyphenation added.} |
| 1030 |
% |
| 1031 |
% \begin{macrocode} |
| 1032 |
\def\ns@neunzig#1{% |
| 1033 |
\ifcase#1\or\or zwan\-zig\or drei\ss ig\or vier\-zig\or% |
| 1034 |
f\"unf\-zig\or sech\-zig\or sieb\-zig\or acht\-zig\or% |
| 1035 |
neun\-zig\fi% |
| 1036 |
} |
| 1037 |
% \end{macrocode} |
| 1038 |
% |
| 1039 |
% \end{macro} |
| 1040 |
% |
| 1041 |
% \Finale |
| 1042 |
% \PrintChanges |
| 1043 |
% \PrintIndex |
| 1044 |
\endinput |