latex3 / hyperref

Hypertext support for LaTeX
169 stars 36 forks source link

error '\deferred@thm@head' #324

Closed aleksejalex closed 9 months ago

aleksejalex commented 11 months ago

when compiling with pdflatex, it returns this error LaTeX hooks Error: Generic hooks cannot be added to '\deferred@thm@head'.

I found that the error causes package hyperref in TexLive2023 when used in same file with \usepackage[...several european languages here...]{babel}. Leaving only one language in babel args solved the problem.

But with TexLive2021 it compiled without any problems.

I've tried reinstalling TexLive2023 several times, updating all installed packages, it didn't help.

u-fischer commented 11 months ago

Make a small but complete example that demonstrates the error.

aleksejalex commented 11 months ago

sure, here it is:

\documentclass[]{article}

\usepackage{amsthm}
\usepackage[british,UKenglish,USenglish,american,czech]{babel}
\usepackage{hyperref}                                             

\newtheorem{foo}{bar}

\begin{document}

    \begin{foo}
        content...
    \end{foo}

\end{document}

it returns some PDF looking ok, but gives an error: LaTeX hooks Error: Generic hooks cannot be added to '\deferred@thm@head'. \begin{foo}

Solution that I found by myself: specify only one language in babel, or don't use hyperref. Since I need in, I chose first one. But it's interesting that TexLive 2021 compiled this without any issues. And out-of-date version of TexLive 2023 also did. So I expect the problem to be somewhere in very near past.

Hope it helped :)

davidcarlisle commented 11 months ago

czech babel is making - active which confuses things here, I think you can hide that via

\documentclass[]{article}

\usepackage{amsthm}
\usepackage[british,UKenglish,USenglish,american,czech]{babel}
\usepackage{hyperref}                                             

\newtheorem{foo}{bar}

\makeatletter

\let\@@deferred@thm@head\deferred@thm@head
\def\deferred@thm@head#1{\@@deferred@thm@head{#1}}
\makeatother
\begin{document}

    \begin{foo}
        content...
    \end{foo}

\end{document}
u-fischer commented 11 months ago

Or disable the shorthand -, either with

\usepackage[british,UKenglish,USenglish,american,czech,shorthands=off]{babel}

or with

\usepackage[british,UKenglish,USenglish,american,czech,shorthands="]{babel}
davidcarlisle commented 11 months ago

@u-fischer yep but I suspect it might be easier for hyperref to arrange a "safer" definition than to disable shorthands

u-fischer commented 10 months ago

@davidcarlisle I did now hide \deferred@thm@head and so it will work with czech. (I hope that no other package tries to patch it later and is unhappy about the change....)

u-fischer commented 9 months ago

that has been resolved in a current hyperref.