summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/babel-contrib/greek/athnum.dtx
blob: 3ea1f5325aaa02511c7d36a4b4f7b153ddf2f21f (plain)
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
% \iffalse meta-comment
%
% Copyright 1989-2008 Johannes L. Braams and any individual authors
% listed elsewhere in this file.  All rights reserved.
% 
% This file is part of the Babel system.
% --------------------------------------
% 
% It 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 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% The Current Maintainer of this work is Johannes Braams.
% 
% The list of all files belonging to the Babel system is
% given in the file `manifest.bbl. See also `legal.bbl' for additional
% information.
% 
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
% \fi
%% \CheckSum{125}
%\iffalse
%
%% This is file `athnum.dtx'
%% (c) 1997-2007 Apostolos Syropoulos.
%% All rights reserved.
%
%  Please report errors or suggestions for improvement to
%    
%    Apostolos Syropoulos
%    366, 28th October Str.
%    GR-671 00 Xanthi, GREECE
%    apostolo at platon.ee.duth.gr or apostolo at obelix.ee.duth.gr
%
%\fi
%
% \iffalse
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\def\PiIt#1{{%
    \newdimen\boxW \newdimen\boxH
    \settowidth{\boxW}{#1}%
    \settoheight{\boxH}{#1}%
    \addtolength{\boxW}{0.8pt}
    \vbox{%
    \hrule width\boxW\hbox{%
          \vrule height\boxH\mbox{#1}%
          \vrule height\boxH}}\kern.5pt}}
\GetFileInfo{athnum.drv}
\begin{document}
   \DocInput{athnum.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% \fi
%
%\title{Athenian Numerals II\footnote{The documentation of this 
% package is essentially the same as that of the package `grnumalt'.
% The `II' serves as a means to distinguish the two documents.}}
% \author{Apostolos Syropoulos\\366, 28th October Str.\\
% GR-671 00 Xanthi, HELLAS\\ Email:\texttt{apostolo@platon.ee.duth.gr}}
% \date{2003/08/24}
%\maketitle
% 
%\MakeShortVerb{\|}
%
%\section{Introduction}
% 
% This \LaTeX\ package implements the macro 
% \DescribeMacro{\athnum}
% |\athnum|. The macro transforms an Arabic numeral, i.e., the kind
% of numerals we all use (e.g., 1, 5, 789 etc), to the corresponding
% {\itshape Athenian} numeral. Athenian numerals were in use only in 
% ancient Athens. The package can be used only in conjunction with the 
% |greek| option of the |babel| package.
%
%\section{The Numbering System}
%
% The athenian numbering system, like the roman one, employs
% letters to denote important numbers. Multiple occurrence of a letter denote
% a multiple of the ``important'' number, e.g., the letter I denotes 1, so
% III denotes 3. Here are the basic digits used in the Athenian numbering
% system:
% \begin{itemize}
%  \item I denotes the number one (1)
%  \item $\Pi$ denotes the number five (5)
%  \item $\Delta$ denotes the number ten (10)
%  \item H denotes the number one hundred (100)
%  \item X denotes the number one thousand (1000) 
%  \item M denotes the number ten thousands (10000)
%\end{itemize}
% Moreover,  the letters $\Delta$, H, X, and M under the letter $\Pi$, 
% denote five times their original value, e.g., the symbol 
% \PiIt{X}, denotes the number 5000, and the symbol  
% \PiIt{$\Delta$}, denotes the number 50. It must be noted that
% the numbering system does not provide negative numerals or a symbol for
% zero. 
%
% The Athenian numbering system is described, among others, in an article in
% Encyclopedia $\Delta o\mu\acute{\eta}$, Vol. 2, page 280, 7th edition,
% Athens, October 2, 1975.
%
% \section{The Code}  
% Before we do anything further, we have to identify the package.
% \StopEventually
%
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[1996/01/01]
\ProvidesPackage{athnum}[2003/08/24\space v1.1]
\typeout{Package: `athnum' v1.1\space <2003/08/24> (A. Syropoulos)}
%    \end{macrocode}
% Next we check to see if the |babel| package is loaded with at least
% the |greek| option. In case it isn't, we opt to produce an error message.
%    \begin{macrocode} 
\@ifpackagewith{babel}{greek}{}{%
   \@ifpackagewith{babel}{polutonikogreek}{}{%
     \PackageError{athnum}{%
     `greek' option of the `babel'\MessageBreak
      package hasn't been loaded}{%
      The commands provided by this package\MessageBreak
      are specially designed for greek language\MessageBreak
      typesetting with the `babel' package. Load\MessageBreak
      it with at least the `greek' option.}\relax
      }}
%    \end{macrocode}
%
% As it is mentioned in the introduction, the Athenian numerals employ
% some special digits. These digits are included in the |cb| fonts of
% Claudio Beccari, and so we must provide access commands.
%    \begin{macrocode}
\DeclareTextCommand{\PiDelta}{LGR}{\char"02\relax}
\DeclareTextCommand{\PiEta}{LGR}{\char"03\relax}
\DeclareTextCommand{\PiChi}{LGR}{\char"04\relax}
\DeclareTextCommand{\PiMu}{LGR}{\char"05\relax}
%    \end{macrocode}
%\begin{macro}{\@@athnum}            
% Now, we turn our attention to the definition of the macro 
% |\@@athnum|. This macro uses one integer variable (or counter in 
% \TeX's jargon.)
%    \begin{macrocode}
\newcount\@ath@num
%    \end{macrocode}
% The macro |\@@athnum| is also defined as a robust command.
%    \begin{macrocode}
\DeclareRobustCommand*{\@@athnum}[1]{%
%    \end{macrocode}
% After assigning to variable |\@ath@num| the value of the macro's argument, 
%we  make sure that the argument is in the expected range, i.e., it is greater
% than zero, and less or equal to $249999$.  In case it isn't, we simply 
% produce a |\space|, warn the user about it and quit. Although, the
% |\athnum| macro is capable to produce an Athenian numeral for even greater
% intergers, the following argument by Claudio Beccari convised me to place
% this above upper limit:
% \begin{quote} 
% According to psychological perception studies (that ancient Athenians
% and Romans perfectly knew without needing to study Freud and Jung)
% living beings (which includes at least all vertebrates, not only
% humans) can perceive up to four randomly set objects of the same kind   
% without the need of counting, the latter activity being a specific
% acquired ability of human kind; the biquinary numbering notation
% used by the Athenians and the Romans exploits this natural
% characteristic of human beings.
% \end{quote}
%    \begin{macrocode}
        \@ath@num#1\relax
        \ifnum\@ath@num<\@ne%
          \space%
          \PackageWarning{athnum}{%
          Illegal value (\the\@ath@num) for athenian numeral}%
        \else\ifnum\@ath@num>249999%
          \space%
          \PackageWarning{athnum}{%
          Illegal value (\the\@ath@num) for athenian numeral}%
        \else
%    \end{macrocode}
% Having done all the necessary checks, we are now ready to do the actual
% computation. If the number is greater than $49999$, then it certainly
% has at least one \PiIt{M} ``digit''. We find all such digits by continuously
% subtracting $50000$ from |\@ath@num|, until |\@ath@num| becomes less than
% $50000$. 
%    \begin{macrocode}
            \@whilenum\@ath@num>49999\do{%
               \PiMu\advance\@ath@num-50000}%
%    \end{macrocode}
% We now check for tens of thousands.
%    \begin{macrocode}
            \@whilenum\@ath@num>9999\do{%
               M\advance\@ath@num-\@M}%
%    \end{macrocode}
% Since a number can have only one \PiIt{X} ``digit'' (equivalent to 5000), it 
% is easy to check it out and produce the corresponding numeral in case it does
% have one.
%    \begin{macrocode}
            \ifnum\@ath@num>4999%
               \PiChi\advance\@ath@num-5000%
            \fi\relax
%    \end{macrocode}
% Next, we check for thousands, the same way we checked for tens of thousands.
%    \begin{macrocode}
            \@whilenum\@ath@num>999\do{%
               Q\advance\@ath@num-\@m}%
%    \end{macrocode}
% Like the five thousands, a numeral can have at most one \PiIt{H} ``digit''
% (equivalent to 500).
%    \begin{macrocode}
            \ifnum\@ath@num>499%
               \PiEta\advance\@ath@num-500%
            \fi\relax
%    \end{macrocode}
% It is time to check hundreds, which follow the same pattern as thousands
%    \begin{macrocode}
            \@whilenum\@ath@num>99\do{%
               H\advance\@ath@num-100}%
%    \end{macrocode}
% A numeral can have only one \PiIt{$\Delta$} ``digit'' (equivalent to 50).
%    \begin{macrocode} 
            \ifnum\@ath@num>49%
               \PiDelta\advance\@ath@num-50%
            \fi\relax
%    \end{macrocode}
% Let's check now decades.
%    \begin{macrocode}         
            \@whilenum\@ath@num>9\do{%
               D\advance\@ath@num by-10}%
%    \end{macrocode}
% We check for five and, finally, for the digits 1, 2, 3, and 4.
%    \begin{macrocode}
            \@whilenum\@ath@num>4\do{%
               P\advance\@ath@num-5}%
            \ifcase\@ath@num\or I\or II\or III\or IIII\fi%
   \fi\fi}
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\@athnum}
% The command |\@athnum| has one argument, which
% is a counter. It calls the command |\@@athnum| to process the value of
% the counter.
%    \begin{macrocode}
\def\@athnum#1{%
     \expandafter\@@athnum\expandafter{\the#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\athnum}
% The command |\athnum| is a wrapper that declares
% a new counter in a local scope, assigns to it the argument of the command
% and calls the macro |\@athnum|. This way the command can process correctly
% either a number or a counter. 
%    \begin{macrocode}
\def\athnum#1{%
     \@ath@num#1\relax
     \@athnum{\@ath@num}}
%</package>
%    \end{macrocode}
%\end{macro}
%
% \section*{Acknowledgment}
% I would like to thank Claudio Beccari for reading the documentation
% and for his very helpful suggestions. In addition, Antonis Tsolomitis
% spotted a bug in the first version, which is corrected in the present
% version. 
% \section*{Dedication}
% I would like to dedicate this piece of work to my son 
% \begin{center}Demetrios-Georgios.\end{center}
% \Finale
%
\endinput