| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2012-2013 by Robin Schneider <[email protected]> |
| 4 |
% |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
% of this license or (at your option) any later version. |
| 8 |
% The latest version of this license is in |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
% version 2005/12/01 or later. |
| 12 |
% |
| 13 |
% The Current Maintainer of this work is Robin Schneider. |
| 14 |
% |
| 15 |
% This work consists of the files fnumprint.dtx and fnumprint.ins |
| 16 |
% and the derived filebase fnumprint.sty. |
| 17 |
% |
| 18 |
% \fi |
| 19 |
% |
| 20 |
% \iffalse |
| 21 |
%<*driver> |
| 22 |
\ProvidesFile{fnumprint.dtx} |
| 23 |
%</driver> |
| 24 |
%<package>%% See file 'fnumprint.dtx' for copyright and licence. |
| 25 |
%<package>\NeedsTeXFormat{LaTeX2e}[1998/12/01] |
| 26 |
%<package>\ProvidesPackage{fnumprint} |
| 27 |
%<*package> |
| 28 |
[2012/08/27 v1.1a Printing fancy numbers] |
| 29 |
%</package> |
| 30 |
% |
| 31 |
%<*driver> |
| 32 |
\documentclass[english]{ltxdoc} |
| 33 |
\newcommand{\PackageURL}{https://github.com/ypid/latex-packages/tree/master/fnumprint} |
| 34 |
\newcommand{\PackageCTANURL}{http://www.ctan.org/pkg/fnumprint} |
| 35 |
\newcommand{\PackageAuthor}{Robin Schneider} |
| 36 |
\newcommand{\PackageAuthorEmail}{[email protected]} |
| 37 |
\newcommand{\PackageName}{\PrintPackage{fnumprint}} |
| 38 |
\newcommand{\PrintPackage}[1]{\textsf{#1}} |
| 39 |
\usepackage{fnumprint} |
| 40 |
\usepackage{ |
| 41 |
babel, |
| 42 |
csquotes, |
| 43 |
xcolor, |
| 44 |
url, |
| 45 |
hypdoc, |
| 46 |
} |
| 47 |
\GetFileInfo{fnumprint.dtx} |
| 48 |
\hypersetup{ |
| 49 |
pdftitle={A manual for \PackageName}, |
| 50 |
pdfauthor={\PackageAuthor{} <\PackageAuthorEmail>}, |
| 51 |
pdfsubject={\fileinfo}, |
| 52 |
baseurl={\PackageURL}, |
| 53 |
pdfkeywords={This document corresponds to \PackageName~\fileversion, |
| 54 |
dated \filedate} |
| 55 |
} |
| 56 |
|
| 57 |
\title{The \PackageName{} package\thanks{This document |
| 58 |
corresponds to \PackageName~\fileversion, dated \filedate.}} |
| 59 |
\author{\PackageAuthor \\ |
| 60 |
\texttt{\href{mailto:\PackageAuthorEmail?subject=LaTeX package fnumprint% |
| 61 |
\&body=Dear Robin Schneider,}% |
| 62 |
{\PackageAuthorEmail}% |
| 63 |
}% |
| 64 |
} |
| 65 |
|
| 66 |
\EnableCrossrefs |
| 67 |
\CodelineIndex |
| 68 |
\RecordChanges |
| 69 |
\begin{document} |
| 70 |
\DocInput{fnumprint.dtx} |
| 71 |
\PrintChanges |
| 72 |
\PrintIndex |
| 73 |
\end{document} |
| 74 |
%</driver> |
| 75 |
% \fi |
| 76 |
% |
| 77 |
% \CheckSum{101} |
| 78 |
% \CharacterTable |
| 79 |
% {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 |
| 80 |
% 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 |
| 81 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 82 |
% Exclamation \! Double quote \" Hash (number) \# |
| 83 |
% Dollar \$ Percent \% Ampersand \& |
| 84 |
% Acute accent \' Left paren \( Right paren \) |
| 85 |
% Asterisk \* Plus \+ Comma \, |
| 86 |
% Minus \- Point \. Solidus \/ |
| 87 |
% Colon \: Semicolon \; Less than \< |
| 88 |
% Equals \= Greater than \> Question mark \? |
| 89 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 90 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 91 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 92 |
% Right brace \} Tilde \~} |
| 93 |
% |
| 94 |
% \changes{v0.1}{2011/06/12}{Initial version} %% ^^A date guessed |
| 95 |
% \changes{v1.0}{2012/08/22}{Wrote this documentation and the \LaTeX{}-package |
| 96 |
% and added support for English} |
| 97 |
% \changes{v1.1}{2012/08/27}{Added optional parameter \enquote{ein}} |
| 98 |
% \changes{v1.1a}{2012/08/27}{Added support for real numbers} |
| 99 |
% |
| 100 |
% \DoNotIndex{\RequirePackage, \DeclareOption, \ProcessOptions} |
| 101 |
% \DoNotIndex{\PackageWarning, \MessageBreak} |
| 102 |
% \DoNotIndex{\DeclareRobustCommand, \newcommand, \renewcommand} |
| 103 |
% \DoNotIndex{\newenvironment} |
| 104 |
% \DoNotIndex{\if, \else, \fi, \ifcase, \or, \ifthenelse, \AND, \value, \relax} |
| 105 |
% \DoNotIndex{\equal, \@currname, \newcounter, \setcounter, \(, \), \NOT, \OR} |
| 106 |
% \DoNotIndex{\endinput} |
| 107 |
% |
| 108 |
% \maketitle |
| 109 |
% |
| 110 |
% \phantomsection |
| 111 |
% \addcontentsline{toc}{section}{\abstractname} |
| 112 |
% \begin{abstract} |
| 113 |
% The \PrintPackage{fnumprint} package can decide to typeset a |
| 114 |
% number either as number or as word name (only in English or German). \\ |
| 115 |
% Information site on CTAN: \url{\PackageCTANURL} \\ |
| 116 |
% Fork me on GitHub: \url{\PackageURL} \end{abstract} |
| 117 |
% |
| 118 |
% \tableofcontents |
| 119 |
% |
| 120 |
% \section{Introduction} |
| 121 |
% The \PackageName{} package defines two macros which decide to |
| 122 |
% typeset a number either as Arabic number or as word name for the number. If |
| 123 |
% the number is between zero and twelve (including zero and twelve) then the |
| 124 |
% word name will be used. This package uses the \PrintPackage{zahl2string} |
| 125 |
% package to convert a number in the word name in German. The conversion of a |
| 126 |
% number (0--12) to the English word name is implemented by this package. If |
| 127 |
% the number is outside of the range then it will be typesetted with the |
| 128 |
% \PrintPackage{numprint} package. |
| 129 |
% |
| 130 |
% \section{Usage} |
| 131 |
% Just load the package placing |
| 132 |
% \begin{quote} |
| 133 |
% |\usepackage{fnumprint}| |
| 134 |
% \end{quote} |
| 135 |
% in the preamble of your \LaTeXe{} source file. In this case the last by |
| 136 |
% \PackageName{} supported language given as class option will be |
| 137 |
% used. You can overwrite this with a package option like |
| 138 |
% this: |
| 139 |
% \begin{quote} |
| 140 |
% |\usepackage[english]{fnumprint}| |
| 141 |
% \end{quote} |
| 142 |
% |
| 143 |
% \DescribeMacro{\fnumprintc} |
| 144 |
% The macro |\fnumprintc| \oarg{eins} \marg{\LaTeX{} counter name} takes a |
| 145 |
% name of a LaTeX counter as not optional parameter and typesets it's |
| 146 |
% value. The optional parameter is only active if the German language was |
| 147 |
% selected. In this case it can be used to typeset \enquote{ein} instead of |
| 148 |
% \enquote{eins}. This is for example necessary if you would like to typeset |
| 149 |
% \enquote{ein Jahr}. |
| 150 |
% |
| 151 |
% \DescribeMacro{\fnumprint} |
| 152 |
% The macro |\fnumprint| \oarg{eins} \marg{number} is like the |\fnumprintc| |
| 153 |
% macro but it takes a number or a macro that expands to a number. A \TeX{} |
| 154 |
% counter can also be used with this macro. |
| 155 |
% |
| 156 |
% \section{Examples} |
| 157 |
% \begin{tabular}{ll} |
| 158 |
% \textbf{macro} & \textbf{expanded macro} \\ |
| 159 |
% |\fnumprint{-1}| & \fnumprint{-1} \\ |
| 160 |
% |\fnumprint{0}| & \fnumprint{0} \\ |
| 161 |
% |\fnumprint{1}| & \fnumprint{1} \\ |
| 162 |
% |\fnumprint{3.14}| & \fnumprint{3.14} \\ |
| 163 |
% |\fnumprint{10}| & \fnumprint{10} \\ |
| 164 |
% |\fnumprint{12}| & \fnumprint{12} \\ |
| 165 |
% |\fnumprint{13}| & \fnumprint{13} \\ |
| 166 |
% |\fnumprint{\the\month}| & \fnumprint{\the\month} \\ |
| 167 |
% |\fnumprint{\the\day}| & \fnumprint{\the\day} \\ |
| 168 |
% |\fnumprintc{page}| & \fnumprintc{page} \\ |
| 169 |
% \end{tabular} |
| 170 |
% |
| 171 |
% \section{ToDo} |
| 172 |
% Here are some things that could be useful. |
| 173 |
% \begin{itemize} |
| 174 |
% \item Provide more features implemented by the \PrintPackage{zahl2string} |
| 175 |
% package and create macros which implement these features for the |
| 176 |
% English language. |
| 177 |
% \end{itemize} |
| 178 |
% |
| 179 |
% \StopEventually{} |
| 180 |
% |
| 181 |
% \section{Implementation} |
| 182 |
% \iffalse |
| 183 |
%<*package> |
| 184 |
% \fi |
| 185 |
% This package depends on these packages. |
| 186 |
% \begin{macrocode} |
| 187 |
\RequirePackage{xifthen} |
| 188 |
\RequirePackage[autolanguage]{numprint} |
| 189 |
% \end{macrocode} |
| 190 |
% \subsection{Language checking} |
| 191 |
% I used the counter |fnumprint@language| to save the (last) selected language. |
| 192 |
% Meaning from the counter values: |
| 193 |
% |
| 194 |
% \begin{tabular}{rl} |
| 195 |
% \textbf{value} & \textbf{meaning} \\ |
| 196 |
% 0 & no supported language selected \\ |
| 197 |
% 1 & German selected \\ |
| 198 |
% 2 & English selected \\ |
| 199 |
% \end{tabular} |
| 200 |
% \begin{macrocode} |
| 201 |
\newcounter{fnumprint@language} |
| 202 |
\setcounter{fnumprint@language}{0} |
| 203 |
\DeclareOption{german}{\setcounter{fnumprint@language}{1}} |
| 204 |
\DeclareOption{ngerman}{\setcounter{fnumprint@language}{1}} |
| 205 |
\DeclareOption{english}{\setcounter{fnumprint@language}{2}} |
| 206 |
\DeclareOption{USenglish}{\setcounter{fnumprint@language}{2}} |
| 207 |
\DeclareOption{american}{\setcounter{fnumprint@language}{2}} |
| 208 |
\DeclareOption{UKenglish}{\setcounter{fnumprint@language}{2}} |
| 209 |
\DeclareOption{british}{\setcounter{fnumprint@language}{2}} |
| 210 |
\DeclareOption{canadian}{\setcounter{fnumprint@language}{2}} |
| 211 |
\DeclareOption{australian}{\setcounter{fnumprint@language}{2}} |
| 212 |
\DeclareOption{newzealand}{\setcounter{fnumprint@language}{2}} |
| 213 |
\ProcessOptions\relax |
| 214 |
% \end{macrocode} |
| 215 |
% If none of the supported languages was selected a package warning will appear. |
| 216 |
% \begin{macrocode} |
| 217 |
\ifcase\value{fnumprint@language} |
| 218 |
\PackageWarning{\@currname}{No supported language selected |
| 219 |
\MessageBreak |
| 220 |
This package supports only English and German |
| 221 |
\MessageBreak |
| 222 |
There will be no word names printed} |
| 223 |
% \end{macrocode} |
| 224 |
% The zahl2string package will only be loaded if it is necessary. |
| 225 |
% \begin{macrocode} |
| 226 |
\or |
| 227 |
\RequirePackage{zahl2string} |
| 228 |
% \end{macrocode} |
| 229 |
% \begin{macro}{\ns@en@neunzehn} |
| 230 |
% This internal marco expands to the English word name for a number. |
| 231 |
% It only goes from 0 to 19. It will only be defined if it is necessary. |
| 232 |
% \begin{macrocode} |
| 233 |
\or |
| 234 |
\newcommand{\ns@en@neunzehn}[1]{% |
| 235 |
\ifcase#1 zero\or one\or two\or three\or four\or five\or six\or% |
| 236 |
seven\or eight\or nine\or ten\or eleven\or twelve\or thirteen\or% |
| 237 |
fourteen\or fifteen\or sixteen\or seventeen\or% |
| 238 |
eighteen\or nineteen\fi% |
| 239 |
} |
| 240 |
\fi |
| 241 |
% \end{macrocode} |
| 242 |
% \end{macro} |
| 243 |
% \subsection{Macro definition} |
| 244 |
% \begin{macro}{\fnumprint} |
| 245 |
% Here is the |\fnumprint| macro definition. |
| 246 |
% It takes one not optional parameter. |
| 247 |
% The parameter must be a number or a macro which expands to a number. |
| 248 |
% It can also take a optional parameter which replaces the German word |
| 249 |
% \enquote{eins} with \enquote{ein}. |
| 250 |
% \begin{macrocode} |
| 251 |
\DeclareRobustCommand{\fnumprint}[2][]{% |
| 252 |
\ifthenelse{\NOT \(\isin{,}{#2} \OR \isin{.}{#2} \) |
| 253 |
\AND -1 < #2 \AND #2 < 13}{% |
| 254 |
\ifthenelse{\value{fnumprint@language} = 1}{% |
| 255 |
\ifthenelse{\equal{#1}{ein} \AND #2 = 1}{ein}{\numstr{#2}}% |
| 256 |
}{% |
| 257 |
\ifthenelse{\value{fnumprint@language} = 2}{% |
| 258 |
\ns@en@neunzehn{#2}% |
| 259 |
}{\numprint{#2}}% |
| 260 |
}% |
| 261 |
}{\numprint{#2}}% |
| 262 |
} |
| 263 |
% \end{macrocode} |
| 264 |
% \end{macro} |
| 265 |
% \begin{macro}{\fnumprintc} |
| 266 |
% Here is the |\fnumprintc| macro definition. |
| 267 |
% It takes one not optional parameter. |
| 268 |
% The parameter must be the name of a \LaTeX{} counter. |
| 269 |
% It can also take a optional parameter which replaces the German word |
| 270 |
% \enquote{eins} with \enquote{ein}. |
| 271 |
% \begin{macrocode} |
| 272 |
\DeclareRobustCommand{\fnumprintc}[2][]{% |
| 273 |
\ifthenelse{-1 < \value{#2} \AND \value{#2} < 13}{% |
| 274 |
\ifthenelse{\value{fnumprint@language} = 1}{% |
| 275 |
\ifthenelse{\equal{#1}{ein} \AND \value{#2} = 1}{ein}{\numstring{#2}}}{% |
| 276 |
\ifthenelse{\value{fnumprint@language} = 2}{% |
| 277 |
\ns@en@neunzehn{\value{#2}}% |
| 278 |
}{\cntprint{#2}}% |
| 279 |
}% |
| 280 |
}{\cntprint{#2}}% |
| 281 |
} |
| 282 |
\endinput |
| 283 |
% \end{macrocode} |
| 284 |
% \end{macro} |
| 285 |
% |
| 286 |
% \iffalse |
| 287 |
%</package> |
| 288 |
% \fi |
| 289 |
% |
| 290 |
% \Finale |
| 291 |
\endinput |