latex3/hyperref

error '\deferred@thm@head'

aleksejalex opened this issue · 7 comments

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.

Make a small but complete example that demonstrates the error.

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 :)

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}

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}

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

@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....)

that has been resolved in a current hyperref.