# Makeindex and Hyperref in Spanish

Following this answer I was given, about how to add small caps roman numbers in the index with babel in Spanish, I have a new problem. With the hyperref package, the links don't go to the right page with these roman numbers. They always go to the very first page of the document.

The link of the table of contents works fine, as well as the words in the index with arabic numbers, but the words in the index with roman numbers don't.

MWE:

\documentclass[a4paper,openright,10pt]{book}
\usepackage[spanish,es-nosectiondot,es-preindex,es-noquoting]{babel}
\usepackage{hyperref}
\usepackage{makeidx}
\makeindex

\title{Example }

\author{Me}

\begin{document}

\frontmatter
\maketitle

\chapter{Introduction}

Hello casa \index{casa} .....

\mainmatter

\chapter{Blaaaaaaaaaaaa}

Words \index{m\'{e}dico}.

\renewcommand{\indexname}{\'{I}ndice de Materias}

\printindex

\end{document}


And the result is:

What should I do to correct the links?

EDIT: An warning message is shown:

0Warning:\040Replacing\040OT1/cmr/m/n'\040by\040\\MessageBreak\040faked\040sma
ll\040caps\040on\040input\040line\0403.\012}\\endgroup\040\\uppercase\040{iii}}
} has been referenced but does not exist, replaced by a fixed one
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/
share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmcsc10.pfb></usr/share
/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share/texliv
e/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texlive/texmf
-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/share/texlive/texmf-dist/f
onts/type1/public/amsfonts/cm/cmsl10.pfb>

• I'm investigating the hyperref internals, which are even trickier than the spanishones ;-). – Javier Bezos Jul 5 '16 at 14:20

There are in fact two issues. Both can be fixed easily thanks to the hooks provided by the packages.

Firstly, the index entries are modified by hyperref, which doesn't recognize a macro defined by spanish. This issue is fixed with the following line before \printindex:

\def\esromanindex#1{\hyperindexformat{\textsc}}


Second, there is little bug in hyperref, which redefines an internal macro wrongly, because to create the target name it maps lowercase small caps to uppercase. But fortunately, there is also a hook, so after loading hyperref (and babel) write:

\makeatletter

It works for me, which of course doesn't mean it works for everyone ;-). I hope it works also for you, and if so, I'll modify spanishfor it to work with hyperref`.