%% \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