0

I'm trying to insert some Roman and Greek numerals in a beamer presentation compliled with XeLaTeX (the choice is determined by the fact that I have also to insert some Egyptian, Babylonian and Maya numerals)

Can romannum be adapted to deal with numbers bigger than 3999 using overbars, and not using repeating M's?

Ingmar
  • 6,690
  • 5
  • 26
  • 47
Mathland
  • 167
  • 5
    You need to explain what you mean. Provide some clear direction in terms of the packages you're using, the current limitations, and visuals of what features you want in the output. Can you do that? – Werner Apr 05 '23 at 17:22

1 Answers1

3

I've never used (or heard of) romannum, but I bet it works something like:

\documentclass{article}

\newcounter{fingers} \def\romannum#1{\setcounter{fingers}{#1}\Roman{fingers}}

\begin{document} \romannum{4005} \end{document}


Revised solution:

\documentclass{article}

\makeatletter \def\romannum#1{\bgroup \count1=#1\relax \ifnum\count1<4000\relax@Roman{\count1}% \else \count2=\numexpr \count1/1000\relax \sbox0{@Roman{\count2}}% \count1=\numexpr \count1-1000*\count2\relax \usebox0\llap{\rule[\dimexpr \ht0+1pt]{\wd0}{0.5pt}}@Roman{\count1}% \fi \egroup} \makeatother

\begin{document} \romannum{4005}

\romannum{5000}

\romannum{9005} \end{document}


This version uses the xstring package to replace I with M etc. in the times 1000 roman numerals.

\documentclass{article}
\usepackage{xstring}

\newsavebox{\vbar} \sbox0{V}\savebox\vbar{\usebox0\llap{\rule[\dimexpr \ht0+1pt]{\wd0}{0.5pt}}}% \newsavebox{\xbar} \sbox0{X}\savebox\xbar{\usebox0\llap{\rule[\dimexpr \ht0+1pt]{\wd0}{0.5pt}}}% \newsavebox{\lbar} \sbox0{L}\savebox\lbar{\usebox0\llap{\rule[\dimexpr \ht0+1pt]{\wd0}{0.5pt}}}% \newsavebox{\cbar} \sbox0{C}\savebox\cbar{\usebox0\llap{\rule[\dimexpr \ht0+1pt]{\wd0}{0.5pt}}}% \newsavebox{\dbar} \sbox0{D}\savebox\dbar{\usebox0\llap{\rule[\dimexpr \ht0+1pt]{\wd0}{0.5pt}}}% \newsavebox{\mbar} \sbox0{M}\savebox\mbar{\usebox0\llap{\rule[\dimexpr \ht0+1pt]{\wd0}{0.5pt}}}%

\makeatletter \def\romannum#1{\bgroup \count1=#1\relax \ifnum\count1<4000\relax @Roman{\count1}% \else \count2=\numexpr \count1/1000\relax \count1=\numexpr \count1-1000*\count2\relax \edef\tempstr{@Roman{\count2}}% substitute letters \StrSubstitute{\tempstr}{M}{\usebox\mbar}[\tempstr]% goes first \StrSubstitute{\tempstr}{I}{M}[\tempstr]% \StrSubstitute{\tempstr}{V}{\usebox\vbar}[\tempstr]% \StrSubstitute{\tempstr}{X}{\usebox\xbar}[\tempstr]% \StrSubstitute{\tempstr}{L}{\usebox\lbar}[\tempstr]% \StrSubstitute{\tempstr}{C}{\usebox\cbar}[\tempstr]% \StrSubstitute{\tempstr}{D}{\usebox\dbar}@Roman{\count1}% \fi \egroup} \makeatother

\begin{document} \romannum{4005}

\romannum{5000}

\romannum{9005}

\romannum{17005}

\romannum{1000000} \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • 1
    It doesn't work since 4005 should be $M\bar{V}V$ and not MMMMV. Similarly 10000 should be $\bar{X}$ and not MMMMMMMMMM..... – Mathland Apr 05 '23 at 21:02
  • Intersting, so 5000 is \bar{V}? (That's a lot of fingers!) – John Kormylo Apr 06 '23 at 02:17
  • Never heard of using a \bar multiplier in Roman numerals. Roman numerals, IMO, are good for dates, years, chapter numbers, Superbowl, etc. but it becomes tedious after 3 or so thousand – which might be the reason that there is little demand for it and, consequently, no corresponding LaTeX package. – Ingmar Apr 06 '23 at 07:08
  • See https://www.britannica.com/topic/Roman-numeral It should be noted that there are muiltiple ways to handle numbers > 4000, but not only is it easy to implement, \bar{IV} is relatively easy to read (as opposed to M\bar{V}). – John Kormylo Apr 06 '23 at 13:51
  • However, M\bar{v} is also possible. – John Kormylo Apr 09 '23 at 20:55