-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autoref sometimes fails, a fix #311
Comments
Slightly improved the proposed fix. (adding a link to corresponding issue in latex3/mathtools latex3/mathtools#56) \documentclass{article}
\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
\begin{document}
\section{title}\label{sec:a}
\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}
\begin{gather}
\int g dx \tag{tag1} \label{eq:t1} \\
\int g_2 dx \tag{tag2} \label{eq:t2} \\
\int g_3 dx \tag{tag3} \label{eq:t3}
\end{gather}
% the most recent label before using \label{eq:1} is referenced
See \autoref{eq:1} and \autoref{eq:t1}
% this makes equation labeled "eq:2" numbered
See \eqref{eq:2} and \eqref{eq:t2}
% equations labeled "eq:3" and "eq:t3" should have no numbers
\end{document}
|
Well I don't quite like the idea to refer to internals of other packages. The official, documented interface of mathtools to mark a label as "referenced" is But the main questions are
One the whole I think hyperref should only insert a hook with argument and leave it to the author or to mathtools to activate the mathtools support. |
Hi, thanks one problem of your fix is: it will not work in older TL version, I am sure not in TL 2019, |
if I understand you correctly, the fix I proposed (or any other for that matter) should better go into mathtools, since it is the 'culprit' and not hyerref? |
Whatever hyperref will do will only work in a current texlive. A current hyperref expect current LaTeX tools and commands to be present and you can't install it in an old texlive. If you want to benefit from improvements, keep your system up-to-date.
There is no culprit. mathtools needs an information and the main question is how to provide. Btw: you could simply define a new command and use that wenn referencing an equation:
|
well, yes, but the problem is, I am using Emacs (AuCTex+reftex) so in order to include a new references into that I need to write an additional elisp style, which is not difficult, but I usually try to avoid to keep things simple |
Hi
The following MWE shows that (TL2023) autoref sometimes fails when used with
mathtools
and theshowonlyrefs
a fix was proposed in fix
And consists in adding
After
\usepackage[colorlinks]{hyperref}
Could that this patch somehow be included in future releases of hyperref?
I will also open an issue on the mathtools github page.
Thanks
Uwe Brauer
The text was updated successfully, but these errors were encountered: