%=====
\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
\begin{enumerate}
\item Here is an item
\item Here is another item with an equation
\begin{equation}
x=5
\label{eq:mine}
\end{equation}
\end{enumerate}
The equation is \autoref{eq:mine}.
\end{document}
%=====
The last line of the DVI/PDF generated says
The equation is item 1.
If I remove amsmath, I get:
The equation is Equation 1.
The tag "1" is always correct, but the AUX file shows:
\newlabel{eq:mine}{{1}{1}{\relax }{Item.3}{}}
That is, "Item" is written out instead of "equation."
\makeatletter
\@hyper@itemfalse
\makeatother
and this line after the equation:
\makeatletter
\@hyper@itemtrue
\makeatother
SEEMS to fix things. So, I guess I just have to patch the math
environments so they ensure that hyper@item is false before their
entrance (and make sure it's set back to whatever it was after exiting
the math environment).
> It seems to be a problem with hyperref. Adding this line before the
> equation:
>
> \makeatletter
> \@hyper@itemfalse
> \makeatother
>
In fact, can't \@hyper@itemfalse can't be asserted JUST AFTER an
enumerate item's counter has been stepped in hyperref.sty.
Can hyperref.sty be fixed to do this?
--Ted
Any news on this front?
-- m
I thought I posted this message earlier, but it hasn't shown up
overnight, so I'll post it again.
I e-mailed the author of hyperref, and I have not yet received a
response.
My working fix for the problem is to insert
% Fixes a problem with how hyperref records item labels
\makeatletter
\let\oldequation\equation
\renewcommand{\equation}{\@hyper@itemfalse\oldequation}
\let\oldgather\gather
\renewcommand{\gather}{\@hyper@itemfalse\oldgather}
\let\oldalign\align
\renewcommand{\align}{\@hyper@itemfalse\oldalign}
\makeatother
just AFTER I include hyperref. That is, I include amsmath (or
mathtools) and then hyperref and then issues those commands.
From my meager understanding of how hyperref's refstepcounter stuff
works, I don't think that will break anything. My items are still
getting "Item" in front of them, and now all of my numbered equations
are getting "Equation" in front of them, even if they're buried within
an item.
I don't *THINK* that I have tested nested items, but I *think* those
will work fine too.
--Ted
I just realized that there are plenty of other AMS math environments
that might also need this fix (other than equation, gather, and
align), and so I now use the following (included after loading
amsmath);
%=====
\makeatletter
\newcommand{\AMShreffix}[1]{%
\expandafter\let\csname old#1\expandafter\endcsname%
\csname #1\endcsname%
\expandafter\renewcommand\csname #1\endcsname{%
\@hyper@itemfalse\csname old#1\endcsname}}
\makeatother
\AMShreffix{equation}
\AMShreffix{align}
\AMShreffix{alignat}
\AMShreffix{flalign}
\AMShreffix{gather}
\AMShreffix{multline}
%=====
If you'd like to add another environment, say xxalignat, then do:
\AMShreffix{xxalignat}
That works for me.
I came to the same conclusion and fixed it in hyperref 6.77m.
Yours sincerely
Heiko <ober...@uni-freiburg.de>