0

I am writing a thesis and I would like to put the title page and abstract into the table of contents. However, my title page hyperlink and abstract hyperlink both link to the title page.

Here is my main Latex file:

% main.tex================================================================

%preamble
\documentclass{my_thesis}

% preamble contains title page, signature page, acknowledgment and abstract texts
\usepackage{import}


% Pacakges used
\usepackage[utf8]{inputenc} % Remove warning on ascii conversion
\usepackage[T1]{fontenc} % Remove warning on ascii conversion
\usepackage[margin=1in,letterpaper]{geometry} % decreases margins
\usepackage{float}  % for figure "H"
\usepackage{amsmath}    % math
\usepackage{hyperref} % hyperlinks
\setlength{\parskip}{0.5em} % paragraph spacing
\usepackage{graphicx}   % figure
\usepackage{subfig}
\usepackage[nottoc]{tocbibind}  % put bib in the table of content 
\usepackage{amsfonts} % for math equations
\usepackage{array} % table
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{listings}   % code

\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\} % paragraph with line break

\begin{document}

    % title page-------------------------------------------
    \input{./Chapter_title/title_page.tex}
    \addcontentsline{toc}{chapter}{Title Page}
    % ----------------------------------------------------

    % abstract -------------------------------------------
    \input{./Chapter_abstract/abstract.tex}
    \addcontentsline{toc}{chapter}{Abstract}
    % ----------------------------------------------------

    % acknowledgement ----------------------------------------
    \input{./Chapter_acknowledgement/acknowledgement.tex}
    \addcontentsline{toc}{chapter}{Acknowledgement}
    % ----------------------------------------------------

    % generate table of contents ============================
    \setcounter{tocdepth}{5}    % set the depth of table of contents
    \tableofcontents
    % ======================================================

    \input{./Chapter_introduction/introduction.tex}

    ...

\end{document}

My title page file:

% title_page.tex================================================
\thispagestyle{empty}
\begin{titlepage}
    \begin{center}
        \vspace*{1cm} 
        
        { \huge
            \textbf{My Ttile}
        }

        ...
                
    \end{center}
\end{titlepage}

My abstract page file:

% abstract.tex=================================================
\thispagestyle{plain} 

\begin{center}
    \vspace*{1cm} 
    
    { \Large
        \textbf{My Title}
    }
    \vspace{0.4cm}
    \large

    by \\
    \vspace{0.4cm}
    \textbf{XXX}
    
    \vspace{0.9cm}
    \textbf{Abstract}
    
\end{center}

 My abstract...

By doing so, I am able to see Title Page and Abstract in my table of contents. However, in the generated table of content, the Title Page and Abstract share the same page number 1 (see the figure below)? But I used \thispagestyle{empty} in the title_page.tex and there is no page number on the title page. The first page starts with the abstract page. And the hyperlinks of Title page and Abstract both link to the title page. Can anyone tell me how to fix this? Thank you! contents

Edit: I added a mini problem-replicate example here my_thesis if anyone want to have a closer look.

4
  • Please provide a full minimal self contained example that others can test as is. Here you are loading files we have no access to (since you're using \input the relevant contents of those files might as well be in your main example document. Plus you list no relevant preamble or document class.
    – daleif
    Aug 12, 2020 at 8:46
  • A hint: you seems to be using hyperref (no preamble so we don't know), but then \addcontentsline{toc}{chapter}{Abstract} has no anchor to point to. Try \phantomsection\addcontentsline{toc}{chapter}{Abstract} instead. Additionally I'd add this right after \textbf{Abstract} not in the main document after the \input as the link then points towards the end of the file.
    – daleif
    Aug 12, 2020 at 8:48
  • Hi daleif! You are right, Thank you for your help! I tried to put \phantomsection\addcontentsline{toc}{chapter}{Abstract} after \textbf{Abstract}, this time the hyperlink can point to the right page. So what is the "anchor" of hyperref? It seems it always points to target like '\chapter' or \section. Since my abstract.tex does not have such a target so it has nowhere to point to?
    – Shiqi
    Aug 12, 2020 at 13:30
  • An internal hyperref link needs somewhere to point to (one may think of it as a set of coordinates of a specific page). So when say \addcontentsline is executed it will take the current target. Normally \addcontentsline sits inside say \chapter and there \refstepcounter will make an anchor/target for us. Here there is no anchor near \textbf{Abstract} it will take the nearest one. which might be the nearest \section etc.
    – daleif
    Aug 12, 2020 at 13:51

1 Answer 1

1

Thanks to daleif. Here is one solution:

1.Delete the \addcontentsline{toc}{chapter}{Abstract} from main.tex file.

2.Add \phantomsection\addcontentsline{toc}{chapter}{Abstract} to the abstruct.tex above \textbf{My Title}.

3.compile twice.

Then the hyperlink of Abstract in the table of contents can point correctly to the abstract page.

The problem is that \addcontentsline{toc}{chapter}{Abstract} has no anchor to point to. So we can use \phantomsection to require hyperref jump to the correct page. You could also have a look at phantomsection.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .