Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

share|improve this question
5  
Does this question help? Roman numerals with over and underline Also related: Using Unicode Roman numerals in XeTeX –  egreg Dec 28 '12 at 14:14
    
@egreg: Unicode suggests to not use the Unicode roman characters; see the comments for tex.stackexchange.com/questions/38695/… –  Martin Schröder Dec 28 '12 at 14:20
    
I added the codes mentioned in " Roman numerals with over and underline" and use: \pagenumbering{barroman}. It turned out not working. It only works in text mode. @ Martin Schröder: I also tried the codes you provided, it seems work, the the page number is like 'âĚř '. –  KOF Dec 28 '12 at 14:24
    
@egreg I agree it is related. However, your solution seems not to be expandable. Do you think the questions should be merged? I suppose not, but I'm not sure. –  tohecz Dec 28 '12 at 18:37
add comment

2 Answers

up vote 9 down vote accepted

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}
share|improve this answer
    
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 ;) –  tohecz Dec 30 '12 at 17:45
add comment

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.

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) \kern -1.07996pt (hyperref) removed on input line 53.

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing `\uppercase' on input line 53.

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing `\endgroup' on input line 53.

I know this is like using Greek symbol in Hyperref, and hence the warning inform arose.

The dot of lower case roman number i is a bit right aligned compared to original i, see [Libertine font] enter image description here The upper case is ok then. enter image description here

share|improve this answer
    
improved I hope –  tohecz Dec 30 '12 at 20:18
    
And if you post an answer because it is too long for a comment, it is a common good habit to make it "community wiki", there's a checkbox for it under the answer text ;) –  tohecz Dec 30 '12 at 20:25
    
@tohecz thanks. –  KOF Dec 30 '12 at 23:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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