Text Formattinghyperref, mathtools | Cross References to Equations fail

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

hyperref, mathtools | Cross References to Equations fail

Post by svend_tveskaeg »

Hi all.

The following MWE is inspired by Heiko Oberdiek's answer in this thread on TeX-Stack-Exchange.

Code: Select all

\documentclass[danish]{article}

\usepackage{babel}
\usepackage{mathtools}
\usepackage{hyperref}

\def\equationautorefname~#1\null{%
  \textsc{Formel}~(#1)\null
}
\addto\extrasdanish{%
  \def\subsectionautorefname{\textsc{Afsnit}}
}

%\mathtoolsset{showonlyrefs}

\begin{document}

\subsection{Triangular number}
\label{tri-numb}
We can choose between
\begin{align}
 \label{rigtig}
  T_{n} &= n^{2} - n + 1,\\
 \label{forkert}
  T_{n} &= \frac{n^{2} + n}{2},
\end{align}
Is \autoref{rigtig} or \autoref{forkert} correct?

\end{document}
This works just as I want but when \mathtoolsset{showonlyrefs} is no longer commented out, the citations are messed up.

How do I fix this?

Thank you in advance!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

hyperref, mathtools | Cross References to Equations fail

Post by localghost »

In my opinion the mathtools option showonlyrefs is only half-baked. The package manual describes two bugs (p. 11f). The first one could be responsible for your trouble here.


Thorsten
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: hyperref, mathtools | Cross References to Equations fail

Post by svend_tveskaeg »

Thank you for pointing me to this!

I will (unfortunately) have to remove this from my document.
Last edited by svend_tveskaeg on Tue Oct 09, 2012 12:03 am, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: hyperref, mathtools | Cross References to Equations fail

Post by cgnieder »

I'm not sure »showonlyrefs« is a good idea anyway. Not to number all equations makes not impossible but very hard for readers to refer to other equations than the ones the author gave a number to. A reference like “The equation three lines below equation (4)” is really not that optimal.

Best Regards
site moderator & package author
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: hyperref, mathtools | Cross References to Equations fail

Post by svend_tveskaeg »

@Clemens:
Good point. However, I am writing a note to my high school students; they do not refer to any equations in my notes themselves---they have a hard enough time understanding the stuff in their textbook, so I just try to write it in another way for them. :o
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply