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.



\title{Example }





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



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

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



And the result is:

What should I do to correct the links?

EDIT: An warning message is shown:

} has been referenced but does not exist, replaced by a fixed one
  • 1
    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:


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:

\addto\pdfstringdefPreHook{\def\es@roman#1{\romannumeral#1 }}

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.

  • That's nice! (+1) – user31729 Jul 5 '16 at 15:19
  • It works perfectly! Thanks a lot Javier (again!). It's a pleasure to learn LaTeX from the best ones! – Minkowski Jul 5 '16 at 15:46
  • Great! I'll prepare a new version, but not right now (I'm very busy finishing babel 3.10). – Javier Bezos Jul 5 '16 at 18:07

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.