summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/grnumalt/grnumalt.dtx
blob: df20e518e61ed4a936b7d93c363c7e87bd01becd (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
278
279
280
281
%% \CheckSum{134}
%% \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         \~}
%\iffalse
%
%% This is file `grnumalt.dtx'
%% (c) 1997 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@platon.ee.duth.gr or apostolo@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{grnumalt.drv}
\begin{document}
   \DocInput{grnumalt.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% \fi
%
%\title{Athenian Numerals}
%\author{Apostolos Syropoulos\\366, 28th October Str.\\
%GR-671 00 Xanthi, HELLAS\\ Email:\texttt{apostolo@platon.ee.duth.gr}}
% \date{1997/09/19}
%\maketitle
% 
%\MakeShortVerb{\|}
%
%\section{Introduction}
% 
% This little \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 special multiples, which the system employs, are drawn 
% \DescribeMacro{\PiIt} with the special macro |\PiIt|. The macro 
% produces a more or less $\Pi$-like shape above a letter. 
%
%\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>
\ProvidesPackage{grnumalt}[1997/09/19\space v1.1]
\typeout{Package: `grnumalt' v1.0\space <1997/09/19> (AS)}
%    \end{macrocode}
%
%\begin{macro}{\PiIt}
% It is very important to be able to correctly typeset  the multiples of 
% the numbering system. For this purpose we define the macro |\PiIt|. The
% macro uses two ``length'' variables.
%    \begin{macrocode}
\newdimen\@boxW \newdimen\@boxH
%    \end{macrocode}
% We make the |\PiIt| macro a robust command.
%    \begin{macrocode}
\DeclareRobustCommand{\PiIt}[1]{%
%    \end{macrocode}
% In order to correctly produce the $\Pi$ symbol we need to know the 
% height and width of the letter that goes under a $\Pi$. This is done by 
% using the standard \LaTeX\ macros: |\settowidth| and |\settoheight|. 
%    \begin{macrocode}
    \settowidth{\@boxW}{#1}%
    \settoheight{\@boxH}{#1}%
%    \end{macrocode}
% Since, the width of an  ordinary rule is 0.4 pt we must add 0.8 pt to
% the width of the letter.
%    \begin{macrocode}
    \addtolength{\@boxW}{0.8pt}
%    \end{macrocode}
% Now comes the interesting part: the actual drawing. We create a vertical
% box. Inside this box we draw a horizontal rule of width equal to
% the width of the letter. Next, we create a horizontal box in order to
% make the vertical lines. We draw the first vertical line, then we put
% the letter in a |\mbox|, since it may be a mathematical 
% symbol\footnote{greek letters are considered  mathematical symbols
% by \TeX.}. After the |\mbox| we draw the second vertical line and we
% ``close'' the horizontal box. A little white space is put after the vertical
% box, so that adjacent multiplies do not look ugly!
%    \begin{macrocode}
    \vbox{%
    \hrule width\@boxW\hbox{%
          \vrule height\@boxH\mbox{#1}%
          \vrule height\@boxH}}\kern.5pt}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\athnum}            
% Now, we turn our attention to the definition of the macro 
% |\athnum|. This macro uses one integer variable.
%    \begin{macrocode}
\newcount\@ath@num
%    \end{macrocode}
% The macro |\athnum| is also defined as a robust command.
%    \begin{macrocode}
\DeclareRobustCommand{\athnum}[1]{%
%    \end{macrocode}
% The macro does not work in math mode so we must ensure that it will not
% be used in math mode. We could use |\ensuremath|, but our definition
% is too long...
%    \begin{macrocode}
        \ifmmode
          \errhelp{^^J This macro has been defined to work^^J
                     *only* in non-math mode. It is definitely^^J
                     sure that you are  using it in math mode.^^J}%
          \errmessage{^^JYou can't use macro atheniannumeral^^J 
                        in math mode.^^J}%
%    \end{macrocode}
% If we are not in math mode, we can start computing the Athenian numeral.
% 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. In case it isn't we simply produce a |\space|, warn the user
% about it and quit.
%    \begin{macrocode}
        \else\@ath@num#1\relax
        \ifnum\@ath@num=\z@%
          \space%
          \PackageWarning{grnumalt}{%
           Illegal value (\the\@ath@num) for athenian numeral}%
        \else\ifnum\@ath@num<\z@%
          \space%
          \PackageWarning{grnumalt}{%
          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 |\NumA|, until |\NumA| becomes less than
% $50000$. 
%    \begin{macrocode}
            \loop\ifnum\@ath@num>49999
               \PiIt{$\mathrm{M}$}
               \advance\@ath@num-50000
            \repeat
%    \end{macrocode}
% We now check for tens of thousands.
%    \begin{macrocode}
            \loop\ifnum\@ath@num>9999
            \mathrm{M}\advance\@ath@num-\@M
            \repeat
%    \end{macrocode}
% Since a number can have only on \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
               \PiIt{$\mathrm{X}$}
               \advance\@ath@num-5000
            \fi
%    \end{macrocode}
% Next, we check for thousands, the same way we checked for tens of thousands.
%    \begin{macrocode}
            \loop\ifnum\@ath@num>999
            \mathrm{X}\advance\@ath@num-\@m
            \repeat
%    \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
               \PiIt{$\mathrm{H}$}
               \advance\@ath@num-500
            \fi
%    \end{macrocode}
% It is time to check hundreds, which follow the same pattern as thousands
%    \begin{macrocode}
            \loop\ifnum\@ath@num>99
            \mathrm{H}\advance\@ath@num-100
            \repeat
%    \end{macrocode}
% A numeral can have only one \PiIt{$\Delta$} ``digit'' (equivalent to 50).
%    \begin{macrocode} 
            \ifnum\@ath@num>49
               \PiIt{$\Delta$}
               \advance\@ath@num-50
            \fi
%    \end{macrocode}
% Let's check now decades.
%    \begin{macrocode}         
            \loop\ifnum\@ath@num>9
            \Delta\advance\@ath@num by-10
            \repeat
%    \end{macrocode}
% We check for fives and, finally, for the digits 1, 2, 3, and 4.
%    \begin{macrocode}
            \ifnum\@ath@num>4
               \Pi
               \advance\@ath@num-5
            \fi
            \ifcase\@ath@num
               \or\mathrm{I}
               \or\mathrm{II}
               \or\mathrm{III}
               \or\mathrm{IIII}
            \fi$
   \fi\fi\fi}
%    \end{macrocode}
% \DescribeMacro{\@athnum} The command |\@athnum| is defined just to make
% it possible to have, e.g., page numbering with athenian numerals.
%    \begin{macrocode}
\let\@athnum\athnum 
%</package>
%    \end{macrocode}
%\end{macro}
%
% \noindent{\large\bfseries Dedication}\\
% I would like to dedicate this piece of work to my son Demetrios-Georgios.
%
% \Finale
%
\endinput