10

The following code created a footnote, the problem is that in the produced pdf file clicking footnote reference 1 doesn't jump to footnote definition1 in bottom of the page, instead, it jumps to the beginning of the pdf file. But if I remove the "\usepackage{setspace}" line everything works. Why is this and how to make it work as I expected? Thanks in advance.

\documentclass[11pt]{article}
\usepackage{hyperref}
\tolerance=1000
\usepackage{setspace}
\title{temp}
\hypersetup{
  colorlinks,%
  citecolor=black,%
  filecolor=black,%
  linkcolor=blue,%
  urlcolor=black
}
\begin{document}

\maketitle
\tableofcontents

\section{Section 1}
\label{sec-1}
TeX is a computer program for typesetting documents, created by Donald Knuth. It
takes a suitably prepared computer file and converts it to a form which may be
printed on many kinds of printers, including dot-matrix printers, laser printers
and high-resolution typesetting machines. LaTeX is a set of macros for TeX that
aims at reducing the user's task to the sole role of writing the content, LaTeX
taking care of all the formatting process. A number of well-established
publishers now use TeX or LaTeX to typeset books and mathematical journals. It
is also well appreciated by users caring about typography, consistent
formatting, efficient collaborative writing and open formats.

\section{Section 2}
\label{sec-2}
TeX is a computer program for typesetting documents, created by Donald Knuth. It
takes a suitably prepared computer file and converts it to a form which may be
printed on many kinds of printers, including dot-matrix printers, laser printers
and high-resolution typesetting machines. LaTeX is a set of macros for TeX that
aims at reducing the user's task to the sole role of writing the content, LaTeX
taking care of all the formatting process. A number of well-established
publishers now use TeX or LaTeX to typeset books and mathematical journals. It
is also well appreciated by users caring about typography, consistent
formatting, efficient collaborative writing and open formats.

\section{Section 3}
\label{sec-3}
TeX is a computer program for typesetting documents, created by Donald Knuth. It
takes a suitably prepared computer file and converts it to a form which may be
printed on many kinds of printers, including dot-matrix printers, laser printers
and high-resolution typesetting machines. LaTeX is a set of macros for TeX that
aims at reducing the user's task to the sole role of writing the content, LaTeX
taking care of all the formatting process. A number of well-established
publishers now use TeX or LaTeX to typeset books and mathematical journals. It
is also well appreciated by users caring about typography, consistent
formatting, efficient collaborative writing and open formats.

\section{Test footnotes}
\label{sec-4}
This text has a footnote \footnote{See section \ref{sec-1}}
\end{document}
York
  • 213

1 Answers1

12

The package setspace modifies the standard definition of \footnote so that single spacing is used in the footnote texts. Also hyperref modifies \footnote so as to make the hyperlinks.

However, hyperref is generally agnostic about the definition of the commands it has to redefine for doing its job (there are many): it just takes the current definition and massages it a bit for adding the hyperlinks.

If you load the package setspace after hyperref, the modification made by the former overrides the change made by the latter. So the correct way is first loading setspace and then hyperref.

There are some packages that should be loaded after hyperref, you find a big list at Which packages should be loaded after hyperref instead of before? and setspace doesn't appear there.

\documentclass[11pt]{article}

\usepackage{setspace}
\usepackage{hyperref}
\hypersetup{
  colorlinks,%
  citecolor=black,%
  filecolor=black,%
  linkcolor=blue,%
  urlcolor=black
}

%\tolerance=1000 %%% Are you really sure?


\title{temp}

\begin{document}

\maketitle
\tableofcontents

\section{Section 1}
\label{sec-1}
TeX is a computer program for typesetting documents, created by Donald Knuth. It
takes a suitably prepared computer file and converts it to a form which may be
printed on many kinds of printers, including dot-matrix printers, laser printers
and high-resolution typesetting machines. LaTeX is a set of macros for TeX that
aims at reducing the user's task to the sole role of writing the content, LaTeX
taking care of all the formatting process. A number of well-established
publishers now use TeX or LaTeX to typeset books and mathematical journals. It
is also well appreciated by users caring about typography, consistent
formatting, efficient collaborative writing and open formats.

\section{Section 2}
\label{sec-2}
TeX is a computer program for typesetting documents, created by Donald Knuth. It
takes a suitably prepared computer file and converts it to a form which may be
printed on many kinds of printers, including dot-matrix printers, laser printers
and high-resolution typesetting machines. LaTeX is a set of macros for TeX that
aims at reducing the user's task to the sole role of writing the content, LaTeX
taking care of all the formatting process. A number of well-established
publishers now use TeX or LaTeX to typeset books and mathematical journals. It
is also well appreciated by users caring about typography, consistent
formatting, efficient collaborative writing and open formats.

\section{Section 3}
\label{sec-3}
TeX is a computer program for typesetting documents, created by Donald Knuth. It
takes a suitably prepared computer file and converts it to a form which may be
printed on many kinds of printers, including dot-matrix printers, laser printers
and high-resolution typesetting machines. LaTeX is a set of macros for TeX that
aims at reducing the user's task to the sole role of writing the content, LaTeX
taking care of all the formatting process. A number of well-established
publishers now use TeX or LaTeX to typeset books and mathematical journals. It
is also well appreciated by users caring about typography, consistent
formatting, efficient collaborative writing and open formats.

\section{Test footnotes}
\label{sec-4}
This text has a footnote \footnote{See section \ref{sec-1}}
\end{document}

By the way, are you really sure about \tolerance=1000? It's quite a large value and you'll risk getting wide interword spaces. It's better to do

\usepackage{microtype}

(before loading hyperref).

egreg
  • 1,121,712
  • 3
    Package setspace is an item in the section "Package Compatibility" of hyperref's README: Package order is \usepackage{setspace} before \usepackage{hyperref} as egreg has answered in more detail. – Heiko Oberdiek Jul 06 '14 at 20:33
  • Sorry egrep about the \tolerance=1000 thing. It was a leftover that I should have deleted. – York Jul 06 '14 at 22:59
  • @York I have nothing to do with egrep, although I've written a package that uses regular expressions. ;-) – egreg Jul 06 '14 at 23:02
  • @egreg: What package is that, a LaTeX package? I'm pretty new to LaTeX, do you have really book/site to recommend? – York Jul 06 '14 at 23:34
  • @York It's called regexpatch, for modifying definitions of commands. You can try Nicola Talbot's “LaTeX for Complete Novices” – egreg Jul 06 '14 at 23:40
  • @egrep: I'll definitely check out your package at some point. Thanks for referring the book, it looks nice but I'm not sure if I have time to read it page to page. Given my developer background, is there a really good reference manual? – York Jul 06 '14 at 23:47
  • @York -- (Assuming a TeX Live install) try texdoc latex2e for the core and texdoc <package name> for indivdidual packages (not all manuals were created equal, however); for the engines, try texdoc-ing luatex, pdftex, and xetex respectively. If not on TeX Live, try the site texdoc.net. – jon Jul 08 '14 at 15:14
  • @egreg: these command line doc are really nice, thanks a lot. – York Jul 08 '14 at 18:48