12

I use roman page number for front matter, I was just wondering, is it possible to make these roman numbers as ligature?

See.

Roman:

and

roman:

KOF
  • 5,019

1 Answers1

12

This introduces two new numberings: xroman and xRoman, that try to do what you want. We had to introduce our own for-cycle, because we have to make everything expandable. In the result, we just add a negative space between the letters. We use small-caps for the lower-case variant, and we use a trick with a robust command to add the dot on i.

EDIT: The new version works with hyperref package without causing warnings.

EDIT 2: The new version allows horizontal adjustments of the dot over i.

enter image description here

\documentclass{article}

\pagenumbering{xroman}

\usepackage{hyperref}

\makeatletter
\DeclareRobustCommand \i@xroman{\rlap{\kern-0.007em\.{}}i}
\def \@xroman@for #1#2\@nil{\if i#1\i@xroman\else#1\fi\ifx\relax#2\relax\else\hskip-0.093em\@xroman@for#2\@nil\fi}
\def \@xRoman@for #1#2\@nil{\uppercase{#1}\ifx\relax#2\else\hskip-0.09em\@xRoman@for#2\@nil\fi}
\newcommand \@Xroman [1]{\begingroup\scshape\expandafter\expandafter\expandafter\@xroman@for\@roman{#1}\relax\@nil\endgroup}
\newcommand \@XRoman [1]{\begingroup        \expandafter\expandafter\expandafter\@xRoman@for\@roman{#1}\relax\@nil\endgroup}
\newcommand \xroman [1]{\expandafter\@xroman\csname c@#1\endcsname}
\newcommand \xRoman [1]{\expandafter\@xRoman\csname c@#1\endcsname}
\AtBeginDocument{\@ifundefined{texorpdfstring}{
  \let\@xroman\@Xroman
  \let\@xRoman\@XRoman
}{
  \newcommand \@xroman [1]{\texorpdfstring{\@Xroman{#1}}{\@roman{#1}}}
  \newcommand \@xRoman [1]{\texorpdfstring{\@XRoman{#1}}{\@Roman{#1}}}
}}
\makeatother  

\begin{document}

\setcounter{page}{3678}

\section{ABC}\label{abc}

This is Section \ref{abc} on page \pageref{abc}.

hello

\end{document}
yo'
  • 51,322
  • how to use this code for front matter page numbering? \pagenumbering{xroman} seems not working. Also i tried \setcounter{page}{3} in the front matter codes, it shows still like "iii". – KOF Dec 28 '12 at 14:39
  • It really worked out, perfect! By the way, using this code with pdflatex in texmaker, it takes much longer time (100% CPU...) than in Terminal (very fast). – KOF Dec 28 '12 at 17:33
  • There is another minor issue, when using \pagenumbering{xroman} or {xRoman}, hyperref warning info:

    Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing `\uppercase' on input line 53. .... I know this is like using Greek symbol in Hyperref, and hence the warning inform arose.

    – KOF Dec 29 '12 at 11:17
  • @KOF Noticed, improved ;) – yo' Dec 30 '12 at 17:45