[Tex/LaTex] Writing Roman numbers in Equation

roman numeralstex-core

What is the command for writing roman numerals like I, II, IV etc. in an equation ? To be noted that my requirement is to write them within $$ …$$ and not as counters or page numbers. Any light on this would be extremely helpful.

Best Answer

If you don't want to do the conversion,

\documentclass{article}
\usepackage{amsmath}

\newcommand{\RN}[1]{%
  \textup{\uppercase\expandafter{\romannumeral#1}}%
}

\begin{document}
\[
\RN{4}+\RN{12}=\RN{16}
\]
\end{document}

enter image description here

If you also don't want to do the arithmetic

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\RN}{m}
 {
  \textup{ \int_to_Roman:n { #1 } }
 }
\ExplSyntaxOff

\begin{document}
\[
\RN{4}+\RN{12}=\RN{4+12}
\]
\end{document}
Related Question