\def\Middleage#1{%
\ifnum#1>0
\expandafter\Middleagei\romannumeral#1\expandafter\relax
\else
\errmessage{Invalid number}%
\fi}
\def\Middleagei#1#2{%
\ifx#2\relax
\expandafter\Middleageii\expandafter#1%
\else
#1\expandafter\Middleagei\expandafter#2%
\fi}
\def\Middleageii#1{%
\expandafter\if\string i#1%
j%
\else
#1%
\fi}
\Middleage{100}
\Middleage{128}
\Middleage{41}
We read two tokens from the expansion of \romannumeral#1\relax; if the second is \relax, then we are at the end; so we have to decide if the last token of the Roman numeral is i; if it is, we print j, otherwise the character.
Using this for representing counters in LaTeX
Add to the code above also
\makeatletter
\def\MAroman#1{\expandafter\@MAroman\csname c@#1\endcsname}
\def\@MAroman#1{\expandafter\Middleage\expandafter{\number#1}}
\makeatother
Now
\pagenumbering{MAroman}
\newcounter{mycount}
\renewcommand{\themycount}{\MAroman{mycount}}
will work as expected.
Different version
The following version will print "i", "ij", "iij", "iv", "v", "vi", "vij" and so on (a final "i" becomes "j" only if preceded by "i").
\makeatletter
\def\Middleage#1{\expandafter\@middleage\expandafter{\number#1}}
\def\@middleage#1{%
\ifnum#1>\z@
\expandafter\@middle@ge\romannumeral#1\expandafter @\expandafter @%
\else
\errmessage{Invalid number}%
\fi}
\def\@middle@ge#1#2#3{%
\if#2@%
#1%
\else
\expandafter\@middl@@ge\expandafter#1\expandafter#2\expandafter#3%
\fi}
\def\@middl@@ge#1#2#3{%
\if#3@%
\expandafter\@m@ddl@@ge\expandafter#1\expandafter#2%
\else
#1\expandafter\@middle@ge\expandafter#2\expandafter#3%
\fi}
\def\@m@ddl@@ge#1#2{%
\expandafter\if\string i#2%
\expandafter\if\string i#1%
ij%
\else
#1#2%
\fi
\expandafter\@gobble
\else
#1#2\expandafter\@gobble
\fi}
\makeatother
\romanand\Roman(ie. accepting a counter as an argument and producing the typeset numerals); on the other hand, it would be nice to have a\MiddleAgeRomansort of thing that would get a number and typeset it accordingly. – mpr Oct 19 '11 at 13:53\MiddleAgeRomanI cannot see it possible hacking\romanor\Romanbut I can be wrong. I have posted some code at pastebin.com/caS5mAnR, if you modify the table to typest the middle age variation, either me or someone would be able to post the code. – Yiannis Lazarides Oct 19 '11 at 14:07ito be changed tojit will be easier to do. Is that the only change? It doesn't appear to be so from wikipedia. – Yiannis Lazarides Oct 19 '11 at 14:28