在内容中添加标题会导致链接到错误的页面

在内容中添加标题会导致链接到错误的页面

我有一个文档,其中有自动生成的标准目录,pdflatex但默认情况下,该目录不包含图表、表格和参考书目列表。

因此,我尝试\addcontentsline{toc}{chapter}{List of Tables}在序言中手动强制使用这些,例如

\addcontentsline{toc}{chapter}{List of Tables}
\listoftables

但我发现,虽然目录包含列表,但页码往往比应有的少一个。因此,如果目录显示List of Tables在第 iv 页,目录中的链接会将我带到标题为 的第 iv 页List of Figures。在目录中,显示List of Figures为第 iii 页。

下面的 LaTeX MWE 说明了正在发生的情况。

一个相关的问题是参考书目的页码。目录显示它在第 14 页,但第 14 页实际上显示的是章节Results

文档正文没有问题,标题在页面上显示正确。所以一定是我没有做对,或者做错了\addcontentsline{...}

有人可以提出什么建议吗?

MWE 代码:

    \documentclass[oneside,12pt]{report} % Use twoside for alternate page headings.

\usepackage{uolthesis}
\usepackage{setspace}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{alltt}
\usepackage{anysize}
\usepackage{appendix}
\usepackage{array}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{changepage}
% \usepackage{cite}
\usepackage{color}
\usepackage{enumerate}
\usepackage{etoolbox}
\usepackage{fancyhdr}
\usepackage{fixltx2e}
\usepackage{footmisc}
% \usepackage{graphics}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{ragged2e}
\usepackage{hyperref}
\usepackage{bookmark}
\usepackage[numbers,sort]{natbib}
% \usepackage{tocbibind}
\usepackage{url}

\marginsize{2.54cm}{2.54cm}{2.54cm}{2.54cm}

% LIST OF ABBREVIATIONS. ---------------------------------------------------------------------------------------

\usepackage[acronym,footnote,nonumberlist]{glossaries} % Makes a list of abbreviations.
\usepackage{glossary-mcols}

\renewcommand{\glossarypreamble}{Text to go here\ldots}

% LIST OF ABBREVIATIONS. --------------------------------------------------------------------------

% NOTE: The LaTeX glossary is in file Abbreviations.tex. The thesis glossary is in file Glossary.tex.

% With thanks to: http://tex.stackexchange.com/questions/197692/adding-a-specific-title-to-
%                 list-of-abbreviations-acronyms-in-latex.

\usepackage[acronym,footnote,nonumberlist]{glossaries} % Makes a list of abbreviations.
\usepackage{glossary-mcols}
% \makeglossaries % This must be run from the command-line: e.g. 'makeglossaries file'
                  % where `file` is the name of the main LaTeX file.
\renewcommand{\glossarypreamble}{Some text\ldots}

