TransWikia.com

Correct hyperref-page reference

TeX - LaTeX Asked on March 22, 2021

This is some sort of follow-up to the question: Compatibility of hypertexnames=false and indexes.

I will post Ulrike Fischer’s answer which shall now serve as MWE for this question:

documentclass[index=totoc]{scrbook}
usepackage{lipsum}
usepackage{makeidx}
makeindex

usepackage[hypertexnames=false]{hyperref}

makeatletter
usepackage{etoolbox}
patchcmdHy@EveryPageBoxHook{Hy@EveryPageAnchor}{Hy@hypertexnamestrueHy@EveryPageAnchor}{}{fail}
makeatother

begin{document}

frontmatter

title{Title}
maketitle

mainmatter

chapter{Chapter 1}
label{chap1}
index{BeginningChapter1}lipsumindex{EndChapter1}

chapter{Chapter 2}
index{BeginningChapter2}lipsumindex{EndChapter2}
pageref{chap1}
printindex
end{document}

Albeit Ulrike Fischer warned that the option is »not much tested«, it also worked in every document I compiled until now (small and large): The page-references lead to correct page-numbers, and they are displayed correctly.

There is a new problem that arises: The absolute page number is still stored somewhere, and used in some PDF-readers and displayed when the cursor hovers over the reference. Two Screenshots from Okular and qpdfviewer (Adobe Acrobat Reader shows nothing, but I am using an old version with wine):

qpdfviewer

okular

Any idea if this can be fixed hyperrefs means? (Another user encountered the same problem here under different circumstances. Loading hyperref first as suggested in the answer actually works for the MWE, but I am dependent to load hyperref after a few other packages in many documents.)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP