TransWikia.com

Title page and Abstract link to the same page?

TeX - LaTeX Asked by Shiqi on July 21, 2021

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]{>{centeringarraybackslash}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.

One Answer

Thanks to daleif. Here is one solution:

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

2.Add phantomsectionaddcontentsline{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.

Correct answer by Shiqi on July 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP