与 hyperref 的 draft 选项、cleveref 的 \cref 以及 \caption 中的 \textbf 冲突

与 hyperref 的 draft 选项、cleveref 的 \cref 以及 \caption 中的 \textbf 冲突

以下 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}

但是,一旦% \textbf{foo}取消注释,(第二次)编译就会失败:

! 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}

然后,如果\hypersetup{draft}被注释掉,编译就不会失败。

你明白发生了什么事吗?

编辑:上下文

  • 最新的 TeX Live 2022

  • 使用pdflatexxelatex或进行编译lualatex

  • 我的文件列表

      article.cls    2021/10/04 v1.4n Standard LaTeX document class
      size10.clo    2021/10/04 v1.4n Standard LaTeX file (size option)
      varioref.sty    2021/07/07 v1.6f package for extended references (FMi)
      hyperref.sty    2022-05-17 v7.00q Hypertext links for LaTeX
      ltxcmds.sty    2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
      iftex.sty    2022/02/03 v1.0f TeX engine tests
      pdftexcmds.sty    2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO)
      infwarerr.sty    2019/12/03 v1.5 Providing info/warning/error messages (HO)
      keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
      kvsetkeys.sty    2019/12/15 v1.18 Key value parser (HO)
      kvdefinekeys.sty    2019-12-19 v1.6 Define keys (HO)
      pdfescape.sty    2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
      hycolor.sty    2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
      letltxmacro.sty    2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
      auxhook.sty    2019-12-17 v1.6 Hooks for auxiliary files (HO)
      nameref.sty    2022-05-17 v2.50 Cross-referencing by name of section
      refcount.sty    2019/12/15 v3.6 Data extraction from label references (HO)
      gettitlestring.sty    2019/12/15 v1.6 Cleanup title references (HO)
      kvoptions.sty    2020-10-07 v3.14 Key value format for package options (HO)
      pd1enc.def    2022-05-17 v7.00q Hyperref: PDFDocEncoding definition (HO)
      intcalc.sty    2019/12/15 v1.3 Expandable calculations with integers (HO)
      etexcmds.sty    2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
      puenc.def    2022-05-17 v7.00q Hyperref: PDF Unicode definition (HO)
      url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
      bitset.sty    2019/12/09 v1.3 Handle bit-vector datatype (HO)
      bigintcalc.sty    2019/12/15 v1.5 Expandable calculations on big integers (HO)
      atbegshi-ltx.sty    2021/01/10 v1.0c Emulation of the original atbegshi
      hpdftex.def    2022-05-17 v7.00q Hyperref driver for pdfTeX
      atveryend-ltx.sty    2020/08/19 v1.0a Emulation of the original atveryend packa
      rerunfilecheck.sty    2019/12/05 v1.9 Rerun checks for auxiliary files (HO)
      uniquecounter.sty    2019/12/15 v1.4 Provide unlimited unique counter (HO)
      cleveref.sty    2018/03/27 v0.21.4 Intelligent cross-referencing
      l3backend-pdftex.def    2022-04-20 L3 backend support: PDF output (pdfTeX)
       ***********
    

相关内容