[Tex/LaTex] Using unicode Roman numerals in XeTeX

roman numeralsunicodexetex

As mentioned in How can I get Roman numerals in text?, there are several ways in which one can add Roman numerals to text in TeX. However, these solutions all seem to use three I's to make a roman numeral 3, rather than combining using the "Number forms" symbols found in many fonts such as "Ⅲ".

Is there a way to get XeTeX to render all of the Roman numerals in a document using the special Roman numeral symbols found in many fonts?

Best Answer

\documentclass{article}
\usepackage{fontspec}
\usepackage{libertine}
\def\uromannumeral#1{\symbol{\numexpr"216F+#1\relax}}
\def\uRomannumeral#1{\symbol{\numexpr"215F+#1\relax}}
\def\uroman#1{\uromannumeral{\the\value{#1}}}
\def\uRoman#1{\uRomannumeral{\the\value{#1}}}

\begin{document}
\uromannumeral{12} \uRomannumeral{7}

\uroman{page} \uRoman{page}

\def\theenumi{\uRoman{enumi}}
\begin{enumerate}
\item foo
\item foo
\item foo
\item foo
\item foo
\end{enumerate}

\end{document}

output