Discussion:
Peter Flynn
2020-06-19 15:53:03 UTC
I'm clearly doing something wrong here.
The link on p.1 points to p.1 and not to p.2 where the label is.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\clearpage
This is where the Foo lives\label{foo}
\end{document}

Peter
Ulrike Fischer
2020-06-19 16:14:45 UTC
Post by Peter Flynn
I'm clearly doing something wrong here.
The link on p.1 points to p.1 and not to p.2 where the label is.
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\clearpage
This is where the Foo lives\label{foo}
\end{document}
You need an anchor. If no counter sets it, you have to set it
manually:

\phantomsection\label{foo}
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
Peter Flynn
2020-06-19 20:15:09 UTC
Post by Ulrike Fischer
Post by Peter Flynn
I'm clearly doing something wrong here.
The link on p.1 points to p.1 and not to p.2 where the label is.
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\clearpage
This is where the Foo lives\label{foo}
\end{document}
You need an anchor. If no counter sets it, you have to set it
\phantomsection\label{foo}
Oooh. In all these years I never found that one. Thank you. And Ulrich.
(Yes, on reflection, all previous links have been in big documents with
lots of structural labels.)

P

u***@web.de
2020-06-19 16:33:41 UTC
Post by Peter Flynn
I'm clearly doing something wrong here.
The link on p.1 points to p.1 and not to p.2 where the label is.
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\clearpage
This is where the Foo lives\label{foo}
\end{document}

Usually a sectioning-command like \section or \subsection
beneath other things expands to a call to
\refstepcounter{<counter>}.

\refstepcounter{<counter>} in turn increments the <counter>
in question and redefines the macro \@currentlabel to deliver
the expansion of the sequence \p@<counter>\the<counter>.

The label-command in turn uses the expansion of \@currentlabel
when it comes to writing referencing-data (these \newlabel-
entries) to the .aux-files.

When the hyperref-package is loaded, \refstepcounter also
places a target/named destination/anchor and stores the name
of that named destination in the macro \@currentHref.

The label-command in turn also uses the expansion of \@currentHref
when it comes to writing referencing-data (these \newlabel-
entries) to the .aux-files. This way referencing-commands can
also retrieve information about the name of target/named destination/
anchor placed into the .pdf-file at the time when the counter
which is to be referenced was incremented.

In your example no sectioning-commands and thus no instances
of \refstepcounter were applied, thus there are no targets/
named destinations/anchors which could be used for hyperlinking.

In such situations you usually get a message in the .log-file and
as default the target will be the first page of the document.

You can apply \phantomsection for placing a target/named destination/
anchor and having \@currentHref redefined to yield the name of that
target/named destination/anchor:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\clearpage
This is where the Foo lives\phantomsection\label{foo}
\end{document}

View the .pdf-file at a very large zoom-factor to see where the
target/named destination/anchor will actually be placed and thus
which "point" of the document/of the second page will be navigated