latex3 / hyperref

Hypertext support for LaTeX
169 stars 36 forks source link

2024-11-01 release: \refstepcounter@optarg ...cref@currentlabel \@nil #360

Open cfr42 opened 3 weeks ago

cfr42 commented 3 weeks ago

I'm not sure where this bug belongs. I also can't reproduce locally because even a new install of TL is out of date. Simplified version of this example:

\documentclass{book}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{cleveref}
\newtheorem{plemma}[chapter]{Lemma}
\begin{document}
\chapter{S}
\begin{plemma}
  T
\end{plemma}
\end{document}
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex 2024.11.2)  3 NOV 2024 07:27
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**document
(./document.tex
LaTeX2e <2024-11-01>
L3 programming layer <2024-10-09>
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/book.cls
Document Class: book 2024/06/29 v1.4n Standard LaTeX document class
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/bk10.clo
File: bk10.clo 2024/06/29 v1.4n Standard LaTeX file (size option)
)
\c@part=\count196
\c@chapter=\count197
\c@section=\count198
\c@subsection=\count199
\c@subsubsection=\count266
\c@paragraph=\count267
\c@subparagraph=\count268
\c@figure=\count269
\c@table=\count270
\abovecaptionskip=\skip49
\belowcaptionskip=\skip50
\bibindent=\dimen141
)
(/usr/local/texlive/2024/texmf-dist/tex/latex/amscls/amsthm.sty
Package: amsthm 2020/05/29 v2.20.6
\thm@style=\toks17
\thm@bodyfont=\toks18
\thm@headfont=\toks19
\thm@notefont=\toks20
\thm@headpunct=\toks21
\thm@preskip=\skip51
\thm@postskip=\skip52
\thm@headsep=\skip53
\dth@everypar=\toks22
)
(/usr/local/texlive/2024/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2024-10-30 v7.01k Hypertext links for LaTeX

(/usr/local/texlive/2024/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
)
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks23
)
(/usr/local/texlive/2024/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty
Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO)
)
(/usr/local/texlive/2024/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty
Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO)
)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pdfescape/pdfescape.sty
Package: pdfescape 2019/12/09 v1.15 Implements pdfTeX's escape features (HO)

(/usr/local/texlive/2024/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty
Package: ltxcmds 2023-12-04 v1.26 LaTeX kernel commands for general use (HO)
)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO
)

(/usr/local/texlive/2024/texmf-dist/tex/generic/infwarerr/infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
))
(/usr/local/texlive/2024/texmf-dist/tex/latex/hycolor/hycolor.sty
Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
)
(/usr/local/texlive/2024/texmf-dist/tex/latex/hyperref/nameref.sty
Package: nameref 2023-11-26 v2.56 Cross-referencing by name of section

(/usr/local/texlive/2024/texmf-dist/tex/latex/refcount/refcount.sty
Package: refcount 2019/12/15 v3.6 Data extraction from label references (HO)
)
(/usr/local/texlive/2024/texmf-dist/tex/generic/gettitlestring/gettitlestring.s
ty
Package: gettitlestring 2019/12/15 v1.6 Cleanup title references (HO)
 (/usr/local/texlive/2024/texmf-dist/tex/latex/kvoptions/kvoptions.sty
Package: kvoptions 2022-06-15 v3.15 Key value format for package options (HO)
))
\c@section@level=\count271
)
(/usr/local/texlive/2024/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count272
)
(/usr/local/texlive/2024/texmf-dist/tex/generic/stringenc/stringenc.sty
Package: stringenc 2019/11/29 v1.12 Convert strings between diff. encodings (HO
)
)
\@linkdim=\dimen142
\Hy@linkcounter=\count273
\Hy@pagecounter=\count274

(/usr/local/texlive/2024/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2024-10-30 v7.01k Hyperref: PDFDocEncoding definition (HO)
Now handling font encoding PD1 ...
... no UTF-8 mapping file for font encoding PD1
)
(/usr/local/texlive/2024/texmf-dist/tex/generic/intcalc/intcalc.sty
Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO)
)
\Hy@SavedSpaceFactor=\count275

(/usr/local/texlive/2024/texmf-dist/tex/latex/hyperref/puenc.def
File: puenc.def 2024-10-30 v7.01k Hyperref: PDF Unicode definition (HO)
Now handling font encoding PU ...
... no UTF-8 mapping file for font encoding PU
)
Package hyperref Info: Hyper figures OFF on input line 4157.
Package hyperref Info: Link nesting OFF on input line 4162.
Package hyperref Info: Hyper index ON on input line 4165.
Package hyperref Info: Plain pages OFF on input line 4172.
Package hyperref Info: Backreferencing OFF on input line 4177.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4424.
\c@Hy@tempcnt=\count276

(/usr/local/texlive/2024/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip17
Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 4763.
\XeTeXLinkMargin=\dimen143

(/usr/local/texlive/2024/texmf-dist/tex/generic/bitset/bitset.sty
Package: bitset 2019/12/09 v1.3 Handle bit-vector datatype (HO)

(/usr/local/texlive/2024/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty
Package: bigintcalc 2019/12/15 v1.5 Expandable calculations on big integers (HO
)
))
\Fld@menulength=\count277
\Field@Width=\dimen144
\Fld@charsize=\dimen145
Package hyperref Info: Hyper figures OFF on input line 6042.
Package hyperref Info: Link nesting OFF on input line 6047.
Package hyperref Info: Hyper index ON on input line 6050.
Package hyperref Info: backreferencing OFF on input line 6057.
Package hyperref Info: Link coloring OFF on input line 6062.
Package hyperref Info: Link coloring with OCG OFF on input line 6067.
Package hyperref Info: PDF/A mode OFF on input line 6072.

(/usr/local/texlive/2024/texmf-dist/tex/latex/base/atbegshi-ltx.sty
Package: atbegshi-ltx 2021/01/10 v1.0c Emulation of the original atbegshi
package with kernel methods
)
\Hy@abspage=\count278
\c@Item=\count279
\c@Hfootnote=\count280
)
Package hyperref Info: Driver (autodetected): hpdftex.

