可點選連結返回目錄

可點選連結返回目錄

關於如何使內容可點擊有很多問題和答案Table of Contents。我想知道如何在文件的其他位置引用Table of Contents並建立連結以單擊並返回到目錄。

我嘗試Table of Contents通過給出自己的標籤\tableofcontents\label{toc},然後使用參考鏈接\ref{toc},但這會產生錯誤:./project.tex:133: Package hyperref Warning: Suppressing empty link on input line 133.

答案1

這可以透過以下方式完成超目標超連結來自超引用包裹。請參閱下面的範例:

\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}

答案2

像這樣的東西:

\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}

隨意更改相關文檔類。

在此輸入影像描述

相關內容