目录之前的元素始终链接到第一页

目录之前的元素始终链接到第一页

我遇到了这个问题,目录之前的部分总是引用目录的第一页。您可以在此处查看此文档 https://drive.google.com/file/d/1tYrxTYiJEj1NuKD9SehEXejADIXgG_kX/view?usp=sharing 以及 Github 存储库中的全部代码https://github.com/abdorah/stage2021

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[sfdefault]{biolinum}
\usepackage[french]{babel}
\usepackage{setspace}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lscape}
\usepackage{bookmark}
\usepackage{rotating}
\usepackage{subcaption}
\usepackage{float}
\usepackage{eurosym}
\usepackage[headheight=13pt,top=3cm, bottom=2cm, left=1cm, right=1cm]{geometry}
\usepackage{pdfpages}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    citecolor=black,
    filecolor=black,
    urlcolor=black,
}
\usepackage{array,multirow,makecell}
\setcellgapes{3pt}
\setlength{\parindent}{1.1cm}
\makegapedcells
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}b{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}b{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}b{#1}}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\fancyfoot[L]{ENSIAS}
\fancyfoot[C]{\textbf{\thepage}}
\fancyfoot[R]{Année universitaire: 2020/2021}
\begin{document}
\begin{titlepage}
    \begin{center}
% this is the page that is referred to by all the elements that exsites between it and the table of content
    \end{center}
\end{titlepage}

\newpage

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

\addcontentsline{toc}{chapter}{Remerciements}
\begin{doublespace}
    \begin{center}
        \vspace*{1cm}
        \textbf{\huge{Remerciements}}
    \end{center}
    \fancyhead[R]{\textbf{Remerciements}}
    \fancyhead[L]{\hspace*{5cm}}

\newpage

    \addcontentsline{toc}{chapter}{Résumé}
    \begin{center}
        \vspace*{1cm}
        \textbf{\huge{Résumé}}
    \end{center}
    \fancyhead[R]{\textbf{Résumé}}
    \fancyhead[L]{\hspace*{5cm}}

\newpage

    \addcontentsline{toc}{chapter}{Abstract}
    \begin{center}
        \vspace*{1cm}
        \textbf{\huge{Abstract}}
    \end{center}
    \fancyhead[R]{\textbf{Abstract}}
    \fancyhead[L]{\hspace*{5cm}}
\end{doublespace}

\fancyhead[R]{\textbf{Table des matières}}
\fancyhead[L]{\hspace*{5cm}}
\tableofcontents

\cleardoublepage
\listoffigures

\cleardoublepage
\renewcommand{\listtablename}{Table des tableaux}
\listoftables

\end{document}

答案1

与包hyperref结合你应该在它前面\addcontentsline添加一个,这样才能链接到正确的页面。\phantomsectionhyperref

梅威瑟:

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[sfdefault]{biolinum}
\usepackage[french]{babel}
\usepackage{setspace}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lscape}
\usepackage{bookmark}
\usepackage{rotating}
\usepackage{subcaption}
\usepackage{float}
\usepackage{eurosym}
\usepackage[headheight=13pt,top=3cm, bottom=2cm, left=1cm, right=1cm]{geometry}
\usepackage{pdfpages}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    citecolor=black,
    filecolor=black,
    urlcolor=black,
}
\usepackage{array,multirow,makecell}
\setcellgapes{3pt}
\setlength{\parindent}{1.1cm}
\makegapedcells
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}b{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}b{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}b{#1}}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\fancyfoot[L]{ENSIAS}
\fancyfoot[C]{\textbf{\thepage}}
\fancyfoot[R]{Année universitaire: 2020/2021}
\begin{document}
    \begin{titlepage}
        \begin{center}
            Text for experimenting only.
            % this is the page that is referred to by all the elements that exsites between it and the table of content
        \end{center}
    \end{titlepage}
    
    \newpage
    
    \pagenumbering{arabic} \setcounter{page}{1}
    
    \phantomsection % added
    \addcontentsline{toc}{chapter}{Remerciements}
    \begin{doublespace}
        \begin{center}
            \vspace*{1cm}
            \textbf{\huge{Remerciements}}
        \end{center}
        Text for experimenting only.
        \fancyhead[R]{\textbf{Remerciements}}
        \fancyhead[L]{\hspace*{5cm}}
        
        \newpage
        
        \phantomsection % added
        \addcontentsline{toc}{chapter}{Résumé}
        \begin{center}
            \vspace*{1cm}
            \textbf{\huge{Résumé}}
        \end{center}
        Text for experimenting only.
        \fancyhead[R]{\textbf{Résumé}}
        \fancyhead[L]{\hspace*{5cm}}
        
        \newpage
        
        \phantomsection % added
        \addcontentsline{toc}{chapter}{Abstract}
        \begin{center}
            \vspace*{1cm}
            \textbf{\huge{Abstract}}
        \end{center}
        Text for experimenting only.
        \fancyhead[R]{\textbf{Abstract}}
        \fancyhead[L]{\hspace*{5cm}}
    \end{doublespace}
    
    \fancyhead[R]{\textbf{Table des matières}}
    \fancyhead[L]{\hspace*{5cm}}
    \tableofcontents
    
    \cleardoublepage
    \listoffigures
    
    \cleardoublepage
    \renewcommand{\listtablename}{Table des tableaux}
    \listoftables
\end{document}

顺便说一句:您的 MWE 缺少一个,\end{document}因此没有它就无法编译。此外,下次您可以尝试稍微缩短您的 MWE,因为许多包和命令对于演示您的问题来说不是必需的(例如tabularx and graphicx等等,仅举几例)。

相关内容