latex3 / tagging-project

Issues related to the tagging project
https://latex3.github.io/tagging-project/
LaTeX Project Public License v1.3c
38 stars 15 forks source link

starred `\newtheorem` produces warnings with hyperref #736

Open mbertucci47 opened 5 days ago

mbertucci47 commented 5 days ago

If hyperref is loaded, the starred \newtheorem produces a warning

Package hyperref Warning: Counter '' or the representation '\theH`
(hyperref)                don't exist. No target created.

Here's an example.

\DocumentMetadata
  {
    lang=en-US,
    pdfversion=2.0,
    pdfstandard=ua-2,
    testphase={phase-III,math,table,title,firstaid}
  }
\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}

\newtheorem*{theorem}{Theorem}

\begin{document}

\begin{theorem}
text
\end{theorem}

\end{document}

This happens because the redefined \@begintheorem unconditionally calls \MakeLinkTarget{\l__block_thm_current_counter_tl}. With an unnumbered theorem \l__block_thm_current_counter_tl is empty. I guess changing this line to \tl_if_empty:nF{##2}{\MakeLinkTarget{\l__block_thm_current_counter_tl}} is enough.

u-fischer commented 5 days ago

good catch and good timing ;-) I just adjusted the firstaid anyway.