latex3 / hyperref

Hypertext support for LaTeX
165 stars 35 forks source link

`\theHcounter` definition doesn't expand commands in counter name #330

Closed u-fischer closed 4 months ago

u-fischer commented 7 months ago

When setting up the \theHcounter representation hyperref doesn't expand commands in the counter name at definition time (differently to the kernel):

\documentclass[11pt]{article}
\usepackage{hyperref}
%\makeatletter
%\def\@definecounter#1{%
%     \H@definecounter{#1}%
%     \expandafter
%     \gdef\csname theH#1\expandafter\endcsname\expandafter
%          {\expandafter\@arabic\csname c@#1\endcsname}}%
%\makeatother   
\def\blub{duck}
\newcounter{\blub}
\show\theduck
\show\theHduck
\begin{document}

\refstepcounter{duck}
xxx
\end{document}

gives

> \theduck=macro:
->\@arabic \c@duck .
l.199 \show\theduck

? 
> \theHduck=macro:
->\arabic {\blub }.

This is a problem if temporary commands are used which have changed their meaning when the counter is actually used. See https://tex.stackexchange.com/questions/709519/hyperref-conflicting-with-enumitem

u-fischer commented 4 months ago

resolved in 7.01i