TransWikia.com

How add correct cross reference hyperlinks to a titlingpage environment?

TeX - LaTeX Asked on June 20, 2021

I have the following command for setting up some titling pages in my PhD thesis:

newcommand{AddPaperTitlePage}[5]{%
    begin{titlingpage*}
    addcontentsline{toc}{chapter}{#1}
    begin{flushright}
    setlengthbeforepapernumskip{30pt}
    setlengthbeforepapernameskip{5baselineskip}
    setlengthbeforepaperdetailskip{2baselineskip}
    
    vspace*{beforepapernumskip}
    {papernumfont#1}
    
    vspace{beforepapernameskip}
    {papernamefont#2}
    
    vspace{beforepaperdetailskip}
    {paperdetailfont#3}[2baselineskip]
    {paperdetailfont#4}[10mm]
    
    %includegraphics[width=0.75textwidth]{./figs/CBS-O-METER}
    
    vfill
    {paperdetailfont Supporting Information Available At:  url{#5}}
    
    end{flushright}
end{titlingpage*}
}

But the hyperlink created in the ToC does not take the reader to the actual page of the titling page, but rather to the last "normally created" chapter in the ToC. Is there a way to make the hyperlink work in the command above?

One Answer

First of always provide a full but minimal example others can copy and test. For example the code here does not show that hyperref is being used. But we know that from context.

In order for hyperlinks to work correctly it need to have something unique to latch onto. Normally this is a counter like chapter, equation etc. Here there are none so the hyperlink ends up weird.

Fir this purpose we have phantomsection which provides something for addcontentsline to latch on to. Use it like thus

phantomsection
addcontentsline.... 

Correct answer by daleif on June 20, 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