# Why is my cross reference not working and some other questions

I am a TEX beginner and I am now learning how to create a reference. I am reading the book "The Not So Short Introduction to LATEX2" by Oetiker, Partl, Hyna, Schlegl; on page 42 section 2.8 Cross Reference, the code is written as

A reference to this section \label{sec:this} looks like:
"see section~\ref{sec:this} on page~\pageref{sec:this}"


And I am using CTex and WinEdt and my questions are:

1. I made a pdf file from the above code, but the section and page numbers are not highlighted and I cannot click on them. Why is it so?
2. I tried to make a reference to other pages by typing its page number like {sec:37}, but it does not work. How can I fix it?
3. What does the code sec actually mean? Is it arbitrary or a predefined syntax?
4. When I typed \label{}, a menu box named Labels (51) appeared, and there is a dropdown menus like c:ISYAC, c:UNBOUND, c:UNIFBURN,... etc... what is that? Do we have to choose from those list or can we write our own like {sec:this}?

Helps are greatly appreciated! Many many thanks!

-
Re #1: you will want to load the hyperref package via \usepackage{hyperref}. Re #2: References to page numbers are not supported this way: You need to add another \label{foo} to refer to another part of the document. Re #3: sec seems to be a prefix for section, it has no value for LaTeX, but is a help for you to remember what you referenced to is a section, and for example not a figure (commonly prefixed by fig). Re #5: Of course you can choose your own label name, and you should do so in fact, after all it's you who will need to remember them. – moewe Dec 31 '13 at 10:23
Welcome to TeX.SE! To create cross-references that act like hyperlinks, you also need to load the hyperref package. For much more information on LaTeX's cross-referencing methods (including hyperref), be sure to check out the posting Cross-reference packages: which to use, which conflict?. – Mico Dec 31 '13 at 10:24
Thank you for all the comments and helps! – Henry Jan 2 '14 at 3:53
Do us a favour and change your username to something more telling than "user1234". ;-) – Tobi Jan 2 '14 at 13:19
Maybe worth a look: Difference between ref, varioref and cleveref. Decision for a thesis. – Tobi Jan 3 '14 at 17:39

The general mechanism is to set an anchor some where in your document with \label{<name>}, where <name> can be a combination of numbers, letters, : and - (to be safe). These anchors must be set explicitly by the author, thats why \ref{sec:47} doesn’t work unless it is not defined by you. After setting up an anchor you can refer to it with \ref{<name>} (giving the corresponding counter, like chapter or section or equation or … number) or \pageref{<name>} (giving the corresponding page number).

Some author use identifiers like sec:, eq:, thm: etc. to make anchor names more human readable but this is not necessary for the mechanism to work.

packages
LaTeX’s mechanism can be extended by some packages:

• hyperref makes references click-able hyper links (and has some more features).
• cleveref finds the right names for labels and prints \ref{anchor5} as section~5 instead of 5, for instance.
• varioref compares the page numbers of anchor and reference and add text like on previous page, on page 6 etc. automatically.
• nameref can print the actual title of an anchor.

MWE

\documentclass[english]{article}

% langage
\usepackage{babel}

% only for \lipsum blind text
\usepackage{lipsum}

% ref packages
\usepackage{nameref}
% folowing  must be in this order
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}
\section{First section}
\lipsum[1-10]

\section{My section}\label{sec:mysection}
\lipsum[1-22]

\section{References}
\begin{itemize}
\item \verb+\ref{sec:mysection}+: \ref{sec:mysection}
\item \verb+\pageref{sec:mysection}+: \pageref{sec:mysection}
\item \verb+\cref{sec:mysection}+: \cref{sec:mysection}
\item \verb+\cpageref{sec:mysection}+: \cpageref{sec:mysection}
\item \verb+\vref{sec:mysection}+: \vref{sec:mysection}% already combined with \cref
\item \verb+\vpageref{sec:mysection}+: \vpageref{sec:mysection}
\item \verb+\nameref{sec:mysection}+: \nameref{sec:mysection}
\end{itemize}
\end{document}


-
Thanks! Your answer is really useful! There is one more question, after it is referenced and linked, the section title, etc are red-boxed, can we change into a coloured text or something like that, a boxed text seems rather disturbing ;) Thanks very much! – Henry Jan 2 '14 at 4:07
yes, try hyperref's colorlinks option (see sec. 3.5) … note the the boxes won't be printed anyway … – Tobi Jan 2 '14 at 9:45