[Tex/LaTex] Best practices for cross-references with hyperref

best practicescross-referencinghyperref

I want to reference some parts of my document. At the moment I read that there are several options. When clicking on a cross-reference one should get to the right part of the document.

The first option is to use labels like explained on wikibooks. But I think that won't produce clickable links.

The second option is better in my opinion: the hyperref package, which I am already using. I found an explanation in the manual.

How can I link parts in the easiest way?

I don't want to put for every section a \label I think that could be done automatically. The entries in the table of contents are linked, thus I presume that some labels are already defined. Also the procedure should be resistant to renaming and moving the section through the document. It that possible or do I have to check my document twice after every change?

Best Answer

Using the labels together with hyperref will produce clickable links, at least it does for me. Here is a short example:

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\tableofcontents

\section{Fermat’s Principle}
    \label{sec:fermat}
    Fermat’s principle states that the path light takes from one point 
    to another is not necessarily the one with the smallest distance,
    but rather the path which can be traversed in the shortest time.
\section{Geometrical Optics}
    Geometrical optics is an approximation for light propagation in 
    cases where the wavelength is very small compared to the
    structures with which the light interacts. Snell’s Law, describing 
    refraction, can be derived from Fermat’s principle 
    (see section~\ref{sec:fermat}).    
\end{document}

enter image description here Naturally, this is resistant to moving and renaming the section, as long as you move the label along with the section and don't rename it.

Related Question