Showing posts with label roman. Show all posts
Showing posts with label roman. Show all posts

Friday, September 07, 2007

Roman numerals in Latex

Ok, we have to admit that it is not easy to input roman numerals in Latex. There is still a way.

In the preamble, i.e. before \begin{document}, define

\makeatletter
\newcommand{\rmnum}[1]{\romannumeral #1}
\newcommand{\Rmnum}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother

Then in the document part, \rmnum{num} is used to input the roman numeral of num, \Rmnum is for the uppercase. If you prefer to use other commands, just change the red part in the definition part.

If only lowercase roman numerals are occasionally used, \romannumeralnum can do it. In this approach, definition is not necessary.

Someone anonymous commented that "Nice, but it fails for N=4000 and above." However, in my system, it is working for 4000 and above.

Update: again, someone anonymous pointed out that MMMM is not allowed. Based on the information I found on the Internet, it is OK. But once the number goes bigger again, the convert is not correct.