Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to adjust the size of the box around the footnote links produced by hyperref? Specifically, I would like to move the base of the box closer to the base of the object inside.

\documentclass[12pt]{article}
\usepackage{hyperref}
\begin{document}
The quick brown fox jumps over the lazy dog\footnote{and lands on a spike}.
\end{document}

footnote link

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

You can try processing your file with xelatex. When I do that with your MWE, hyperref forms a box tightly around the footnote. When I tried with pdflatex, I received the same output as in the image you attached.

share|improve this answer
1  
+1 -- I think your "comment" is an answer. (Just to be clear: I tested it and it worked.) –  lockstep Feb 9 '12 at 19:48
2  
IMHO changing the compiler is not a general solution. I for myself would like to stick with pdflatex. –  Martin Scharrer Feb 10 '12 at 11:37
    
I get an assortment of different results using different engines on different machines. I'm going to avoid boxed links in the future. –  Ian Thompson Mar 2 '12 at 16:32
add comment

"You can[...] adjust it for pdflatex with[...] hacking hyperref" (Lars Kotthoff, http://tex.stackexchange.com/a/44032/6865), thus:

enter image description here

\documentclass{article}
\usepackage{hyperref}

% If you like footnotesymbols instead of numbers:
%\def\thefootnote{\fnsymbol{footnote}}

\usepackage{ltxcmds}

\makeatletter

\renewcommand{\footnote}[2][\empty]{%
  \nolinebreak%
  \addtocounter{footnote}{+1}%
  \xdef\sfootnote@number{\arabic{footnote}}%
  \ltx@ifpackageloaded{hyperref}{% hyperref loaded
    \ifHy@hyperfootnotes% option hyperfootnotes=true
      \addtocounter{Hfootnote}{+1}%
      % Code from the hyperref package
        \global\let\Hy@saved@currentHref\@currentHref%
        \hyper@makecurrent{Hfootnote}%
        \global\let\Hy@footnote@currentHref\@currentHref%
        \global\let\@currentHref\Hy@saved@currentHref%
      % End of code form the hyperref package
    \fi%
   }{% hyperref not loaded, nothing to be done here
   }%
  \xdef\sfootnote@opt{#1}% contains the optional argument
  \xdef\sfootnote@arabic{\arabic{footnote}}% is the Arabic footnotenumber
  \edef\sfootnote@formated{\thefootnote}% could also be * or dagger
  \ifx\sfootnote@opt\empty% i.e. no optional argument used
    \footnotetext{\label{fnr:\sfootnote@arabic}#2}%
  \else%
    \ltx@ifpackageloaded{hyperref}{% hyperref loaded
      \footnotetext[#1]{\phantomsection\label{fnr:\sfootnote@arabic}#2}%
     }{% hyperref not loaded
      \footnotetext[#1]{\label{fnr:\sfootnote@arabic}#2}%
     }%
  \fi%
  \ltx@ifpackageloaded{hyperref}{% hyperref package loaded
    \ifHy@hyperfootnotes% option hyperfootnotes=true
      \hbox {\@textsuperscript {\normalfont \ref{fnr:\sfootnote@arabic}}}%
    \else% option hyperfootnotes=false
      \hbox {\@textsuperscript {\normalfont \ref*{fnr:\sfootnote@arabic}}}%
    \fi%
  }{% hyperref package not loaded
    \hbox {\@textsuperscript {\normalfont \ref{fnr:\sfootnote@arabic}}}%
   }%
}

\makeatother

\begin{document}
The quick\footnote{really fast} brown\footnote{maybe more like a dark red} fox
jumps over the\footnote[1]{custom footnote number: 1} lazy
dog\footnote{and escapes the hunt}.

\newpage

It is easier to test the hyperlinks when there is a second page!

\end{document}

Footnotes are quiet tricky - http://tex.stackexchange.com/search?q=footnote currently lists nearly 400 questions. Therefore there is no guarantee that this will work for more complex situations or with one or the other of the many packages handling footnotes.

share|improve this answer
add comment

You can't adjust it for pdflatex without hacking hyperref. It uses a PDF annotation to display the link and the size of the box is defined by a Rect ... inside the PDF. The code that generates that is

/H.B {/Rect[pdf@llx pdf@lly pdf@urx pdf@ury]} def

i.e. it uses the coordinates of the bounding box as determined by pdflatex. You would need to work around this and adjust the incorrect bounding box.

I'd recommend that you go with the xelatex answer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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