[Tex/LaTex] Using ligatures from libertine for roman numerals in pdftex

libertineligaturesroman numerals

I am using the Linux Libertine font through the libertine-legacy package with pdftex. This font contains nice ligatures for roman numerals, e.g., \LibertineGlyph{tworoman} gives ii. Now I want to use those glyphs whereever they occur with counters, e.g., page numbers in frontmatter, and part numbering. In the end I would like to have an analogue to \roman, say \ligroman, that I can feed to \pagenumberstyle etc.

Best Answer

From Ⅰ to Ⅻ

Libertine and \libertineGlyph

In my example I use XeLaTeX and libertineotf which provides \libertineGlyph and the glyphs. As stated in my comment, this should work with libertine-legacy, too. The new libertine-type1 and biolinum-type1 don't support this anymore.

This provides two macros:

  • \libertineRoman{<countername>} for majuscle, and
  • \libertineroman{<countername>} for minuscle Roman digits .

This approach converts only numbers between 1 and 12 into the special roman digit glyphs.

Code

\documentclass{article}
\usepackage{libertineotf}% replace with libertine-legacy
%\usepackage[T1]{fontenc}% use with pdfLaTeX
\newcommand*{\libertineRoman}[1]{%
    \def\Romantemp{}%
    \ifnum\value{#1}>0\relax%
        \ifnum\value{#1}<13\relax%
            \edef\Romantemp{\ifcase\value{#1}\or One\or Two\or Three\or Four\or Five\or Six\or Seven\or Eight\or Nine\or Ten\or Eleven\or Twelve\fi}%
            \libertineGlyph{\Romantemp roman}%
        \else\Roman{#1}\fi%
    \else\Roman{#1}\fi%
}
\newcommand*{\libertineroman}[1]{%
    \def\Romantemp{}%
    \ifnum\value{#1}>0\relax%
        \ifnum\value{#1}<13\relax%
            \edef\Romantemp{\ifcase\value{#1}\or one\or two\or three\or four\or five\or six\or seven\or eight\or nine\or ten\or eleven\or twelve\fi}%
            \libertineGlyph{\Romantemp roman}%
        \else\roman{#1}\fi%
    \else\roman{#1}\fi%
}
\begin{document}
\newcounter{testRoman}
\setcounter{testRoman}{13}
\loop\ifnum\value{testRoman}>1\relax\addtocounter{testRoman}{-1}
    \thetestRoman: \roman{testRoman} \Roman{testRoman} \libertineroman{testRoman} \libertineRoman{testRoman} \par
\repeat
\end{document}

Output

enter image description here

Unicode (Xe-/LuaLaTeX only)

A solution that uses the whole range of Unicode's Roman digits is already available.