2

Considering the following example:

\documentclass{memoir}
\usepackage{makeidx}
\makeindex
%\usepackage[hyperindex=false]{hyperref}%doesn't help
\usepackage{hyperref} %commenting out this one would do.
\begin{document}
\frontmatter
Something\index{Something}. And something else\index{Something else}
\mainmatter
Something\index{Something}. And something else\index{Something else}
\printindex
\end{document}

And the following minimal xindy style file, formatting roman page numbers as small caps:

(markup-locref :class "roman-page-numbers" :open  "\textsc{" :close "}")

$ xindy -M texindy -M scpages.xdy example.idx

This works when I comment out hyperref:

working minimum example

However with hyperref roman numbers do not get formatted as small caps:

enter image description here

How do I make it work with hyperref?

Edit: One possible workaround is to comment out hyperref just for building the index. Once I'm satisfied with the index I can comment it back in again, but I'll have to comment out \makeindex and not run xindy, which means that if because of editing my project some entries get pushed onto another page it will not automatically be reflected in the index. Also, in the pdf the page numbers will not be clickable. For print this workaround is sufficient, and at least hyperref works for the rest of the file, i.e. separate page ranges for front- and mainmatter in the pdf.

Edit:

Another temporary fix is to run a perl one liner over the .ind-file:

perl -pi -e 's/(\\hyperpage{.*?})/\\textsc{$1}/g' myfile.ind

which encapsulates every instance of \hyperpage{[some number]} with \textsc{}. That way one doesn't need to switch hyperref between commented in and out, thus streamlining the build process. The numbers become clickable, and one gets the desired small caps for the roman numbers. This line can be conveniently added to a buildscript after the xindy call.

5
  • 1
    Just make the change to the format for all entries. \textsc{\thepage} is equivalent to \thepage if \thepage gives an Arabic numeral anyway. At least, normally it is. If you are using a particular font configuration it might not be. But it would be better to have the page numbering set up so \thepage does the right thing on its own.
    – cfr
    Sep 29, 2015 at 0:51
  • 2
    I have in my archives the defifinition of a \pagenumbering{scroman}. Do you think it might be useful, and compatible with memoir?
    – Bernard
    Sep 29, 2015 at 0:56
  • @Bernard It might be useful. Just post it, I will see if it works, or if it can easily be adapted. My page headers I can easily change to work with that.
    – muk.li
    Sep 29, 2015 at 1:04
  • 1
    @Bernard I can more-or-less see how to do this for standard classes (just been looking before I saw your comment). But memoir seems to do something different and I can't figure it out at all.
    – cfr
    Sep 29, 2015 at 1:22
  • @Bernard I am getting the impression that if I completely change the frontmatter page numbering to small caps I will have to define a new alphabet and a new location-class for xindy, not sure how trivial that would be.
    – muk.li
    Sep 29, 2015 at 1:24

1 Answer 1

1

I propose a possible tool to achieve what you want. This defines 3 new page numbering styles. They were not written by me, but I can't remember who did, probably at my request, to solve some problem of old-style typography.

The 3 styles are: scroman (roman style with small caps), osroman (like roman, except if page number in consecutive is, the last i is replaced with j, and scosroman (same as previous, with small caps). Here is an example:

\documentclass[openany]{book}
\usepackage{ebgaramond}

\usepackage{lipsum}% texte bidon

\makeatletter
\newcommand{\oldstyleroman}[1]{\expandafter\@oldstyleroman#1\@nil}
\def\@oldstyleroman#1#2\@nil{%
  \ifcat$\detokenize{#2}$%
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\if#1ij\else#1\fi}% si #2 est vide
  {#1\@oldstyleroman#2\@nil}% si #2 n'est pas vide
}
\def\scroman#1{\expandafter\@scroman\csname c@#1\endcsname}
\def\@scroman#1{{\scshape\romannumeral #1}}
\def\osroman#1{\expandafter\@osroman\csname c@#1\endcsname}
\def\@osroman#1{{\oldstyleroman{\romannumeral #1}}}
\def\scosroman#1{\expandafter\@scosroman\csname c@#1\endcsname}
\def\@scosroman#1{{\scshape\oldstyleroman{\romannumeral #1}}}
\makeatother

\usepackage{hyperref}

\begin{document}

\tableofcontents

\frontmatter
\pagenumbering{scroman}

\chapter{Introduction}
\section{Titre}
\lipsum[1-10]
\section{Titre}
\label{page}
\lipsum[11-20]

\mainmatter
\chapter{A Matter of Styles}
\lipsum[21-25]

Voir page~\pageref{page}.


\end{document}

enter image description here

enter image description here

4
  • The question was about the index
    – egreg
    Sep 29, 2015 at 2:06
  • @egreg: I know, that's why I only proposed this code as a possible tool to achieve what the O.P. wants
    – Bernard
    Sep 29, 2015 at 2:09
  • By now I sort of got it to work using a xindy style file, except I have to get it to play nice with hyperref, still thanks.
    – muk.li
    Sep 29, 2015 at 3:58
  • Oh, and your solution for changing the page numbers to small caps did also work after changing the class to memoir.
    – muk.li
    Sep 29, 2015 at 4:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .