3

The old Libertine package, which worked with pdfTeX, included a command \libertineGlyph{}. \libertineGlyph{Fourroman} printed

But how can I get these roman numbers used for numbering sections and even in the TOC?

I found Using ligatures from libertine for roman numerals in pdftex , but I do not know how to make it work.

MWE:

\documentclass[ngerman]{article}
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
\usepackage{babel,blindtext}
 \usepackage{libertine}


\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%
}


%%% Roman numbers
\renewcommand{\thesection}{\Roman{section}}

%%% Roman ligatures from Linux Libertine?
%\renewcommand{\thesection}{\libertineRoman{section}}
%%% DOES NOT WORK


\begin{document}
\tableofcontents{}

{\libertineGlyph{Fourroman}} 

\blinddocument

\end{document}

Cave: I use the old libertine package from years ago, which provides \libertineGlyph for pdfTeX. However, maybe somebody can give me a hint.

4

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

enter image description here

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}
  • Although my example does not use \tableofcontents it would work with it, too. – clemens Aug 22 '13 at 15:30
  • Whoo! Worx perfectly, with pdfLaTeX and TOC! I'll test it in real life documents and will report, if there were any issue. However: Thank you very much! – Keks Dose Aug 22 '13 at 16:46
  • @KeksDose you're welcome :) – clemens Aug 22 '13 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.