[Tex/LaTex] A problem with the size of hyperref boxes around links

hyperreflinks

I have trouble with the size of boxes around links when using hyperref. When I run the following minimal working example with LaTeX,

\documentclass[letter,10pt]{amsart}
\usepackage{hyperref}
\hypersetup{pdfborder = {0 0 2}}

\newtheorem{Thm}{Theorem}

\begin{document}

\begin{Thm} \label{Fractions}
$ \dfrac{p}{q} + \dfrac{r}{s} = \dfrac{p s + q r}{q s} $.
\end{Thm}

Applying Theorem \autoref{Fractions}, we get
$ \dfrac{1}{3} + \dfrac{4}{5} = \dfrac{5 + 12}{15} = \dfrac{17}{15} $.

\end{document}

I get a box around the counter ‘1’ that is too tall (having the same height as the fractions that appear on the same line). When I run it with XeLaTeX instead (which some people say solves the problem), I get a box that is too short and overlaps with the text! What I need is a box that fits the content nicely with no overlaps and does not at all depend on the size of other text on the same line.

Could someone help me out here? Thank you very much!


Additional Comment

I have been told that it is the use of \dfrac that causes the box around the counter to be too tall, but I want to be able to use \dfrac without having this problem. Compiling with XeLaTeX almost solves the problem, but the box is too small for my liking, because its frame overlaps with the text within and makes it hard to read.

Best Answer

In case of pdfTeX, the box depth and height is taken from the current box, which is large, because of the math stuff in the same line.

The box for the link can be reduced by putting the link into another box. However, the contents of the box is no longer broken across lines and spaces inside the box are fixed and do not shrink or stretch anymore.

The following example also defines the \autoref name for counter Thm:

\documentclass[10pt]{amsart}
\usepackage{hyperref}
\hypersetup{pdfborder = {0 0 2}}

\newtheorem{Thm}{Theorem}

\newcommand*{\Thmautorefname}{Theorem}

\begin{document}

\begin{Thm} \label{Fractions}
$ \dfrac{p}{q} + \dfrac{r}{s} = \dfrac{p s + q r}{q s} $.
\end{Thm}

Applying \mbox{\autoref{Fractions}}, we get
$ \dfrac{1}{3} + \dfrac{4}{5} = \dfrac{5 + 12}{15} = \dfrac{17}{15} $.

\end{document}

Result

Related Question