hyperref icon indicating copy to clipboard operation
hyperref copied to clipboard

`\if@hyper@item` it not reset after an item with optional argument

Open u-fischer opened this issue 4 years ago • 0 comments

This leads to wrong destination names (and so can affect autoref), but the links should be okay, so not a serious problem.

see also https://tex.stackexchange.com/q/586551/2388

\documentclass[11pt]{article}
\usepackage{hyperref}
\usepackage{xpatch}
\begin{document}

\newcounter{test}
Some text \makeatletter
\begin{enumerate}
\item   \if@hyper@item true \else false \fi
 \refstepcounter{test}\label{a}
\item[a] \if@hyper@item true \else false \fi 
 \refstepcounter{test}\label{b}
\end{enumerate}

\xpatchcmd\@item{\ignorespaces}{\@hyper@itemfalse\ignorespaces}{}{\fail}

\begin{enumerate}
\item   \if@hyper@item true \else false \fi
\refstepcounter{test}\label{c}
\item[a] \if@hyper@item true \else false \fi
\refstepcounter{test}\label{d}
\end{enumerate}

\end{document}
\newlabel{a}{{1}{1}{}{test.1}{}}
\newlabel{b}{{2}{1}{}{Item.2}{}}
\newlabel{c}{{3}{1}{}{test.3}{}}
\newlabel{d}{{4}{1}{}{test.4}{}}

u-fischer avatar Mar 09 '21 22:03 u-fischer