The new libertine
package also provides \libertineGlyph
if XeLaTeX or LuaLaTeX is used. This made it possible for me to come up with a solution without installing the old package. The code should also work for the old package.
A counter representation command such as \arabic
should be expandable if you don't want to run into troubles. Your commands are not expandable, though.
Below I define five commands:
\LibertineRomanByName{<name>}
-- a shortcut for \libertineGlyph{<name>roman}
.
\LibertineUCRomanByInt{<integer>}
-- gives the uppercase libertine glyph for the given integer (as long as the integer is in the range of 1--12).
\LibertineLCRomanByInt{<integer>}
-- gives the lowercase libertine glyph for the given integer (as long as the integer is in the range of 1--12).
\lbtRoman{<counter>}
-- gives the uppercase libertine glyph for the corresponding counter value or the usual result of \Roman
if the counter is out of range.
\lbtroman{<counter>}
-- gives the lowercase libertine glyph for the corresponding counter value or the usual result of \roman
if the counter is out of range.
The Code
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}
\setcounter{section}{7}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}
\setcounter{section}{13}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}
\LibertineUCRomanByInt{1} \LibertineLCRomanByInt{1}\par
\LibertineUCRomanByInt{2} \LibertineLCRomanByInt{2}\par
\LibertineUCRomanByInt{3} \LibertineLCRomanByInt{3}\par
\LibertineUCRomanByInt{4} \LibertineLCRomanByInt{4}\par
\LibertineUCRomanByInt{5} \LibertineLCRomanByInt{5}\par
\LibertineUCRomanByInt{6} \LibertineLCRomanByInt{6}\par
\LibertineUCRomanByInt{7} \LibertineLCRomanByInt{7}\par
\LibertineUCRomanByInt{8} \LibertineLCRomanByInt{8}\par
\LibertineUCRomanByInt{9} \LibertineLCRomanByInt{9}\par
\LibertineUCRomanByInt{10} \LibertineLCRomanByInt{10}\par
\LibertineUCRomanByInt{11} \LibertineLCRomanByInt{11}\par
\LibertineUCRomanByInt{12} \LibertineLCRomanByInt{11}
\setcounter{section}{7}
\renewcommand*\thesection{\lbtRoman{section}}
\section{Let's see: it works!}
then gives

Here's the complete code:
% arara: lualatex
\documentclass{article}
\usepackage{libertine}
\makeatletter
\newcommand*\LibertineRomanByName[1]{\libertineGlyph{#1roman}}
\newcommand*\LibertineUCRomanByInt[1]{%
\ifcase#1%
\or\LibertineRomanByName{One}%
\or\LibertineRomanByName{Two}%
\or\LibertineRomanByName{Three}%
\or\LibertineRomanByName{Four}%
\or\LibertineRomanByName{Five}%
\or\LibertineRomanByName{Six}%
\or\LibertineRomanByName{Seven}%
\or\LibertineRomanByName{Eight}%
\or\LibertineRomanByName{Nine}%
\or\LibertineRomanByName{Ten}%
\or\LibertineRomanByName{Eleven}%
\or\LibertineRomanByName{Twelve}%
\fi
}
\newcommand*\LibertineLCRomanByInt[1]{%
\ifcase#1%
\or\LibertineRomanByName{one}%
\or\LibertineRomanByName{two}%
\or\LibertineRomanByName{three}%
\or\LibertineRomanByName{four}%
\or\LibertineRomanByName{five}%
\or\LibertineRomanByName{six}%
\or\LibertineRomanByName{seven}%
\or\LibertineRomanByName{eight}%
\or\LibertineRomanByName{nine}%
\or\LibertineRomanByName{ten}%
\or\LibertineRomanByName{eleven}%
\or\LibertineRomanByName{twelve}%
\fi
}
\newcommand*\lbtRoman[1]{\expandafter\@lbtRoman\csname c@#1\endcsname}
\newcommand*\@lbtRoman[1]{%
\ifnum#1=0
0%
\else
\ifnum#1<13
\LibertineUCRomanByInt{#1}%
\else
\@Roman{#1}%
\fi
\fi
}
\newcommand*\lbtroman[1]{\expandafter\@lbtroman\csname c@#1\endcsname}
\newcommand*\@lbtroman[1]{%
\ifnum#1=0
0%
\else
\ifnum#1<13
\LibertineLCRomanByInt{#1}%
\else
\@roman{#1}%
\fi
\fi
}
\makeatother
\begin{document}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}
\setcounter{section}{7}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}
\setcounter{section}{13}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}
\LibertineUCRomanByInt{1} \LibertineLCRomanByInt{1}\par
\LibertineUCRomanByInt{2} \LibertineLCRomanByInt{2}\par
\LibertineUCRomanByInt{3} \LibertineLCRomanByInt{3}\par
\LibertineUCRomanByInt{4} \LibertineLCRomanByInt{4}\par
\LibertineUCRomanByInt{5} \LibertineLCRomanByInt{5}\par
\LibertineUCRomanByInt{6} \LibertineLCRomanByInt{6}\par
\LibertineUCRomanByInt{7} \LibertineLCRomanByInt{7}\par
\LibertineUCRomanByInt{8} \LibertineLCRomanByInt{8}\par
\LibertineUCRomanByInt{9} \LibertineLCRomanByInt{9}\par
\LibertineUCRomanByInt{10} \LibertineLCRomanByInt{10}\par
\LibertineUCRomanByInt{11} \LibertineLCRomanByInt{11}\par
\LibertineUCRomanByInt{12} \LibertineLCRomanByInt{11}
\setcounter{section}{7}
\renewcommand*\thesection{\lbtRoman{section}}
\section{Let's see: it works!}
\end{document}