latex3 / hyperref

Hypertext support for LaTeX
165 stars 35 forks source link

Conflict with draft option, cleveref's \cref and... \textbf in \caption #238

Closed dbitouze closed 2 years ago

dbitouze commented 2 years ago

Issue

Until hyperref v7.00n (at least), the following MCE:

\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}

\hypersetup{draft}

\begin{document}
\begin{figure}
  \caption{%
    foo%
    \textbf{foo}%
  }
  \label{bar}
\end{figure}

See \cref{bar}.
\end{document}

worked like a charm. But since at least v7.00p, the (second) compilation fails with:

! Use of \@@cref@getlabel doesn't match its definition.
\text@command #1->\edef \reserved@a {
                                     \unexpanded {#1}}\ifx \reserved@a \@emp...

l.36 See \cref{bar}

Context

u-fischer commented 2 years ago

actually the bug is old. You get the same error with older version if you load nameref before hyperref. It was hidden as normally nameref was loaded in begindocument. As a workaround add this after begin document:

\makeatletter
\long\def\@secondoffive#1#2#3#4#5{#2}
\long\def\@fifthoffive#1#2#3#4#5{#5}
\makeatother
dbitouze commented 2 years ago

actually the bug is old. You get the same error with older version if you load nameref before hyperref. It was hidden as normally nameref was loaded in begindocument. As a workaround add this after begin document:

\makeatletter
\long\def\@secondoffive#1#2#3#4#5{#2}
\long\def\@fifthoffive#1#2#3#4#5{#5}
\makeatother

OK, thanks. Is a real fix planned?

u-fischer commented 2 years ago

I already pushed a fix, but I don't know yet when I will upload to ctan.

dbitouze commented 2 years ago

Bug still present with hyperref 2022-06-13 v7.00r.

u-fischer commented 2 years ago

hm. I wonder what I did there. Need to check.

u-fischer commented 2 years ago

Oh I see, I forgot to merge this change.