3

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.

  • That box is as high as the line. Since you have \dfrac in that line the line height is large and so is the box. To check put a blank line after we get. – user11232 Sep 17 '15 at 9:08
  • 1
    This is one of the reasons I prefer colorlinks. – John Kormylo Sep 17 '15 at 14:53
  • @Harish: Hi Harish. Yes, I understand that \dfrac causes the problem, but I would like a fix that makes the size of a link box dependent on only its content, regardless of whether I use \dfrac or not. – Berrick Caleb Fillmore Sep 17 '15 at 18:40
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.