\include{DummyGlossary}
% \renewcommand{\glsnamefont}[1]{\textbf{#1}}

\makeglossaries
\glossarystyle{mcolindex}
% \glossarystyle{long}

% PART, CHAPTER AND SECTION NUMBERING.  -----------------------------------------------------------------------------------------------------------------

\makeatletter

\let\LaTeXStandardPart\part%
\newcommand{\unstarredpart@@noopt}[1]{%
    \unstarredpart@@opt[#1]{#1}%
}

\newcommand{\unstarredpart@@opt}[2][]{%
    \cleardoublepage% (For clearing content before.)
    \begingroup%
    \let\newpage\relax%
    \LaTeXStandardPart[#1]{#2}%
    \endgroup%
}

\newcommand{\starredpart}[1]{%
    \LaTeXStandardPart*{#1}%
}

\newcommand{\unstarredpart}{%
    \@ifnextchar[{\unstarredpart@@opt}{\unstarredpart@@noopt}%
}

\renewcommand{\part}{%
  \@ifstar{\starredpart}{\unstarredpart}%
}

% BIBLIOGRAPHY PREAMBLE. --------------------------------------------------------------------------

\renewcommand{\bibpreamble}{The references below are listed in order of author(s).}

% BEGIN DOCUMENT. ---------------------------------------------------------------------------------

\begin{document}

    \pagenumbering{roman}

    % Title page.
    \title{\textcolor{red}{** WORKING DRAFT **}}
    \author{Author}

    \begin{abstract}
        This report\ldots
    \end{abstract}

    % LISTINGS. ---------------------------------------------------------------------------------------

    \tableofcontents

    % Print glossary.
    \glsaddall
    \printglossary[type=acronym,title={List of Abbreviations}]\addcontentsline{toc}{chapter}{List of Abbreviations}    
    \printglossaries%[title={List of abbreviations}]

    % Print algorithms. 
    \clearpage% or \clearpage under the oneside option
    \phantomsection% Mark a hyperref link location
    \addcontentsline{toc}{chapter}{List of Algorithms}% Add contents entry for List of Tables
    \listofalgorithms% Start List of Tables
    \setcounter{chapter}{0}

    % Print figures.    
    \clearpage% or \clearpage under the oneside option
    \phantomsection% Mark a hyperref link location
    \addcontentsline{toc}{chapter}{List of Figures}% Add contents entry for List of Tables
    \listoffigures% Start List of Tables

    % Print tables.           
    \clearpage% or \clearpage under the oneside option
    \phantomsection% Mark a hyperref link location
    \addcontentsline{toc}{chapter}{List of Tables}% Add contents entry for List of Tables
    \listoftables% Start List of Tables

    \pagenumbering{arabic}

    \chapter{Introduction}

    Some text for the second reference \cite{Date}.

    \noindent Some text for the first reference \cite{Abiteboul_et_al}.

    \noindent Some text for the first reference \cite{Paass_et_al}.

    \noindent Abbreviations W3C and WWW.

    \chapter{Background}
    \chapter{Review}

    \part{Case study one}
    \chapter{Apparatus}
    \chapter{Method}
    \chapter{Experiment}
    \chapter{Results}

    \part{Case study two}
    \chapter{Apparatus}
    \chapter{Method}
    \chapter{Experiment}
    \chapter{Results}

    \appendix

    % Print figures.
    \clearpage% or \clearpage under the oneside option
    \phantomsection% Mark a hyperref link location
    \addcontentsline{toc}{chapter}{Bibliography}% Add contents entry for List of Tables
    \bibliography{DummyBibliography}
    \bibliographystyle{plain}



\end{document}

及参考书目:

@book{Abiteboul_et_al,
  author = {S. Abiteboul and P. Buneman and D. Suciu},
  title = {Data on the web: From relations to semi-structured data and XML},
  publisher = {Morgan-Kaufmann},
  address = {San Francisco, CA, USA},
  year = {2000}
}

@book{Date,
  author    = {C. J. Date},
  title     = {{An Introduction to Database Systems, 6th Edition}},
  publisher = {Addison-Wesley},
  year      = {1995},
  isbn      = {0-201-82458-2},
  timestamp = {Thu, 03 Jan 2002 11:51:07 +0100},
  biburl    = {http://dblp.uni-trier.de/rec/bib/books/aw/Date95},
  bibsource = {dblp computer science bibliography, http://dblp.org
}

@inproceedings{Paass_et_al,
  author    = {Gerhard Paa\ss and
               Edda Leopold and
               Martha Larson and
               J{\"{o}}rg Kindermann and
               Stefan Eickeler},
  title     = {{SVM Classification Using Sequences of Phonemes and Syllables}},
  booktitle = {Principles of Data Mining and Knowledge Discovery, 6th European Conference,
               {PKDD} 2002, Helsinki, Finland, August 19-23, 2002, Proceedings},
  year      = {2002},
  pages     = {373--384},
  crossref  = {DBLP:conf/pkdd/2002},
  url       = {http://dx.doi.org/10.1007/3-540-45681-3_31},
  doi       = {10.1007/3-540-45681-3_31},
  timestamp = {Fri, 12 Sep 2014 20:22:12 +0200},
  biburl    = {http://dblp.uni-trier.de/rec/bib/conf/pkdd/PaassLLKE02},
  bibsource = {dblp computer science bibliography, http://dblp.org}
}

答案1

您需要在正确的页面上才能发出与内容相关的宏。为此用途

\cleardoublepage% or \clearpage under the oneside option
\phantomsection% Mark a hyperref link location
\addcontentsline{toc}{chapter}{\listtablename}% Add contents entry for List of Tables
\listoftables% Start List of Tables

人们可以对 ToC、LoF 以及\chapterToC 中尚未包含的任何其他相关条目执行类似操作。

如果您希望将所有列表元素添加到目录中,您也可以添加tocbibind包裹你的序言。

相关内容