如何在参考书目开头创建指向目录的超链接

如何在参考书目开头创建指向目录的超链接

我想在参考书目的开头添加指向目录的超链接:在此处输入图片描述

我的(显而易见的)方法是:

\documentclass[letterpaper,11pt]{book}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\usepackage{hyperref}

\title{How do I add a hyperlink in thebibliography to the table of contents?}

\begin{document}

\frontmatter

\maketitle

% this is the hypertarget I want to put in thebibliography
\addtocontents{toc}{\protect\hypertarget{toc}{}}

\tableofcontents

\mainmatter

\chapter{Chapter 1}

I cite authors and books:  \cite{author1,book1}.

\begin{thebibliography}{}

%Here I want the hyperlink to the table of contents, 
%but if I don't know how to do it without getting an error:

%\hyperlink{toc}{Hyperlink back to table of contents.}

\bibitem{author1}
This is the info of citation 1.

\bibitem{book1}
This is the info of citation 2.

\end{thebibliography}
\end{document}

使用

    \bibitem{whatever} \hyperlink{toc}{Hyperlink back to table of contents.}

\bibitem{author1}
This is the info of citation 1.

\bibitem{book1}
This is the info of citation 2.

作品:

在此处输入图片描述

但我不知道如何删除该号码(我尝试搜索该方法但没有找到任何东西)。

我在论坛上看到过类似的问题,但它们只会让我更加困惑,因为我没有看到任何人问这个特定的任务。不过,如果这是一个重复的问题,我很抱歉,我以为这很简单,但我很难找到所需的超链接。

答案1

您可以将超链接添加为\bibname和 的一部分\contentsname

\documentclass[letterpaper,11pt]{book}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\usepackage{hyperref}
\usepackage{etoolbox}

\title{How do I add a hyperlink in thebibliography to the table of contents?}

\let\oldcontentsname=\contentsname
\patchcmd{\tableofcontents}{\MakeUppercase\contentsname}{\MakeUppercase\oldcontentsname}{}{FAILED}

\let\oldbibname=\bibname
\patchcmd{\thebibliography}{\MakeUppercase\bibname}{\MakeUppercase\oldbibname}{}{FAILED}

\begin{document}

\frontmatter

\maketitle

\def\contentsname{\protect\hypertarget{toc}{\oldcontentsname}\par
  \protect\hyperlink{bib}{\Large Hyperlink to bibliography.}}
\tableofcontents

\mainmatter

\chapter{Chapter 1}

I cite authors and books:  \cite{author1,book1}.

\def\bibname{\protect\hypertarget{bib}{\oldbibname}\par
  \protect\hyperlink{toc}{\Large Hyperlink to table of contents.}}
\begin{thebibliography}{}

\bibitem{author1}
This is the info of citation 1.

\bibitem{book1}
This is the info of citation 2.

\end{thebibliography}
\end{document}

相关内容