[Tex/LaTex] How to write fancy-looking Roman numerals

fontsroman numerals

Is there a way to produce Roman numerals in the text in a way that there is an "overline and underline" connected? I have tried using combinations like

\overline{\underline{XVI}}

but the lines are disconnected. I'm looking a solution that produces similar numerals to the picture below.

Fancy numerals

Best Answer

\documentclass{article}
\usepackage{stackengine}
\setstackEOL{\\}
\newcounter{tmpctr}
\newcommand\fancyRoman[1]{%
  \setcounter{tmpctr}{#1}%
  \setbox0=\hbox{\kern.2pt\textsf{\Roman{tmpctr}}}%
  \setstackgap{S}{-.6pt}%
  \Shortstack{\rule{\dimexpr\wd0+.1ex}{.7pt}\\\copy0\\
              \rule{\dimexpr\wd0+.1ex}{.7pt}}%
}
\begin{document}
Fancy Romans:

1--5: \fancyRoman{1}
\fancyRoman{2}
\fancyRoman{3}
\fancyRoman{4}
\fancyRoman{5}

6--10: \fancyRoman{6}
\fancyRoman{7}
\fancyRoman{8}
\fancyRoman{9}
\fancyRoman{10}

11--12: \fancyRoman{11}
\fancyRoman{12}
\end{document}

enter image description here