1

When using notoccite and hyperref, I change the page number to roman with \pagenumbering. The page numebrs in TOC are correct but the ones in the PDF bookmark are still arabic. This bug happens only when compiling with xelatex. The pdflatex and lualatex work fine.

macOS 11.2.3
XeTeX 3.141592653-2.6-0.999993 (TeX Live 2021)
xdvipdfmx Version 20210318
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18>
Package: notoccite 2000/07/20
Package: hyperref 2021-02-27 v7.00k Hypertext links for LaTeX
\documentclass{book}

\usepackage{notoccite}
\usepackage{hyperref}

\begin{document}

\pagenumbering{roman}
\tableofcontents

\newcommand\test{%
  \chapter{Title}%
  \section{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \section{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \section{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \subsection{Title}%
}

% Make sure the TOC has more than one page
\test
\test
\test

\end{document}

enter image description here

Page numbers in TOC are correct.

enter image description here

Page numbers in PDF bookmark are still arabic.

1 Answer 1

1

hyperref's code to set the page labels tests for \nofiles, and as nottoccite sets this too false it never writes the needed info to the aux-file. You can overwrite the command:

\documentclass{book}

\usepackage{notoccite}
\usepackage{hyperref}
\makeatletter
 \def\HyPL@StorePageLabel#1{%
      \begingroup
        \edef\Hy@tempa{\the\Hy@abspage<<#1>>}%
        \immediate\write\@mainaux{%
          \string\HyPL@Entry{\Hy@tempa}%
        }%
      \endgroup}
\makeatother    
\begin{document}

\pagenumbering{roman}
\tableofcontents

\newcommand\test{%
  \chapter{Title}%
  \section{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \section{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \section{Title}%
  \subsection{Title}%
  \subsection{Title}%
  \subsection{Title}%
}

% Make sure the TOC has more than one page
\test
\test
\test

\end{document}

With the new pdfmanagement code which is currently in pdfmanagement-testphase this patch is not needed. The pagelabels should work fine there.

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{}
\documentclass{book}

\usepackage{notoccite}
\usepackage{hyperref}
1
  • It works and thanks a lot!
    – Zeping Lee
    Apr 24, 2021 at 10:35

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.