(/usr/local/texlive/2024/texmf-dist/tex/latex/hyperref/hpdftex.def
File: hpdftex.def 2024-10-30 v7.01k Hyperref driver for pdfTeX

(/usr/local/texlive/2024/texmf-dist/tex/latex/base/atveryend-ltx.sty
Package: atveryend-ltx 2020/08/19 v1.0a Emulation of the original atveryend pac
kage
with kernel methods
)
\Fld@listcount=\count281
\c@bookmark@seq@number=\count282

(/usr/local/texlive/2024/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
Package: rerunfilecheck 2022-07-10 v1.10 Rerun checks for auxiliary files (HO)

(/usr/local/texlive/2024/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty
Package: uniquecounter 2019/12/15 v1.4 Provide unlimited unique counter (HO)
)
Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2
85.
)
\Hy@SectionHShift=\skip54
) (/usr/local/texlive/2024/texmf-dist/tex/latex/cleveref/cleveref.sty
Package: cleveref 2018/03/27 v0.21.4 Intelligent cross-referencing
Package cleveref Info: `hyperref' support loaded on input line 2370.
LaTeX Info: Redefining \cref on input line 2370.
LaTeX Info: Redefining \Cref on input line 2370.
LaTeX Info: Redefining \crefrange on input line 2370.
LaTeX Info: Redefining \Crefrange on input line 2370.
LaTeX Info: Redefining \cpageref on input line 2370.
LaTeX Info: Redefining \Cpageref on input line 2370.
LaTeX Info: Redefining \cpagerefrange on input line 2370.
LaTeX Info: Redefining \Cpagerefrange on input line 2370.
LaTeX Info: Redefining \labelcref on input line 2370.
LaTeX Info: Redefining \labelcpageref on input line 2370.
Package cleveref Info: `amsthm' support loaded on input line 3026.
)
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2024-05-08 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count283
\l__pdf_internal_box=\box52
)
No file document.aux.
\openout1 = `document.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for PD1/pdf/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
LaTeX Font Info:    Checking defaults for PU/pdf/m/n on input line 7.
LaTeX Font Info:    ... okay on input line 7.
Package hyperref Info: Link coloring OFF on input line 7.
\@outlinefile=\write3
\openout3 = `document.out'.

Chapter 1.
! Use of \cref@override@label@type doesn't match its definition.
\refstepcounter@optarg ...cref@currentlabel \@nil 
                                                  {\@tempa }}
l.9 \begin{plemma}

? 
! Emergency stop.
\refstepcounter@optarg ...cref@currentlabel \@nil 
                                                  {\@tempa }}
l.9 \begin{plemma}

End of file on the terminal!

Here is how much of TeX's memory you used:
 9397 strings out of 473382
 158842 string characters out of 5721212
 579726 words of memory out of 5000000
 32457 multiletter control sequences out of 15000+600000
 559328 words of font info for 40 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 75i,0n,79p,251b,400s stack positions out of 10000i,1000n,20000p,200000b,200000s
!  ==> Fatal error occurred, no output PDF file produced!

! Emergency stop.
\refstepcounter@optarg ...cref@currentlabel \@nil 
                                                  {\@tempa }}
l.9 \begin{plemma}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on document.log.

Timeout/Error status: 1 [pdflatex][document]

I realise this is probably not really hyperref's fault and it should be fixed in cleveref but .... In any case, apologies for reporting it here.

muzimuzhi commented 3 weeks ago

It's the \refstepcounter[plemma]{chapter} used by \begin{plemma} that throws the error.

cleveref assumes the hyperref-patched \refstepcounter always call \H@refstepcounter, thus it further patches \H@refstepcounter to add its own logic, especially the logic to update \cref@currentlabel.

But now hyperref doesn't redefine \refstepcounter anymore and \H@refstepcounter is never used in it. This leaves the \cref@currentlabel in its initial value (which is empty) and an error is thrown when it's updated by

    \protected@edef\cref@currentlabel{%
      \expandafter\cref@override@label@type%
        \cref@currentlabel\@nil{#1}}%

It's so messy that I don't fully understand the patching dependencies.

The LaTeX firstaid already contains some patch for cleveref (see for example https://github.com/latex3/latex2e/commit/3d8c18544c01f88703fd88ce77118d82df32aa23), so perhaps the fix will eventually go into firstaid too.

dbitouze commented 3 weeks ago

I guess same kind of issue with:

\documentclass{article}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\begin{lstlisting}
Foo
\end{lstlisting}
\end{document}

which fails to compile with:

^C
! Interruption.
\lsthk@EveryPar ...entprefix {\cref@currentprefix 
                                                  }
l.7 Foo

?

test.log

u-fischer commented 3 weeks ago

@dbitouze I have a fix for this in a branch. I will handle that later today.