Link clicável de volta ao índice

Link clicável de volta ao índice

Existem muitas perguntas e respostas sobre como tornar o Table of Contentsconteúdo clicável. Gostaria de saber como fazer uma referência ao Table of Contentse criar um link em outro lugar do documento para clicar e voltar ao índice.

Tentei fornecer Table of Contentsseu próprio rótulo \tableofcontents\label{toc}e depois usar um link de referência, \ref{toc}mas isso produziu o erro:./project.tex:133: Package hyperref Warning: Suppressing empty link on input line 133.

Responder1

Isso pode ser feito comhipertargetehiperlinkdehiperrefpacote. Veja o exemplo abaixo:

\documentclass{article}
\usepackage{hyperref}

\begin{document}
Title Page\newpage

% Add a link target to the TOC itself
\addtocontents{toc}{\protect\hypertarget{toc}{}}

% Print the TOC
\tableofcontents
\newpage

% Sections with a hyperlink to TOC
\section[One]{One. Go to \hyperlink{toc}{TOC}}
Text that points to \hyperlink{toc}{Table of Contents}.

\end{document}

Responder2

Algo assim:

\documentclass{book}


\usepackage{hyperref}

\begin{document}

\phantomsection 
\hypertarget{MyToc}{}  % Make an anchor to the toc
\tableofcontents

\chapter{Dummy}


\chapter{Yet another Dummy}

Jump to my incredible \hyperlink{MyToc}{Table of contents}

\end{document}

Altere a documentclass relevante à vontade.

insira a descrição da imagem aqui

informação relacionada