目录未链接到参考文献

目录未链接到参考文献

我正在用 Latex 写论文,但无法让目录正确链接到我使用该apacite软件包创建的参考列表。下面是说明我的问题的 MWE:

\documentclass[12pt,oneside,english]{article}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage[english]{babel}

\usepackage{titlesec}
\newcommand\sectionbreak{\clearpage}
\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage[toc]{appendix}
\renewcommand{\setthesubsection}{\Alph{subsection}} 

\usepackage{hyperref}
\usepackage{cleveref}
\crefname{appsec}{Appendix}{Appendices}

\usepackage{blindtext}
\usepackage[natbibapa]{apacite}
\usepackage[]{setspace}

\usepackage{filecontents}

\begin{filecontents}{jobname.bib}
    @book{author_book,
        title = {Book's title},
        author = {Author, Some},
        location = {The City},
        publisher = {Publisher},
        date = {2005},
    }
\end{filecontents}
\begin{document}

% Table of contents
\clearpage
\pdfbookmark[1]{Contents}{toc}
\tableofcontents

% Sections
\section{The first section}
Some text is need to push the section title to the next page \citep{author_book}. \hyperref[sec:references]{This} link to the references actually links to the second section. Why is that?
\section{The second section}
Again, some text.

% Bibliography
\begin{singlespacing}
\raggedright{
\bibliographystyle{apacite}
\bibliography{jobname}}\label{sec:references}
\end{singlespacing}

% Appendices
\appendices
\subappendices
\crefalias{section}{appsec}
\section*{Appendices}
\subsection{Some tables}\label[appsec]{app:tables}
This should actually be a table.

\subsection{Some more figures}
And here could be a figure.
\end{document}

我删除了所有我确信与问题无关的内容。如您所见,目录中的页码是正确的,但单击“参考文献”实际上会链接到参考书目之前的第二个。hyperref第一部分中的链接也是如此。我尝试过的一些方法是不使用包tocbibind,而是使用\addcontentsline参考书目中的,但那没有用。

答案1

您需要\phantomsection为链接添加一个锚点 - 因为参考书目没有编号,所以 hyperref 不会自动完成此操作:

\clearpage
\phantomsection %anchor
\begin{singlespacing}
\raggedright
\bibliographystyle{apacite}
\bibliography{jobname}\label{sec:references}
\end{singlespacing}

答案2

\clearpage在之前使用\appendices应该可以工作:

\documentclass[12pt,oneside,english]{article}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage[english]{babel}

\usepackage{titlesec}
\newcommand\sectionbreak{\clearpage}
\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage[toc]{appendix}
\renewcommand{\setthesubsection}{\Alph{subsection}} 

\usepackage{hyperref}
\usepackage{cleveref}
\crefname{appsec}{Appendix}{Appendices}

\usepackage{blindtext}
\usepackage[natbibapa]{apacite}
\usepackage[]{setspace}

\usepackage{filecontents}

\begin{filecontents}{jobname.bib}
    @book{author_book,
        title = {Book's title},
        author = {Author, Some},
        location = {The City},
        publisher = {Publisher},
        date = {2005},
    }
\end{filecontents}
\begin{document}

% Table of contents
\clearpage
\pdfbookmark[1]{Contents}{toc}
\tableofcontents

% Sections
\section{The first section}
Some text is need to push the section title to the next page \citep{author_book}. \hyperref[sec:references]{This} link to the references actually links to the second section. Why is that?
\section{The second section}
Again, some text.

% Bibliography
\begin{singlespacing}
\raggedright{
\bibliographystyle{apacite}
\bibliography{jobname}}\label{sec:references}
\end{singlespacing}

% Appendices
\clearpage
\appendices
\subappendices
\crefalias{section}{appsec}
\section*{Appendices}
\subsection{Some tables}\label[appsec]{app:tables}
This should actually be a table.

\subsection{Some more figures}
And here could be a figure.
\end{document}

相关内容