1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
% \iffalse meta-comment
%
% Copyright (C) 2011 by Raphaël Pinson <raphink@gmail.com>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Raphaël Pinson.
%
% This work consists of the files babyloniannum.dtx and babyloniannum.ins
% and the derived filebase babyloniannum.sty.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{babyloniannum.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{babyloniannum}
%<*package>
[2011/08/19 0.5 Typeset Babylonian numerals with XeTeX and LuaTeX]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{babyloniannum}[2011/08/19]
\usepackage{metalogo}
\usepackage{pgffor}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{babyloniannum.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{138}
%
% \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 \~}
%
%
% \changes{0.5}{2011/08/19}{Fix documentation and kerning}
% \changes{0.4}{2011/08/18}{To infinity and beyond}
% \changes{0.3}{2011/08/17}{Add counter function}
% \changes{0.2}{2011/08/17}{Improved documentation}
% \changes{0.1}{2011/08/17}{Initial release}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{babyloniannum.dtx}
% \title{The \textsf{babyloniannum} package}
% \author{Raphaël Pinson \\ \url{raphink@gmail.com}}
% \date{\fileversion~from \filedate}
%
% \renewcommand{\thesection}{\babylonian{section}}
% \renewcommand{\thesubsection}{\babylonian{section}.\babylonian{subsection}}
%
% \maketitle
%
% \section{Introduction}
%
% This package was created as an answer to a
% question\footnote{\url{http://tex.stackexchange.com/questions/25939/typesetting-babylonian-numerals/25947\#25947}}
% about typesetting Babylonian numerals asked on \url{http://tex.stackexchange.com}.
%
% This package allows to typeset Babylonian numerals using \XeTeX{} or \LuaTeX{}.
% It makes use of the \babylonianfont{} Paleo-Babylonian TrueType font
% which can be downloaded at \url{http://www.hethport.uni-wuerzburg.de/cuneifont/}.
%
% \section{Usage}
%
%
% \DescribeMacro{\babylonianfont}
%
% Set the font used. Currently, only the \babylonianfont{} font has been tested.
% Let me know if you get the package to work with other fonts.
%
% Example usage: \verb!\babyloninanfont{Santakku}!
%
% \DescribeMacro{\babyloniannum}
%
% This is the main macro of this package. It takes a number between 1 and 59
% as argument and typesets it with Babylonian numerals.
%
% Example usage:
%
% \verb!\babyloninannum{424000}! is \babyloniannum{424000} (1,57,46,40 in base 60)
%
% \verb!\babyloninannum{21609}! is \babyloniannum{21609} (6,0,9 in base 60)
%
% \DescribeMacro{\babylonian}
%
% Like \verb!\arabic! or \verb!\roman!, this macro takes a counter
% name as argument and returns its Babylonian representation.
%
% For example, this documentation is typeset with:
% \begin{verbatim}
% \renewcommand{\thesection}{\babylonian{section}}
% \end{verbatim}
%
% \DescribeMacro{\unicodedisp}
%
% This macro lets you print characters using their unicode reference.
% It is used by \verb!\babyloniannum! to display Babylonian numbers.
%
% Example usage: \verb!\unicodedisp{1230B}!
%
% \pagebreak
% \section{Table of characters}
%
% Below is a sample list of Babylonian characters this package can typeset:
%
% \begin{minipage}{0.3\textwidth}
% \noindent\foreach \n in {1,...,40}{%
% \n~\babyloniannum{\n}\\
% }
% \end{minipage} \hfill
% \begin{minipage}{0.3\textwidth}
% \noindent\foreach \n in {41,...,80}{%
% \n~\babyloniannum{\n}\\
% }
% \end{minipage} \hfill
% \begin{minipage}{0.3\textwidth}
% \noindent\foreach \n in {81,...,120}{%
% \n~\babyloniannum{\n}\\
% }
% \end{minipage}
%
% \section{Known issues}
%
% \subsection{Glyph for 20}
%
% The glyph for number 20 was not found in the \babylonianfont{} font.
% Therefore, it has been replaced by the combination of two 10 glyphs,
% with a kerning adjustment.
%
% \subsection{Glyph for 0}
%
% The Babylonian system has no glyph for 0, which is represented by a
% large space. In this package, 0 is implemented as a 0.5em kerning space.
%
% \subsection{Multiples of 60}
%
% The Babylonian numeral system is a sexagesimal system
% (a positional base 60 system), which does not feature a glyph for 0.
% Therefore, a number such as \babyloniannum{23} can stand for
% $23$, $23 \times 60$ or $23 \times 60 \times 60$ or even $23/60$.
% Only the context allows to decide which number is represented.
%
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
% \begin{macrocode}
\ProvidesPackage{babyloniannum}
\RequirePackage{fontspec}
\RequirePackage{xunicode}
\RequirePackage{numname}
% \end{macrocode}
%
% \begin{macro}{\babylonianfont}
% \begin{macrocode}
\newcommand{\babylonianfont}{Santakku}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\unicodedisp}
% \begin{macrocode}
\newcommand{\unicodedisp}[1]{\char"#1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\babylonian}
% \begin{macrocode}
\newcommand{\babylonian}[1]{%
\protect\babyloniannum{\arabic{#1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\babylonianglyph}
% \begin{macrocode}
\newcommand{\babylonianglyph}[1]{%
\ifnum #1 > \z@ % glyph is not zero
\chardef\m@mten=10 % cuts by units of 10
\numdigits{#1} % parse number
\ifcase\c@xsm@mctr %
\relax %
\or
\unicodedisp{1230B} %10
\or
\unicodedisp{1230B}\kern-0.15em{}\unicodedisp{1230B} %20 -- unknown?
\or
\unicodedisp{1230D} %30
\or
\unicodedisp{1240F} %40
\or
\unicodedisp{12410} %50
\fi
\ifnum \c@ism@mctr > \z@ %
\ifnum \c@xsm@mctr > \z@ %
\kern-0.5em{} % make glyphs closer
\fi %
\fi %
\ifcase\c@ism@mctr %
\or
\unicodedisp{12079} %1
\or
\unicodedisp{1222B} %2
\or
\unicodedisp{12408} %3
\or
\unicodedisp{120FB} %4
\or
\unicodedisp{1240A} %5
\or
\unicodedisp{1240B} %6
\or
\unicodedisp{1240C} %7
\or
\unicodedisp{1240D} %8
\or
\unicodedisp{1240E} %9
\fi
\addtocounter{baby@glyphs}{1}%
\else
\ifnum\c@baby@glyphs > \z@ %
\kern0.5em{}% empty space for zero
\fi
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\babylonian@setcounters}
% \begin{macrocode}
\newcounter{baby@ism@mctr} % "units"
\newcounter{baby@xsm@mctr} % "tens"
\newcounter{baby@csm@mctr} % "hundreds"
\newcounter{baby@ksm@mctr} % "thousands"
\newcounter{baby@xksm@mctr} % "ten thousands"
\newcounter{baby@cksm@mctr} % "hundred thousands"
\newcounter{baby@msm@mctr} % "millions"
\newcounter{baby@xmsm@mctr} % "ten millions"
\newcounter{baby@cmsm@mctr} % "hundred millions"
\newcounter{baby@bsm@mctr} % "billions"
\newcommand{\babylonian@setcounters}{%
\setcounter{baby@ism@mctr}{\c@ism@mctr}%
\setcounter{baby@xsm@mctr}{\c@xsm@mctr}%
\setcounter{baby@csm@mctr}{\c@csm@mctr}%
\setcounter{baby@ksm@mctr}{\c@ksm@mctr}%
\setcounter{baby@xksm@mctr}{\c@xksm@mctr}%
\setcounter{baby@cksm@mctr}{\c@cksm@mctr}%
\setcounter{baby@msm@mctr}{\c@msm@mctr}%
\setcounter{baby@xmsm@mctr}{\c@xmsm@mctr}%
\setcounter{baby@cmsm@mctr}{\c@cmsm@mctr}%
\setcounter{baby@bsm@mctr}{\c@bsm@mctr}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\babyloniannum}
% \begin{macrocode}
\newcounter{baby@glyphs}%
\newcommand{\babyloniannum}[1]{%
\chardef\m@mten=60 % Cut by units of 60
\numdigits{#1} % Parse number
\babylonian@setcounters%
{\fontspec{\babylonianfont}%
\mbox{%
\setcounter{baby@glyphs}{0}%
\babylonianglyph{\c@baby@bsm@mctr}%
\babylonianglyph{\c@baby@cmsm@mctr}%
\babylonianglyph{\c@baby@xmsm@mctr}%
\babylonianglyph{\c@baby@msm@mctr}%
\babylonianglyph{\c@baby@cksm@mctr}%
\babylonianglyph{\c@baby@xksm@mctr}%
\babylonianglyph{\c@baby@ksm@mctr}%
\babylonianglyph{\c@baby@csm@mctr}%
\babylonianglyph{\c@baby@xsm@mctr}%
\babylonianglyph{\c@baby@ism@mctr}%
}}
}
% \end{macrocode}
% \end{macro}
%
%
% \iffalse
%</package>
% \fi
%
% \Finale
\endinput
|