latex3 / hyperref

Hypertext support for LaTeX
170 stars 36 forks source link

hyperref and thmtools #359

Closed GMS103 closed 3 weeks ago

GMS103 commented 3 weeks ago

After the last updates, I am getting a lot of errors like the following:

Package hyperref Info: bookmark level for unknown The defaults to 0 on input line 11.

and

warning  (pdf backend): ignoring duplicate destination with the name 'The.1'

MWE:

% !TEX program = LuaLaTeX
\RequirePackage{latexbug}
\documentclass{article}
\usepackage{thmtools}
\declaretheoremstyle[numberwithin=section]{mytheostyle}
\declaretheorem[name=Theorem,numbered=yes,style=mytheostyle]{The}
\usepackage{hyperref}
\begin{document}
\section{Title of first section}
\begin{The}
Blah.
\end{The}
\section{Title of second section}
\begin{The}
Blah blah.
\end{The}
\end{document}

bug.log

GMS103 commented 3 weeks ago

Mentioned in https://github.com/muzimuzhi/thmtools/issues/70

mbertucci47 commented 3 weeks ago

This is a thmtools problem, not hyperref because the equivalent \newtheorem statement does not produce duplicate destinations.

\documentclass{article}

\usepackage{hyperref}
\newtheorem{The}{Theorem}[section]

\begin{document}
\section{Title of first section}
\begin{The}
Blah.
\end{The}
\section{Title of second section}
\begin{The}
Blah blah.
\end{The}
\end{document}

Also note these are not errors but warnings.

u-fischer commented 3 weeks ago

As said these are not errors. The info about the bookmark level is not new, I get that also in older texlive. thmtools misses here to define the toc level. This can be done with

\makeatletter
\def\toclevel@The{1} %or some other level
\makeatother

The warning about the destination is new. hyperref no longer (re)defines the \thH<counter> as the kernel handles that. But as thmtools uses a non-standard way to declare "numberwithin" counters it will have to reset \theH<counter> itself. E.g.

\declaretheoremstyle[numberwithin=section]{mytheostyle}
\declaretheorem[name=Theorem,numbered=yes,style=mytheostyle]{The}
\renewcommand\theHThe{\thesection .\arabic {The}}
GMS103 commented 3 weeks ago

Thanks, it works. I have asked Yukai Chou about this.