I thought that someone must have asked this, but my searches didn't find it.

I am looking to refer back to the table of contents from places in my document. How can I do this?

A further improved version that will put two links in every page and links point to the TOC.

\documentclass{article}
\usepackage{blindtext}
\usepackage{eso-pic}
\usepackage{hyperref}
\usepackage{ifthen}

\newcommand\AtPageUpperRight[1]{\AtPageUpperLeft{%
\put(\LenToUnit{\paperwidth},\LenToUnit{-0.3\paperheight}){#1}%
}}%
\newcommand\AtPageLowerRight[1]{\AtPageLowerLeft{%
\put(\LenToUnit{\paperwidth},\LenToUnit{0.3\paperheight}){#1}%
}}%

{%
\AtPageUpperRight{\put(-70,0){\hyperref[toc]{Go to TOC}}}
\AtPageLowerRight{\put(-70,0){\hyperref[toc]{Go to TOC}}}
}%
}%
{}%

\begin{document}
\tableofcontents\label{toc}
\Blinddocument
\end{document}


If you don't want to display the links (you will in the final document), you can disable them by switching the boolean:

%\setboolean{linktoc}{true}  %%% comment to hide links


You get

• How would I change this to keep the TOC link off my title page? – user77402 Jan 2 '16 at 23:58
• @eliyahu-g Try {\hypersetup{hidelinks} \tableofcontents\label{toc} } – user11232 Jan 30 '16 at 1:30

Since you are using hyperref you can simply add a \label to the \tableofcontents command and then refer to it with \hyperref.

MWE:

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\tableofcontents\label{toc}

\clearpage

\section{A section}

\end{document}


• I upvoted but realize now after having read Heiko's answer that \pageref does not work correctly if the table of contents extend on more than one page... – user4686 Mar 7 '14 at 16:22
• @jfbu In fact I didn't use \pageref. \hyperref works correctly in any case. – karlkoeller Mar 7 '14 at 16:38
• I did notice you did not use \pageref! I was dissuaded from posting an answer when I saw yours, as I thought it nailed it, but then realized about the \pageref issue. The OP was not specific and \pageref is mentioned in the other answers. – user4686 Mar 7 '14 at 16:44

The normal reference system of LaTeX can be used including packages such as hyperref/nameref, titleref, ...

The tricky part is put \label at the right place. hyperref likes it right after the title, then the anchor of the \label remains the title. Also putting \label at the end of the \tableofcontents has the risk for a wrong page reference, if the table of contents is more than one page long.

The following example uses an indirect, defensive approach. \label is put right at the beginning of the .toc file via \addtocontents. In the first run, the \label goes into the .toc file, then in the next run it is propagated to the .aux file and in the third LaTeX run the reference is available. Therefore three LaTeX runs are needed:

\documentclass{article}

\AtBeginDocument{%
}

\begin{document}
\tableofcontents
\section{Hello World}
\end{document}


The .toc file:

\label {toc}
\contentsline {section}{\numberline {1}Hello World}{1}


Result:

The counter toclabel is defined and used to generate several label names, e.g. toc1, toc2, toc3:

\documentclass{article}

\newcounter{toclabel}
\AtBeginDocument{%
}

\begin{document}
\input{\jobname.toc}
\newpage
\input{\jobname.toc}
\newpage
\tableofcontents
\section{Hello World}
\end{document}


• Can you please explain what \protect does? in \protect\label{toc} – Kartik Mar 6 '14 at 14:54
• – Mangara Mar 6 '14 at 16:10
• This will fail if one can typeset multiple times a table of contents from the .toc file, which admittedly is not the case with the standard classes (and excluding toc-devoted packages). – user4686 Mar 7 '14 at 16:39
• @jfbu: This is not much of a problem, see the updated answer. – Heiko Oberdiek Mar 7 '14 at 16:52
• you fixed it fast ;-)... – user4686 Mar 7 '14 at 16:54

Assuming you want a page reference, and you are using a standard class, I would do the following:

\documentclass{article}
\let\oldcontentsname\contentsname
\renewcommand{\contentsname}{\oldcontentsname\label{contents}}
\begin{document}

\tableofcontents

\clearpage

\section{Section 1}

on page \pageref{contents}.

\clearpage

\section{Section 2}

\pageref{contents}.

\end{document}


If \tableofcontents doesn't start a new page, you could just issue the \label immediately before it, but doing it this way makes sure the label ends up in the right place if a new page is started with the title.

With etoc this works out of the box, with or without hyperref:

\documentclass{article}
\usepackage{hyperref}
\usepackage{etoc}

\begin{document}
\tableofcontents\label{toc}

\clearpage
\newcount\cnta
\loop

Note that without etoc the page reference will be wrong (with or without hyperref, the page will be 4 and not the correct 1). Here is what happens then:
• let's hope it does not create others ... :). [release 1.07k just to be issued fixes compatibility with tocloft] – user4686 Mar 7 '14 at 16:48