# [OS X TeX] Linking to forward labels

Victor Ivrii vivrii at gmail.com
Sat Mar 15 06:08:24 EDT 2014

On Fri, Mar 14, 2014 at 10:30 PM, Peter Teeson <peter.teeson at icloud.com>wrote:

> Hi:
> I've looked at the LaTeX Wikibook docn on \hyperref and \label but I still
> don't understand how to do something.
> Consider a sentence where I wish to link, in this case,  the word* here *to
> a label that is defined forward. For example:
>
>  For a Quick Start go *here* but if you need  Detailed Instructions go
> *here.*
> .... several intervening pages....
>
> \label{sec:QuickStart}
>
> .... more intervening pages....
>
> \label{sec:Detailed Instructions}
>
>
> As far as I understand it the \ref only refers to already defined \labels.
> And I can't seem to get it working with \hyperref.
>

You are completely confused and your confusion is not hyperref related.

When you run latex (or pdflatex) on foo.tex  it stores all \label
information (in particular, to what each label corresponds) in foo.aux
file. When you run (pdf)latex again it reads foo.aux into memory and wipes
it out to (re)create again and uses this information to use with \ref.

In particular when you run (pdf)latex first time it cannot read foo.aux and
therefore all \ref{} return ?? . Further when you make new labels between
runs or add and remove some equations between runs pdf(latex) uses old
foo.aux and therefore may still produce some ?? and have wrong references.
Therefore you need either latex again (better thrice due to possible change
of pagination) or use latexmk.

The same applies to \eqref, \pageref, \nameref, \cite (here \label is
replaced by  \bibitem ) and also to their * cousins in \hyperref.

HTH
--

Victor Ivrii
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://email.esm.psu.edu/pipermail/macosx-tex/attachments/20140315/9c4ae746/attachment.html>