Skip to content

mathtools, amsart, appendix, autoref fails (fix of issue 311 does not work) #372

@ouboub

Description

@ouboub

Hi
A year ago a fix (isseu 311) solved the problem concerning the interaction between autoref and mathtools,
However the fix fails for amsart together with appendix style as the following MWE shows

\documentclass[12pt,reqno]{amsart}
\usepackage{appendix}
\usepackage{amsmath,amsthm}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\usepackage[colorlinks]{hyperref}

\makeatletter
\AddToHook{package/mathtools/after}{%
  \def\HyRef@autoref#1#2{%
    \begingroup
      \Hy@safe@activestrue
      \@nameuse{MH_if_boolean:nT}{show_only_refs}{%
        % excerpted from \noeqref in mathtools.sty
        \edef\@tempa{#2}%
        %% will be done in \HyRef@autosetref
        % \@ifundefined{r@\@tempa}{%
        %   \protect\G@refundefinedtrue%
        %   \@latex@warning{Reference `\@tempa' on page \thepage \space
        %     undefined (\string\noeqref)}%
        % }{}%
        \if@filesw
          \protected@write\@auxout{}{\string\MT@newlabel{\@tempa}}%
        \fi
      }%
      \expandafter\HyRef@autosetref\csname r@#2\endcsname{#2}{#1}%
    \endgroup
  }
}
\makeatother
\newcommand\autoeqref[1]{\noeqref{#1}\autoref{#1}}
\begin{document}
\section{title}\label{sec:a}
\begin{appendices}
\begin{gather}
  \int f   dx = 0\label{eq:1} \\
  \int f_2 dx = 0\label{eq:2} \\
  \int f_3 dx = 0 \label{eq:3}
\end{gather}
% the most recent label before using \label{eq:1} is referenced
See \autoref{eq:1}  does work
% this makes equation labeled "eq:2" numbered
See \eqref{eq:2} woks
\end{appendices}
\end{document}

Any idea how fix this problem?
Thanks
Uwe Brauer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions