summaryrefslogtreecommitdiff
path: root/macros/generic/misc/arabic.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/generic/misc/arabic.tex
Initial commit
Diffstat (limited to 'macros/generic/misc/arabic.tex')
-rw-r--r--macros/generic/misc/arabic.tex55
1 files changed, 55 insertions, 0 deletions
diff --git a/macros/generic/misc/arabic.tex b/macros/generic/misc/arabic.tex
new file mode 100644
index 0000000000..acba65e59f
--- /dev/null
+++ b/macros/generic/misc/arabic.tex
@@ -0,0 +1,55 @@
+%--------------------------------------------
+% Ole Michael Selberg, October 5, 1995
+% TeX macros to make a Roman number Arabic
+%
+% Syntax: \arabicnumeral <Roman number >
+%--------------------------------------------
+\catcode`@=11
+\newcount\r@mancount \newcount\current \newcount\previous
+\def\@valueofcurrent{%
+ \ifx\next i\global\current=1 \else
+ \ifx\next v\global\current=5 \else
+ \ifx\next x\global\current=10 \else
+ \ifx\next l\global\current=50 \else
+ \ifx\next c\global\current=100 \else
+ \ifx\next d\global\current=500 \else
+ \ifx\next m\global\current=1000 \else
+ \global\r@mancount=-100000
+ \immediate\write16{Line \the\inputlineno: non-Roman digit!}
+ \fi\fi\fi\fi\fi\fi\fi}
+\def\stop{\stop}
+\def\arabicnumeral #1 {\r@mancount=0 \current=0 \previous=10000
+ \fr@mroman#1\stop}
+\def\fr@mroman {\afterassignment\@testchar\let\next}
+\def\@testchar{%
+ \ifx\next\stop
+ \ifnum\r@mancount<0 (Wrong Roman numeral: ???)
+ \else
+ \the\r@mancount
+ \fi
+ \let\next\relax
+ \else \@valueofcurrent
+ \advance\r@mancount by\current
+ \ifnum\previous<\current
+ \multiply\previous by2
+ \advance\r@mancount by -\previous
+ \fi
+ \let\next\fr@mroman
+ \fi
+ \previous=\current
+ \next}
+\catcode`@=12
+\endinput
+
+
+---------------------------------------------------------------------------
+Ole Michael Selberg,
+Institutt for oesteuropeiske og orientalske studier
+Universitetet i Oslo
+Pb. 1030 Blindern
+N-0315 Oslo
+
+Phone: (47) 22 85 67 94
+Fax: (47) 22 85 41 40
+
+