Debian Codegraph @

texmf-dist/doc/latex/numspell/numspell.tex

raw
1 %%
2 %% `numspell.tex' documentation of the numspell package
3 %%
4 %% Copyright 2017-2026 by Tibor Tómács
5 %%
6 %% This work may be distributed and/or modified under the
7 %% conditions of the LaTeX Project Public License, either version 1.3
8 %% of this license or (at your option) any later version.
9 %% The latest version of this license is in
10 %% http://www.latex-project.org/lppl.txt
11 %% and version 1.3 or later is part of all distributions of LaTeX
12 %% version 2005/12/01 or later.
13 %%
14 %% This work has the LPPL maintenance status `maintained'.
15 %%
16 %% The Current Maintainer of this work is Tibor Tómács.
17 %%
18 \documentclass[12pt]{article}
19 \usepackage[a4paper,margin=1in]{geometry}
20 \usepackage[pdfstartview=FitH,colorlinks,allcolors=black,bookmarksnumbered,hyperfootnotes=false]{hyperref}
21 \usepackage[T1]{fontenc}
22 \usepackage[magyar,italian,latin,ngerman,french,english]{babel}
23 \usepackage[symbol]{footmisc}
24 \usepackage{numspell,listings,xcolor,amsmath,upquote}
25 \flushbottom
26 \setlength{\labelsep}{0pt}
27 \setlength{\parindent}{0pt}
28 \setlength{\parskip}{6pt}
29
30 \lstnewenvironment{examplelst}{\lstset{
31 aboveskip=\bigskipamount,
32 basicstyle=\ttfamily,
33 backgroundcolor=\color{black!10},
34 frame=trbl,
35 framesep=3pt,
36 columns=fullflexible,
37 xleftmargin=3.4pt,
38 xrightmargin=3.4pt,
39 keepspaces}}{}
40
41 \newcommand{\commandinline}{\lstinline[
42 literate={<}{{$\langle$}}1{>}{{$\rangle$}}1,
43 delim={[is][\color{green!50!black}\normalfont\itshape]{!}{!}},
44 basicstyle=\color{blue!80!black}\ttfamily,
45 columns=fullflexible,
46 keepspaces]}
47
48 \newcommand{\verbinline}{\lstinline[
49 literate={<}{{$\langle$}}1{>}{{$\rangle$}}1,
50 delim={[is][\color{green!50!black}\normalfont\itshape]{!}{!}},
51 basicstyle=\ttfamily,
52 columns=fullflexible,
53 keepspaces]}
54
55 \begin{document}
56
57 \title{The {\bfseries\sffamily numspell} package\\{\large v1.9 (2026/02/02)}}
58 \author{Tibor Tómács\\{\normalsize\href{mailto:[email protected]}{\texttt{[email protected]}}}}
59 \date{}
60 \maketitle
61
62 \section{Introduction}
63 The \texttt{numspell} package spells out cardinal and ordinal integers up to 66 digits long.
64
65 The package supports British and American English, French, German, Hungarian, Italian, and Latin in its classical, medieval, modern, and ecclesiastical variants.\footnote{Thanks to Keno Wehr for the Latin language module.}
66 Number spelling is performed using the currently active language.
67
68 The \texttt{numspell} package requires the services of the \texttt{xstring} and \texttt{iflang} packages.
69
70 Load the package as usual, with
71 \begin{flushleft}
72 \commandinline|\usepackage{numspell}|
73 \end{flushleft}
74
75 \section{Commands}
76 \begin{description}
77 \item\commandinline|\numspell[!<zeros>!]{!<num>!}|\\
78 Spelling the cardinal number $n=\text{\color{green!50!black}\itshape$\langle$num$\rangle$}\cdot10^{\text{\color{green!50!black}\itshape$\langle$zeros$\rangle$}}$, where $0\leq n\leq 10^{66}-1$. The default value of \commandinline|!<zeros>!| is \texttt{0}. For example
79 \begin{flushleft}
80 \verb|\numspell{12000}| $\to$ \numspell{12000}\\
81 \verb|\numspell[3]{12}| $\to$ \numspell[3]{12}\\
82 \verb|\numspell[6]{12}| $\to$ \numspell[6]{12}\\
83 \verb|\numspell[63]{1}| $\to$ \numspell[63]{1}
84 \end{flushleft}
85
86 \item\commandinline|\thenumspell|\\
87 The \verb|\numspell| stores the result in this command. For example
88 \begin{flushleft}
89 \verb|\numspell{12000}; \thenumspell| $\to$ \numspell{12000}; \thenumspell\\
90 \verb|\numspell{1}; \numspell{2}; \thenumspell| $\to$ \numspell{1}; \numspell{2}; \thenumspell
91 \end{flushleft}
92
93 \item\commandinline|\numspellsave{!<name>!}|\\
94 Creates \commandinline|\thenumspell!<name>!| containing the current \verb|\thenumspell|.
95
96
97 For example
98 \begin{verbatim}
99 \numspell{1};
100 \numspellsave{MyNum}
101 \numspell{2};
102 \thenumspell;
103 \thenumspellMyNum
104 \end{verbatim}
105 \numspell{1};
106 \numspellsave{MyNum}
107 \numspell{2};
108 \thenumspell;
109 \thenumspellMyNum
110
111 \item\commandinline|\numspelldashspace{!<length>!}|\\
112 In the number spelling, the spaces around the dashes are flexibility for the optimal hyphenation. Its value is \texttt{0pt plus} \commandinline|!<length>!|.
113 The default value of \commandinline|!<length>!| is \texttt{2pt}. For example
114 \begin{verbatim}
115 \selectlanguage{magyar}
116 \numspell{1234567890123456789000}\\
117 \numspelldashspace{0pt}
118 \numspell{1234567890123456789000}
119 \end{verbatim}
120 {\selectlanguage{magyar}
121 \numspell{1234567890123456789000}\\
122 \numspelldashspace{0pt}
123 \numspell{1234567890123456789000}}
124
125 \item\commandinline|\numspell*[!<zeros>!]{!<num>!}|\\
126 It works like \verb|\numspell|, but the number spelling will not be printed.
127 In other words, the following two lines are equivalent:
128 \begin{flushleft}
129 \verbinline|\numspell[!<zeros>!]{!<num>!}|\\
130 \verbinline|\numspell*[!<zeros>!]{!<num>!}\thenumspell|
131 \end{flushleft}
132 For example
133 \begin{verbatim}
134 \numspell*{1}
135 \numspellsave{MyNum}
136 \numspell*{2}
137 \thenumspell;
138 \thenumspellMyNum
139 \end{verbatim}
140 \numspell*{1}
141 \numspellsave{MyNum}
142 \numspell*{2}
143 \thenumspell;
144 \thenumspellMyNum
145
146 \item\commandinline|\Numspell[!<zeros>!]{!<num>!}|\\
147 It works like \verb|\numspell|, but the first letter will be capital. For example
148 \begin{flushleft}
149 \verb|\Numspell{12000}| $\to$ \Numspell{12000}\\
150 \verb|\Numspell[3]{12}| $\to$ \Numspell[3]{12}\\
151 \verb|\Numspell[6]{12}| $\to$ \Numspell[6]{12}\\
152 \verb|\Numspell[63]{1}| $\to$ \Numspell[63]{1}
153 \end{flushleft}
154
155 \item\commandinline|\Numspell*[!<zeros>!]{!<num>!}|\\
156 It works like \verb|\Numspell|, but the number spelling will not be printed.
157 In other words, the following two lines are equivalent:
158 \begin{flushleft}
159 \verbinline|\Numspell[!<zeros>!]{!<num>!}|\\
160 \verbinline|\Numspell*[!<zeros>!]{!<num>!}\thenumspell|
161 \end{flushleft}
162 For example
163 \begin{verbatim}
164 \Numspell*{1}
165 \numspellsave{MyNum}
166 \Numspell*{2}
167 \thenumspell;
168 \thenumspellMyNum
169 \end{verbatim}
170 \Numspell*{1}
171 \numspellsave{MyNum}
172 \Numspell*{2}
173 \thenumspell;
174 \thenumspellMyNum
175
176 \item\commandinline|\ordnumspell[!<zeros>!]{!<num>!}|\\
177 Spelling the ordinal number
178 $n=\text{\color{green!50!black}\itshape$\langle$num$\rangle$}\cdot10^{\text{\color{green!50!black}\itshape$\langle$zeros$\rangle$}}$,
179 where $0\leq n\leq 10^{66}-1$. The default value of \commandinline|!<zeros>!| is \texttt{0}. For example
180 \begin{flushleft}
181 \verb|\ordnumspell{12000}| $\to$ \ordnumspell{12000}\\
182 \verb|\ordnumspell[3]{12}| $\to$ \ordnumspell[3]{12}\\
183 \verb|\ordnumspell[6]{12}| $\to$ \ordnumspell[6]{12}\\
184 \verb|\ordnumspell[63]{1}| $\to$ \ordnumspell[63]{1}
185 \end{flushleft}
186
187 \item\commandinline|\ordnumspell*[!<zeros>!]{!<num>!}|\\
188 It works like \verb|\ordnumspell|, but the number spelling will not be printed.
189 In other words, the following two lines are equivalent:
190 \begin{flushleft}
191 \verbinline|\ordnumspell[!<zeros>!]{!<num>!}|\\
192 \verbinline|\ordnumspell*[!<zeros>!]{!<num>!}\thenumspell|
193 \end{flushleft}
194 For example
195 \begin{verbatim}
196 \ordnumspell*{1}
197 \numspellsave{MyNum}
198 \ordnumspell*{2}
199 \thenumspell;
200 \thenumspellMyNum
201 \end{verbatim}
202 \ordnumspell*{1}
203 \numspellsave{MyNum}
204 \ordnumspell*{2}
205 \thenumspell;
206 \thenumspellMyNum
207
208 \item\commandinline|\Ordnumspell[!<zeros>!]{!<num>!}|\\
209 It works like \verb|\ordnumspell|, but the first letter will be capital. For example
210 \begin{flushleft}
211 \verb|\Ordnumspell{12000}| $\to$ \Ordnumspell{12000}\\
212 \verb|\Ordnumspell[3]{12}| $\to$ \Ordnumspell[3]{12}\\
213 \verb|\Ordnumspell[6]{12}| $\to$ \Ordnumspell[6]{12}\\
214 \verb|\Ordnumspell[63]{1}| $\to$ \Ordnumspell[63]{1}
215 \end{flushleft}
216
217 \item\commandinline|\Ordnumspell*[!<zeros>!]{!<num>!}|\\
218 It works like \verb|\Ordnumspell|, but the number spelling will not be printed.
219 In other words, the following two lines are equivalent:
220 \begin{flushleft}
221 \verbinline|\Ordnumspell[!<zeros>!]{!<num>!}|\\
222 \verbinline|\Ordnumspell*[!<zeros>!]{!<num>!}\thenumspell|
223 \end{flushleft}
224 For example
225 \begin{verbatim}
226 \Ordnumspell*{1}
227 \numspellsave{MyNum}
228 \Ordnumspell*{2}
229 \thenumspell;
230 \thenumspellMyNum
231 \end{verbatim}
232 \Ordnumspell*{1}
233 \numspellsave{MyNum}
234 \Ordnumspell*{2}
235 \thenumspell;
236 \thenumspellMyNum
237 \end{description}
238
239 \section{Commands for English language}
240 If the \texttt{english}, \texttt{british}, \texttt{ukenglish} or \texttt{UKenglish} language is active, then the number spelling will happen in British English. But it will be in American English, if the \texttt{american}, \texttt{usenglish} or \texttt{USenglish} language is active.
241 \begin{description}
242 \item\commandinline|\numspellUS|\\
243 Using British English, you can rechange the number spelling to American English by this command.
244 \item\commandinline|\numspellGB|\\
245 Using American English, you can rechange the number spelling to British English by this command.
246 \end{description}
247
248 \section{Commands for French language}
249 The following commands only work, if \texttt{french} language is active.
250 \begin{description}
251 \selectlanguage{french}
252 \item\commandinline|\numspellpremiere|\\
253 By default, \verb|\ordnumspell{1}| $\to$ \ordnumspell{1},\\
254 but \verb|\numspellpremiere\ordnumspell{1}| $\to$ {\numspellpremiere\ordnumspell{1}}
255
256 \item\commandinline|\numspellpremier| (default)\\
257 \verb|\numspellpremiere\ordnumspell{1};|\\
258 \verb|\numspellpremier\ordnumspell{1}|\\[2mm]
259 {\numspellpremiere\ordnumspell{1}}; {\numspellpremier\ordnumspell{1}}
260 \end{description}
261
262 \section{Commands for Hungarian language}
263 The following commands only work, if \texttt{magyar} or \texttt{hungarian} language is active.
264 \begin{description}
265 \item\commandinline|\anumspell[!<zeros>!]{!<num>!}|\\
266 It works like \verb|\numspell|, but the number spelling will start with Hungarian definite article. For example
267 \begin{flushleft}
268 {\selectlanguage{magyar}
269 \verb|\anumspell{1}| $\to$ \anumspell{1}\\
270 \verb|\anumspell{2}| $\to$ \anumspell{2}}
271 \end{flushleft}
272
273 \item\commandinline|\anumspell*[!<zeros>!]{!<num>!}|\\
274 It works like \verb|\anumspell|, but the number spelling will not be printed.
275 In other words, the following two lines are equivalent:
276 \begin{flushleft}
277 \verbinline|\anumspell[!<zeros>!]{!<num>!}|\\
278 \verbinline|\anumspell*[!<zeros>!]{!<num>!}\thenumspell|
279 \end{flushleft}
280 For example
281 \begin{verbatim}
282 \anumspell*{1}
283 \numspellsave{MyNum}
284 \anumspell*{2}
285 \thenumspell;
286 \thenumspellMyNum
287 \end{verbatim}
288 {\selectlanguage{magyar}
289 \anumspell*{1}
290 \numspellsave{MyNum}
291 \anumspell*{2}
292 \thenumspell;
293 \thenumspellMyNum}
294
295 \item\commandinline|\Anumspell[!<zeros>!]{!<num>!}|\\
296 It works like \verb|\anumspell|, but the first letter will be capital.
297
298 \item\commandinline|\Anumspell*[!<zeros>!]{!<num>!}|\\
299 It works like \verb|\anumspell*|, but the first letter will be capital.
300
301 \item\commandinline|\aordnumspell[!<zeros>!]{!<num>!}|\\
302 It works like \verb|\ordnumspell|, but the number spelling will start with Hungarian definite article. For example
303 \begin{flushleft}
304 {\selectlanguage{magyar}
305 \verb|\aordnumspell{1}| $\to$ \aordnumspell{1}\\
306 \verb|\aordnumspell{2}| $\to$ \aordnumspell{2}}
307 \end{flushleft}
308
309 \item\commandinline|\aordnumspell*[!<zeros>!]{!<num>!}|\\
310 It works like \verb|\aordnumspell|, but the number spelling will not be printed.
311 In other words, the following two lines are equivalent:
312 \begin{flushleft}
313 \verbinline|\aordnumspell[!<zeros>!]{!<num>!}|\\
314 \verbinline|\aordnumspell*[!<zeros>!]{!<num>!}\thenumspell|
315 \end{flushleft}
316 For example
317 \begin{verbatim}
318 \aordnumspell*{1}
319 \numspellsave{MyNum}
320 \aordnumspell*{2}
321 \thenumspell;
322 \thenumspellMyNum
323 \end{verbatim}
324 {\selectlanguage{magyar}
325 \aordnumspell*{1}
326 \numspellsave{MyNum}
327 \aordnumspell*{2}
328 \thenumspell;
329 \thenumspellMyNum}
330
331 \item\commandinline|\Aordnumspell[!<zeros>!]{!<num>!}|\\
332 It works like \verb|\aordnumspell|, but the first letter will be capital.
333
334 \item\commandinline|\Aordnumspell*[!<zeros>!]{!<num>!}|\\
335 It works like \verb|\aordnumspell*|, but the first letter will be capital.
336 \end{description}
337
338 \section{Commands for Italian language}
339 The following commands only work, if \texttt{italian} language is active.
340 \begin{description}
341 \selectlanguage{italian}
342 \item\commandinline|\numspellitmasculine| (default)\\
343 The ordinal numbers will be printed in masculine form. For example\\
344 \verb|\ordnumspell{1}| $\to$ \ordnumspell{1}
345
346 \item\commandinline|\numspellitfeminine|\\
347 The ordinal numbers will be printed in feminine form. For example\\
348 \verb|\numspellitfeminine\ordnumspell{1};|\\
349 \verb|\numspellitmasculine\ordnumspell{1}|\\[2mm]
350 {\numspellitfeminine\ordnumspell{1}}; {\numspellitmasculine\ordnumspell{1}}
351 \end{description}
352
353 \section{Commands for the Latin language}
354 The following commands only work, if one of the next languages is active: \texttt{latin}, \texttt{classicallatin}, \texttt{medievallatin}, or \texttt{ecclesiasticallatin}.
355 \begin{description}
356 \selectlanguage{latin}
357 \item\commandinline|\numspelllamasculine| (default)\\
358 All numbers will be printed in masculine form. For example\\
359 \verb|\numspell{1}, \numspell{2}, \numspell{200}, \ordnumspell{1}|\\[2mm]
360 \numspell{1}, \numspell{2}, \numspell{200}, \ordnumspell{1}
361
362 \item\commandinline|\numspelllafeminine|\\
363 All numbers will be printed in feminine form. For example\\
364 \verb|\numspelllafeminine|\\
365 \verb|\numspell{1}, \numspell{2}, \numspell{200}, \ordnumspell{1}|\\[2mm]
366 \numspelllafeminine
367 \numspell{1}, \numspell{2}, \numspell{200}, \ordnumspell{1}
368
369 \item\commandinline|\numspelllaneuter|\\
370 All numbers will be printed in neuter form. For example\\
371 \verb|\numspelllaneuter|\\
372 \verb|\numspell{1}, \numspell{2}, \numspell{200}, \ordnumspell{1}|\\[2mm]
373 \numspelllaneuter
374 \numspell{1}, \numspell{2}, \numspell{200}, \ordnumspell{1}
375 \end{description}
376
377 \section{A known issue}
378
379 The \texttt{numspell} package commands can be safely written in sectioning commands (\commandinline|\part|, \commandinline|\chapter|, \commandinline|\section|, etc.), but if you also use the \texttt{hyperref} or \texttt{bookmarks} packages, in some cases wrong result will be displayed in the bookmark:
380
381 \begin{enumerate}\setlength{\labelsep}{5pt}
382 \item If you write at least one numspell-command in \commandinline|\part| or \commandinline|\chapter| commands.
383 \item If you write at least two numspell-commands in any sectioning command.
384 \end{enumerate}
385
386 For example, the following code inserts incorrect text into the bookmark:
387
388 \begin{examplelst}
389 \part{The \numspell{123} ...}
390
391 \chapter{The \numspell{987} ...}
392
393 \section{From \numspell{123} to \numspell{987}}
394 \end{examplelst}
395
396 These problems can be solved in the following way:
397
398 \begin{examplelst}
399 \numspell*{123}
400 \part{The \numspell{123} ...}
401
402 \numspell*{987}
403 \chapter{The \numspell{987} ...}
404
405 \numspell*{123}\numspellsave{TempA}
406 \numspell*{987}\numspellsave{TempB}
407 \section{From \thenumspellTempA\ to \thenumspellTempB}
408 \end{examplelst}
409
410 \section{Examples}
411
412 \begin{examplelst}
413 \documentclass{article}
414 \usepackage[T1]{fontenc}
415 \usepackage[magyar,italian,latin,ngerman,french,english]{babel}
416 \usepackage{numspell}
417 \usepackage[group-separator={,}]{siunitx}
418 \begin{document}
419 \def\mynum{123456789}
420 \noindent
421 In British English the spelling of \num{\mynum} is
422 \emph{\numspell{\mynum}}.
423 \par\smallskip\noindent
424 In American English the spelling of \num{\mynum} is
425 \foreignlanguage{american}{\em\numspell{\mynum}}.
426 \par\smallskip\noindent
427 In French the spelling of \num{\mynum} is
428 \foreignlanguage{french}{\em\numspell{\mynum}}.
429 \par\smallskip\noindent
430 In German the spelling of \num{\mynum} is
431 \foreignlanguage{ngerman}{\em\numspell{\mynum}}.
432 \par\smallskip\noindent
433 In Hungarian the spelling of \num{\mynum} is
434 \foreignlanguage{magyar}{\em\numspell{\mynum}}.
435 \par\smallskip\noindent
436 In Italian the spelling of \num{\mynum} is
437 \foreignlanguage{italian}{\em\numspell{\mynum}}.
438 \par\smallskip\noindent
439 In Latin the spelling of \num{\mynum} is
440 \foreignlanguage{latin}{\em\numspell{\mynum}}.
441 \end{document}
442 \end{examplelst}
443 \def\mynum{123456789}
444 \noindent
445 In British English the spelling of 123,456,789 is
446 \emph{\numspell{\mynum}}.
447 \par\smallskip\noindent
448 In American English the spelling of 123,456,789 is
449 \foreignlanguage{american}{\em\numspell{\mynum}}.
450 \par\smallskip\noindent
451 In French the spelling of 123,456,789 is
452 \foreignlanguage{french}{\em\numspell{\mynum}}.
453 \par\smallskip\noindent
454 In German the spelling of 123,456,789 is
455 \foreignlanguage{ngerman}{\em\numspell{\mynum}}.
456 \par\smallskip\noindent
457 In Hungarian the spelling of 123,456,789 is
458 \foreignlanguage{magyar}{\em\numspell{\mynum}}.
459 \par\smallskip\noindent
460 In Italian the spelling of 123,456,789 is
461 \foreignlanguage{italian}{\em\numspell{\mynum}}.
462 \par\smallskip\noindent
463 In Latin the spelling of 123,456,789 is
464 \foreignlanguage{latin}{\em\numspell{\mynum}}.
465
466 \begin{examplelst}
467 \documentclass{article}
468 \usepackage{numspell}
469 \newcounter{mycount}
470 \begin{document}
471 The
472 \makeatletter
473 \@whilenum\value{mycount}<51
474 \do{\ordnumspell{\themycount}\stepcounter{mycount},\ }\dots
475 \makeatother
476 \end{document}
477 \end{examplelst}
478 \makeatletter
479 \newcounter{mycount}
480 The
481 \@whilenum\value{mycount}<51
482 \do{\ordnumspell{\themycount}\stepcounter{mycount},\ }\dots
483 \makeatother
484
485 \begin{examplelst}
486 \documentclass{article}
487 \usepackage{numspell}
488 \newcounter{mycount}
489 \def\themycount{\numspell{\arabic{mycount}}}
490 \begin{document}
491 \Numspell{0},
492 \makeatletter
493 \@whilenum\value{mycount}<30
494 \do{\stepcounter{mycount}\themycount,\ }\dots
495 \makeatother
496 \end{document}
497 \end{examplelst}
498 \def\themycount{\numspell{\arabic{mycount}}}
499 \setcounter{mycount}{0}
500 \makeatletter
501 \Numspell{0},
502 \@whilenum\value{mycount}<30
503 \do{\stepcounter{mycount}\themycount,\ }\dots
504 \makeatother
505
506 \end{document}