链接未指向正确的页面

链接未指向正确的页面

问题是摘要、说明、简历和附录的链接(以及 PDF 书签)没有指向正确的页面。摘要指向介绍,titlepage附录指向介绍等。此外,书签中的章节属于介绍 :( 可能是因为我编排了页码(我需要)。我试了很多方法,我打算保持原样 :( 如果您发现错误,请更正我的代码。我是初学者,在调整选项、软件包等方面遇到了很多困难...

\makeatletter
\renewcommand*{\@pnumwidth}{3em}  
\makeatother 

\documentclass[a4paper,12pt,ngerman]{article}
\usepackage[
colorlinks, 
linkcolor=black,
filecolor=black,
citecolor=black
]{hyperref}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{eurosym}
\usepackage{latexsym}
\usepackage{graphicx}
\usepackage[abbr,agsmcite,agsm,round]{harvard}
\usepackage{longtable}
\usepackage{portland}
\usepackage{lscape}
\usepackage[onehalfspacing]{setspace}
\usepackage{footmisc}
\usepackage{hyphenat}
\usepackage{rotating}
\usepackage[USenglish]{babel}
\usepackage{array}
\usepackage{tabularx}
\usepackage[latin1]{inputenc}
\usepackage[para]{threeparttable}
\usepackage{caption}
\usepackage[capposition=top]{floatrow}
%\usepackage[subfigure]
\usepackage{currvita}
\usepackage{enumitem}

%\usepackage[latin9]{inputenc}
%\usepackage[T1]{fontenc}

\setcounter{MaxMatrixCols}{12}

\setlength{\skip\footins}{10mm}
\setlength{\evensidemargin}{0cm}
\setlength{\textwidth}{15cm}
\setlength{\textheight}{23cm}
\setlength{\topmargin}{-1cm}
\pagenumbering{arabic}
\renewcommand\harvardand{and}
\renewcommand{\labelenumi}{\Alph{enumi})}
\renewcommand{\labelenumii}{\arabic{enumii}.}
\renewcommand{\cite}{\citeasnoun} 
\renewcommand{\harvardand}{and} 

\begin{document}

\begin{titlepage}
\begin{center}
Title
\end{center}
\end{titlepage}

\newpage
\pagenumbering{Roman}%
\renewcommand{\abstractname}{Acknowledgements}
\begin{abstract}
\noindent
bla bla
\end{abstract}
\newpage

\phantom{T}\vspace{5,3cm}
\renewcommand{\abstractname}{Abstract}
\begin{abstract}
TEXT
\end{abstract}
\addcontentsline{toc}{section}{Abstract}
\newpage

\tableofcontents
\newpage

\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\newpage

\listoftables
\addcontentsline{toc}{section}{List of Tables}
\newpage

\section*{Symbols}

\addcontentsline{toc}{section}{Symbols}%
\newpage

\section*{List of abbreviations}
\begin{tabular}{L{5.5cm} L{9cm}}
\end{tabular}%

\addcontentsline{toc}{section}{List of abbreviations}%
\newpage

\pagenumbering{arabic}
\setcounter{page}{1}%

\section{Introduction}
text text text
\newpage

\section{System and whatever}
\subsection{System}

\setcounter{table}{0}
\setcounter{figure}{0}  
\setcounter{section}{0} 

\newcommand{\initAnhang}{
    \renewcommand{\thepage}{\Alph{section}\ \arabic{page}}
    \newpage
}
\renewcommand\appendix{\par
        \renewcommand\thesection{\Alph{section}}
        \renewcommand\thesubsection{\Alph{section}\arabic{subsection}}
    \renewcommand\thefigure{\Alph{section}\arabic{figure}}
        \renewcommand\thetable{\Alph{section}\arabic{table}}}

\newcommand{\anhang}[1]{
    \setcounter{page}{1}
    \input{#1}
    \newpage
}       

\appendix\initAnhang
\section{Appendix}
%\addcontentsline{toc}{section}{Appendix}%
\subsection{Descriptive Statistics}

\newpage

\nocite{*}
\bibliographystyle{dcu}
\bibliography{bib}
\addcontentsline{toc}{section}{References}
\newpage

\section*{Explanation}
\addcontentsline{toc}{section}{Explanation}
\newpage

\begin{cv}{CV}
\addcontentsline{toc}{section}{CV}%
\end{cv}

\end{document}

答案1

除了hyperref在调用的包中放在第一位而不是最后面之外,我认为它们没有什么不好;但你确定你需要它们全部吗?

无论如何,我会把fontencinputencbabel放在第一位:

\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc} % recommended for German
\usepackage[latin1]{inputenc}
\usepackage[USenglish,ngerman]{babel}

<...other packages...>

\usepackage[
  colorlinks,
  linkcolor=black,
  filecolor=black,
  citecolor=black
  ]{hyperref} %% should be last

\makeatletter
\renewcommand*{\@pnumwidth}{3em}  
\makeatother 

<...other settings...>

有关错误链接的问题在于命令的顺序:

\begin{document}

\pagenumbering{alph} % not to get duplicate links (see Ulrike's comment)
\begin{titlepage}
\begin{center}
Title
\end{center}
\end{titlepage}

\newpage
\pagenumbering{Roman}

\begingroup %% there will be no need to reset \abstractname
\renewcommand{\abstractname}{Acknowledgements}
\begin{abstract}
\noindent
bla bla
\end{abstract}
\endgroup

\newpage

\vspace*{5,3cm} %% the space won't disappear at the top of the page

\phantomsection
\addcontentsline{toc}{section}{Abstract}

\begin{abstract}
TEXT
\end{abstract}

\newpage

\tableofcontents

\newpage

\phantomsection
\addcontentsline{toc}{section}{List of Figures}
\listoffigures

\newpage

<...similarly for the other lists...>

通过\phantomsection设置链接位置;通过将其放置\addcontentsline在分页符之后,您就知道对该页面的引用是正确的。

答案2

作为最后一个包加载hyperref然后

...
\phantomsection
\phantom{T}\vspace{5.3cm}
\renewcommand{\abstractname}{Abstract}
\begin{abstract}
TEXT
\end{abstract}
\addcontentsline{toc}{section}{Abstract}
\newpage
...

答案3

最后,我解决了这个问题。在我只有一个附录的情况下,这已经足够了:

\setcounter{table}{0}       
\setcounter{page}{1}

\newcommand{\initAnhang}{
    \renewcommand{\thepage}{A\arabic{page}}
    \newpage
}
\renewcommand\appendix{\par
        \renewcommand\thesection{A}
        \renewcommand\thesubsection{A\arabic{subsection}}
        \renewcommand\thetable{A\arabic{table}}}        

\appendix\initAnhang
\section{Appendix}
\subsection{Descriptive Statistics}

我没有重置章节的计数器(这就是问题所在!),而是手动输入“A”来开始计数从“A”开始的附录、页面和表格。

链接的红色边框只有hyperref

\usepackage[abbr,agsmcite,agsm,round]{harvard}

相关内容