latex3/hyperref

theorem anchor on the wrong page

u-fischer opened this issue · 0 comments

The new patch of \@thm in hyperref tries to avoid that anchors gets lost (see e.g. issue #8) by delaying the anchor into the next para/begin hook.

This doesn't work if the theorem is near a page break and the header or footer issues a \par (e.g. in fancyhdr where \parbox is used).

\documentclass[12pt]{book}
\newtheorem{theorem}{theorem}
\newtheorem{proof}{proof}
\makeatletter
\def\@oddhead{\parbox[t]{\linewidth}{head}}

\usepackage{hyperref}
\AddToHook{cmd/Hy@theorem@refstepcounter/before}{\AddToHookNext{para/begin}{HERE IS THE THEOREM ANCHOR!! }}
\begin{document}

\vspace*{36\baselineskip} 

line\\ line\\ line
    \begin{theorem}
        theorem
    \end{theorem} 
\end{document}

Probably the only way to resolve this is to move the anchor into the \item itself.