# \ref with tight box surrounding the reference

How can I make the colored box around a reference appear completely tight?

MWE:

\documentclass[a4paper,twoside,openright,final,12pt]{book}
\usepackage{etex}
\usepackage[english]{babel}
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{charter}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[framed, thmmarks]{ntheorem}
\usepackage{hyperref}
\hypersetup{bookmarksopen=true,pdfpagelayout=TwoPageRight}
\usepackage[top=2.4cm, bottom=2cm, left=2cm, right=2cm]{geometry}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\theoremseparator{:}            %%
\theorembodyfont{\normalfont\it}%%
\theoremstyle{plain}            %%
\newtheorem{envThm}{Theorem}    %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\thispagestyle{empty}
\begin{envThm}\label{thm1}~\\
{\rm\textbf{a)}} Bla bla bla.\\
{\rm\textbf{b)}} Bla bla bla.\\
{\rm\textbf{c)}} Bla bla bla.
\end{envThm}

bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla \ref{thm1} bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla \hyperref[thm1]{\ref*{thm1}.b)} bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla \hyperref[thm1]{\ref*{thm1}.a)} bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla $bla bla bla \overset{\scriptscriptstyle\hyperref[thm1]{\ref*{thm1}.b)}}{=} bla bla bla$ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\end{document}


Instead of , I wish to have .

And if I later conclude that this is too tight, but I still want it to be tight, just not completely, how do I regulate tightness?

-

Package hyperref knows option pdflinkmargin that can be used to specify the link margin, but the behavior depends on the driver.

## pdfTeX

Internally \pdflinkmargin of pdfTeX is used to set the link margin. The default is 1pt. First pdfTeX takes the width from the link contents and the height and depth are taken from the surrounding box. Then the length \pdflinkmargin is added to all borders. This is done, when the annotations are written, when the page is shipped out, not when the link annotation is created.

\hypersetup{pdflinkmargin=...} sets \pdflinkmargin locally.

• The link area is increased by larger elements of the surrounding box. This can be fixed to some degree by putting the link into \mbox. Its drawbacks are:

• The link cannot be broken across lines.
• Spaces inside the link loose their stretchability.
• Link margins can only be changed for all links of a page.

## pdfmark drivers

Supported since hyperref 2012/10/13 v6.83j.

\hypersetup{pdflinkmargin=...} has global effect.

## dvipdfm/dvipdfmx/XeTeX

Links use \special{pdf:bann ...} that allows breakable links and calculate the link dimensions automatically without the possibility to add a link margin.

-
Hmm, \pdflinkmargin=0pt works very good. However, for a reference (e.g. 7.13.1), the amount of space below is larger than above. Any help on that? – Leon Jan 20 '13 at 15:51
@LeonLampret Driver pdfTeX takes the height and depth of the surrounding box. Putting the reference inside \mbox should help. – Heiko Oberdiek Jan 20 '13 at 17:15
\mbox doesn't work like I'd like it to, but I think I'll be content with \pdflinkmargin=0pt. Thank you! – Leon Jan 20 '13 at 17:32