# Typesetting Roman numerals within LaTeX text

I want to typeset real Roman numerals (both uppercase and lowercase) in LaTeX text. I've checked out a previous thread but found no satisfactory solution. (In fact, several solutions mentioned in that thread doesn't work for me. I don't know why.)

I personally use the straightforward approach of

    \newcounter{counter}
\newcommand{\upperRomannumeral}[1]{\setcounter{counter}{#1}\Roman{counter}}
\newcommand{\lowerromannumeral}[1]{\setcounter{counter}{#1}\roman{counter}}


but it is still not satisfactory. Is there any better way to perform the task?

-
I guess there must be some userpackages to handle this? It's weird not having any package for such a daily task. (Well by daily I mean Roman numerals are not fancy symbols used only in a very limited circle.) –  4ae1e1 Jan 13 '13 at 5:25
A better approach would create a single counter (perhaps even avoid this and use a scratch counter), use \setcounter and avoid the spurious spaces within the macro. –  Werner Jan 13 '13 at 5:27
@Werner Thank you for this good advice! –  4ae1e1 Jan 13 '13 at 5:47
@cmhughes Well, thanks for welcoming but actually I'm not new here... Recently I signed up for a new stack exchange id ;) –  4ae1e1 Jan 13 '13 at 5:48

If I understand you right, it seems like you are after in-line lists that are numbered in Roman numerals. I think the enumitem package is up to the job for this kind of thing.

## Code

\documentclass[preview,border=5]{standalone}

\usepackage{enumitem}

\newlist{inlineroman}{enumerate*}{1}
\setlist[inlineroman]{itemjoin*={{, and }},afterlabel=~,label=\roman*.}

\newcommand{\inlinerom}[1]{
\begin{inlineroman}
#1
\end{inlineroman}
}

\newlist{Inlineroman}{enumerate*}{1}
\setlist[Inlineroman]{itemjoin*={{, and }},afterlabel=~,label=\Roman*.}

\newcommand{\InlineRom}[1]{
\begin{Inlineroman}
#1
\end{Inlineroman}
}

\begin{document}
I would like to cite some properties. Here are the properties listed in-line using small Roman numerals: \inlinerom{\item first, \item second \item third.}

Here are other properties listed as capital Roman numerals: \InlineRom{\item First property \item Second property \item Third property.}
\end{document}


## Output

-
@KevinSayHi Am I right that I saw in one of your comments, now probably deleted, that you want a list of some kind? That is the reason I created this answer. Can you make your question clearer? Please tell me if this helps you. If not, I would delete it to tidy up the place. –  hpesoj626 Jan 13 '13 at 7:15
Oh, great! I used enumitem to do labeling in enumerate environment, but never realized that there are inline lists. Thank you so much! –  4ae1e1 Jan 13 '13 at 7:17
Well, what I need is not only lists, but rather free usage of roman numerals. But based on your code there is definitely a workaround to do that. –  4ae1e1 Jan 13 '13 at 7:20
@KevinSayHi You might want to check out the manual again. enumitem now has a lot of goodies apart from labeling your items. :) In your terminal/command prompt, type texdoc enumitem. –  hpesoj626 Jan 13 '13 at 7:42

You might try using the biblatex package. It has a \RN command that does uppercase roman numerals. That way you don't have to create your own command. biblatex is usually loaded to do bibliographies, but it does the roman numerals as well.

-
Thanks, but what about lowercase roman numerals? They are actually more widely used, as least to me, within mathematical contexts. Properties or conditions are usually enumerated as i, ii, iii, etc. and later on I need to access them. –  4ae1e1 Jan 13 '13 at 5:46

If you use the xparse package, then you can very nicely define a single command which will set the roman numerals in upper or lower case depending on whether or not there is a star to the command name.

Here is a MWE which uses a counter

\documentclass{article}
\newcounter{myromanumeral}
\usepackage{xparse}
\NewDocumentCommand{\myrm}{s m}
{\setcounter{myromanumeral}{#2}%
\IfBooleanTF #1{\Roman}{\roman}{myromanumeral}}
\begin{document}
Hello, does this work \myrm{19}?  Or this \myrm*{19}?
\end{document}


If you really don't want to use a counter you can do something like the following:

\makeatletter
\NewDocumentCommand{\myrmo}{s m}
{\expandafter\def\csname c@my@private@counter\endcsname{#2}%
\IfBooleanTF #1{\Roman}{\roman}{my@private@counter}}
\makeatother


Please notice how in my code I use % at the end of the lines. This prevents extra space from creeping in where I don't want it.

If you want to stick with your own commands, then rewrite them as

\newcounter{counter}

\newcommand{\upperRomannumeral}[1]{%
\setcounter{counter}{#1}%
\Roman{counter}%
}

\newcommand{\lowerromannumeral}[1]{%
\setcounter{counter}{#1}%
\roman{counter}%
}

-
Thanks, but these are still based on the same principle, only a little trick to make it simpler. Have you noticed that the spacing by directly using \Roman and \roman is wierd? I didn't include the spacing adjustment hspace in my original code, since they are font size dependent; given that you have to use hspace, the command is always frustrating :( I really expect some pre-defined packages to handle these so I don't see the mess in my code... –  4ae1e1 Jan 13 '13 at 7:07
I guess I'm not understanding what you're looking for. What kind of spacing issues are you concerned about? I'm not seeing a spacing issue. –  A.Ellett Jan 13 '13 at 7:10
Oh, really? When I don't adjust the spacing, the blank around roman numerals are about 10pts wider than expected on both sides. –  4ae1e1 Jan 13 '13 at 7:13
I think this is an issue with how you're writing your command. I've added some more details to my answer above. Also, try running my commands. You should notice that they don't create any extra space. –  A.Ellett Jan 13 '13 at 7:18
Yes, it's a problem with my command. Yours does not create extra space, but mine creates roughly 7pt when the font is set to 10pt. I don't know why... –  4ae1e1 Jan 13 '13 at 7:26

Usually Roman numerals are used with counters for enumerated lists or as numbers for sectional units and the \roman and \Roman facilities do just this.

If all you want is to print some number in Roman numerals, here are two easy macros:

\newcommand{\upperRomannumeral}[1]{\uppercase\expandafter{\romannumeral#1}}
\newcommand{\lowerromannumeral}[1]{\romannumeral#1\relax}


Thus you can write

The king Louis~\upperRomannumeral{14} was called le roi soleil''


but typing Louis~XIV would be clearer and shorter.

-
Great! Thank you very much. –  4ae1e1 Jan 13 '13 at 15:40